Thursday, 2 May 2013

TRANSPORTING keyword example. To Change a single field/Column in Internal Table without changing remaining columns of same Row


          LOOP AT file_structure INTO gw_file_structure.
        CLEAR gv_tabix .
        gv_tabix sy-tabix .

        READ TABLE gt_components INTO gw_components INDEX gv_tabix.
        gw_file_structure-file_size gw_components-comp_size.
        IF sy-subrc EQ 0.
          MODIFY file_structure FROM gw_file_structure
          INDEX gv_tabix TRANSPORTING file_size.
        ENDIF.
      ENDLOOP.


only file_size has to be changed in the internal table, so we are using TRANSPORTING command.

Note : Instead of transporting , always using field symbols as we don't need to maintain the logic for tabix or index and clear the workarea. We can directly change it in the workarea which will reflect in the internal table.

No comments:

Post a Comment