Retrieve p_r_request-> get_src information in AMDP for BW/4HANA 2.0 TRFNs
For many of us existing BW consumers, while moving to BW/4HANA platform it’s quite common a scene these days that we change the existing BW transformation routines from ABAP to AMDP to leverage the HANA performance in better possible way. In one of our cases, we had dataflows from several source ADSOs into one target ADSO. And the ABAP start routine in the TRFN had to look into the active tables of the source ADSOs for respective loads to find out the maximum date from it’s source. In ABAP we had this method : p_r_request-> get_src which can get us back the source provider’s technical name for the load request. I was searching for something similar to replicate the same logic in AMDP.
However, while trying to build a custom solution to replicate the method p_r_request-> get_src, with great inputs from Torsten Kessler I found out that there’s already a set of available parameters in each AMDP global area of TRFNs. 🙂
methods GLOBAL_START importing value(i_error_handling) type STRING value(i_req_dtp_name) type STRING value(i_req_logsys) type STRING value(i_req_src_name) type STRING value(i_req_src_type) type STRING value(i_req_tgt_name) type STRING value(i_req_tgt_type) type STRING value(i_req_requid) type STRING value(inTab) type TN_T_IN_GLOBAL_START exporting value(outTab) type TN_T_OUT_GLOBAL_START value(errorTab) type TN_T_ERROR .
Above are the available parameters in GLOBAL_START of the AMDP. These are filled accordingly for each load request going through an AMDP. These parameters contain different technical information associated with the load eg. logical system, technical names of source, target, type of the source/target, request ID of load request etc as shown in above screenshot. In this context I have used i_req_src_name in order to replicate the code in p_r_request-> get_src in ABAP. A note to remember, i_req_src_name provides the source of the DTP (so the source infoprovider) & not the source of the TRFN (which might be an infosource as well).
A code snippet from my scenario is provided as below : Here I am trying to stamp the maximum billing date (last sales date) from different sales ADSOs’ active tables (source providers : SRCADSOX, X = 1,2,3) for the delta combination of material & plant data.
METHOD GLOBAL_START BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY USING /BIC/ASRCADSO12 /BIC/ASRCADSO22 /BIC/ASRCADSO32. -- *** Begin of routine - insert your code only below this line *** outTab = select case :i_req_src_name when 'SRCADSO1' then max( a.BILL_DATE ) when 'SRCADSO2' then max( b.BILL_DATE ) when 'SRCADSO3' then max( c.BILL_DATE ) end as BILL_DATE, it.RECORDMODE, it.PLANT, it.MAT_PLANT, it.RECORD, it.SQL__PROCEDURE__SOURCE__RECORD from :intab as it LEFT JOIN "/BIC/ASRCADSO12" as a ON it.MAT_PLANT = a.MAT_PLANT AND it.PLANT = a.PLANT LEFT JOIN "/BIC/ASRCADSO22" as b ON it.MAT_PLANT = b.MAT_PLANT AND it.PLANT = b.PLANT LEFT JOIN "/BIC/ASRCADSO32" as c ON it.MAT_PLANT = c.MAT_PLANT AND it.PLANT = c.PLANT WHERE it.RECORDMODE <> 'X' group by it.RECORDMODE, it.PLANT, it.MAT_PLANT, it.RECORD, it.SQL__PROCEDURE__SOURCE__RECORD;
Note : We had an ABAP code for this whole activity in the start routine of TRFN before using p_r_request-> get_src & preparing the active table name of the ADSOs dynamically by concatenating the ‘/BIC/A’ & ‘2’ partz as prefix & suffix to the source name. With AMDP, I could as of now, build a case based script by hardcoding the constant source provider names in the data flow. This may as well be optimized further using dynamic sql preparing the table name & using the look up dynamically without using the constant table names in join condition.
Needless to say, by switching from ABAP to AMDP in HANA based BW TRFN, we reduced the runtime of the load to from 14 minutes to just 23 seconds. Awesome isn’t it? 😉
Hello Abhi, thanks, great blog!
You are on BW/4 right?
Do you know if there any plans to provide this parameters also in BW7.50 on Hana?
Hi Lukas, thanks! Yes we are on BW/4. Unfortunately, right now I have no BW on HANA system to check up on.:( But you may ask SAP if they can provide a pilot note to get these params on your version of installation.
Hope you have a good day!