‎2008 Nov 13 4:34 AM
Hi Experts,
I have created Table control on screen . After entering no of rows of data manually in Table control and after clicking on save button, entered data should be get saved into the corresponding table.
Please help me on this issue.
Thanks & Regards,
Nagaraju C.
‎2008 Nov 13 4:47 AM
Hi,
If you are talking about a Standard SAP Table , then you should only use BDC, BAPI or IDOC to populate the Table data.
If it is a Custom Z Table, then you can use INSERT Statement.
Catch the Function Code triggred by the SAVE Button and put your code there only.
Refer:
http://www.saptechnical.com/Tutorials/ABAP/TableControl/Demo.htm
Edited by: AJAY TIWARI on Nov 13, 2008 5:49 AM
‎2008 Nov 13 4:47 AM
Hi,
If you are talking about a Standard SAP Table , then you should only use BDC, BAPI or IDOC to populate the Table data.
If it is a Custom Z Table, then you can use INSERT Statement.
Catch the Function Code triggred by the SAVE Button and put your code there only.
Refer:
http://www.saptechnical.com/Tutorials/ABAP/TableControl/Demo.htm
Edited by: AJAY TIWARI on Nov 13, 2008 5:49 AM
‎2008 Nov 13 4:48 AM
Hi,
try this..
in PAI.
case ok_code.
when 'SAVE'.
modify <DBtablename> from table <itab>.
end case.
‎2008 Dec 16 11:08 AM
program znmodpl2.
tables : zntable.
data : it_table type table of zntable with header line.
controls : tabcntrl type tableview using screen 100.
data : ok_code type sy-ucomm.
&----
*& Module STATUS_0100 OUTPUT
&----
text
----
module status_0100 output.
set pf-status '0100'.
set titlebar '100'.
move-corresponding it_table to zntable.
endmodule. " STATUS_0100 OUTPUT
&----
*& Module USER_COMMAND_0100 INPUT
&----
text
----
module user_command_0100 input.
case ok_code.
when 'INS'.
it_table-carrier = zntable-carrier .
it_table-personnelno = zntable-personnelno.
it_table-flightname = zntable-flightname.
it_table-flightdate = zntable-flightdate.
it_table-f_name = zntable-f_name.
it_table-l_name = zntable-l_name.
it_table-rol_emp = zntable-rol_emp.
it_table-telephone = zntable-telephone.
it_table-city_dept = zntable-city_dept.
it_table-city_arrv = zntable-city_arrv.
append it_table.
insert into zntable values it_table.
message 'SUCCESSFUL INSERTION OF DATA' type 'S' .
when 'EXIT'.
leave program.
endcase.
endmodule. " USER_COMMAND_0100 INPUT
*************************************************************************************
The Flow Logic will be :
process before output.
loop at it_table with control tabcntrl.
module status_0100.
endloop.
process after input.
loop at it_table .
module user_command_0100.
endloop.
thank & regards,
Nilay Sarkar.
‎2008 Dec 16 11:22 AM
Hi Nagaraju,
Use this code, its working.
Take the name of input/output fields in the table as wa-field_name.
At screen flow logic
PROCESS BEFORE OUTPUT.
MODULE STATUS_8003.
LOOP WITH CONTROL PO_TB. "PO_TB is the name of table control on screen
ENDLOOP.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_8003.
LOOP WITH CONTROL PO_TB. "PO_TB is the name of table control on screen
MODULE INSERT_DATA. "module to insert data into the database table from the internal table
ENDLOOP.
MODULE SAVE_DATA. "module to save data from table control to database table
In PBO
module STATUS_8003 output.
SET PF-STATUS 'Z_ADDRC'.
* SET TITLEBAR 'xxx'.
endmodule. " STATUS_8003 OUTPUT
In PAI
MODULE USER_COMMAND_8003 INPUT.
OK_CODE = SY-UCOMM.
CASE OK_CODE.
WHEN 'BACK'.
LEAVE TO SCREEN 8001.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_8003 INPUT
MODULE INSERT_DATA INPUT.
APPEND WA_ZEKPO TO IT_ZEKPO.
ENDMODULE. " INSERT_DATA INPUT
MODULE SAVE_DATA INPUT.
DATA : A LIKE SY-DBCNT.
OK_CODE = SY-UCOMM.
CASE OK_CODE.
WHEN 'SAVE'.
MODIFY ZEKPO FROM TABLE IT_ZEKPO. "this will insert new records and update existing records
* INSERT ZEKPO FROM TABLE IT_ZEKPO. "this will insert records, but you need to make out for validations
A = SY-DBCNT.
IF SY-SUBRC = 0.
MESSAGE S008 WITH A. "Success msg with number of records inserted/updated/modified.
ENDIF.
ENDCASE.
ENDMODULE. " SAVE_DATA INPUT
Hope this solves your problem.
Thanks & Regards
Tarun Gambhir
Edited by: Tarun Gambhir on Dec 17, 2008 11:56 AM