Application Development 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: 

Delete modify in itab

Former Member
0 Kudos

hi gurus,

i am new in abap and i have a report in which in a selection screen

has 3 fields as months cur. date and material no.

and two parameters as chkbox on selection of these chkbox

one for delete and other for modify data in table.

plz send the codes abt delete and modify

i make it this but have an error.

TABLES: S225.

*************************************************************************

  • D A T A

*************************************************************************

DATA: OK_CODE LIKE SY-UCOMM.

*DATA: ITAB LIKE S225 OCCURS 0 WITH HEADER LINE.

*************************************************************************

  • SELECTION SCREEN / PARAMETERS *

*************************************************************************

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.

SELECT-OPTIONS:S_spmon FOR s225-spmon OBLIGATORY LOWER CASE,

s_sptag FOR s225-sptag OBLIGATORY,

S_MATNR FOR S225-MATNR OBLIGATORY.

SELECTION-SCREEN SKIP 1.

PARAMETERS: P1 AS CHECKBOX DEFAULT 'X',

P2 AS CHECKBOX.

SELECTION-SCREEN END OF BLOCK b1.

**************************************************************************

  • START OF SELECTION

***************************************************************************

START-OF-SELECTION.

PERFORM GET_DATA.

PERFORM DELETE_DATA.

*forms to fetch data in fields

FORM GET_DATA.

SELECT spmon sptag matnr FROM s225

*INTO CORRESPONDING FIELDS OF TABLE ITAB

WHERE SPMON IN S_SPMON AND

SPTAG IN S_SPTAG AND

MATNR IN S_MATNR.

ENDFORM.

*form for delete data

FORM DELETE_DATA.

CASE OK_CODE.

WHEN 'P1'.

DELETE SPMON FROM s225.

MESSAGE I002 WITH 'Data is Deleted'.

*WHEN 'P2'.

*INSERT: SPMON,SPTAG, MATNR INTO ITAB.

*MESSAGE S004 WITH 'Data is Saved Successfully'.

ENDCASE.

ENDFORM.

plz help me and send information to correct it.

thanks.

3 REPLIES 3

piyush_mathur
Active Participant
0 Kudos

Hi Jayant...

Please refer below piece of code:

For Delete data from Internal table ITAB:

DELETE ITAB INDEX sy-tabix.

To modify data in internal table ITAB :

MODIFY ITAB Where condition.

Let me know if still you have any doubts.

Reagrds,

Piyush

Reward Points, if helps.

Former Member
0 Kudos

Hi Jayant

Looks like your program is a report. Hence, don't handle the selection screen inputs through OKC_DE, which is generally forllowed for Dialog or Module Pool Program. You can change your code as below, that solve the problem,

TABLES: S225.

*************************************************************************

D A T A

*************************************************************************

DATA: OK_CODE LIKE SY-UCOMM.

*DATA: ITAB LIKE S225 OCCURS 0 WITH HEADER LINE.

*************************************************************************

SELECTION SCREEN / PARAMETERS *

*************************************************************************

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.

SELECT-OPTIONS:S_spmon FOR s225-spmon OBLIGATORY LOWER CASE,

s_sptag FOR s225-sptag OBLIGATORY,

S_MATNR FOR S225-MATNR OBLIGATORY.

SELECTION-SCREEN SKIP 1.

PARAMETERS: P1 AS CHECKBOX DEFAULT 'X',

P2 AS CHECKBOX.

SELECTION-SCREEN END OF BLOCK b1.

**************************************************************************

START OF SELECTION

***************************************************************************

START-OF-SELECTION.

PERFORM GET_DATA.

PERFORM DELETE_DATA.

*forms to fetch data in fields

FORM GET_DATA.

SELECT spmon sptag matnr FROM s225

*INTO CORRESPONDING FIELDS OF TABLE ITAB

WHERE SPMON IN S_SPMON AND

SPTAG IN S_SPTAG AND

MATNR IN S_MATNR.

ENDFORM.

*form for delete data

FORM DELETE_DATA.

if P1 is not initial.

DELETE SPMON FROM s225.

MESSAGE I002 WITH 'Data is Deleted'.

endif.

if P2 is not initial.

modify SPMON from S225.

MESSAGE I002 WITH 'Data is Modified'.

endif.

ENDFORM.

Hope this helps !

Kind Regards

Ranganath

Former Member
0 Kudos

Hi Jayant,

I will send differnt variation on DELETE and MODIFY.

DELETE:

BASED ON DATABASE TABLES

1.DELETE FROM dbtab.

2.DELETE dbtab FROM TABLE itab.

BASED ON INTERNAL TABLE.

1.DELETE itab INDEX idxno.

2.DELETE itab INDEX sy-tabix.

3.DELETE itab where <condition>.

MODIFY:

BASED ON DATABASE TABLES

1. MODIFY DTTAB.

BASED ON INTERNAL TABLE.

1. MODIFY TABLE itab [FROM wa]

Reward points if helpful.

Kiran kumar.G.A