Skip to Content
Technical Articles

Retrieve DTP filter values in BW/4HANA AMDP TRFNs (similar to P_R_REQUEST->GET_TH_RANGE( ) in ABAP)

Hello There!

This blog post is an extension of one of my previous blog posts regarding replication of the methods in p_r_request into AMDP TRFNs in BW/4HANA 2.0 context. As already stated in the earlier blog post,  a set of predefined parameters is available in each AMDP global area of TRFNs.

In each load request, these parameters can help us retreiving the source, target of a DTP, technical name of DTP, technical name of DTP directly. We can also monitor them in the debug mode.

The parameters denote information as following :

i_req_dtp_name : DTP’s technical name.

i_req_logsys : logical system ID pertaining to the load request

i_req_requid : request ID of the load request

i_req_src_name : technical name of the source provider of the DTP

i_req_src_type : source provider type

i_req_tgt_name : technical name of the target provider of the DTP

i_req_tgt_type : target provider type

 

However, with these already available parameters, one often sought after information is the DTP filter values, that could be derived using  p_r_request->get_th_range( ) in ABAP based transformations. The filter values can also be derived using the parameter called i_req_requid & joining it with the process_tsn of table RSPMDTASELECTION. RSPMDTASELECTION table holds the information of the filter being used by the DTP for a particular load request.

Let’s take an example :

I have an aDSO ZADSO_AH, which has data of 6 different sales organizations. I have included a field called FILTER in the same to monitor if we can correctly capture the correct DTP filter within it using AMDP self loop transformation. Now I have executed a DTP with filter only on 2 sales organizations : SO01 & SO02.

As mentioned earlier, I can see the filter value in table : RSPMDTASELECTION as below using the request number of the DTP load against PROCESS_TSN field :

Now to get these selections in AMDP I had to make a join with this table with our intab using the available parameter : i_req_requid.

A simple code snippet is shown below :

METHOD GLOBAL_END BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT 
OPTIONS READ-ONLY USING RSPMDTASELECTION.
 
** left outer join is for capturing the data if there is no filter, 
** NULL is replaced by blank with ifNull expression.

outTab = SELECT SALESORG,
       RECORDMODE,
       :i_req_requid  as REQUEID,
       ifNull(r.SELECTIONS,'') as FILTER,
       RECORD,
       SQL__PROCEDURE__SOURCE__RECORD

 FROM :inTab left outer join  RSPMDTASELECTION as r on 1 = 1
         AND r.PROCESS_TSN = :i_req_requid;


 errortab = SELECT '' AS ERROR_TEXT, '' AS SQL__PROCEDURE__SOURCE__RECORD 
            FROM DUMMY WHERE DUMMY <> 'X';

The code is quite self explanatory, the parameter : i_req_requid here holds the same information as process_tsn field in RSPMDTASELECTION table does pertaining to the DTP request in context. I have selected the field SELECTIONS from the same table & have written it back in the aDSO field : FILTER.

Let’s have a look into the data loaded in new data table :

As it can be seen in the above screenshot, the value from field SELECTIONS in table RSPMDTASELECTION is written to the field called : FILTER in the aDSO.

PS : If the DTP was executed without any filter values, it would just store blank value since we have the left outer join & ifNull check in the code.

This way, it is possible to read the filter values of a DTP load request in an AMDP within BW/4HANA 2.0.

Hope this blog post will help gaining some insights about the ways of achieving some of the ABAP features in BW/4HANA 2.0 AMDP based TRFNs.Readers are most welcome to share any comment/feedback/experience regarding this topic for enriching our mutual knowledge bank.

You can also use the space for Q&A section for questions/doubts regarding similar/different topics.

Cheers!
Abhi

 

 

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