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

table control in module pool

Former Member
0 Likes
398

hi all,

here i m writing coding for updating kmstand in the first table zfm_kfz.\

i have 2 tables zfm_kfz and zfm_kmvrg

zfm_kfz is generated by using table maintenance generator

where as zfm_kmvrg by using screen update the kmstand in first table zfm_kfz

this is the code,plz correct this code

CONTROLS tabctrl TYPE TABLEVIEW USING SCREEN 100.

DATA: cols LIKE LINE OF tabctrl-cols,

lines TYPE i.

DATA: ok_code TYPE sy-ucomm,

save_ok TYPE sy-ucomm.

DATA: itab TYPE TABLE OF zfm_kmvrg,

fs_itab LIKE LINE OF itab,

fl_change TYPE c,

fl_error TYPE c.

*TABLES fs_itab.

LOOP AT tabctrl-cols INTO cols.

cols-screen-input = '0'.

MODIFY tabctrl-cols FROM cols INDEX sy-tabix.

ENDLOOP.

*SELECT * FROM spfli INTO TABLE itab.

CALL SCREEN 100.

----


  • MODULE status_0100 OUTPUT

----


*

----


MODULE status_0100 OUTPUT.

SET PF-STATUS 'SCREEN_100'.

DESCRIBE TABLE itab LINES lines.

tabctrl-lines = lines.

ENDMODULE. "status_0100 OUTPUT

----


  • MODULE cancel INPUT

----


*

----


MODULE cancel INPUT.

LEAVE PROGRAM.

ENDMODULE. "cancel INPUT

----


  • MODULE read_table_control INPUT

----


*

----


MODULE read_table_control INPUT.

MODIFY itab FROM fs_itab INDEX tabctrl-current_line.

ENDMODULE. "read_table_control INPUT

----


  • MODULE user_command_0100 INPUT

----


*

----


MODULE user_command_0100 INPUT.

DATA:

lw_index TYPE i.

save_ok = sy-ucomm.

  • CLEAR ok_code.

CASE sy-ucomm.

WHEN 'ADD'.

LOOP AT tabctrl-cols INTO cols.

cols-screen-input = '1'.

MODIFY tabctrl-cols FROM cols INDEX sy-tabix.

ENDLOOP.

CLEAR fs_itab.

APPEND fs_itab TO itab.

WHEN 'SAVE'.

IF NOT itab[] IS INITIAL.

LOOP AT itab[] INTO fs_itab.

lw_index = sy-tabix.

  • IF NOT fs_itab IS INITIAL.

  • MODIFY zfm_kmvrg FROM fs_itab.

*

  • IF sy-subrc EQ 0.

UPDATE zfm_kfz set kmstand = fs_itab-kmstand

WHERE kfznr = fs_itab-kfznr.

  • ELSE.

IF sy-subrc ne 0.

fl_error = 'X'.

WRITE:/ 'The record number', lw_index,

'has not been updated'.

ENDIF.

  • ENDIF.

ENDLOOP.

ELSE.

MESSAGE s000(0) WITH 'No data is present to update'.

ENDIF.

ENDCASE.

IF fl_error = 'X'.

LEAVE TO LIST-PROCESSING.

ELSE.

MESSAGE s000(0) WITH

'All the records have been updated successfully'.

ENDIF.

ENDMODULE. "user_command_0100 INPUT

2 REPLIES 2
Read only

Former Member
0 Likes
367

hi

good

go through this table control steps, which ll help youto get a clear idea about the table conrol and use accordingly.

http://sap.niraj.tripod.com/id25.html

thanks

mrutyun^

Read only

Former Member
0 Likes
367

Hi Narendra,

I hope your value is not updating into the Table and if this is the case then try using this systax for updating,

UPDATE dbtab FROM TABLE itab or

UPDATE dbtab FROM wa.

This works successfully only if there are value which you need to update. Its always better to use Modiffy statement since it inserts if no values were found or updates if there is a Match.

MODIFY dbtab FROM wa or

MODIFY dbtab FROM TABLE itab.

Hope this works.

Thanks and Regards,

Prashanth