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

master data dealetion program

Former Member
0 Likes
750

hello friends,

I have to create one program,in which whatever data range will enter by user in selection screen those master data will be delete from the master table.

Can you please tell me the logic behind that....

Thanks in advance

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
727

Hello Amar,

You can delete the data from master data.

Before deleting, you need to lock the table and after deleting you need to unlock the table.

Here is one sample code which ii used for deletion of material numbers from master data MARA..

REPORT y16v_update_zvleknvv1.

TABLES: mara.

SELECT-OPTIONS: s_matnr FOR mara-matnr.

START-OF-SELECTION.

    • Lock the table*

PERFORM lock.

    • Deleting the records from the Table*

DELETE FROM mara WHERE matnr IN s_matnr.

IF sy-subrc EQ 0.

WRITE 'Deleted'.

ENDIF.

    • Unlock the table*

PERFORM unlock.

*&----


*

*& Form LOCK

*&----


*

    • Lock the Database Table*

*----


*

FORM lock.

CALL FUNCTION 'ENQUEUE_E_TABLEE'

EXPORTING

mode_rstable = 'E'

tabname = 'MARA'

EXCEPTIONS

foreign_lock = 1

system_failure = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDFORM. " LOCK

*&----


*

*& Form UNLOCK

*&----


*

    • Unlock the Database Table*

*----


*

FORM unlock.

CALL FUNCTION 'DEQUEUE_E_TABLEE'

EXPORTING

mode_rstable = 'E'

tabname = 'MARA'.

ENDFORM. " UNLOCK

Its working.

Reward If Helpful.

Regards

--

Sasidhar Reddy Matli.

Edited by: Sasidhar Reddy Matli on Jan 24, 2008 3:33 PM

5 REPLIES 5
Read only

Former Member
0 Likes
727

hi,

you can use se 38 tyranscation and write code as follows

eg

tables:/BIC/SZSLESID7(SID table name).

delete from /BIC/SZSLESID7 where fieldname = condition.

plzz reward if it is useful......

Read only

Former Member
0 Likes
727

Hi Amar,

Try like this code.

tables spfli.

select-options s_carrid for spfli-carrid.

delete from spfli where carrid in s_carrid.

Plzz reward if it is useful,

Mahi.

Read only

Former Member
0 Likes
728

Hello Amar,

You can delete the data from master data.

Before deleting, you need to lock the table and after deleting you need to unlock the table.

Here is one sample code which ii used for deletion of material numbers from master data MARA..

REPORT y16v_update_zvleknvv1.

TABLES: mara.

SELECT-OPTIONS: s_matnr FOR mara-matnr.

START-OF-SELECTION.

    • Lock the table*

PERFORM lock.

    • Deleting the records from the Table*

DELETE FROM mara WHERE matnr IN s_matnr.

IF sy-subrc EQ 0.

WRITE 'Deleted'.

ENDIF.

    • Unlock the table*

PERFORM unlock.

*&----


*

*& Form LOCK

*&----


*

    • Lock the Database Table*

*----


*

FORM lock.

CALL FUNCTION 'ENQUEUE_E_TABLEE'

EXPORTING

mode_rstable = 'E'

tabname = 'MARA'

EXCEPTIONS

foreign_lock = 1

system_failure = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDFORM. " LOCK

*&----


*

*& Form UNLOCK

*&----


*

    • Unlock the Database Table*

*----


*

FORM unlock.

CALL FUNCTION 'DEQUEUE_E_TABLEE'

EXPORTING

mode_rstable = 'E'

tabname = 'MARA'.

ENDFORM. " UNLOCK

Its working.

Reward If Helpful.

Regards

--

Sasidhar Reddy Matli.

Edited by: Sasidhar Reddy Matli on Jan 24, 2008 3:33 PM

Read only

0 Likes
727

Thanks Boss for your answer.

Ok please tell me if we enter one material number then will it delete one row complitly with all information releated to that.

Read only

0 Likes
727

DO NOT DELETE RECORDS FROM SAP TABLES IN ANY METHOD POSTED PREVIOUSLY.

THEY ARE STUPID IN TELLING YOU WHAT TO DO.

IF YOU DELETE FROM MARA, WHAT ABOUT MARC, MARD, MARM, MAKT shall I go on.

And posting this in caps was not by accident either.