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

Please advise on SELECT --- CORRESPONDING ...

Former Member
0 Likes
734

TYPES: BEGIN OF ty_data,

Field1 like table-field1,

Field2 like table-field2,

Field3 like table-field3,

end of ty_data.

DATA: t_data TYPE TABLE OF ty_data.

SELECT field2 field3

INTO CORRESPONDING FIELDS OF TABLE t_data

FROM table

WHERE a <> ''

AND b = 'CO'

AND c = '01'.

While I use the above SELECT statement I do not get any data in my internal table . All the columns are blanks though it shows that there are 1000 records .

SELECT field2 field3

INTO TABLE t_data

FROM table

WHERE a <> ''

AND b = 'CO'

AND c = '01'.

When I use the one above I get the data for all the 1000 records but they are not populated in the right column in the internal table .

Please advise where I am going wrong .

Also After I get all the data for field2 and field3 . I need to loop again at t_data and create a relationship between field2 and field3 which is going to be field1 = ‘zzzz’.

Please advise .

Thank you,

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
708

Hi,

If you use INTO TABLE the sequence has to match..

So Move the FIELD1 declaration to the third position..

TYPES: BEGIN OF ty_data,

Field2 like table-field2,

Field3 like table-field3,

<b>Field1 like table-field1,</b>

end of ty_data.

Thanks,

Naren

5 REPLIES 5
Read only

Former Member
0 Likes
708

Make your fields lower case:

TYPES: BEGIN OF ty_data,

field1 like table-field1,

field2 like table-field2,

field3 like table-field3,

end of ty_data.

They must match the DB table exactly.

Read only

0 Likes
708

The table only has field2 and field3 .

After getting field2 and field3 I need to create a relationship 'ZZZZ' between fields2 and field3 which will field1 = 'ZZZZ'.

Thanks ,

Read only

0 Likes
708

Where does the ZZZZ come from?

Read only

Former Member
0 Likes
709

Hi,

If you use INTO TABLE the sequence has to match..

So Move the FIELD1 declaration to the third position..

TYPES: BEGIN OF ty_data,

Field2 like table-field2,

Field3 like table-field3,

<b>Field1 like table-field1,</b>

end of ty_data.

Thanks,

Naren

Read only

Former Member
0 Likes
708

Do not use Corresponding field statement ( It has Preformance issue ).

First Declare your Internal Table like :

  • Structure

TYPES: BEGIN OF ty_data,

Field2 like table-field2,

Field3 like table-field3,

end of ty_data.

  • Internal Table

DATA: t_data TYPE TABLE OF ty_data.

  • Work Area

Data : wa_data like line of t_data.

  • Structure

TYPES: BEGIN OF ty_data1,

Field1 like table-field1,

end of ty_data1.

  • Internal Table

DATA: t_data1 TYPE TABLE OF ty_data1.

  • Work Area

Data : wa_data1 like line of t_data1.

Start-of-selection.

SELECT field2 field3

INTO TABLE t_data

FROM table

WHERE a <> ''

AND b = 'CO'

AND c = '01'.

Now loop your internal table

Loop at t_data into wa_data.

• Do the your comparision

And modify the data into one more internal table

T_data1 has value now.

Endloop.

Reward Points if it is helpful

Thanks

Seshu