• No results found

Changing Partner s Address Data of the Sales Order

N/A
N/A
Protected

Academic year: 2021

Share "Changing Partner s Address Data of the Sales Order"

Copied!
9
0
0

Loading.... (view fulltext now)

Full text

(1)

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 1

Changing Partner’s Address Data

of the Sales Order

Applies to:

SAP ECC 6.0. For more information, visit the ABAP homepage.

Summary

This article explains how to change partner’s address data in sales order programmatically.

Author: Oleg Zilin

Company: Ozone Consulting JLLC, Republic of Belarus

Created on: 3 February 2011

Author Bio

Oleg Zilin started his IT career more than 30 years ago. He programmed with COBOL, Visual Basic, Delphi, and Java and long ago with FORTRAN for mainframes. He has been working with the SAP solutions since 2004. He has the experience in IT Services, Automotive, Electronics, Consumer Products, Manufacturing industries. At present he works for the company ‘Ozone Consulting JLLC’ in Republic of Belarus as programmer analyst (ABAP4 Developer)

(2)

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 2

Table of Contents

Introduction ... 3

The Interface of the Functional Module ... 4

Some Words about the Functional Module ... 4

The Source Code of the Function ... 5

Conclusion ... 7

Related Content ... 8

(3)

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 3

Introduction

In order to see and change partner’s address data, it’s necessary: 1. Start transaction VA02 for processed sales order ; 2. Press ‘ Display doc. header details’;

3. Choose the bookmark ‘Partners’.

If you create a sales order (Transaction - VA01) without partner’s address data, then will be used data from the master data.

If we double click on the field of the partner, we can get partner’s address data and change it.

During this a new user address ID will be created with new partner’s address data for this sales order only. The master data for this partner will be unchanged. You can test it in the tables KNA1, ADRC and VBPA. Thus we have changed the address data by means of transaction VA02.

Sometimes, it should be made programmatically.

(4)

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 4

The Interface of the Functional Module

We define input parameters of the function module in this way:

Exceptions:

Some Words about the Functional Module

It is possible to create new ADDRNUMBER in table ADRC and write address data in the database directly, but it is bad practice. For work with addresses we have to use the Business Address Services (BAS). It is recommended SAP. More information about BAS can you get in the SAP documentation

(BC–SRV-ADR). BAS functional groups:SZA0,SZA1, SZA5,SZA7.

The function module 'BAPI_SALESORDER_CHANGE' uses BAS function modules to maintain addresses. For this reason, we will use following functional modules:

'BAPISDORDER_GETDETAILEDLIST'; 'BAPI_SALESORDER_CHANGE'; 'BAPI_TRANSACTION_COMMIT'.

(5)

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 5

The Source Code of the Function

FUNCTION ZSO_PARTNERS_ADDR_DATA_CHANGE.

*"--- *"*"Local Interface:

*" IMPORTING

*" REFERENCE(IM_VBELN) TYPE VBELN *" REFERENCE(IM_PARVW) TYPE PARVW *" REFERENCE(IM_ADDRESS) TYPE BAPIADDR1 *" EXCEPTIONS *" ERROR_DETAIL_INFORMATION *" PARTNER_FUNCTION_NOT_FOUND *" ERROR_OF_SALESORDER_CHANGING *"--- type-pools : abap . constants :

CNST_NEW_ADDR type addr_link value '999999' ,

CNST_UPDATE type updkz_d value 'U' , CNST_ERR_R type bapiflag value 'R' . data :

ls_selected type order_view, ls_vbeln type sales_key , ls_header type bapisdhd , lt_vbeln type table of sales_key , lt_header type table of bapisdhd , lt_partners type table of bapisdpart , lt_return type table of bapiret2 , lt_partner_ch type table of bapiparnrc , lt_address type table of bapiaddr1 , ls_hdr1 type bapisdh1 , ls_hdr1_x type bapisdh1x , ls_partner_ch type bapiparnrc , ls_address type bapiaddr1 . field-symbols :

<fs_partners> type bapisdpart , <fs_return> type bapiret2 .

* --- * Get detail information about sales order * --- ls_selected-header := abap_true .

ls_selected-partner := abap_true . ls_selected-address := abap_true . ls_vbeln-vbeln := im_vbeln .

append ls_vbeln-vbeln TO lt_vbeln .

CALL FUNCTION 'BAPISDORDER_GETDETAILEDLIST' EXPORTING i_bapi_view = ls_selected TABLES sales_documents = lt_vbeln order_headers_out = lt_header order_partners_out = lt_partners.

(6)

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 6

ls_hdr1_x-updateflag := CNST_UPDATE . read table lt_header

into ls_header index 1. if sy-subrc = 0 . ls_hdr1-sales_org := ls_header-sales_org . ls_hdr1-distr_chan := ls_header-distr_chan. ls_hdr1-division := ls_header-division . else. raise error_detail_information . endif. ls_partner_ch-document := im_vbeln . ls_partner_ch-updateflag := CNST_UPDATE . * --- * Set partners info

* --- ls_partner_ch-partn_role := im_parvw .

read table lt_partners assigning <fs_partners>

with key partn_role = im_parvw . if sy-subrc = 0 .

ls_partner_ch-addr_link := CNST_NEW_ADDR .

ls_partner_ch-address := <fs_partners>-address . ls_partner_ch-p_numb_old := <fs_partners>-customer . ls_partner_ch-p_numb_new := <fs_partners>-customer . append ls_partner_ch to lt_partner_ch .

unassign <fs_partners> . else.

raise partner_function_not_found . endif.

* --- * Set new address

* --- ls_address := im_address . ls_address-addr_no := CNST_NEW_ADDR . APPEND ls_address TO lt_address .

* --- * Sales order change

* --- CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING salesdocument = im_vbeln order_header_in = ls_hdr1 order_header_inx = ls_hdr1_x behave_when_error = CNST_ERR_R TABLES return = lt_return partnerchanges = lt_partner_ch partneraddresses = lt_address. * --- * Errors handling * ---

loop at lt_return assigning <fs_return> where type = 'E' or type = 'A'. raise error_of_salesorder_changing .

(7)

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 7

unassign <fs_return>.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'. ENDFUNCTION.

Conclusion

Thus, we see that if we change the address data of the partner in sales order - master data does not vary. A new user address ID with the new address data will be created only for processed sales order.

Using this functional module, it is possible to write the functional module for copying of the partner’s address data with partner’s function Ship-to to Bill-to et cetera.

(8)

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 8

Related Content

SDN Forum

(9)

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 9

Disclaimer and Liability Notice

This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.

SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk.

SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document.

References

Related documents

SherWeb’s Advisor Program is the gateway to the cloud industry for IT professionals wishing to offer hosted services to their customers without having to handle support and

In order to display a customer, follow the SAP Easy Access menu path:.. Logistics ► Sales and Distribution ► Master Data ► Business Partner ► Customer ► Display ►

 General Data  Company Code data  Sales area Data  Excise details Partner Functions in customer master.. Partner functions are terms that describe the people

Koutandos and Prinos (2005) conducted large-scale physical tests to study the hydraulic characteristics of a fixed box-type wave barrier in shallow and intermediate waters for

Abstract In this paper the well-known minimax theorems of Wald, Ville and Von Neumann are generalized under weaker topological conditions on the payoff function ƒ and/or extended

(CST) Freescale Semiconductor Provides a comprehensive software development environment for building networking systems based on Freescale Semiconductor's C-Port network

In January 2005, the Office of Information Technology (OIT) was created by Executive Order, consolidating functions, staff, and equipment from the Bureau of Information Services (BIS)

Without an enterprise view into master data, some companies cannot link product data from their PIM application to customer and channel-partner data from their MDM solution to