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: 

SELECT statement

Former Member
0 Kudos

Hi everybody,

I have to get only three fields form a Ztable and pass them to an internal table(which is of type another Ztable)

Field names are different in the Ztable and the internal table

Please give me the SELECT ststement

Thanks in advance

1 ACCEPTED SOLUTION

JozsefSzikszai
Active Contributor
0 Kudos

hi Ajay,

fields in ztable: z1, z2, z3

fields in internal table: i1, i2, i3.

SELECT z1 AS i1
              z2 AS i2
              z3 AS i3
              FROM ztable
              INTO CORRESPONDING FIELDS OF TABLE itab
              WHERE ...

hope this helps

ec

9 REPLIES 9

Former Member
0 Kudos

Try this...


SELECT <fld> <fld2> <fld3> INTO (itab-fld1, itab-fld2, itab-fld3) FROM <tab>
WHERE <COND>.

APPEND itab.

ENDSELECT.

Former Member
0 Kudos

Hi,

let me know all the 3 fields are having same data type and lengths?

send me those fields.

thanks,

Sreeram.

0 Kudos

Yes all the three fields have same datatypes and lengths

Only the field headings have been chaned

regards

Former Member
0 Kudos

Hi Ajay,

Create a structure called zxxx

IN ZXXX CREATE THE 3 FIELDS FROM THE ZTABLE

BEGIN OF ITAB OCCURS 0

INCLUDE STRUCTURE ZXXX

END OF ITAB.

Regards,

Sreenivas

0 Kudos

select field1 field2 field3

from ztable

into (ls_struct_table2-fieldx,s_struct_table2-fieldy,s_struct_table2-fieldz)

where ....

append ls_struct_table2 to table2.

endselect.

This code is very dangerous but, now i only remember this form.

Luck

Former Member
0 Kudos

hi,

Ajay

do neccasary data declarations

select f1 f2 f3

from ztable1

into (v1, v2, v3)

ztable2-f1 = v1.

ztable2-f2 = v2.

ztable2-f3 = v3.

append ztable2.

endselect.

plzzzzzz reward if useful

feel free to ask any quieries my mail id is mutyalasunilkumar@gmail.com

Former Member
0 Kudos

Dear Ajay,

Assuming zfield1, zfield2, and zfield3 to be the three fields in your ZTABLE AND

I_ZTAB to be the internal table of the structure type ZTABLE with different field names:

SELECT ZFIELD1 ZFIELD2 ZFIELD3

FROM ZTABLE

INTO <I_ZTAB-Field1> <I_ZTAB-Field2> <I_ZTAB-Field3>

WHERE <CONDITION>.

ENDSELECT.

Regards,

Raj

<b>Please reward points if helpful.</b>

Former Member
0 Kudos

hi.

use this code

data : begin of itab occurs 0,

f1 like ztable-fn1,

f2 like ztable-fn2,

end of itab.

select fn1 fn2 from table ztable into corresponding feilds of table itab .

reward if useful

JozsefSzikszai
Active Contributor
0 Kudos

hi Ajay,

fields in ztable: z1, z2, z3

fields in internal table: i1, i2, i3.

SELECT z1 AS i1
              z2 AS i2
              z3 AS i3
              FROM ztable
              INTO CORRESPONDING FIELDS OF TABLE itab
              WHERE ...

hope this helps

ec