Skip to Content
Author's profile photo Philipp Peters

Delete requests from Advanced DSO (ADSO)

While working with SAP BWonHANA we came to the point to delete requests from an Advanced DSO using a program. Unfortunately there is no funtion module like RSSM_PROCESS_REQUDEL_ODSO for classic DSO.

So I spend some nice time with the ABAP Debugger and found a solution:

PARAMETERS: p_adsonm TYPE rsoadsonm.

DATA: ls_tlogo       TYPE rstran_s_tlogo,
      lt_tlogo_tabl  TYPE rsdso_t_data_tlogo_tabl,
      lr_task_param  TYPE REF TO cl_rsdso_data_task_param,
      lr_task_caller TYPE REF TO cl_rsdso_data_task_caller.

"fill TLOGO structure
ls_tlogo-tlogo = 'ADSO'.
ls_tlogo-objnm = p_adsonm.

"create instance of cl_rsdso_data_request_list
DATA(lr_request_list) = cl_rsdso_data_request_list=>create(
  i_s_tlogo   = ls_tlogo ).

"refresh list
lr_request_list->refresh( ).

"get list of all requests in XREF format
DATA(lt_request_xref) = lr_request_list->get_t_request_xref( ).

"do some stuff to determine relevant requests
...

...

"create another instance of cl_rsdso_data_request_list with XREF list
"why this?
"I cannot create lr_request_list with i_task_type = 'DELETE' and
"execute the method "refresh". But without i_task_type = 'DELETE'
"the method "start" of lr_task return with a dump...
"So, lets do this twice..
lr_request_list = cl_rsdso_data_request_list=>create(
  i_s_tlogo   = ls_tlogo
  i_task_type = 'DELETE'
  i_t_request_xref = lt_request_xref ).


"create task for deletion
DATA(lr_task) = cl_rsdso_data_task=>create(
  i_s_tlogo = ls_tlogo
  i_type = 'DELETE'
  i_t_tlogo_tabl = lt_tlogo_tabl
  i_r_request_list = lr_request_list
  i_r_param = lr_task_param
  i_r_caller = lr_task_caller ).

"start deletion
lr_task->start( ).

"get status
DATA(lv_status) = lr_task->get_status( ).
"get log
DATA(l_r_log)  = lr_task->get_r_log( ).

"write messages
LOOP AT l_r_log->get_t_msg( ) ASSIGNING FIELD-SYMBOL(<f_s_msg>).
  "WHERE msgty = 'X' OR msgty = 'A' OR msgty = 'E' OR msgty = 'W'.
  DATA ls_msg TYPE rspc_s_msg.

  MOVE-CORRESPONDING <f_s_msg> TO ls_msg.
  MESSAGE ID ls_msg-msgid TYPE ls_msg-msgty NUMBER ls_msg-msgno
  WITH ls_msg-msgv1 ls_msg-msgv2 ls_msg-msgv3 ls_msg-msgv4.

ENDLOOP.

Maybe there is another way to get rid of the second instance of cl_rsdso_data_request_list. If you find a way, please tell me ?

 

Please let me know if I’ve missed anything or something is incorrect.

Hope it helps!

Thanks ?

Assigned tags

      20 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hi, you need to delete the change log of a classic DSO? For that there is a standard step in process chains, no need to use a program.

      Author's profile photo Philipp Peters
      Philipp Peters
      Blog Post Author

      Hi Miguel,
      this is for advanced DSO, not classic DSO.

      Best regards
      Philipp

      Author's profile photo Oliver Becker
      Oliver Becker

      Thanks Philipp ?

       

      Author's profile photo Former Member
      Former Member

       

      Hi Phillip,

      I was exactly looking for such this solution. Thank you for giving a solution.

      But I have a issue.. when I tried to use your code as is.. I face few errors in data definition itself. I am in Version BW 7.4 SP15. Which version is your code in?

      Author's profile photo Philipp Peters
      Philipp Peters
      Blog Post Author

      Hi Meyyappan,
      we are on BW 7.5 SP05. Maybe you can adjust the code for your release without losing functionality?

      Best regards
      Philipp

      Author's profile photo Baljinder Sidhu
      Baljinder Sidhu

      Hi All,

       

      We are using BW 7.5 SP07 and i am able to simply right click the provider and delete data, which removes the request. Must have been functionality added post SP05 perhaps?

       

      Thanks,

      Bal.

       

      Author's profile photo Philipp Peters
      Philipp Peters
      Blog Post Author

      Hi Bal,
      the code is for background processing.

      Best regards,
      Philipp

      Author's profile photo Loed Despuig
      Loed Despuig

      Thanks for the program, will try it. But I think it will delete all the requests in the ADSO, right?

      Loed

      Author's profile photo Philipp Peters
      Philipp Peters
      Blog Post Author

      Hi Loed,

      take a look at the comment "do some stuff to determine relevant requests". Otherwise the program will delete all requests, right.

       

      Philipp

      Author's profile photo Loed Despuig
      Loed Despuig

      Hi Philipp,

      Can you provide a sample code to delete specific request?

      Also, I'm planning to make the request to be entered as PARAMETER so I can use it in PRODUCTION to delete specific request.

      Thanks a lot.

      Loed

      Author's profile photo Philipp Peters
      Philipp Peters
      Blog Post Author

      Hi Loed,

      in internal table lt_request_xref are all request of this ADSO. So you only have to delete from this tablet he requests  you want to keep. All other requests will be deleted.

      Best regards

      Philipp

      Author's profile photo Loed Despuig
      Loed Despuig

      Thanks a lot, I will try it.

      Loed

      Author's profile photo sheik subhani
      sheik subhani

      Hi Philipp,

       

      I have used your programme in my system where we are using BI 7.5 and SP09 where I use to delete the Old requests from the ADSO , where as Iam getting the below error.

       

      "
      Create request declaration contains invalid source requests" . Could you please suggest how to solve this issue.

       

      Thanks

      Subhani.

       

      Author's profile photo sheik subhani
      sheik subhani

      Hello ,

       

      Can any one please respond to the above query, its bit urgent. Please help

       

      Regards

      Sheik

      Author's profile photo Mynyna Chau
      Mynyna Chau

      I recommend posting your question in the Q&A section of SAP Community: https://answers.sap.com/questions/ask.html

      Active community members can then provide answers to your question.

      Best regards

      Mynyna (SAP Community moderator)

      P.S.: The "Alert moderator" button is only for cases where the SAP Community rules of engagement are violated. Please do not use this button to reach out to community members.

      Author's profile photo Philipp Peters
      Philipp Peters
      Blog Post Author

      Hi Subhani,

      I could reproduce your error but I dont know why this error appears. In my case I got an entry with an empty Loading-TSN (just "00000000000000000000000) and a filled Activation-TSN ("2018..."). I dont know where this entry comes from.

      Could you check if you could find the corrupt request in ADSO Administration? As an workaround maybe you could delete all requests from internal table lt_request_xref where Loading-TSN (SRC_TSN) is empty. I dont think that this constellation should be normal.

      Best regards

      Philipp

      Author's profile photo Sri Vidya
      Sri Vidya

      Hi Philipp Peters ,

      Thanks for the post and I tried this.I modified the code to delete the ADSO requests older than 6 months. But I am also getting the same error as ” Create request declaration contains invalid source requests ” and there are no corrupted requests from ADSO.

      Is there any solution for this?

       

      Regards,

      Vidya

      Author's profile photo Jorge Pascazi
      Jorge Pascazi

      Dear Philipp,

      Thank you very much for the publication. I tried this on BW4HANA 2.0 SP 7.5 and the result was as expected. Now I need to delete daily a specific ADSO, since the process chain Delete Complete Data Target Contents option  did not work and the ADSO definition does not allow the process chain option Clean Up Old Request in ADSO, I need to use the Execute ABAP Program option in this process chain, so how should your program adjust to delete this specific ADSO?

      Thanks again.

      Jorge

      Author's profile photo Richard Owczynik
      Richard Owczynik

      Dear Philipp,

      my task was to delete the last broken request for an ADSO automatically if a process chain fails, to roll back everything. I tried your code and didn’t get any error message, just nothing happened, the request stayed there. So I was not investigating to much, I just did some research with the debugger and found another solution. I wanted to post it here, maybe somebody finds it useful.

        DATAlv_request_tsn TYPE rspm_request_tsn,
      lr_request     TYPE REF TO cl_rsbk_request,

      lv_adso type RSPM_DATATARGET.

       

      * Abgebrochenen Prozess TSN id suchen
      SELECT SINGLE request_tsn FROM rspmrequest INTO lv_request_tsn
      WHERE datatarget      EQ lv_adso
      AND request_status  EQ ‘RR’
      OR request_status     EQ ‘RG’
      OR request_status     EQ ‘GR’
      OR request_status     EQ ‘YR’ ).

      IF sysubrc 0.
      lr_request cl_rsbk_request=>create_from_dbi_request_tsn lv_request_tsn ).
      TRY.
      lr_request->delete).

      CATCH cx_rs_foreign_lock INTO DATA(lr_err).

      CATCH cx_rs_failed INTO DATA(lr_failed).
      ENDTRY.

      ADSO requests are stored in the table rspmrequest we have to search for the red request and then delete it.

      This is a very simple approach and only works for the last broken request, if you need to delete more requests then it’s getting more complicated because maybe (depending on ADSO type) you should roll back more requests, etc. That would need some further research and adjustments on the code.

      Regards,

      Richard

      Author's profile photo Marko Tadic
      Marko Tadic

      Dear Richard,

       

      Diy you maybe find a way to delete a request from PSA (Data Source) connected to this one in ADSO? If we just delete the data from ADSO, in the next run Process Chain is going to trigger again the file from Data Source into ADSO and in that way produce the error again.

       

      Thank you in advance!

      Marko