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

Save Data to DB Table

Former Member
0 Likes
2,164

Hi Gurus,

I have developed a module pool program.In that i have a screen with a table control which is editable.

Now i have entered some values in the table control and when i press the save button the data is need to be updated in DB table.

Can anyone send Reference programs for such type of requirement??

Thanks in advance......

8 REPLIES 8
Read only

aarif_baig
Active Participant
0 Likes
1,695

Hi ,

U will have to use....

PAI.

case sy-ucomm.

when 'save'.

modify ....

endcase.

Read only

Former Member
0 Likes
1,695

Hi Madan,

This has been discussed several times in SDN. You can use the search button to get the results.

https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_all&query=howtoupdatedatabasetablefromtable+control&adv=false&sortby=cm_rnd_rankvalue

Cheers

VJ

Read only

Former Member
Read only

Former Member
0 Likes
1,695

In PAI of your prog

Use SY-UCOMM

When its SAVE

Write a subroutine MODULE...

In this module use

MODIFY dbtab FROM warea.

This will help

Regards,

Prashant

Read only

lijisusan_mathews
Active Contributor
0 Likes
1,695

Hi,

Assuming that you have written the modify statement for internal table in PAI in the loop ( ie your internal table has latest updated values ) , all you need to do is is to add the following code to your function code save.:

modify DB-rabname from table itab.

and you have to add SAVE button to you rPF status too.

regards

Suzie

Read only

Former Member
0 Likes
1,695

program zmodpl2.

tables : ztable.

data : it_table type table of ztable 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 ztable.

endmodule. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


module user_command_0100 input.

case ok_code.

when 'INS'.

it_table-carrier = ztable-carrier .

it_table-personnelno = ztable-personnelno.

it_table-flightname = ztable-flightname.

it_table-flightdate = ztable-flightdate.

it_table-f_name = ztable-f_name.

it_table-l_name = ztable-l_name.

it_table-rol_emp = ztable-rol_emp.

it_table-telephone = ztable-telephone.

it_table-city_dept = ztable-city_dept.

it_table-city_arrv = ztable-city_arrv.

append it_table.

insert into ztable values it_table.

message 'SUCCESSFUL INSERTION OF DATA' type 'S' .

when 'EXIT'.

leave program.

endcase.

endmodule. " USER_COMMAND_0100 INPUT

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

and 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.

Read only

Former Member
0 Likes
1,695

Hi,

Refer to these threads

Regards

Manasa

Read only

Former Member
0 Likes
1,695

Hi,



MODULE check INPUT.
  MODIFY it_zmara INDEX t_ctrl-current_line.
  IF t_ctrl-current_line GT ln.
    READ TABLE it_zmara WITH KEY matnr = it_zmara-matnr.
    IF sy-subrc NE 0.
*INSERTING REC IF IT DOES NOT EXIST
      APPEND it_zmara.
    ELSE.
      MESSAGE i005 WITH 'MATERIAL NO.' it_zmara-matnr
      'ALREADY EXIST'.

    ENDIF.
  ENDIF.
ENDMODULE.                 " CHECK  INPUT


MODULE user_command_1000 INPUT.
  DATA: ok_code_ans(1) TYPE c.   "STORING ANSWER OF OK_CODE

  IF ok_code = 'PF_CAN'.
    LEAVE TO SCREEN 0.
  ENDIF.
  IF ok_code = 'CB_SAV'.
    MODIFY zmara FROM TABLE it_zmara.
  ENDIF.
end module.

Thanks,

Krishna...