Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Table maintenance event - DELETE info

Former Member
0 Likes
6,530

Hi GURUs,

Please can any one suggest, am I coding correct at

table event "Delete 03 or 04".

This below code is not giving me the desired result, its not pointing at the index which is marked for deletion.

{ Loop at total.

IF <action> = GELOESCHT.

w_sys = extract+8(16). "Extracts the sysid

Delete from ZTESTO where SYSID = w_sys.

ENDIF.

clear w_sys.

endloop.}

MY requirement, want to capture the field data marked for deletion at table maintenance(SM30)(single/mutiple entries) into workarea and delete the same entries from another Ztable.

please tell me, if there are otherways to do the same.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,093

Hi,

Before writing the following code please make sure that your internal table(total) contains only records which are marked as 'm' or some flag(means selection of records).

{ Loop at total.

IF <action> = GELOESCHT.

w_sys = total-fieldname.

Delete from ZTESTO where SYSID = w_sys.

ENDIF.

clear w_sys.

endloop.}

this will delete the records which are selected only.

Regards,

Kishore K

Hi GURUs,

Please can any one suggest, am I coding correct at

table event "Delete 03 or 04".

This below code is not giving me the desired result, its not pointing at the index which is marked for deletion.

{ Loop at total.

IF <action> = GELOESCHT.

w_sys = extract+8(16). "Extracts the sysid

Delete from ZTESTO where SYSID = w_sys.

ENDIF.

clear w_sys.

endloop.}

MY requirement, want to capture the field data marked for deletion at table maintenance(SM30)(single/mutiple entries) into workarea and delete the same entries from another Ztable.

please tell me, if there are otherways to do the same.

5 REPLIES 5
Read only

Former Member
0 Likes
3,094

Hi,

Before writing the following code please make sure that your internal table(total) contains only records which are marked as 'm' or some flag(means selection of records).

{ Loop at total.

IF <action> = GELOESCHT.

w_sys = total-fieldname.

Delete from ZTESTO where SYSID = w_sys.

ENDIF.

clear w_sys.

endloop.}

this will delete the records which are selected only.

Regards,

Kishore K

Read only

Former Member
0 Likes
3,093

Hello ND,

The Event 03/04 is a little more complex than looping at TOTAL or EXTRACT and reading directly.

You are doing a Loop at TOTAL, but are reading EXTRACT.

Next, the <action> contains the global action, but not the required content - > Selected entry(ies) of TOTAL, which are marked for deletion. For this, read the flags <XACT> and <XMARK>, on the TOTAL.

Further, TOTAL and EXTRACT usually contain hexadecimal values, and the read of 8(16) may not always work. What is recommended is - create a data type variable casted to your structure (of current view/table where you are creating event). Read your TOTAL or EXTRACT into this. From here, you can read your desired field and perform your necessary action.

If you implement the above two steps, you wouldn't need a LOOP at TOTAL statement at all. A simpler READ statement may also help, but anyways.

Finally, your requirement is to delete an entry from table 2, for a deletion in table 1.

In this regard, it is usually better to go for Event 04 (AFTER DELETION), which confirms that the main deletion (in table1) has definitely happened.

For further reference, go through the help portal documentations for Events in View maintenance - Link:[Help Portal|http://help.sap.com/saphelp_47x200/helpdata/en/91/ca9f32a9d111d1a5690000e82deaaa/frameset.htm]

Cheers

Rekha

Edited by: Rekha S on May 5, 2008 12:14 PM

Read only

0 Likes
3,093

Thanks a lot that was really helpfull info, but i have already completed my requirement.

LOOP at total.

IF <action> EQ GELOESCHT or <action> EQ UPDATE_GELOESCHT or <action> EQ NEUER_GELOESCHT.

w_sys = total+8(8).

Delete from zxxxx where SYSIDNT = w_sys.

Delete from zyyyy where R3SYSTEM = w_sys.

ENDIF.

ENDLOOP.

Read only

Former Member
3,093

Hi,

You can check TOTAL or EXTRACT internal tables to see al datas that your Z* table has.

in ebent 03 for table maintenance;

There should be an 'M' character(marked to delete) .. You can understand that the line which was marked to delete by checking this M. But first you have to check that in which character of line this M is placed. Because it depends of your Z table Columns..

here is the sample code;

  FIELD-SYMBOLS <fs> TYPE ANY.

  DATA:ls_uhc  LIKE uhccaseattr20.

  DATA:ls_xyz LIKE z_xyz.

  ASSIGNtotal TO <fs> CASTING TYPE c. " TYPE CASTING must be done first



  LOOP AT total ASSIGNING <fs>. " read all lines and differentiate the marked line

    IF <fs>+61(1) = 'M'.

      SELECT SINGLE * FROM uhccaseattr20 INTO ls_uhc

        WHERE field1 = <fs>+3(10).

      IF sy-subrc = 0 .

        SELECT SINGLE * FROM z_xyz INTO ls_xyz

          WHERE field1 =  z_xyz-field.

        IF sy-subrc NE 0 .

          MESSAGE e113(z_mes) WITH z_xyz-field.

        ENDIF.

      ENDIF.

    ENDIF.

  ENDLOOP.

Read only

former_member491621
Contributor
0 Likes
3,093

Hi N D,

You can try writing your code in the PAI of the screen of the Table maintenance generator.

PROCESS AFTER INPUT.

MODULE LISTE_EXIT_COMMAND AT EXIT-COMMAND.

MODULE LISTE_BEFORE_LOOP.

LOOP AT EXTRACT.

   MODULE LISTE_INIT_WORKAREA.

   CHAIN.

    FIELD ZTABLENAME-FIELD1 .

    FIELD ZTABLENAME-FIELD2 .

    MODULE SET_UPDATE_FLAG ON CHAIN-REQUEST.

   ENDCHAIN.

   FIELD VIM_MARKED MODULE LISTE_MARK_CHECKBOX.

   CHAIN.

    MODULE LISTE_UPDATE_LISTE.

    MODULE <your_module>.          " Create this module

   ENDCHAIN.

ENDLOOP.

MODULE LISTE_AFTER_LOOP.

And write the code in the module

IF function = 'GELOESCHT'.

w_sys = extract+8(16). "Extracts the sysid

Delete from ZTESTO where SYSID = w_sys.

ENDIF.

clear w_sys.

Try it and let me know if you get any issues

Hope this helps