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: 

ADDRESS PARTNER CHANGED in VA01

Former Member
0 Kudos

How can I change one of the information (ADDR1_DATA-NAME_CO) from Ship-to partner (PARWV = WE) when SAVE the order (VA01 or VA02)?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

The solution for me was:

DATA: LW_OBJTYPE TYPE SWO_OBJTYP,
LW_VBTYP TYPE VBTYP,
LWA_ADDR1_WE TYPE ADDR1_DATA,
LI_WARNING TYPE ADDR_ERROR_TAB,
LI_ADDR_IN TYPE TABLE OF /BUP/AQ0SANFREQ,
LWA_ADDR_IN TYPE /BUP/AQ0SANFREQ,
LI_ADDR_OUT TYPE TABLE OF /BUP/AQ0SERGREQ,
LWA_ADDR_OUT TYPE /BUP/AQ0SERGREQ,
IWA_HEADER TYPE /WUE/SSF_DOC_HEADER,
LW_KEY TYPE ADDR_REF-APPL_KEY,
LW_HANDLE TYPE SZAD_FIELD-HANDLE.

READ TABLE XVBPA WITH KEY PARVW = 'WE'.

SELECT SINGLE * FROM ADRC
INTO CORRESPONDING FIELDS OF LWA_ADDR1_WE
WHERE ADDRNUMBER = XVBPA-ADRNR AND
DATE_FROM = '00010101' AND
NATION = ''.

IF SY-SUBRC = 0.
LWA_ADDR1_WE-NAME_CO = 'PACKAGE 123'. "THE FIELD THAT I NEEDED TO CHANGE
ENDIF.

CALL FUNCTION 'SD_OBJECT_TYPE_DETERMINE'
EXPORTING
I_DOCUMENT_TYPE = XVBAK-VBTYP
IMPORTING
E_BUSINESS_OBJECT = LW_OBJTYPE
EXCEPTIONS
OTHERS = 1.

CALL FUNCTION 'SD_PARTNER_ADDRESS_SET'
EXPORTING
FIC_OBJECTTYPE = LW_OBJTYPE
FIC_OBJECTKEY = ''
FIF_PARVW = 'WE'
FIF_POSNR = '000000'
FIF_PARNR = KUWEV-KUNNR (Ship to party)
FIF_ADDRESS_CHECK = ' '
IMPORTING
ET_WARNING = LI_WARNING
CHANGING
FIS_ADDRESS = LWA_ADDR1_WE
EXCEPTIONS
PARAMETER_INCOMPLETE = 1
OBJECT_NOT_FOUND = 2
PARTNER_NOT_FOUND = 3
CHANGE_NOT_POSSIBLE = 4
ADDRESS_NOT_OK = 5
OTHERS = 6.

IF SY-SUBRC <> 0.
RETURN.
ENDIF.

PERFORM PARTNER_DATA_GET IN PROGRAM SAPMV45A.

11 REPLIES 11

former_member156446
Active Contributor
0 Kudos

Name usually comes from Master data . To change name you would need to update in XD02.

Jelena
Active Contributor
0 Kudos

The ship-to address comes from the customer master and can be changed manually in the order. It shouldn't be manipulated by ABAP if that's what you are asking.

Former Member
0 Kudos

Yes, I know where they come from, but you can change it (VBPA table) just for your sales order, not master data records.
In my case, we need to enter a correct NAME_OC of it, according to a condition specific when SAVE the order.

csaba_szommer
Active Contributor
0 Kudos

If you need to determine an address from a certain set of addresses, it would make sense of maintaing the possible ship-to parties (addresses) in advance and determine the right ship-to in the order (and not creating a new temporariy adress all the time during order processing).

In case the address changes from order to order and there's no way to maintain the possible set of addresses (ship-to parties) in advance (?), you can save a new address number for the ship-to business partner in user exit MV45AFZZ / USEREXIT_SAVE_DOCUMENT_PREPARE provided the address (number) already exists in ARDC (you would need to create the address during the program run - there's a bapi for this purpose). I didn't try it, so you may face problems because of the database updates (adress and order).

Other technical solution could be to simply use an event development for business object BUS2032. Once the "created" or "changed" events are triggered, you could update the business partner's data of the order with the corresponding bapi (BAPI_SALESORDER_CHANGE).

0 Kudos

please,how to use the bapi of BAPI_SALESORDER_CHANGE to change the information of ship-to partner , i tried , but didn't work.

Former Member
0 Kudos

The problem is the run time of my change.

Using this BAPI, I should have to wait for a sales order number to use.
I want to change some internal tables during saving the order, like XVBADR and XVBPA in MV45AFZZ include but until now without success.

0 Kudos

I don't think you interpreted properly what I wrote. In case of the suggested event development there's no problem with the update ("run time of change"), as it is called once the update took place.

0 Kudos

I understood and I am trying to use.
The first parameter in this function is VBELN and I don't have yet to run the BAPI.

The requirement is to change the field NAME_OC from partner address during the creation of sales order VA01.

0 Kudos

Sorry, it seems you need to understand how an event development works, only after that you will be able to interpret my answer.,

I cannot help you further.

0 Kudos

Here we cannot use workflow events for this.

tks for your time.

Former Member
0 Kudos

The solution for me was:

DATA: LW_OBJTYPE TYPE SWO_OBJTYP,
LW_VBTYP TYPE VBTYP,
LWA_ADDR1_WE TYPE ADDR1_DATA,
LI_WARNING TYPE ADDR_ERROR_TAB,
LI_ADDR_IN TYPE TABLE OF /BUP/AQ0SANFREQ,
LWA_ADDR_IN TYPE /BUP/AQ0SANFREQ,
LI_ADDR_OUT TYPE TABLE OF /BUP/AQ0SERGREQ,
LWA_ADDR_OUT TYPE /BUP/AQ0SERGREQ,
IWA_HEADER TYPE /WUE/SSF_DOC_HEADER,
LW_KEY TYPE ADDR_REF-APPL_KEY,
LW_HANDLE TYPE SZAD_FIELD-HANDLE.

READ TABLE XVBPA WITH KEY PARVW = 'WE'.

SELECT SINGLE * FROM ADRC
INTO CORRESPONDING FIELDS OF LWA_ADDR1_WE
WHERE ADDRNUMBER = XVBPA-ADRNR AND
DATE_FROM = '00010101' AND
NATION = ''.

IF SY-SUBRC = 0.
LWA_ADDR1_WE-NAME_CO = 'PACKAGE 123'. "THE FIELD THAT I NEEDED TO CHANGE
ENDIF.

CALL FUNCTION 'SD_OBJECT_TYPE_DETERMINE'
EXPORTING
I_DOCUMENT_TYPE = XVBAK-VBTYP
IMPORTING
E_BUSINESS_OBJECT = LW_OBJTYPE
EXCEPTIONS
OTHERS = 1.

CALL FUNCTION 'SD_PARTNER_ADDRESS_SET'
EXPORTING
FIC_OBJECTTYPE = LW_OBJTYPE
FIC_OBJECTKEY = ''
FIF_PARVW = 'WE'
FIF_POSNR = '000000'
FIF_PARNR = KUWEV-KUNNR (Ship to party)
FIF_ADDRESS_CHECK = ' '
IMPORTING
ET_WARNING = LI_WARNING
CHANGING
FIS_ADDRESS = LWA_ADDR1_WE
EXCEPTIONS
PARAMETER_INCOMPLETE = 1
OBJECT_NOT_FOUND = 2
PARTNER_NOT_FOUND = 3
CHANGE_NOT_POSSIBLE = 4
ADDRESS_NOT_OK = 5
OTHERS = 6.

IF SY-SUBRC <> 0.
RETURN.
ENDIF.

PERFORM PARTNER_DATA_GET IN PROGRAM SAPMV45A.