*&----------------------- ------------------------- -----------*
*& Report ZMODIFYITAB *
*& *
*&----------------------- ------------------------- -----------*
*& Example of Modifying an internal table value *
*& *
*&----------------------- ------------------------- -----------*
*&-Created By details------------------ ----------------------*
*& *
*& Author : www.sapdev.co.uk *
*& SAP ABAP development *
*&----------------------- ------------------------- -----------* ************************* ************
*Start-of-selection. ************************* ************
*End-of-selection.
Report ZMODIFYITAB. type-pools: slis. "ALV Declarations*Data Declaration *----------------
TYPES: BEGIN OF t_ekpo, ebeln TYPE ekpo-ebeln, ebelp TYPE ekpo-ebelp, statu TYPE ekpo-statu, aedat TYPE ekpo-aedat, matnr TYPE ekpo-matnr, menge TYPE ekpo-menge, meins TYPE ekpo-meins, netpr TYPE ekpo-netpr, peinh TYPE ekpo-peinh, END OF t_ekpo. DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0, wa_ekpo TYPE t_ekpo.*************************
START-OF-SELECTION. select ebeln ebelp statu aedat matnr menge meins netpr peinh up to 10 rows from ekpo into table it_ekpo.*************************
END-OF-SELECTION. loop at it_ekpo into wa_ekpo. wa_ekpo-netpr = '100'. MODIFY it_ekpo INDEX sy-tabix FROM wa_ekpo TRANSPORTING netpr. endloop.
Add/Change a row in internal table
You would not use the modify command to add an entry to an internal table, this would be done using the APPEND command. When updating an itab simply read the table first to check if an entry exists with required key and then MODIFY or APPEND based on the result:
You would not use the modify command to add an entry to an internal table, this would be done using the APPEND command. When updating an itab simply read the table first to check if an entry exists with required key and then MODIFY or APPEND based on the result:
READ it_ekpo into wa_ekpo with key ebeln = ld_ebeln. if sy-subrc eq 0. MODIFY it_ekpo from wa_ekpo index sy-tabix. else. APPEND wa_ekpo to it_ekpo. endif.
0 Comments