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: 

SQL query joins

amysh95
Participant
0 Kudos

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

DoanManhQuynh
Active Contributor

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

s1252
Participant

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'.

DoanManhQuynh
Active Contributor

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)

0 Kudos

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