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

SQL query joins

amysh95
Participant
0 Likes
1,006

Hey,

I am having trouble to get field data from structure.

select single * into @data(wa_vbap2)
from vbap as v
left outer join vbfa as x
on v~vbeln = x~vbelv
left outer join vbfa as y
on x~vbeln = y~vbelv and x~vbtyp_v = 'G'
where y~vbeln = @vbeln and y~vbtyp_v = 'C'.

this is my query and in debugging mode i have this.

i want to fetch fields from V. how can i do this?

like

zproj_name = wa_vbap2-zproj_name. (giving error)

thanks.

1 ACCEPTED SOLUTION
Read only

DoanManhQuynh
Active Contributor
898

because you dont specific field name ( select * from a join ) then fields of each table will save in corresponding nested structure of return structure. you can access field like below:

zproj_name = wa_vbap2-v-zproj_name.(i suppose zproj_name is under vbap which you define alias as V in query, if not you have to change it)

3 REPLIES 3
Read only

s1252
Product and Topic Expert
Product and Topic Expert
898

You can try specifying only fields from V like below

select single v~* into @data(wa_vbap2)
 from vbap as v
 left outer join vbfa as x
 on v~vbeln = x~vbelv
 left outer join vbfa as y
 on x~vbeln = y~vbelv and x~vbtyp_v = 'G'
 where y~vbeln = @vbeln and y~vbtyp_v = 'C'.
Read only

DoanManhQuynh
Active Contributor
899

because you dont specific field name ( select * from a join ) then fields of each table will save in corresponding nested structure of return structure. you can access field like below:

zproj_name = wa_vbap2-v-zproj_name.(i suppose zproj_name is under vbap which you define alias as V in query, if not you have to change it)

Read only

0 Likes
898

i am using @data(wa_vbap2) it will create itselft.

after executing query i am getting the data but don't know how to display or pass that data into another field.

anyway Thank you all, I resolve my issue. i checked that structure filed in debugging and got my answer.

now i am using like this.

zproj_name = wa_vbap2-v-zproj_name