Sapass

 Simplify SAP R/3 development with Excel VBA/VB RFC  
Home> Bapi>AddressContPart



Index

AddressContPart

AddressContPart


No description is available


11-Dec-2005


Methods

Available Methods


  • Change : BAPI to change contact person addresses [ BAPI_ADDRESSCONTPART_CHANGE ]
  • GetDetail : BAPI to read contact person addresses [ BAPI_ADDRESSCONTPART_GETDETAIL ]
  • SaveReplica : BAPI for inbound distribution of contact person addresses [ BAPI_ADDRCONTPART_SAVEREPLICA ]

11-Dec-2005


Change

Change


The contact person address is determined from the specified objecttypes and the object key, and is updated with the specified address and communication data, if required.
This module differs from a standard change BAPI in that not only canexisting entries be changed, but also telephone number, fax number, etc. address attributes, can be deleted or added.

Reference structures (checkboxes) are used to select entries to be changed.

Example

* Change a contact person address:
* Change, delete and add a telephone number

DATA: objtype_p LIKE bapi4003_1-objtype,
obj_id_p LIKE bapi4003_1-objkey,
objtype_c LIKE bapi4003_1-objtype,

obj_id_c LIKE bapi4003_1-objkey,
obj_id_ext LIKE bapi4003_1-extension,
context LIKE bapi4003_1-context,
address_number LIKE adrc-addrnumber,
person_number LIKE adrp-persnumber,
bapiadtel LIKE bapiadtel OCCURS 0 WITH HEADER LINE,

bapiadtel_x LIKE bapiadtelx OCCURS 0 WITH HEADER LINE,
return LIKE bapiret2 OCCURS 0.

* Choose the following customer contact person address object types and
* object key:
objtype_p = 'BUS1006001'
obj_id_p = <person number (KNVK)>
objtype_c = 'KNA1'
obj_id_c = <customer number>
obj_id_ext = ' '

context = '0005'

* Get existing data by calling, e.g. FM 'BAPI_ADDRCONTPART_GETDETAIL'
...

* Enter reference structure data
* The telephone number with serial number '002' is to be deleted and
* that with serial number '003' updated

CLEAR: bapiadtel[], bapiadtel_x[].

CLEAR: bapiadtel, bapiadtel_x.

bapiadtel-consnumber = '002'.
bapiadtel_x-updateflag = 'D'.
APPEND: bapiadtel, bapiadtel_x. "Delete entry

CLEAR: bapiadtel, bapiadtel_x.
bapiadtel-consnumber = '003'.
bapiadtel-extension = '77733'.
bapiadtel_x-extension = 'X'.
bapiadtel_x-updateflag = 'U'.
APPEND: bapiadtel, bapiadtel_x. "Update entry


CLEAR: bapiadtel, bapiadtel_x.
bapiadtel-telephone = '06227'.
bapiadtel-extension = '11111'.
bapiadtel_x-updateflag = 'I'.
APPEND: bapiadtel, bapiadtel_x. "Insert new entry

* call change module
CALL FUNCTION 'BAPI_ADDRCONTPART_CHANGE'
EXPORTING
obj_type_p = objtype

obj_id_p = obj_id
obj_type_c = objtype
obj_id_c = obj_id
obj_id_ext = obj_id_ext
context = context
IMPORTING
address_number = address_number
person_number = person_number
TABLES

bapiadtel = bapiadtel
bapiadtel_x = bapiadtel_x
return = return.

* Get errors and warnings from the RETURN table.
* If successful, the contact person address and communication data is
* now updated in the system.
* The address number is in the ADDRESS_NUMBER field and the person

* number in the PERSON_NUMBER field.

Notes

To delete, e.g. a telephone number in the table of existing telephonenumbers of an address, the 'UPDATEFLAG' field in the reference structure must contain a 'D' in the appropriate line.
To add an entry, it must contain 'I' and the data to be inserted must be passed.

All lines to be inserted (I) and their reference structures must be after all change (U) and delete (D) entries.
The change reference structure and data sequence is significant, andmust be the same as the sequence of data to be changed, sorted by serial numbers, in the system.

Change data key fields must always be filled, and are taken intoaccount as far as possible. It is not significant whether, e.g. alltelephone number change comments are followed by fax number changecomments, or vice versa; only the sequence within entries with the same
key is important, unless the communication address or comment serialnumbers are only partially or not specified, in which case the data sequence is significant.
The key fields are:

Structure | Fields

---------------------------------


BAPIAD3VL | ADDR_VERS, FROM_DATE

BAPIADTEL | CONSNUMBER

... | ...

BAPIADPAG | CONSNUMBER

BAPICOMREM | COMM_TYPE, CONSNUMBER, LANGU

You can pass the communication address and comment serial numbersempty, in which case the sequence of the data passed is significant, so
for example if you want to delete the telephone number in the secondposition in the in ascending order of serial numbers sorted existingtelephone numbers, from the database, you must pass a dummy telephonenumber with update flag (U) in the first position, without selecting
fields to update, and a telephone number with delete flag (D) in the second position.
The communication addresses in the database are usually not sorted byserial numbers, so you must first determine the sequence of the communication addresses sorted by serial numbers.

This procedure is not advisable because it is easy to make mistakes inthe data sequence. Specifying the serial number as key is safer.

You should assign your own serial numbers for communication addressesand their comments to be inserted (I), so that the communication
address - comment assignment is clear. Ensure that the serial numbersare not already used in the database, unless you want to assign acomment explicitly to an existing communication address. If you assignno numbers, it is assumed that all comments to be inserted belong to
the communication addresses to be inserted, and they are assigned bythe sequence of the data passed. (This would be appropriate if acomment in another language than the creation language is to assigned to a communication address.)

Then the first telephone number comment in German flagged for insertion
(I) is assigned to the first telephone number to be inserted. The thirdfax number comment in English to be inserted (I) is assigned to the third fax number to be inserted specified.
You cannot assign a comment to an existing communication address in this way. You need the correct serial number.


If one type of communication address and its comments has serial numbers and another does not, this does not affect the overallfunctionality. All communication types are processed separately, i.e.if all addresses of a communication type have serial numbers, they are
used, even if there are no serial numbers for all or some addresses ofanother communication type. The addresses of such communication types are processed in the order of their data.

You can specify serial numbers for communication addresses to beinserted (I) and omit them for communication addresses to be updated
(U) and deleted (D), and vice versa. They are processed separatelyusing serial numbers or the data sequence as appropriate. Communicationaddresses to be updated (U) or delete (D) must both be passed either completely with or completely without serial numbers.

You are on the safe side if you always pass a serial number.

You must first read the data to be changed (e.g. with FMBAPI_ADDRESSCONTPART_GETDETAIL) if you also want to change communication data, to get the communication data serial numbers.


The address number of the organization for the object type and objectkey is returned in the export parameter ADDRESS_NUMBER, the contact person number im the PERSON_NUMBER field.

Processing warnings and errors are in the RETURN table.

To be able to use this function module, the System needs to associate the BOR object types to be used to their addresses.

The table TSADOBJ must contain the BOR object type application tablesand address reference fields. The address reference read callback function module must be in table TSADRV.
If TSADOBJ and TSADRV do not contain these entries, the function moduleputs a message in the error table RETURN, and the BOR object address cannot be processed.


This function contains no COMMIT command as required by the BAPI programming guidelines from Release 4.0.
See OSS note 131838.

The result is returned in the communication data transfer structuresBAPIADTEL, BAPIADFAX, ... , BAPIADPAG and their comment transfer
structure BAPICOMREM, if no exception error ('E') occurred in the BAPI processing.
So if a communication address has been processed, BAPIAD* contains thedata as they are in the database, or would be after the next COMMIT.
For example the field 'TEL_NO' is filled with a complete telephone
number. More importantly, the communication address serial numbers usedare also returned. This is particularly useful for new communication addresses.
If a communication address or comment could not be processed, the errorflag 'ERRORFLAG' is set to 'X' and the serial number 'CONSNUMBER' to '000' in its row in the BAPIAD* structure.


To maintain address communication data with this BAPI:

after you have created, changed or deleted communication data one number must be flagged as the standard number (STD_NO = 'X').

Assign a serial number (CONSNUMBER) to each communication address. This
preserves the assignment between communication addresses and any comments which you may maintain, possibly in several languages.
You can choose these numbers when creating, but they may be changed when saving, if for example they already exist.
Use the serial numbers which are saved in the database to change or delete communication addresses.


11-Dec-2005


GetDetail

GetDetail


The address data of the contact person address is determined from the specified object type and object key.
The address number and the person number in the current system are also returned.

Example

* Read a contact person address:
DATA: objtype_p LIKE bapi4003_1-objtype,
obj_id_p LIKE bapi4003_1-objkey,

objtype_c LIKE bapi4003_1-objtype,
obj_id_c LIKE bapi4003_1-objkey,
obj_id_ext LIKE bapi4003_1-extension,
context LIKE bapi4003_1-context,
address_number LIKE adrc-addrnumber,
person_number LIKE adrp-persnumber,

bapiad3vl LIKE bapiad3vl OCCURS 0,
bapiadtel LIKE bapiadtel OCCURS 0,
bapiadfax LIKE bapiadfax OCCURS 0,
...
bapicomrem LIKE bapicomrem OCCURS 0,
return LIKE bapiret2 OCCURS 0.

* Assign the following object types and object key to the

* customer contact person address:
objtype_p = 'BUS1006001'
obj_id_p = <partner number (KNVK)>
objtype_c = 'KNA1'
obj_id_c = <customer number>
obj_id_ext = ' '
context = '0005'

* Change module call
CALL FUNCTION 'BAPI_ADDRCONTPART_CHANGE'
EXPORTING
obj_type_p = objtype

obj_id_p = obj_id
obj_type_c = objtype
obj_id_c = obj_id
obj_id_ext = obj_id_ext
context = context
IMPORTING
address_number = address_number
person_number = person_number
TABLES

bapiad3vl = bapiad3vl
bapiadtel = bapiadtel
...
bapicomrem = bapicomrem
return = return.

* The address data is now in the BAPIAD3VL, ..., BAPICOMREM tables.
* The RETURN table contains all errors and warnings which occurred.

* The address number and the person number are in the ADDRESS_NUMBER
* and PERSON_NUMBER fields.

Notes

The sequence of the communication data in the tables is the serialnumber of the data in the system involved. The same applies to the communication comments.

The address number of the person address for the object type and objectkey is returned in the ADDRESS_NUMBER export parameter, the person number in the PERSON_NUMBER field.
Processing warnings and errors are in the RETURN table.
INCLUDE ADDRESS_TSADOBJ_AND_BAPIS OBJECT DOKU ID TX


11-Dec-2005


SaveReplica

SaveReplica


The contact person data are determined from the specified organizationand person object type and key, and overwritten by the specifiedcurrent address and communication data. This module is usually called by the ALE function module IDOC_INPUT_ADR3MAS.


Example

* Replicate a contact person address: copy the current status in the
* AB1 system to AB2

An ALE IDOC is created and distributed in AB1 by the module ALE_ADDRCONTPART_SAVEREPLICA after the function moduleMASTERIDOC_CREATE_REQ_ADR3MAS has been called.
When the IDOC arrives in AB2, it is read by the module
IDOC_INPUT_ADR3MAS, and its data is passed to the module BAPI_ADDRCONTPART_SAVEREPLICA. The organization object type OBJ_TYPE_C,the person object type OBJ_TYPE_P, the organization object key OBJ_ID_C, the person object key OBJ_ID, the object key extensionOBJ_ID_EXT, and the context CONTEXT are the same as in the source system.

For example, values are assigned as follows in the company address of a customer contact person:
Person object type: 'BUS1006001'
Person object key: <partner number (KNVK)>
Organization object type: 'KNA1'
Organization object key: <customer number>

(extension empty): ' '
context: '0005'

The module call is as follows:

DATA: bapiad3vl  like bapiad3vl occurs 0,
bapiadtel like bapiadtel occurs0,
...
bapicomrem like bapicomrem occurs 0,
return like bapiret2,
addrnumber like adrc-addrnumber,

persnumber like adrp-persnumber.

CALL FUNCTION 'BAPI_ADDRCONTPART_SAVEREPLICA'
EXPORTING
OBJ_TYPE_P = 'BUS1006001'
OBJ_ID_P = '4811'
OBJ_TYPE_C = 'KNA1'
OBJ_ID_C = '4712'
OBJ_ID_EXT = ' '
CONTEXT = '0005'

IMPORTING
RETURN = return
ADDRESS_NUMBER = addrnumber
PERSON_NUMBER = persnumber
tables
bapiad3vl = bapiad3vl
BAPIADTEL = bapiadtel
BAPIADFAX = bapiadfax
BAPIADTTX = bapiadttx

BAPIADTLX = bapiadtlx
BAPIADSMTP = bapiadsmtp
BAPIADRML = bapiadrml
BAPIADX400 = bapiadx400
BAPIADRFC = bapiadrfc
BAPIADPRT = bapiadprt
BAPIADSSF = bapiadssf
BAPIADURI = bapiaduri

BAPIADPAG = bapiadpag
BAPICOMREM = bapicomrem.
IF NOT RETURN IS INITIAL.
...
ENDIF.

The contact partner data for address number ADDRNUMBER and person number PERSNUMBER has now been updated in AB2.


Note

Error messages are in the return structure RETURN.
The valid contact person address number and person number for thetarget system are returned in the ADDRESS_NUMBER und PERSON_NUMBER parameters.

The result is returned in the communication data transfer structures
BAPIADTEL, BAPIADFAX, ... , BAPIADPAG and their comment transferstructure BAPICOMREM, if no exception error ('E') occurred in the BAPI processing.
So if a communication address has been processed, BAPIAD* contains thedata as they are in the database, or would be after the next COMMIT.

For example the field 'TEL_NO' is filled with a complete telephonenumber. More importantly, the communication address serial numbers usedare also returned. This is particularly useful for new communication addresses.
If a communication address or comment could not be processed, the error
flag 'ERRORFLAG' is set to 'X' and the serial number 'CONSNUMBER' to '000' in its row in the BAPIAD* structure.


11-Dec-2005