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

inserting data to database through screen fields

Former Member
0 Likes
554

Hi friend iam passing a value from one field and if i press a push button 'SAVE' the value should update in the database . I tried with some coding . But it come with some error like the workare is not long enough .

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 .

<b><b>INSERT VBAK FROM X_DATA.

  • VBAK-VBELN = X_DATA-VBELN.</b></b>

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

3 REPLIES 3
Read only

Former Member
0 Likes
508

Hi Vighnesh,

Please add MANDT field in the structure of t_data and then check.

Please let me know in case of any concern.

Thank you.

Award points if found useful.

Read only

abdulazeez12
Active Contributor
0 Likes
508

Hi Vignesh-

Dont declare 3-4 fields for updating the database tables..declare an internal table by including all the fields of the table..like

DATA: iatb like VBAK occurs 0 with header line.

then enter values in required fields and then use your stmt..

INSERT VBAK FROM X_DATA.

This will work..

Cheers

Read only

Former Member
0 Likes
508

hi..

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