Skip to main content

Community

Other: SAP table column descriptions using SAP Data Dictinaries

Not planned

Please sign in to leave a comment.

Comments

2 comments

  • Official comment

    Hi Michael, 

    Fivetran does not plan to add SAP table and column descriptions to HVR destinations. It is on the roadmap for the managed service.

    Anyway, you can still add it yourself to you target tables as SAP stores table/column description in two data dictionary tables, so you can replicate those and generate the descriptions yourself.

    This can be done in three steps:

    Step 1: Replicate the dictionary tables

    • Select DD02T (table texts) and DD03T (column texts) in the schema tab of your SAP ERP on HANA connection.
    • Run a sync so both tables land in the same dataset as your SAP tables.

    Step 2: Generate the statements
    The query below only creates ALTER statements and changes nothing. Replace {your project - schema} with your own project and dataset, for example myproject.sap_data. Set ddlanguage to your language, since 'E' means English.

     
    sql
    WITH tbl AS (
      SELECT tabname, ddtext
      FROM `{your project - schema}.DD02T`
      WHERE ddlanguage = 'E' AND as4local = 'A' AND as4vers = '0000'
        AND TRIM(ddtext) <> ''
      QUALIFY ROW_NUMBER() OVER (PARTITION BY tabname ORDER BY ddtext) = 1
    ),
    col AS (
      SELECT tabname, fieldname, ddtext
      FROM `{your project - schema}.DD03T`
      WHERE ddlanguage = 'E' AND as4local = 'A'
        AND TRIM(ddtext) <> ''
      QUALIFY ROW_NUMBER() OVER (PARTITION BY tabname, fieldname ORDER BY ddtext) = 1
    )
    SELECT FORMAT(
             'ALTER TABLE `%s.%s.%s` SET OPTIONS (description = %T);',
             i.table_catalog, i.table_schema, i.table_name, t.ddtext
           ) AS stmt
    FROM tbl t
    JOIN `{your project - schema}.INFORMATION_SCHEMA.TABLES` i
      ON UPPER(i.table_name) = UPPER(t.tabname)
     AND i.table_type = 'BASE TABLE'
    UNION ALL
    SELECT FORMAT(
             'ALTER TABLE `%s.%s.%s` ALTER COLUMN `%s` SET OPTIONS (description = %T);',
             i.table_catalog, i.table_schema, i.table_name, i.column_name,
             SUBSTR(c.ddtext, 1, 1024)
           )
    FROM col c
    JOIN `{your project - schema}.INFORMATION_SCHEMA.COLUMNS` i
      ON UPPER(i.table_name) = UPPER(c.tabname)
     AND UPPER(i.column_name) = UPPER(c.fieldname);

    Step 3: Review and run

    • Check a sample of the output first.
    • Run the statements with an account that may update tables in the dataset.
    • Run them in a test dataset first if you can.

    Good to know

    • Target names equal the SAP names, so tables and columns match one to one.
    • Only objects that exist in BigQuery get a description, and quotes in texts are escaped safely.
    • Column descriptions are cut at 1024 characters, which is the BigQuery maximum.
    • Namespaced SAP tables such as /BI0/... are skipped if your target names differ.
    • Descriptions are not kept in sync automatically, so rerun the query after new tables or columns appear.
    • If your SAP system has descriptions in several languages, pick the one you need with ddlanguage.

    Best regards,
    Edwin

    Hi Michael,

    Thank you for raising this request. We can clearly see the value of populating SAP table column descriptions in a destination using SAP Data Dictionary information, especially for reporting and downstream data consumers. We already have a similar improvement defined in our product backlog. We will add this request to give more weight to this feature for future consideration.

    At this time, however, this work is not yet planned in our upcoming releases. We will keep you updated as priorities evolve.

    Best regards,

    Edwin