Skip to Content
author's profile photo Former Member
Former Member

table control in module pool

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Oct 03, 2006 at 09:18 AM

    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^

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 03, 2006 at 09:39 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.