Application Development and Automation 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: 
Read only

Update field content

Former Member
0 Likes
741

Hi

I Have this code

LOOP AT lt_tab2 INTO ls_tab.

SELECT SINGLE budat INTO aux_budat_df FROM zmm_trocdev_item

WHERE zproc EQ ls_tab-zproc

AND st_glob EQ 'E'.

BREAK-POINT.

ENDLOOP.

I need update the field BUDAT_DF of table LT_TAB2 with content of AUX_BUDAT_DF

I Try to made an UPDATE but doens't work... what is the better way to do this ?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
719

Hi,

Check out the below code:

1. Avoid select statements in between the loops they are major performace issue.

data:
begin of wa,
zproc type zmm_trocdev_item-zproc,
budat typer zmm_trocdev_item-budat,
end of wa.

data:
itab like standard table of wa with header line.

if not lt_tab2[] is initial.
select zproc
          budat
   into table itab
   from zmm_trocdev_item
    for all entries in lt_tab2
 where zproc eq lt_tab2-zproc
    and st_glob eq 'E'.
endif.

LOOP AT lt_tab2 INTO ls_tab.
read table itab with key zproc = ls_tab-zproc.
if sy-subrc eq 0.
  ls_tab-BUDAT_DF = itab-budat.
  modify lt_tab2 from ls_tab index sy-tabix transporting BUDAT_DF.
endif.
endloop.

Thanks & Regards,

Navneeth K.

5 REPLIES 5
Read only

Former Member
0 Likes
719

LOOP AT lt_tab2 INTO ls_tab.

update LT_TAB2

set BUDAT_DF to ls_tab-BUDAT_DF

WHERE zproc EQ ls_tab-zproc

AND st_glob EQ 'E'.

endloop.

Read only

Former Member
0 Likes
720

Hi,

Check out the below code:

1. Avoid select statements in between the loops they are major performace issue.

data:
begin of wa,
zproc type zmm_trocdev_item-zproc,
budat typer zmm_trocdev_item-budat,
end of wa.

data:
itab like standard table of wa with header line.

if not lt_tab2[] is initial.
select zproc
          budat
   into table itab
   from zmm_trocdev_item
    for all entries in lt_tab2
 where zproc eq lt_tab2-zproc
    and st_glob eq 'E'.
endif.

LOOP AT lt_tab2 INTO ls_tab.
read table itab with key zproc = ls_tab-zproc.
if sy-subrc eq 0.
  ls_tab-BUDAT_DF = itab-budat.
  modify lt_tab2 from ls_tab index sy-tabix transporting BUDAT_DF.
endif.
endloop.

Thanks & Regards,

Navneeth K.

Read only

Former Member
0 Likes
719

Hello,

You can use a MODIFY TABLE <internal table> from <work area> transporting <workarea fieldname>.

Please make sure that you have got the value in work area with which you want to update the internal table before the modify statement.

Thanks,

Jayant.

Read only

Former Member
0 Likes
719

Hi,

Try this piece of code.

LOOP AT lt_tab2 INTO ls_tab.

SELECT SINGLE budat INTO aux_budat_df FROM zmm_trocdev_item

WHERE zproc EQ ls_tab-zproc

AND st_glob EQ 'E'.

BREAK-POINT.

ls_tab-budat_df = aux_bdat_df.

modify lt_tab2 from ls_tab transporting budat_df.

ENDLOOP.

Read only

Former Member
0 Likes
719

Hi you can modify by using the TABIX. try this one...

LOOP AT IT_TAB2 INTO LS_TAB.

WA_TABIX = SY-TABIX.

SELECT SINGLE BUDAT

INTO AUX_BUDAT_DF

FROM ZMM_TROCDEV_ITEM

WHERE ZPROC = LS_TAB-ZPROC AND

ST_GLOB = 'E'.

IF SY-SUBRC = 0.

LS_TAB-BUDAT = AUX_BUDAT_DF.

MODIFY IT_TAB2 INDEX WA_TABIX FROM LS_TAB.

ENDIF.

ENDLOOP.

Regards,

R