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

module pool programs

Former Member
0 Likes
425

hai to all.

iam creating a transaction screen .

from that screen iwant to insert the data into database.

how can we pass the data from screen element to database -fields.

can i pass the data through the insert command.

plz suggest me .

thanks ...

satya.

2 REPLIES 2
Read only

Former Member
0 Likes
397

Hi Satya,

Go through the below example for updating VBAK TABLE:

first take a internal table(it_vbak) which would have a same structure of vbak(including mandt) ...

then modify or move record in it_vbak from record(which u want update or insert) use composite key funda..

then finally update vbak table from it_vbak table....

SAMPLE SOURCE CODE :

TABLES : vbak .

TYPES: BEGIN OF t_data,

vbeln TYPE vbak-vbeln,

erdat TYPE vbak-erdat,

erzet TYPE vbak-erzet,

ernam TYPE vbak-ernam,

END OF t_data.

DATA : x_data TYPE T_DATA,

it_data TYPE TABLE OF t_data .

DATA : ok_code LIKE sy-ucomm .

DATA : so_no LIKE vbak-vbeln .

CONTROLS tc TYPE TABLEVIEW USING SCREEN 100 .

CALL SCREEN 100 .

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE user_command_0100 INPUT.

CASE ok_code.

WHEN 'DISPLAY'.

SELECT vbeln erdat erzet ernam FROM vbak INTO TABLE it_data WHERE vbeln = so_no .

CLEAR ok_code .

WHEN 'EXIT'.

LEAVE PROGRAM.

CLEAR ok_code.

WHEN 'UPDATE'.

LOOP AT it_data INTO x_data.

UPDATE vbak SET ernam = x_data-ernam

WHERE vbeln = x_data-vbeln.

ENDLOOP.

COMMIT WORK.

WHEN 'SAVE'.

X_DATA-VBELN = SO_NO .

INSERT VBAK FROM X_DATA.

  • VBAK-VBELN = X_DATA-VBELN.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Module UPDATE INPUT

&----


  • text

----


MODULE update INPUT.

MODIFY it_data FROM x_data INDEX tc-current_line TRANSPORTING vbeln ernam.

ENDMODULE. " UPDATE INPUT

<b>Kindly Reward points if you found the reply helpful.</b>

Cheers,

CHAITANYA.

Read only

Former Member
0 Likes
397

Hi,

take the work area of that table, assign the values to that work area, now you can update the table using "Insert" or "modify" statement.

example.

tables: mara.

data:

wa_mara type mara.

wa_mara-matnr = 'Material Number'.

wa_mara-erdat = sy-datum.

insert mara values wa_mara.

this is an example don't update any SAP standard tables using this method, you have to do this task using standard transactions only.

reward if needful.

Thanks,

Sreeram.