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

SAP Blog

Kayıtlı Üye
Katılım
22 Ara 2017
Mesajlar
1,925
Tepki puanı
7
Puanları
6
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.

global.jpg


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.

debug.jpg


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.

dtp.jpg


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 :

selection.jpg


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 :

Kod:
METHOD GLOBAL_END BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT 
OPTIONS READ-ONLY USING RSPMDTASELECTION.

** create temporary table with load request ID & filter values, 
** if there is no filter, NULL is replaced by blank with ifNull expression.

tt_req = select
         :i_req_requid as req,
         ifNull(r.SELECTIONS,'') as FILTER
         from :intab left outer join RSPMDTASELECTION as r on 1= 1
         AND r.PROCESS_TSN = :i_req_requid;

outTab = SELECT SALESORG,
       RECORDMODE,
       t.req  as REQUEID,
       t.FILTER,
       RECORD,
       SQL__PROCEDURE__SOURCE__RECORD

 FROM :inTab inner join :tt_req as t ON 1 = 1 AND t.REQ = :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 :

filter-value.jpg


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

Okumaya devam et...
 
Üst