Skip to Content
0

ADDRESS PARTNER CHANGED in VA01

Apr 04, 2017 at 02:49 PM

167

avatar image
Former Member

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)?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

6 Answers

Best Answer
avatar image
Former Member Apr 11, 2017 at 03:03 PM
0

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.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Apr 04, 2017 at 03:27 PM
-1

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

Share
10 |10000 characters needed characters left characters exceeded
Jelena Perfiljeva
Apr 04, 2017 at 10:02 PM
0

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.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Apr 05, 2017 at 06:16 AM
0

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.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Apr 05, 2017 at 11:07 AM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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

0
avatar image
Former Member Apr 05, 2017 at 11:18 AM
0

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.

Show 4 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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
Former Member

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
Former Member

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
Former Member

Here we cannot use workflow events for this.

tks for your time.

0