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 table control problem

Former Member
0 Likes
379

hi,

here i m entering data in table control it will be updated in the table zfm_kmvrg and kmstand is updated in the table zfm_kfz. for this purpose i m writing coding in module pool when i execute this table control in debbugging fs_itab shows empty even when entering the values ..why?

here i m posting my code

table control field r kfznr, kostentraeger, kmstand from zfm_kmvrg table

coding:

REPORT ZFM_KMVRG .

CONTROLS tabctrl TYPE TABLEVIEW USING SCREEN 100.

TABLES zfm_kmvrg.

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,

  • DATA : Begin of itab occurs 0,

  • kfznr like zfm_kfz-kfznr,

  • kostentraeger like zfm_kfz-kostentraeger,

  • kmstand like zfm_kfz-kmstand,

  • end of itab.

fs_itab like line of itab,

fl_error type c.

  • fs_itab LIKE LINE OF itab,

  • fl_change TYPE c,

  • fl_error TYPE c.

*TABLES zfm_kmvrg.

LOOP AT tabctrl-cols INTO cols.

IF cols-screen-input = '0'.

MODIFY tabctrl-cols FROM cols INDEX sy-tabix.

  • insert tabctrl-cols into cols FROM cols INDEX sy-tabix.

*

ENDIF.

ENDLOOP.

*SELECT * FROM zfm_kmvrg INTO TABLE itab.

CALL SCREEN 100.

----


  • MODULE status_0100 OUTPUT

----


*

----


MODULE status_0100 OUTPUT.

SET PF-STATUS 'SCREEN_100'.

  • SELECT KFZNR KOSTENTRAEGER KMSTAND FROM zfm_kmvrg INTO CORRESPONDING FIELDS OF

  • TABLE itab.

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

CLEAR ok_code.

CASE save_ok.

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

LEAVE PROGRAM.

WHEN 'SAVE'.

IF NOT itab IS INITIAL.

Sort itab by kfznr kostentraeger kmstand ascending.

LOOP AT itab INTO fs_itab.

lw_index = sy-tabix.

IF NOT fs_itab IS INITIAL.

MODIFY zfm_kmvrg FROM fs_itab.

  • insert zfm_kmvrg from fs_itab.

  • insert zfm_kmvrg from itab.

IF sy-subrc eq 0.

UPDATE zfm_kfz set kmstand = fs_itab-kmstand WHERE kfznr = fs_itab-kfznr.

ELSE.

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

naimesh_patel
Active Contributor
0 Likes
346

Hello,

In this moudle: you need to append the values.

MODULE read_table_control INPUT.

read table itab into wa_itab with key matnr = fs_itab-matnr. " your primary key of itab

if sy-sybrc = 0.

MODIFY itab FROM fs_itab INDEX tabctrl-current_line.

else.

append fs_itab to itab.

endif.

ENDMODULE. "read_table_control INPUT

Regards,

Naimesh

Read only

Former Member
0 Likes
346

Though you have commented the clear statement before the APPEND.

I do not see any initialization of fs_itab fields...are they linked to the screen fields >

If so use it within loop...endloop and check.

Regards

Anurag