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: 

TO Move one field from one internal table to onother internal table

Former Member
0 Kudos

Hi friends

in my ITAB1 Iam having follwing records

lgnum matnr werks lgpla

ABC 4545 1000 021234

ABC 4545 1000 031234

ABC 4545 1000 041234

ABC 4545 1000 051234

ABC 4545 1000 061234

ABC 4545 1000 071234

ABC 4545 1000 081234

ABC 4545 1000 091234

now my requiremnet is i have to move only all the values of LGPLA to another internal table ITAB2.

how can i do that.

can any one tell me how to do that.

Regards,

priyanka.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Priyanka,

Try the following:

If you have only one field(lpgla) in itab2.

Loop at itab1.

itab2-lpgla = itab1-lpgla.
append itab2.
clear itab2.

Endloop.

Regards,

Chandra Sekhar

8 REPLIES 8

Former Member
0 Kudos

loop at itab1 and in the loop pass the values to itab2

Former Member
0 Kudos

Hi Priyanka,

Refer the following codes,that will solve ur probelm..

loop at itab1.

move : itab1-LGPLA to itab2-LGPLA.

append itab2.

endloop.

Hope this helps,

Regards,

T.D.M.

Former Member
0 Kudos

hi,

If Your second Internal table have only one Filed ie LGPLA then use MOVE CORRESPONDING.

Otherwise loop at itab1 and place all the LGPLA into itab2 one by one.

Regards

Sumit Agarwal

Former Member
0 Kudos

Hi Priyanka,

Try the following:

If you have only one field(lpgla) in itab2.

Loop at itab1.

itab2-lpgla = itab1-lpgla.
append itab2.
clear itab2.

Endloop.

Regards,

Chandra Sekhar

bpawanchand
Active Contributor
0 Kudos

Hi

Check this snippet

DATA :

BEGIN OF fs_itab1,

a TYPE i,

b TYPE f,

END OF fs_itab1.

DATA :

BEGIN OF fs_itab2,

a TYPE i,

d TYPE c,

END OF fs_itab2.

DATA :

t_itab1 LIKE

STANDARD TABLE

OF fs_itab1.

DATA :

t_itab2 LIKE

STANDARD TABLE

OF fs_itab2.

DO 5 TIMES.

CLEAR fs_itab1.

fs_itab1-a = sy-index.

fs_itab1-b = sy-index.

APPEND fs_itab1 TO t_itab1.

ENDDO.

LOOP AT t_itab1 INTO fs_itab1.

MOVE-CORRESPONDING fs_itab1 TO fs_itab2.

APPEND fs_itab2 TO t_itab2.

ENDLOOP.

LOOP AT t_itab2 INTO fs_itab2.

WRITE :

/ fs_itab2-a,

fs_itab2-d.

ENDLOOP.

Regards

Pavan

Former Member
0 Kudos

A very raw example of how to do it.

Notice that I only filled the table to a given row.

From here you can do your own amendments and make it work for you.

TYPES: BEGIN OF tt,
       lgnum(10) TYPE c,
       matnr(10) TYPE c,
       werks(10) TYPE c,
       lgpla(10) TYPE c,
       END OF tt.

DATA: itab1 TYPE STANDARD TABLE OF tt,
      itab2 TYPE STANDARD TABLE OF tt,
      wa1   TYPE tt,
      wa2   TYPE tt,
      l     TYPE i.


wa1-lgnum = 'ABC'.
wa1-matnr = '4545'.
wa1-werks = '1000'.
wa1-lgpla = '021234'.

APPEND wa1 TO itab1.

wa1-lgnum = 'ABC'.
wa1-matnr = '4545'.
wa1-werks = '1000'.
wa1-lgpla = '031234'.

APPEND wa1 TO itab1.

wa1-lgnum = 'ABC'.
wa1-matnr = '4545'.
wa1-werks = '1000'.
wa1-lgpla = '041234'.

APPEND wa1 TO itab1.

wa1-lgnum = 'ABC'.
wa1-matnr = '4545'.
wa1-werks = '1000'.
wa1-lgpla = '051234'.

APPEND wa1 TO itab1.


DESCRIBE TABLE itab1 LINES l. " gives you how many lines itab1 has
DO l TIMES.
  READ TABLE itab1 INTO wa1 INDEX sy-index.
  wa2-lgpla = wa1-lgpla.
  APPEND wa2 TO itab2.
ENDDO.

LOOP AT itab2 INTO wa2.
  WRITE: /, wa2-lgpla.
ENDLOOP.

Avraham

0 Kudos

Hey Avraham

can u provide me ur help on one of my issue.

if so, i can tell u my requirment.

Regards,

priyanka.

Former Member
0 Kudos

Hi,

You can do in the following way....

types: begin of t_itab2,

lgpla(10) type c,

end of t_itab2.

data:itab2 type table of t_itab2.

data:wa_itab2 type t_itab2.

loop at itab .

wa_itab2-lgpla = itab-lgpla.

append wa_itab2 into itab2.

endloop.

u do some changes according to ur requirement i hope this will help u....

Thanks & Regards

Ashu Singh.