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: 

VA0# - internal address table?

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

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

10 REPLIES 10

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Yes, the new address is stored in table like ADRC and ADRP. You would use the ADRNR number and go to these tables to get the address.

Regards,

Rich Heilman

0 Kudos

Rich, thanks for the help. How do I find the new address number?

0 Kudos

> Rich, thanks for the help. How do I find the new

> address number?

~Suresh

deleted.. irrelevant response

Message was edited by:

Suresh Datti

Former Member
0 Kudos

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

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

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

0 Kudos

Rich, thanks a lot for that piece of code. I am going to try that out right now.

Davis

0 Kudos

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.

0 Kudos

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

0 Kudos

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

Former Member
0 Kudos

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