Skip to Content

Creating Multiple Records using Expert Routine

Business Scenario:

We need to maintain an approval hierarchy for the commodity codes, where as data has threshold(From and To) percentages for approval as well as the number of levels of approval of approving price changes for each commodity in individual  ztables.

Here is a look at each table data

Approval Level Table

PRODH – Product Hierarchy/Commodity Code

FTOLER – Starting Tolerance/threshold %

TTOLER – Ending Tolerance/threshold %

LEVELS — Approval Levels

Note: Fields in  bold indicates Primary Key


Approval Role Table

PRODH – Product Hierarchy/Commodity Code

Approval Level no / Approval Levels

Approval Role

Note: Fields in bold indicates Primary Key



As you see there is no proper  Key relation between these table (Level, Role) to join and bring them in a single table, So we extracted all the ztables to BW and build a DSO’s(Staging) on top of them. And on top of Level data DSO(Staging) we designed a logical DSO where we are creating multiple records for each level and appover using an Expert Routine.


Example: if the Commodity level is 2 in the Level DSO(Staging), then in th eLogical Level dso it should show two transacion i.e both levels 1 and 2 with no change in the tolerence levels(threshold values). Please see the visuals/pictures  for better understanding

Here is the code used in expert routine

Expert Routine

TYPES: BEGIN OF ty_approle,

             zglbsupp TYPE /bic/oizglb_supp,

             tlevel   TYPE /bi0/oirf_tlevel,

             approle  TYPE /bic/oizapprole,

            END OF ty_approle.

DATA: itab_approle TYPE TABLE OF ty_approle INITIAL SIZE 0,

           wa_approle   TYPE ty_approle.


       FREE: itab_approle.

       SELECT /bic/zglb_supp  rf_tlevel  /bic/zapprole into table itab_approle

              FROM /bic/azsupappl00  WHERE /bic/zglb_supp = <source_fields>/bic/zglb_supp.

        IF sysubrc = 0.

         SORT itab_approle BY zglbsupp tlevel.

         delete itab_approle where tlevel > <source_fields>RF_TLEVEL.

         LOOP AT itab_approle INTO wa_approle.

           RESULT_FIELDS/BIC/ZGLB_SUPP = <source_fields>/BIC/ZGLB_SUPP.

           RESULT_FIELDS/BIC/ZFTOLER1 = <source_fields>/BIC/ZFTOLER.

           RESULT_FIELDS/BIC/ZETOLER1 = <source_fields>/BIC/ZETOLER.

           RESULT_FIELDSrf_tlevel = wa_approletlevel.

           RESULT_FIELDSCREATEDON = <source_fields>CREATEDON.

           RESULT_FIELDSCREATED_BY = <source_fields>CREATED_BY.

           RESULT_FIELDSPH_CHANGON = <source_fields>PH_CHANGON.

           RESULT_FIELDSPH_CHANGBY = <source_fields>PH_CHANGBY.

           RESULT_FIELDS/bic/zapprole = wa_approleapprole.





     END LOOP.

Load the data


As said earlier for each level in the approval level data, multiple records should be created in the target level..


You must be Logged on to comment or reply to a post.
  • hi,
    i have not used expert routines to create multiple records. What happens when the data package size is set to 50000 but after record creation the data package size increases to ~70000. Will the ~20000 be sent in a separate package or do we need to handle this specifically?