Skip to Content

Scenario :

We may come across different inconsistencies in the data base tables due to incorrect request deletions happened in the Infoproviders, Infopackages etc.. At times, we are forced to delete those unwanted requests from the database tables by getting into the Debug mode(/h). This document will help us to delete the unwanted requests from different tables by using a ABAP program.

We should not delete any table entry just like that. A very well experienced guy can take up this activity. He should know what he is deleting. Please be careful. It is just a workaround. Please always take a backup of entries which you are trying to delete. If you want to restore, you can create these entries again.

Step 1: Goto SE38 and create a executable program called Z_DELETE_FROM_TABLE

SE38.JPG

Step 2: Copy & Paste the below code in Source Code


*&———————————————————————*
*& Report  Z_DELETE_FROM_TABLE
*&
*&———————————————————————*
*&
*&
*&———————————————————————*

REPORT  z_delete_from_table .

DATA: lv_tabname TYPE string,
       lv_temp TYPE rsodsactreqdatapakid.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text001.
PARAMETERS: r1 RADIOBUTTON GROUP rad1 USER-COMMAND rad1 DEFAULT ‘X’,         “RSODSACTREQ
             r2 RADIOBUTTON GROUP rad1,                                       “RSSELDONE
             r3 RADIOBUTTON GROUP rad1,                                       “RSICCONT
             r4 RADIOBUTTON GROUP rad1,                                       “RSSDLINIT
             r5 RADIOBUTTON GROUP rad1,                                       “RSREQICODS
             r6 RADIOBUTTON GROUP rad1,                                       “RSREQDONE
             r7 RADIOBUTTON GROUP rad1.                                       “RSSDLINITSEL
SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK rad1 WITH FRAME TITLE text001.
PARAMETERS: p_ods TYPE rsodsactreqodsobject MODIF ID one,
             p_req TYPE rsodsactreqrequest MODIF ID one,
             p_pid TYPE char6 MODIF ID one.        “rsodsactreq-datapakid MODIF ID one.
SELECTION-SCREEN END OF BLOCK rad1.

SELECTION-SCREEN BEGIN OF BLOCK rad2 WITH FRAME TITLE text002.
PARAMETERSp_rnr TYPE rsseldonernr MODIF ID two.
SELECTION-SCREEN END OF BLOCK rad2.

SELECTION-SCREEN BEGIN OF BLOCK rad3 WITH FRAME TITLE text002.
PARAMETERSp_rnr1 TYPE rsseldonernr MODIF ID b3,
              p_lrnr TYPE rssdlinitlast_delta_rnr MODIF ID b3.
SELECTION-SCREEN END OF BLOCK rad3.

AT SELECTION-SCREEN OUTPUT.
   PERFORM select_scrn.

START-OF-SELECTION.

   PERFORM req_check.

   IF r1 IS NOT INITIAL.
     DELETE FROM rsodsactreq WHERE odsobject = p_ods
                               AND request = p_req
                               AND datapakid = lv_temp.      “p_pid.
   ELSEIF r4 IS NOT INITIAL.
     DELETE FROM rssdlinit WHERE rnr = p_rnr1
                             AND last_delta_rnr = p_lrnr.
   ELSE.
     PERFORM get_tabname.
     DELETE FROM (lv_tabname) WHERE rnr = p_rnr.
   ENDIF.

   IF sysubrc <> 0.
     WRITE: ‘no record found.’.
   ELSE.
     WRITE: ‘record deleted from table.’.
   ENDIF.

END-OF-SELECTION.

*&———————————————————————*
*&      Form  REQ_CHECK
*&———————————————————————*
*       text
*———————————————————————-*
*  –>  p1        text
*  <–  p2        text
*———————————————————————-*
FORM req_check .
   lv_temp = p_pid.
   IF r1 IS NOT INITIAL.
     IF p_ods IS INITIAL OR p_req IS INITIAL OR p_pid IS INITIAL.   “OR lv_temp is INITIAL.
       MESSAGE ‘Please enter ODS,Request number and Data Packet ID’ TYPE ‘I’.
       STOP.
     ENDIF.
   ELSEIF r4 IS NOT INITIAL.
     IF p_rnr1 IS INITIAL OR p_lrnr IS INITIAL.   “OR lv_temp is INITIAL.
       MESSAGE ‘Please enter RNR and Last Delta RNR’ TYPE ‘I’.
       STOP.
     ENDIF.
   ELSE.
     IF p_rnr IS INITIAL.
       MESSAGE ‘Please enter RNR number’ TYPE ‘I’.
       STOP.
     ENDIF.
   ENDIF.

ENDFORM.                    ” REQ_CHECK

*&———————————————————————*
*&      Form  SELECT_SCRN
*&———————————————————————*
*       text
*———————————————————————-*
*  –>  p1        text
*  <–  p2        text
*———————————————————————-*
FORM select_scrn .
   IF r1 = ‘X’.
     LOOP AT SCREEN.
       IF  screengroup1 = ‘TWO’ OR screengroup1 = ‘B3’.
         screenrequired = 0.
         screeninput = 0.
         screeninvisible = 1.
         screenactive = 0.
         MODIFY SCREEN.
       ENDIF.
     ENDLOOP.
   ELSEIF r4 = ‘X’.
     LOOP AT SCREEN.
       IF screengroup1 = ‘ONE’ OR screengroup1 = ‘TWO’.
         screenrequired = 0.
         screeninput = 0.
         screeninvisible = 1.
         screenactive = 0.
         MODIFY SCREEN.
       ENDIF.
     ENDLOOP.
   ELSE.
     LOOP AT SCREEN.
       IF screengroup1 = ‘ONE’ OR screengroup1 = ‘B3’.
         screenrequired = 0.
         screeninput = 0.
         screeninvisible = 1.
         screenactive = 0.
         MODIFY SCREEN.
       ENDIF.
     ENDLOOP.
   ENDIF.
ENDFORM.                    ” SELECT_SCRN

*&———————————————————————*
*&      Form  GET_TABNAME
*&———————————————————————*
*       text
*———————————————————————-*
*  –>  p1        text
*  <–  p2        text
*———————————————————————-*
FORM get_tabname .
   IF r2 IS NOT INITIAL.
     lv_tabname = ‘RSSELDONE’.
   ELSEIF r3 IS NOT INITIAL.
     lv_tabname = ‘RSICCONT’.
*  ELSEIF r4 IS NOT INITIAL.
*    lv_tabname = ‘RSSDLINIT’.
   ELSEIF r5 IS NOT INITIAL.
     lv_tabname = ‘RSREQICODS’.
   ELSEIF r6 IS NOT INITIAL.
     lv_tabname = ‘RSREQDONE’.
   ELSEIF r7 IS NOT INITIAL.
     lv_tabname = ‘RSSDLINITSEL’.
   ENDIF.
ENDFORM.                    ” GET_TABNAME

Step 3 : Click on Execute and you will be asked to enter the Request(Lenghty Tehcnical Name etc..)

Input Screen.JPG

Hence the table entry will be deleted.

I have considered 7 tables in the program. You can configure any other tables also by enhancing the above code.


To report this post you need to login first.

12 Comments

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

  1. Former Member

    Hallo Suman,

    can you give me a real life example where I can use your smart code?  I can not really comprehend why we need to delete entries from tables? I can not really get this thread, although it seems very useful 🙂

    Sherif

    (0) 
    1. Former Member Post author

      I gave the scenario in my introduction of this blog. This will help you when you don’t have authorization to delete the bad entries from the tables.

      (0) 
    1. Former Member Post author

      It is not safe if you delete them just like that. You should know it is not required any more in BW, then only you should get into these tables and knock off those unwanted requests. This is basically a work around. This is not a straight concept.

      (0) 

Leave a Reply