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

JOIN Select on VBAK and VBAP issue

former_member295881
Contributor
0 Likes
2,293

Hello Experts,  I’m trying to write a JOIN SELECT statement on VBAK and VBAP tables but having challenge to get information which I need. Following is the select statement. I’ve provided as many filters as I could and two of them (b~kdmat and a~bstdk pv_ship_date) are taken from input parameters.  

SELECT a~vbeln a~audat a~vbtyp a~auart a~faksk a~bsark a~bstdk a~zzshch             

              b~posnr b~kdmat b~cuobj              

               INTO TABLE t_sales_order                

                    FROM vbak AS a INNER JOIN vbap AS b  ON a~vbeln = b~vbeln                                     

                    where a~vbtyp = lc_vbtyp                         

                    and ( a~auart = lc_zlcy or a~auart = lc_zshp )                         

                    and ( a~augru = lc_sh or  a~augru = lc_lc )                         

                    and ( a~bsark = lc_zonl or a~bsark eq lc_zpws or a~bsark = lc_zoff or a~bsark = lc_zedi or a~bsark = lc_zotb )                         

                    and b~kdmat = pv_pin_number                                                  

                    and a~bstdk eq pv_ship_date. 

Based on input parameter when I look into the tables VBAK and VBAP then I can find records (one each) in both tables but the above statement doesn’t fetch it and SY-SUBRC value becomes 4. Can anybody see what’s wrong with this statement?   Many thanks in Advance.  Best Regards.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,077

hello,

On first look my suggestion would be convert the ( a~auart = lc_zlcy or a~auart = lc_zshp ) into a a~auart in lc_all where lc_all is a range and has values contained in  lc_zlcy  and lc_zshp. do it for all the remaining also.

Let me know if this helps.

best regards,

swanand

hello,

On first look my suggestion would be convert the ( a~auart = lc_zlcy or a~auart = lc_zshp ) into a a~auart in lc_all where lc_all is a range and has values contained in  lc_zlcy  and lc_zshp. do it for all the remaining also.

Let me know if this helps.

best regards,

swanand

2 REPLIES 2
Read only

Former Member
0 Likes
2,078

hello,

On first look my suggestion would be convert the ( a~auart = lc_zlcy or a~auart = lc_zshp ) into a a~auart in lc_all where lc_all is a range and has values contained in  lc_zlcy  and lc_zshp. do it for all the remaining also.

Let me know if this helps.

best regards,

swanand

Read only

former_member295881
Contributor
0 Likes
2,077

Hello Swanand,

Many thanks for a great suggestion. Actually it was date parameter which was causing the issue as well as if date it not provided in input parameter. Now I've changed it keep in range type table which resolve the issue.

Many thanks again.