【IT168 技术文章】
在SAP的应用中,很多地方需要用到地址和联系方式,sap对于地址采用了集中维护,最近对这进行了学习,收集到的一些资料供大家参考,也请大家多多指点。
一、相关package
SZAD
二、相关表(可以参见ADDR_SAVE_INTERN函数的操作)
1 ADR2 : 电话号码 (业务地址服务)(ADDRNUMBER(10),PERSNUMBER(10))
2.ADR3:传真号 (业务地址服务)(ADDRNUMBER(10),PERSNUMBER(10))
3.ADR4:电传号码 (业务地址服务)(ADDRNUMBER(10),PERSNUMBER(10))
4.ADR5:电传号码 (业务地址服务)(ADDRNUMBER(10),PERSNUMBER(10))
5.ADR6:SMTP 编号 (业务地址服务)(ADDRNUMBER(10),PERSNUMBER(10))
6.ADR7:远程邮件地址 (R/3 - R/3; 业务地址服务) (ADDRNUMBER(10),PERSNUMBER(10))
7.ADRC:地址 (业务地址服务) (ADDRNUMBER(10))
8.ADCP:个人/地址分配 (业务地址服务)(ADDRNUMBER(10),PERSNUMBER(10)),纪录用户哪些数据被维护如:FLAGCOMM3为'X'表示传真号被维护;
9.ADRP:个人(办公地址管理)(PERSNUMBER(10))
三、相关BAPI
BAPI_ADDRESSPERS_CHANGE
BAPI_ADDRESSPERS_GETDETAIL
四、获取下一个地址自动编号(代码)
1.供应商地址的读取
addr_ref-appl_table = 'EKKO'.
addr_ref-appl_field = 'ADRNR'.
addr_ref-appl_key(3) = ekko-mandt.
addr_ref-appl_key+3(10) = ekko-ebeln.
addr_ref-addr_group = 'ME03'.
addr_ref-owner = space.
* get address number
CALL FUNCTION 'ADDR_NUMBER_GET'
EXPORTING
address_handle = address_handle
address_reference = addr_ref
IMPORTING
address_number = p_ekko-adrnr
EXCEPTIONS
address_handle_not_exist = 1
internal_error = 2
parameter_error = 3
OTHERS = 4.
2.客户的地址
3.获取合作伙伴地址号码
先获取联系人编号
REFERENCE-APPL_TABLE = ‘KNVK’.
REFERENCE-APPL_FIELD = ‘PRSNR’.
*PERSON-KEY_CONTENT为合作伙伴的编号
CONCATENATE SY-MANDT PERSON-KEY_CONTENT INTO REFERENCE-APPL_KEY.
REFERENCE-PERS_GROUP = C_ADDRESS_GROUP.
REFERENCE-ADDRNUMBER = ADDRESS_NUMBER.
IF ADDRESS_TYPE = C_TYPE_2.
REFERENCE-PERS_ADDR = 'X'.
CLEAR REFERENCE-ADDRNUMBER.
ELSE.
CLEAR REFERENCE-PERS_ADDR.
ENDIF.
REFERENCE-OWNER = 'X'.
CALL FUNCTION 'ADDR_PERSON_NUMBER_GET'
EXPORTING
PERSON_HANDLE = PERSONHANDLE
PERSON_REFERENCE = REFERENCE
IMPORTING
PERSON_NUMBER = ZAV_TAB-PERSON-NUMBER
EXCEPTIONS
INTERNAL_ERROR = 1
PERSON_HANDLE_NOT_EXIST = 2
PARAMETER_ERROR = 3
OTHERS = 4.
*在获取地址编号
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
NR_RANGE_NR = '01'
OBJECT = 'ADRNR'
QUANTITY = REQUESTED_QUANTITY
IMPORTING
NUMBER = NUMBER
QUANTITY = QUANTITY
RETURNCODE = RETURNCODE_NUMBERRANGE
EXCEPTIONS
INTERVAL_NOT_FOUND = 1
NUMBER_RANGE_NOT_INTERN = 2
OBJECT_NOT_FOUND = 3
QUANTITY_IS_0 = 4
QUANTITY_IS_NOT_1 = 5
INTERVAL_OVERFLOW = 6
OTHERS = 7.
五、一些常用地址如何读取
1. 客户地址
客户地址的读取你首先要读KNA1表,找出客户对应的地址编号(ADRNR)字段,在根据此字段去读取ADRC表,再读取其他相关表(ADR2 ..)
SELECT * FROM ADR2
INTO TABLE <ft_temp>
WHERE addrnumber = iv_addrnumber
AND persnumber = iv_persnumber.
2 SD的合作伙伴的地址
KNVK:户主要联系伙伴(PARNR(10)),该表含有连个字段:ADRNP_2(10)->地址号码,PRSNR(10)->人员编号,再根据这两个号码去读取相关表数据。