Skip to Content

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

image

Approval Role Table

PRODH – Product Hierarchy/Commodity Code

Approval Level no / Approval Levels

Approval Role

Note: Fields in bold indicates Primary Key

image

Design

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.

image

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.

LOOP AT SOURCE_PACKAGE ASSIGNING <source_fields>.

       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.

           APPEND RESULT_FIELDS TO RESULT_PACKAGE.

           CLEAR RESULT_FIELDS.

         ENDLOOP.

        ENDIF.

     END LOOP.

Load the data

image

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

!https://weblogs.sdn.sap.com/weblogs/images/251925283/CommodityCodeApprovalHierarchyrecordssplit1.JPG|height=300|alt=image|width=700|src=https://weblogs.sdn.sap.com/weblogs/images/251925283/CommodityCodeApprovalHierarchyrecordssplit1.JPG|border=0!

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. Benedict Venmani Felix
    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?
    (0) 
      1. Vamsidhar Kaliki

        Hi Jyothi,

        Good posts in this community. I would like you to click on the “Follow” button in my profile so that we can send direct messages when ever we have doubts or issues in system.

        Thank You,

        Vamsidhar.K

        (0) 

Leave a Reply