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

How to pick two fields from an internal table which has many fields

Former Member
0 Likes
1,084

EX:Given format

Field1 Field2 Field3 Field4(we get these 4 fields in the form of Tab delimited text file)

How to pick Field2 and Field3 with all the value into another internal table which has these two fields ?

Ex:Required format

Field2 Field3

Thanks in advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,063

Hi shilpa,

loop at itab1 into wa_itab1.

wa_itab2-field2 = wa_itab1-field2.

wa_itab2-field3 = wa_itab1-field3.

append wa_itab2 to itab2.

endloop.

Regards,

Vidya

EX:Given format

Field1 Field2 Field3 Field4(we get these 4 fields in the form of Tab delimited text file)

How to pick Field2 and Field3 with all the value into another internal table which has these two fields ?

Ex:Required format

Field2 Field3

Thanks in advance.

6 REPLIES 6
Read only

Former Member
0 Likes
1,064

Hi shilpa,

loop at itab1 into wa_itab1.

wa_itab2-field2 = wa_itab1-field2.

wa_itab2-field3 = wa_itab1-field3.

append wa_itab2 to itab2.

endloop.

Regards,

Vidya

Read only

Former Member
0 Likes
1,063

Hi shilpa,

1. I don't think it is directly possible,

in case of upload using GUI_UPLOAD.

(we have to design the internal table,

as per the data in the file)

2. However, we can do the reverse,

in case of download using GUI_DOWNLOAD

(If our internal table contains 5 fields,

we can output only 2,5 field for eg)

using the parameter COL_SELECT_MASK )

regards,

amit m.

Read only

Former Member
0 Likes
1,063

You split the text from the four fields on TAB.

loop at itab.

SPLIT itab-field at cl_abap_char_utilities=>horizontal_tab into f1 f2 f3 f4.

move f2 to itab1-f2.

move f3 to itab1-f3.

append itab1.

endloop.

Regards

Anurag

Message was edited by: Anurag Bankley

Message was edited by: Anurag Bankley

Read only

Manohar2u
Active Contributor
0 Likes
1,063

Create a new internal table with field2 and field3 fields.

then use move-corresponding statement to move from itab1 to itab2.

move corresponding itab1[] to itab2[]

Regds

Manohar

Read only

Former Member
0 Likes
1,063

Hi,

While uploading data from flat file you couldn`t filter based on field names. After uploading the data, create a second internal table with fields of your need and use MOVE-CORRESPONDING ITAB1 TO ITAB2.

Hope the info. is helpful, reward if so.

Regards

Read only

Former Member
0 Likes
1,063

If I got you right:

If you simply want to copy these two fields from one table to another:


DATA:
   lt_itab1 TYPE TABLE OF TS_ITAB1.
   lt_itab2 TYPE TABLE OF TS_ITAB2.
   ls_itab1 TYPE TS_ITAB1, " structure with F1-F4
   ls_itab2 TYPE TS_ITAB2. " structure with F2, F3
   
   LOOP at lt_itab1 INTO ls_itab1.
      MOVE-CORRESPONDING ls_itab1 TO ls_itab2.
      APPEND ls_itab2 TO lt_ITAB2.
   ENDLOOP.

If it is not what you were looking for - be more specific when asking a question.