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

Issue with Heavyweight select

former_member295881
Contributor
0 Likes
394

Hello Experts,

I need to get some address information from ADRC table. Now this is the link. I've sales order pulled and save in an internal table from VBAP git_vbap, now to get address information I've to first take a sales order number VBELN and POSNR then go in VBPA and look for value ADRNR for matching VBELN and POSNR. Once i successfully get ADRNR values (will be 2 values 1 for origin address and other for destination) then go in ADRC table and get CITY, POSTAL CODE, COUNTRY AND REGION.

I'm keep all VBAP values in git_vbap. Then trying to do a select statement to get information from VBPA AND ADRC in one shot. BUT WHEN I EXECUTE CODE SAP TAKE FOREVER ON THIS SELECT AND I'VE TO STOP PROGRAM MANUALLY. Can anybody see what's wrong with this select.

Here is my code for reference.

&----


*& Form GET_ADDRESS_DETAIL

&----


  • text

----


  • -->P_GIT_VBAK text

  • -->P_GIT_VBAP text

  • <--P_LI_OUTPUT_DETAIL text

----


FORM GET_ADDRESS_DETAIL USING P_GIT_VBAK type tt_vbak

P_GIT_VBAP type tt_vbap

CHANGING P_LI_OUTPUT_DETAIL type git_output_detail.

data:

git_vbpadrc type standard table of t_vbpadrc initial size 0.

select v~vbeln

v~posnr

v~parvw

v~adrnr

a~addrnumber

a~city1

a~post_code1

a~country

a~region

into table git_vbpadrc

from vbpa as v join adrc as a on vadrnr = aaddrnumber

join vbap as h on vvbeln = hvbeln

for all entries in p_git_vbap

where v~vbeln = p_git_vbap-vbeln

and v~posnr = p_git_vbap-posnr

and v~parvw = 'ZO' " Origin address

or v~parvw = 'ZD'. " Destination address

if sy-subrc eq 0.

sort git_vbpadrc by vbeln posnr.

endif.

ENDFORM. " GET_ADDRESS_DETAIL

  • ---------------------------------- t_vbpadrc structure -------------------------------------

Type:

begin of t_vbpadrc,

vbeln type vbpa-vbeln, "Sales Order

posnr type vbpa-posnr, "Item

parvw type vbpa-parvw, "Function

adrnr type vbpa-adrnr, "Address

addrnmber type adrc-addrnumber, "Address ID

city1 type adrc-city1, "City

post_code1 type adrc-post_code1, "postal code/zipcode

country type adrc-country, "Country

region type adrc-region, "region

end of t_vbpadrc.

  • -------------------------------- --------------------------------------------------------------

Many thanks in advance.

Hello Experts,

I need to get some address information from ADRC table. Now this is the link. I've sales order pulled and save in an internal table from VBAP git_vbap, now to get address information I've to first take a sales order number VBELN and POSNR then go in VBPA and look for value ADRNR for matching VBELN and POSNR. Once i successfully get ADRNR values (will be 2 values 1 for origin address and other for destination) then go in ADRC table and get CITY, POSTAL CODE, COUNTRY AND REGION.

I'm keep all VBAP values in git_vbap. Then trying to do a select statement to get information from VBPA AND ADRC in one shot. BUT WHEN I EXECUTE CODE SAP TAKE FOREVER ON THIS SELECT AND I'VE TO STOP PROGRAM MANUALLY. Can anybody see what's wrong with this select.

Here is my code for reference.

&----


*& Form GET_ADDRESS_DETAIL

&----


  • text

----


  • -->P_GIT_VBAK text

  • -->P_GIT_VBAP text

  • <--P_LI_OUTPUT_DETAIL text

----


FORM GET_ADDRESS_DETAIL USING P_GIT_VBAK type tt_vbak

P_GIT_VBAP type tt_vbap

CHANGING P_LI_OUTPUT_DETAIL type git_output_detail.

data:

git_vbpadrc type standard table of t_vbpadrc initial size 0.

select v~vbeln

v~posnr

v~parvw

v~adrnr

a~addrnumber

a~city1

a~post_code1

a~country

a~region

into table git_vbpadrc

from vbpa as v join adrc as a on vadrnr = aaddrnumber

join vbap as h on vvbeln = hvbeln

for all entries in p_git_vbap

where v~vbeln = p_git_vbap-vbeln

and v~posnr = p_git_vbap-posnr

and v~parvw = 'ZO' " Origin address

or v~parvw = 'ZD'. " Destination address

if sy-subrc eq 0.

sort git_vbpadrc by vbeln posnr.

endif.

ENDFORM. " GET_ADDRESS_DETAIL

  • ---------------------------------- t_vbpadrc structure -------------------------------------

Type:

begin of t_vbpadrc,

vbeln type vbpa-vbeln, "Sales Order

posnr type vbpa-posnr, "Item

parvw type vbpa-parvw, "Function

adrnr type vbpa-adrnr, "Address

addrnmber type adrc-addrnumber, "Address ID

city1 type adrc-city1, "City

post_code1 type adrc-post_code1, "postal code/zipcode

country type adrc-country, "Country

region type adrc-region, "region

end of t_vbpadrc.

  • -------------------------------- --------------------------------------------------------------

Many thanks in advance.

1 REPLY 1
Read only

Former Member
0 Likes
355

I do not understand why you are keeping VBAP in join loop when you already have data in internal table !

Well this statement is trying to select data first from VBPA based on address number with matching ADRC record...

Then filter with entry from VBAP and finally with internal table...

I would suggest select it from VBPA and delete duplicate address numbers and select from ADRC...

Thanks