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

Re : Internal tables

Former Member
0 Likes
1,246

Hi Guru's,

I have 2 internal tables ALV_LTB AND IT_BOM.

IN ALV_LTB i have the data like

stlal I stlnr I stlst I datuv I............

03 I 40 I - I 02.04.2008

02 I 60 I - I 03.04.2008

IN IT_BOM i have the data like this

stlal I stlnr I stlst I datuv

03 I 40 I 02 I 02.04.2008

02 I 60 I 01 I 03.04.2008

i want to modify the internal table ALV_LTB like beloow

stlal I stlnr I stlst I datuv

03 I 40 I 02 I 02.04.2008

02 I 60 I 01 I 03.04.2008

can any one help me how to do this...

Thanks & Best Regards,

Praveen.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,203
loop at alv_tb into wa_alv.
read table it_bom into wa_bom with key stlal = wa_alv-stlal. "Read the corresponding entry
wa_alv-stlst = wa_bom-stlst. 
modify alv_tb from wa_alv transporting stlst. "modify the alv table
endloop.

Hi Guru's,

I have 2 internal tables ALV_LTB AND IT_BOM.

IN ALV_LTB i have the data like

stlal I stlnr I stlst I datuv I............

03 I 40 I - I 02.04.2008

02 I 60 I - I 03.04.2008

IN IT_BOM i have the data like this

stlal I stlnr I stlst I datuv

03 I 40 I 02 I 02.04.2008

02 I 60 I 01 I 03.04.2008

i want to modify the internal table ALV_LTB like beloow

stlal I stlnr I stlst I datuv

03 I 40 I 02 I 02.04.2008

02 I 60 I 01 I 03.04.2008

can any one help me how to do this...

Thanks & Best Regards,

Praveen.

7 REPLIES 7
Read only

Former Member
0 Likes
1,203

Hi You can use MOVE-CORRESPONDING..

MOVE-CORRESPONDING alv_tab TO it_bom.

Hope this helps...

Read only

Former Member
0 Likes
1,203

Hi,

Try this......

LOOP AT IT_BOM.

LOOP AT ALV_LTB WHERE stlal = IT_BOM-stlal AND stlnr = IT_BOM-stlnr.

ALV_LTB-stlst = IT_BOM-stlst.

MODIFY ALV_LTB.

ENDLOOP.

ENDLOOP.

Read only

Former Member
0 Likes
1,203

hi,

you may try the following approach:

loop at it_ltb into wa_ltb.
g_tabix = sy-tabix.
read table it_bom into wa_bom with key stlal = wa_ltb-stlal.
wa_ltb-stlst = wa_bom-stlst.
modify it_ltb from wa_ltb transporting stlst index g_tabix.
clear wa_ltb.
clear wa_bom.
clear g_tabix.
endloop.

best regards,

Prinan

Read only

Former Member
0 Likes
1,204
loop at alv_tb into wa_alv.
read table it_bom into wa_bom with key stlal = wa_alv-stlal. "Read the corresponding entry
wa_alv-stlst = wa_bom-stlst. 
modify alv_tb from wa_alv transporting stlst. "modify the alv table
endloop.
Read only

Former Member
0 Likes
1,203

hi praveen,

as far as i understand u want to modify the stlst value in the ALV_LTB table... right?

so..

loop at alv_ltb into ls_alv_ltb. "ls_alv_ltv is work area for alv_ltb.
    clear ls_IT_BOM.
*reading the same row of IT_BOM.
    read table IT_BOM into ls_IT_BOM with key stlal = ls_alv_ltb-stlal stlnr = ls_alv_ltb-stlnr.
    if sy-subrc = 0.
         ls_alv_ltb-stlst = ls_IT_BOM-stlst.
*modifying alv_ltb from the value we got from IT_BOM
         modify alv_tlb from ls_alv_ltb.
    endif.
    clear : ls_alv_ltb.
endloop.

i hope this helps...

Read only

Former Member
0 Likes
1,203

Hello


LOOP AT ALV_LTB.
  READ TABLE IT_BOM WITH KEY STLAL = ALV_LTB-STLAL
                             STLNR = ALV_LTB-STLNR.
  IF SY-SUBRC = 0.
    ALV_LTB-STLST = IT_BOM-STLST.
    MODIFY ALV_LTB INDEX SY-TABIX.
  ENDIF.
ENDLOOP.

Read only

harimanjesh_an
Active Participant
0 Likes
1,203

Hi,

If you use FIELD SYMBOLS, it will also improve the performance.

Declare a field symbol of type similar to that of ALV_LTB so that we can avoid MODIFY statement which will improve performance.

LOOP AT ALV_LTB ASSIGNING <FS_LTB>.

READ TABLE IT_BOM WITH KEY STLAL = <FS_LTB>-STLAL

STLNR = <FS_LTB>-STLNR.

IF SY-SUBRC = 0.

<FS_LTB>-STLST = IT_BOM-STLST.

ENDIF.

ENDLOOP.

UNASSIGN <FS_LTB>.

Thanks,

Harimanjesh AN