Technology Blog Posts by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
lakshminarasimhan_n4
Active Contributor
0 Kudos
417

We had a target ADSO in B4HANA and there are 2 DTP's loading it, one DTP runs on all dates except 1st date of the month and other DTP runs only on the 1st date of the month.

We had 2 scenarios here which are given below, lets name the DTP’s that runs all dates except 1st as "DTP A" and DTP runs only on 1st as "DTP B".

  • DTP B when run on 1st must delete the data loaded by DTP A.
  • DTP B when run on 1st must not delete the previous loads from DTP B

To get this scenario, we can use "Delete overlapping request" in the process chain and we need to use the ABAP routine. This blog details on the same.

The routine where the ABAP code will be written in highlighted inside the variant.

1.png

We have a routine getting generated with same name as the variant name “compute_<variant name>”.

We have a global area to define the global variable and internal tables.

There are few "using" and "changing" parameters

I_REQUEST_JUST_LOADED – The request that is loading the data

I_DTP – Table containing dtp name, target adso, source object

C_T_REQUESTS_FOR_DEL - contains all active requests of the target ADSO, that can be deleted or                                                               can be removed from deletion. This is an internal table containing 2                                                                     columns,  “request” and “will_be_deleted” are the columns. “request” is the                                                         request id and  "will_be_deleted" can be set to ‘X’ if needs to be deleted.

2.png

Code

 field-symbols <l_request> type cl_rsdso_olrproc=>request_type.
  clear e_subrc.


" To get DTP details and this can be used when multiple DTP's are used
" to the target
  select process_tsn, process_id
  from rspmprocess into table (lt_idnti)
  for all entries in
  @c_t_requests_for_del
  where
  process_tsn = @c_t_requests_for_del-request.

  loop at lt_idnti into data(la_idnti).
   write: / 'Request ID ', la_idnti-process_tsn,
            'DTP used to Load ', la_idnti-process_id.
  endloop.


  loop at c_t_requests_for_del assigning <l_request>.

    read table lt_idnti into la_idnti with key
    process_tsn = <l_request>-request.

    "When we have data loaded on 1st,
    "we check if there are any previous data loads from
    "DTP_8IHQ1NO4FEU72L924FCHGP5EQ,
    "if it is present, then we need to delete the request.
    if sy-subrc = 0 and
    la_idnti-process_id = 'DTP_8IHQ1NO4FEU72L924FCHGP5EQ'.
     <L_REQUEST>-WILL_BE_DELETED = 'X'.
    else.
     <L_REQUEST>-WILL_BE_DELETED = ''.
    endif.

    write : / 'Incoming Data ',
              'Request ID ', <l_request>-request,
              'DTP Loaded it ',la_idnti-process_id,
              'will_be_deleted?(X Means "YES") ',
              <l_request>-will_be_deleted.

  endloop.

 

Code is detailed below,

The below code will help us to identify the request id in the target ADSO and DTP from where the request id got loaded.

This is needed for us, as we need to identify the requests from DTP A and we need to delete it.

  select process_tsn, process_id
  from rspmprocess into table @DATA(lt_idnti)
  for all entries in
  @c_t_requests_for_del
  where
  process_tsn = @c_t_requests_for_del-request.

The below statement will generate the “spool list”  when the process chain run in the background.

This is just a way to investigate on what really happened or help us to backtrack.

We can omit it, but I included just to backtrack.

  loop at lt_idnti into data(la_idnti).
   write: / 'Request ID ', la_idnti-process_tsn,
            'DTP used to Load ', la_idnti-process_id.
  endloop.

The internal table C_T_REQUESTS_FOR_DEL is looped and we pass the request id to the previous internal table LT_IDNTI. This is needed to get the DTP.

When we have data loaded on 1st we check if there are any previous data loads from DTP A if it is present, then we  delete the request by setting WILL_BE_DELETED = 'X'
Again write statements here are just to generate the spool list and help us back track

  loop at c_t_requests_for_del assigning <l_request>.

    read table lt_idnti into la_idnti with key
    process_tsn = <l_request>-request.

    "When we have data loaded on 1st,
    "we check if there are any previous data loads from
    "DTP_8IHQ1NO4FEU72L924FCHGP5EQ,
    "if it is present, then we need to delete the request.
    if sy-subrc = 0 and
    la_idnti-process_id <> 'DTP_8IHQ1NO4FEU72L924FCHGP5EQ'.
     <L_REQUEST>-WILL_BE_DELETED = 'X'.
    else.
     <L_REQUEST>-WILL_BE_DELETED = ''.
    endif.

    write : / 'Incoming Data ',
              'Request ID ', <l_request>-request,
              'DTP Loaded it ',la_idnti-process_id,
              'will_be_deleted?(X Means "YES") ',
              <l_request>-will_be_deleted.
  endloop.

Process chain is designed to add the decision between alternative variant to run the data load based on condition 1st and non 1st

3.png

Inside the “Decide Between Multiple Alternatives”

4.png

Labels in this area