Application Development 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: 

Modify statement

Former Member
0 Kudos

Hi all ,

This is my code .i have to change one material number value in the it_zws_plcsmev1 and append to it_zws_plcsmev table . Its working fine now.

Is there any performance issues with this code ?

t_mara1[] = t_mara[].------> is this appends the records in the same sequence of t_mara because i need to read the previous record .

LOOP AT t_mara WHERE matnr NE t_upload1-matnr.

READ TABLE it_zws_plcsmev1 INDEX 1 .

it_zws_plcsmev1-matnr = t_mara-matnr.

v_ind = v_ind + 1.

IF v_ind = '1'.

MODIFY it_zws_plcsmev1 TRANSPORTING matnr WHERE matnr = t_upload1-matnr .

APPEND LINES OF it_zws_plcsmev1 TO it_zws_plcsmev.

ENDIF.

IF v_ind GT '1'.

v_index = v_ind - 1.

READ TABLE t_mara1 INDEX v_index.

MODIFY it_zws_plcsmev1 TRANSPORTING matnr WHERE matnr = t_mara1-matnr .

APPEND LINES OF it_zws_plcsmev1 TO it_zws_plcsmev.

ENDIF.

ENDLOOP.

Is there any better way to write the same code ?

2 REPLIES 2

Former Member
0 Kudos

Hi,



LOOP AT t_mara WHERE matnr NE t_upload1-matnr.
READ TABLE it_zws_plcsmev1 INDEX 1 .
if SY-SUBRC = 0.       " Add this
it_zws_plcsmev1-matnr = t_mara-matnr.
v_ind = v_ind + 1.

IF v_ind = '1'.
MODIFY it_zws_plcsmev1 TRANSPORTING matnr WHERE matnr = t_upload1-matnr .
APPEND LINES OF it_zws_plcsmev1 TO it_zws_plcsmev.
ENDIF.
Endif.        " Endif for Sy-subrc 
IF v_ind GT '1'.
v_index = v_ind - 1.
READ TABLE t_mara1 INDEX v_index.
IF sy-subrc = 0.   " Add this
MODIFY it_zws_plcsmev1 TRANSPORTING matnr WHERE matnr = t_mara1-matnr .
APPEND LINES OF it_zws_plcsmev1 TO it_zws_plcsmev.
ENDIF.
ENDIF.   " Endif for Sy-SUBRC 
ENDLOOP.

Former Member
0 Kudos

please go throught eh below code and see it .... otherwise give the fullcode of it ....

t_mara1[] = t_mara[].
Append  t_mara1 .

LOOP AT t_mara WHERE matnr NE t_upload1-matnr.
READ TABLE it_zws_plcsmev1 with  key  matnr = t_mara-matnr .
v_ind = v_ind + 1.

IF v_ind = '1'.
MODIFY it_zws_plcsmev1 TRANSPORTING matnr WHERE matnr = t_upload1-matnr .
APPEND LINES OF it_zws_plcsmev1 TO it_zws_plcsmev.
ENDIF.
IF v_ind GT '1'.
v_index = v_ind - 1.
READ TABLE t_mara1 with  key  matnr = t_mara-matnr .
MODIFY it_zws_plcsmev1 TRANSPORTING matnr WHERE matnr = t_mara1-matnr .
APPEND LINES OF it_zws_plcsmev1 TO it_zws_plcsmev.
ENDIF.

ENDLOOP.

<b>Note :</b>

and you can refer the library for both the statements READ & MODIFY ... by pressing F1 on it . combination of both willl solve you problem ....

reward points if it is usefulll ....

Girish