‎2008 Nov 03 3:06 AM
hi,
i created a table with fields mandt, cno, cname and cdesc.
then i designed a screen with all these fields.
now i want to enter the data in the table via these screen.
for this, in flow logic where i have to maintain the logic?
‎2008 Nov 03 3:19 AM
‎2008 Nov 03 3:35 AM
Hi Kumar,
Basic steps that you have to follow is declare the structure for your field ITAB and Workareas and trigger the logic for Moving and Inserting the text into your table.
Small example for your need
TOP
TABLES: ZTABLE. "Suppose my name of the table.
TYPES: BEGIN OF ST_ZTABLE,
MANDT TYPE ZTABLE-MANDT,
cno TYPE ZTABLE-cno,
cname TYPE ZTABLE-cname,
cdesc TYPE ZTABLE-cdesc,
END OF ST_ZTABLE.
DATA: IT_ZTABLE TYPE TABLE OF ST_ZTABLE, " INTERNAL TABLE
W_ZTABLE TYPE ST_ZTABLE, " WORK AREA
WA_ZTABLE TYPE ZTABLE.
PBO
If you are having any logo or drop down whatever declarations that you have declare here menu too.
PAI
MODULE USER_COMMAND_0901 INPUT.
CASE SY-UCOMM.
WHEN 'SAVE'.
W_ZTABLE-cno = ZTABLE-cno.
W_ZTABLE-CNAME = ZTABLE-CNAME.
W_ZTABLE-CDESC = ZTABLE-CDESC.
MOVE-CORRESPONDING W_ZTABLE TO WA_ZTABLE.
INSERT INTO ZTABLE VALUES WA_ZTABLE.
IF SY-SUBRC = 0.
MESSAGE 'DATA SAVED SUCCESSFULLY' TYPE 'I'..
ENDIF.
ENDCASE.
ENDMODULE.
Make sure your input field names will be tablename-fieldname.
Cheers!!
VEnk@
Edited by: Venkat Reddy on Nov 3, 2008 9:22 AM
‎2008 Nov 03 4:10 AM
Hi Kumar,
You need to create a Structure to populate and create a Table Control from it. So you can use that Table Control to populate data and then you can use the same to save the data to the Database table.
You can have a look at the demo code for the Table control Creation.
DEMO_DYNPRO_TABLE_CONTROL*
You need to write the Database Access code in the SAVE Function Code in the PAI event.
Thanks,
Samantak.