abap-关于sap地址,传真,邮箱的地址读取

  • A+
所属分类:Notes

在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
WHERE addrnumber = iv_addrnumber
AND persnumber = iv_persnumber.
2 SD的合作伙伴的地址
KNVK:户主要联系伙伴(PARNR(10)),该表含有连个字段:ADRNP_2(10)->地址号码,PRSNR(10)->人员编号,再根据这两个号码去读取相关表数据。
六、地址写入代码摘抄
FUNCTION ADDR_SAVE_INTERN.
*"----------------------------------------------------------------------
*"*"Verbuchungsfunktionsbaustein:
*"
*"*"Lokale Schnittstelle:
*" TABLES
*" ADRC_D STRUCTURE ADRC
*" ADRC_U STRUCTURE ADRC
*" ADRC_I STRUCTURE ADRC
*" ADRCT_D STRUCTURE ADRCT
*" ADRCT_U STRUCTURE ADRCT
*" ADRCT_I STRUCTURE ADRCT
*" ADRP_D STRUCTURE ADRP
*" ADRP_U STRUCTURE ADRP
*" ADRP_I STRUCTURE ADRP
*" ADCP_D STRUCTURE ADCP
*" ADCP_U STRUCTURE ADCP
*" ADCP_I STRUCTURE ADCP
*" ADRT_D STRUCTURE ADRT
*" ADRT_U STRUCTURE ADRT
*" ADRT_I STRUCTURE ADRT
*" ADR2_D STRUCTURE ADR2
*" ADR2_U STRUCTURE ADR2
*" ADR2_I STRUCTURE ADR2
*" ADR3_D STRUCTURE ADR3
*" ADR3_U STRUCTURE ADR3
*" ADR3_I STRUCTURE ADR3
*" ADR4_D STRUCTURE ADR4
*" ADR4_U STRUCTURE ADR4
*" ADR4_I STRUCTURE ADR4
*" ADR5_D STRUCTURE ADR5
*" ADR5_U STRUCTURE ADR5
*" ADR5_I STRUCTURE ADR5
*" ADR6_D STRUCTURE ADR6
*" ADR6_U STRUCTURE ADR6
*" ADR6_I STRUCTURE ADR6
*" ADR7_D STRUCTURE ADR7
*" ADR7_U STRUCTURE ADR7
*" ADR7_I STRUCTURE ADR7
*" ADR8_D STRUCTURE ADR8
*" ADR8_U STRUCTURE ADR8
*" ADR8_I STRUCTURE ADR8
*" ADR9_D STRUCTURE ADR9
*" ADR9_U STRUCTURE ADR9
*" ADR9_I STRUCTURE ADR9
*" ADR10_D STRUCTURE ADR10
*" ADR10_U STRUCTURE ADR10
*" ADR10_I STRUCTURE ADR10
*" ADR11_D STRUCTURE ADR11
*" ADR11_U STRUCTURE ADR11
*" ADR11_I STRUCTURE ADR11
*" ADR12_D STRUCTURE ADR12
*" ADR12_U STRUCTURE ADR12
*" ADR12_I STRUCTURE ADR12
*" ADR13_D STRUCTURE ADR13
*" ADR13_U STRUCTURE ADR13
*" ADR13_I STRUCTURE ADR13
*" ADRCOMC_D STRUCTURE ADRCOMC
*" ADRCOMC_U STRUCTURE ADRCOMC
*" ADRCOMC_I STRUCTURE ADRCOMC
*" ADRG_D STRUCTURE ADRG
*" ADRG_U STRUCTURE ADRG
*" ADRG_I STRUCTURE ADRG
*" ADRGP_D STRUCTURE ADRGP
*" ADRGP_U STRUCTURE ADRGP
*" ADRGP_I STRUCTURE ADRGP
*" ADRV_D STRUCTURE ADRV
*" ADRV_U STRUCTURE ADRV
*" ADRV_I STRUCTURE ADRV
*" ADRVP_D STRUCTURE ADRVP
*" ADRVP_U STRUCTURE ADRVP
*" ADRVP_I STRUCTURE ADRVP
*" EXCEPTIONS
*" DATABASE_ERROR
*" INTERNAL_ERROR
*"----------------------------------------------------------------------
* Initialisierung der FG sicherstellen
PERFORM. CHECK_FOR_INITIALIZATION.
DEFINE WRITE_TO_DB.
DELETE &1 FROM TABLE &1_D.
IF SY-SUBRC <> 0.
MESSAGE A840 WITH '&1' RAISING DATABASE_ERROR.
* Datenbankfehler beim L鰏chen aus Tabelle &
ENDIF.
UPDATE &1 FROM TABLE &1_U.
IF SY-SUBRC <> 0.
MESSAGE A841 WITH '&1' RAISING DATABASE_ERROR.
* Datenbankfehler beim 膎dern von Tabelle &
ENDIF.
INSERT &1 FROM TABLE &1_I.
IF SY-SUBRC <> 0.
MESSAGE A842 WITH '&1' RAISING DATABASE_ERROR.
* Datenbankfehler beim Einf黦en in Tabelle &
ENDIF.
END-OF-DEFINITION.
WRITE_TO_DB ADRC .
* WRITE_TO_DB ADRCT . "*912d
DELETE ADRCT FROM TABLE ADRCT_D. "*912i
IF SY-SUBRC <> 0. "*912i
MESSAGE A840 WITH 'ADRCT' RAISING DATABASE_ERROR. "*912i
ENDIF. "*912i
UPDATE ADRCT FROM TABLE ADRCT_U. "*912i
IF SY-SUBRC <> 0. "*912i
MESSAGE A841 WITH 'ADRCT' RAISING DATABASE_ERROR. "*912i
ENDIF. "*912i
MODIFY ADRCT FROM TABLE ADRCT_I. "*912i
IF SY-SUBRC <> 0. "*912i
MESSAGE A842 WITH 'ADRCT' RAISING DATABASE_ERROR. "*912i
ENDIF. "*912i
WRITE_TO_DB ADRP .
WRITE_TO_DB ADCP .
WRITE_TO_DB ADRT .
WRITE_TO_DB ADR2 .
WRITE_TO_DB ADR3 .
WRITE_TO_DB ADR4 .
WRITE_TO_DB ADR5 .
WRITE_TO_DB ADR6 .
WRITE_TO_DB ADR7 .
WRITE_TO_DB ADR8 .
WRITE_TO_DB ADR9 .
WRITE_TO_DB ADR10 . "*178i
WRITE_TO_DB ADR11 . "*178i
WRITE_TO_DB ADR12 . "*178i
WRITE_TO_DB ADR13 . "*178i
WRITE_TO_DB ADRCOMC.
WRITE_TO_DB ADRG .
WRITE_TO_DB ADRGP .
WRITE_TO_DB ADRV .
WRITE_TO_DB ADRVP .
ENDFUNCTION.

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:1   其中:访客  1   博主  0

    • ag

      ADDR_SELECT_ADRC_ARRAY ADDR_SELECT_ADRC_SINGLE