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

how to update contents in a table created using module pool programming? unable to do that process for the below code

*&---------------------------------------------------------------------*

*& Module Pool ZCDSHOP

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

PROGRAM ZCDSHOP.

tables : zcustomer.

CONTROLS MATERIAL TYPE TABLEVIEW USING SCREEN 2000.

TYPES: BEGIN OF ST_zCUSTOMER,

zfirstname type zcustomer-zfirstname,

zlastname type zcustomer-zlastname,

zadress type zcustomer-zadress,

zcdname type zcustomer-zcdname,

ztakendate type zcustomer-ztakendate,

zlastdate type zcustomer-zlastdate,

zamount type zcustomer-zamount,

END OF ST_zCUSTOMER.

DATA: IT_ST TYPE TABLE OF ST_zCUSTOMER,

WA_ST TYPE ST_zCUSTOMER,

IT_zCUSTOMER TYPE zCUSTOMER,

WA_zCUSTOMER TYPE zCUSTOMER,

OK_CODE LIKE SY-UCOMM.

start-of-selection.

CALL SCREEN 2000.

*&---------------------------------------------------------------------*

*& Module V1 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE V1 INPUT.

CASE OK_CODE.

WHEN 'SAVE'.

WA_ST-zfirstname = zCUSTOMER-zfirstname.

WA_ST-zlastname = zCUSTOMER-zlastname.

WA_ST-zadress = zcUSTOMER-zadress.

WA_ST-zcdname = zCUSTOMER-zcdname.

WA_ST-ztakendate = zCUSTOMER-ztakendate.

WA_ST-zlastdate = zCUSTOMER-zlastdate.

WA_ST-zamount = zCUSTOMER-zamount.

MOVE-CORRESPONDING WA_ST TO WA_zCUSTOMER.

INSERT INTO zCUSTOMER VALUES WA_zCUSTOMER.

WHEN 'DELETE'.

WA_ST-zfirstname = zCUSTOMER-zfirstname.

WA_ST-zlastname = zCUSTOMER-zlastname.

WA_ST-zadress = zcUSTOMER-zadress.

WA_ST-zcdname = zCUSTOMER-zcdname.

WA_ST-ztakendate = zCUSTOMER-ztakendate.

WA_ST-zlastdate = zCUSTOMER-zlastdate.

WA_ST-zamount = zCUSTOMER-zamount.

MOVE-CORRESPONDING WA_ST TO WA_zCUSTOMER.

DELETE zCUSTOMER FROM WA_zCUSTOMER.

WHEN 'MODIFY'.

WA_ST-zfirstname = zCUSTOMER-zfirstname.

WA_ST-zlastname = zCUSTOMER-zlastname.

WA_ST-zadress = zcUSTOMER-zadress.

WA_ST-zcdname = zCUSTOMER-zcdname.

WA_ST-ztakendate = zCUSTOMER-ztakendate.

WA_ST-zlastdate = zCUSTOMER-zlastdate.

WA_ST-zamount = zCUSTOMER-zamount.

MODIFY zCUSTOMER FROM WA_zCUSTOMER.

ENDCASE.

ENDMODULE. " V1 INPUT

*&---------------------------------------------------------------------*

*& Module EXIT INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE EXIT INPUT.

IF OK_CODE = 'EXIT'.

LEAVE PROGRAM.

ENDIF.

ENDMODULE. " EXIT INPUT

*&---------------------------------------------------------------------*

*& Module STATUS_2000 OUTPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

module STATUS_2000 output.

* SET PF-STATUS 'xxxxxxxx'.

* SET TITLEBAR 'xxx'.

endmodule. " STATUS_2000 OUTPUT

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Jun 12, 2012 at 09:25 AM

    Hi Ranjith,

    Instead of INSERT staement in SAVE , use below statements

    MODIFY zCUSTOMER FROM WA_zCUSTOMER.
    COMMIT WORK. "To write records on Database

    Best Regards,

    Sachin

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 12, 2012 at 09:13 AM

    Hi Ranjith,

    In modify part you are missing the move corresponding statement.

    MOVE-CORRESPONDING WA_ST TO WA_zCUSTOMER.

    Please add this statement and your code would work.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 12, 2012 at 10:45 AM

    Hi Ranjit,

    To update a transparent table from a workarea or an internal table, you must declare the internal table/workarea of exactly the same type as the transparent table. You will also have to declare field MANDT (if present in transparent table).

    Regards,

    Prashant

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 12, 2012 at 08:42 AM

    Hi Ranjith

    From your code I take it that your SAVE function is not working....

    Try changing your Insert to Modify zdbtzb from itab.

    In this if the record (comparing keys) exists then the table is updated and if it doesn't then it will be inserted.

    Hope this Helps

    Regards

    Vic

    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.