Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

update database table from table control.

Former Member
0 Likes
1,284

hii friends., i want to update database table from table control. i am using internal table to populate the table control.

3 REPLIES 3
Read only

Former Member
0 Likes
543

Hi,

Check these threads for sample program.

Regards,

Maha

Read only

Former Member
0 Likes
543

hi,

You can do it PAI under module USER_COMMAND. and you can use standard UPDATE/MODIFY/DELETE statements to update ur database table and make sure u use a commit work after the use of ablove mentioned statements.

kindly check this.

PROCESS BEFORE OUTPUT.

MODULE status_9010.

LOOP WITH CONTROL tab_control.

MODULE move_data_to_table.

ENDLOOP.

PROCESS AFTER INPUT.

LOOP WITH CONTROL tab_control.

MODULE move_data_from_table.

ENDLOOP.

****************************

&----


*& Module move_data_to_table OUTPUT

&----


  • This is to move the data from the internal table to the table control

----


MODULE move_data_to_table OUTPUT.

  • This is to move the data from the internal table to the table control

zmpets_mode-modecode,zmpets_range-rangeid,zmpets_servfacto-factor are column name of table control

READ TABLE int_factor INDEX tab_control-current_line.

IF sy-subrc = 0.

zmpets_mode-modecode = int_factor-modecode.

zmpets_range-rangeid = int_factor-rangeid.

zmpets_servfacto-factor = int_factor-factor.

ENDIF.

ENDMODULE. " move_data_to_table OUTPUT

**********************

&----


*& Module move_data_from_table INPUT

&----


  • Date is moved from the table control to the Internal Table

----


MODULE move_data_from_table INPUT.

  • To move the data from the table control to internal table 'INT_FACTOR'.

int_factor-modecode = zmpets_mode-modecode.

int_factor-rangeid = zmpets_range-rangeid.

int_factor-factor = zmpets_servfacto-factor.

*here if the data is there, it will modify

MODIFY int_factor INDEX tab_control-current_line.

IF sy-subrc NE 0. "data not exixting in table control . ie new data, then append it

APPEND int_factor.

CLEAR int_factor.

ENDIF.

ENDMODULE. " move_data_from_table INPUT

Also refer to this link:

http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dbac5e35c111d1829f0000e829fbfe/content.htm

<b>Reward points if found helpful…..

Cheers,

Chandra Sekhar.</b>

Read only

Former Member
0 Likes
543

Dear Aditya,

I understand that you want to update the data collected into internal table into the database table, the <b>UPDATE</b>, MODIFY statement can be used to update database table from the table control. These statements can be used in the PAI of your program. The complete update process in SAP is explained in the link given below: <a href="http://help.sap.com/saphelp_nw04s/helpdata/en/e5/de86d835cd11d3acb00000e83539c3/frameset.htm">Updates in SAP System</a>

Also check the standard programs which will help you understand the concept better.

RSDEMO_TABLE_CONTROL

DEMO_DYNPRO_TABLE_CONTROL_1

DEMO_DYNPRO_TABLE_CONTROL_2

RSDEMO_TABLE_CONTROL

Best Regards,

Rajesh

<b>Please reward points if found helpful.</b>