05-03-2007 7:06 PM
Hello everybody. When we create a sales order and override the ship-to address I need to find out where that new address is stored. I imagine there is some internal table that stores that address. We want to be able to print that new address in a z-report. Does anybody have any ideas?
Regards,
Davis
05-03-2007 7:11 PM
For example, he is some code which is in our shipping label print program, it gets the dynamic address from the sales document.
* Get ship to partner
clear xvbpa.
select single * into xvbpa
from vbpa
where vbeln = xvbak-vbeln
and parvw = 'WE'. " <- Ship To Partner
* Get address from address table.
clear xadrc.
select single * into xadrc
from adrc
where addrnumber = xvbpa-adrnr "<- ADRNR from partner
and date_to = '99991231'.
xout-name1 = xadrc-name1.
xout-street = xadrc-street.
xout-city1 = xadrc-city1.
xout-region = xadrc-region.
xout-post_code1 = xadrc-post_code1.
Regards,
RIch Heilman
05-03-2007 7:09 PM
05-03-2007 7:10 PM
05-03-2007 7:13 PM
> Rich, thanks for the help. How do I find the new
> address number?
~Suresh
deleted.. irrelevant response
Message was edited by:
Suresh Datti
05-03-2007 7:11 PM
Hi,
You can check it in the VBPA for the partner function 'WE'..
OR
Get the address number ADRNR from VBPA for the partner function 'WE'..
Then use the address number in the table ADRC to get the details..
Thanks,
Naren
05-03-2007 7:11 PM
For example, he is some code which is in our shipping label print program, it gets the dynamic address from the sales document.
* Get ship to partner
clear xvbpa.
select single * into xvbpa
from vbpa
where vbeln = xvbak-vbeln
and parvw = 'WE'. " <- Ship To Partner
* Get address from address table.
clear xadrc.
select single * into xadrc
from adrc
where addrnumber = xvbpa-adrnr "<- ADRNR from partner
and date_to = '99991231'.
xout-name1 = xadrc-name1.
xout-street = xadrc-street.
xout-city1 = xadrc-city1.
xout-region = xadrc-region.
xout-post_code1 = xadrc-post_code1.
Regards,
RIch Heilman
05-03-2007 7:14 PM
Rich, thanks a lot for that piece of code. I am going to try that out right now.
Davis
05-03-2007 7:45 PM
Rich, that works wonders. How can I do this using "for all entries"? I know how to write those select statements but I don't know how to tie the address numbers from adrc to the entries in the internal table. I hope that makes sense. Below is code I have so far (thanks to your help).
Regards,
Davis
LOOP AT it_detail INTO wa_detail.
CLEAR: wa_vbpa,
wa_adrc.
SELECT SINGLE * INTO wa_vbpa FROM vbpa
WHERE vbeln = wa_detail-vbeln
AND parvw = 'WE'.
SELECT SINGLE * INTO wa_adrc
FROM adrc
WHERE addrnumber = wa_vbpa-adrnr
AND date_to = '99991231'.
wa_detail-we_num = wa_vbpa-kunnr.
wa_detail-we_name = wa_adrc-name1.
wa_detail-we_name2 = wa_adrc-name2.
wa_detail-we_street = wa_adrc-street.
wa_detail-we_city = wa_adrc-city1.
wa_detail-we_state = wa_adrc-region.
wa_detail-we_zip = wa_adrc-post_code1.
wa_detail-we_tel = wa_adrc-tel_number.
MODIFY it_detail FROM wa_detail.
ENDLOOP.
05-03-2007 8:08 PM
Didn't test it, but this may work.
types: begin of ttmp,
vbeln type vbak-vbeln,
kunnr type vbpa-kunnr,
name1 type adrc-name1,
name2 type adrc-name2,
street type adrc-street,
city1 type adrc-city1,
region type adrc-region,
post_code1 type adrc-post_code1,
tel_number type adrc-tel_number,
end of ttmp.
data: it_detail type table of tdet.
data: wa_detail like line of it_detail.
data: itmp type table of ttmp.
data: xtmp like line of itmp.
* FILL IT_DETAIL HERE
sort it_detail ascending by vbeln.
select * into corresponding fields of table itmp
from vbpa
inner join adrc
on vbpa~adrnr = adrc~ADDRNUMBER
for all entries in it_detail
where vbpa~vbeln = it_detail-vbeln
and vbpa~parvw = 'WE'.
loop at it_detail into wa_detail.
read table itmp into xtmp with key vbeln = wa_detail-vbeln.
if sy-subrc = 0.
wa_detail-we_num = xtmp-kunnr.
wa_detail-we_name = xtmp-name1.
wa_detail-we_name2 = xtmp-name2.
wa_detail-we_street = xtmp-street.
wa_detail-we_city = xtmp-city1.
wa_detail-we_state = xtmp-region.
wa_detail-we_zip = xtmp-post_code1.
wa_detail-we_tel = xtmp-tel_number.
modify it_detail from wa_detail.
endif.
endloop.
Regards,
RIch Heilman
05-03-2007 8:15 PM
Rich, thanks for your help. I actually figured it out right before you posted. The sad thing is I had the whole problem already answered in my program but I didn't realize it; I was just putting it in the wrong internal table. Thanks again for all of your help.
Davis
05-03-2007 7:19 PM
If you are trying to get this in a Z report, you will have to go from VBAK to VBPA using VBELN and the partner function if your partners for the sales document are defined at the header level.
SELECT SINGLE ADRNR FROM VBPA WHERE VBELN = VBAK-VBELN AND POSNR = '000000' AND PARVW = 'WE'.
If your partners for the document are at an item level, you will have to go to VBPA from VBAP.
SELECT SINGLE ADRNR FROM VBPA WHERE VBELN = VBAP-VBELN AND POSNR = VBAP-POSNR AND PARVW = 'WE'.