Skip to Content
author's profile photo Former Member
Former Member

Delete modify in itab

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Jan 17, 2008 at 04:13 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 17, 2008 at 04:16 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 17, 2008 at 05:00 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.