06-12-2012 8:34 AM
*&---------------------------------------------------------------------*
*& 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
06-12-2012 10: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
06-12-2012 9: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
06-12-2012 10: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.
06-12-2012 10: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
06-12-2012 10:42 AM
Hi Ranjith,
Seems to be a simple utility to play with the contents of the table.
Is there any specific reason that you are not creating "Table Maintenance Generator" for this requirement.
You can achieve all this without bothering about any coding part.
06-12-2012 11: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