0

In my dynpro, I have a table controller, named TC300, that is showing data from my database table zma_kostl. When I change some data in the table controller, the data will be modified even in the database table. This is true when I change the data to some other random data. But when I change the data in a cell to a blank value, the change is not propagated to a database table.

Do you have any idea why?? I think there is error somewhere in module save_data. Do you have any ideas, how to improve the code?

Here is my code:

Top Include:

FUNCTION-POOL zma_ic_screen.

TABLES  zma_kostl.

CONTROLS TC300 TYPE TABLEVIEW USING SCREEN 300.
DATA: cols LIKE LINE OF TC300-cols.

DATA it_zma_kostl TYPE TABLE OF zma_kostl.

Dynpro 300:

PROCESS BEFORE OUTPUT.
  MODULE data_retrieval.

  LOOP AT it_zma_kostl INTO zma_kostl WITH CONTROL TC300.
  ENDLOOP.

  MODULE SET_LINES.

PROCESS AFTER INPUT.
  LOOP AT it_zma_kostl.
    MODULE read_table_control_300.
  ENDLOOP.

  MODULE SAVE_DATA.

Modules:

MODULE data_retrieval OUTPUT.
  IF it_zma_kostl IS INITIAL.
    SELECT kostl
      FROM zma_kostl
      INTO CORRESPONDING FIELDS OF TABLE it_zma_kostl.
  ENDIF.

ENDMODULE.

MODULE read_table_control_300 INPUT.
   MODIFY it_zma_kostl FROM zma_kostl INDEX tc300-current_line.
ENDMODULE.

MODULE save_data INPUT.
  MODIFY zma_kostl FROM TABLE it_zma_kostl.
ENDMODULE.

MODULE set_lines OUTPUT.
  DATA VLINES TYPE I.
  DESCRIBE TABLE it_zma_kostl LINES VLINES.
  TC300-LINES = VLINES + 1.
  DESCRIBE TABLE it_zma_work_section LINES VLINES.
  TC400-LINES = VLINES + 1.
ENDMODULE.
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
stepanVich
  • 318
  • 4
  • 11
  • 2
    The only idea which comes to my mind is that you emptied a field that is part of the primary key of the database table, then `MODIFY` doesn't change the old line, it creates a new one. – Sandra Rossi Jul 25 '21 at 16:29
  • Another idea: maybe you look at the table contents from another session, while you have paused the debugger right after `MODIFY`, so you can't see the changes until there is a database commit. – Sandra Rossi Jul 26 '21 at 11:37
  • 1
    Another idea: to continue on first idea about primary key, maybe you defined a unique secondary index on that table column, or a database constraint/trigger which fails. – Sandra Rossi Jul 26 '21 at 11:39
  • 1
    Could you provide a link to a git repository of your minimal reproducible code, including the DynPro screen and the table definition, so that we can reproduce? Thanks. – Sandra Rossi Jul 27 '21 at 01:38
  • you can check sy-subrc value after `MODIFY` statement in `save-data` and see if it returns smth other than 0 – Suncatcher Jul 27 '21 at 10:06

0 Answers0