abap--about SAP Address, fax, address of the mailbox read

Source: Internet
Author: User

In the SAP application, many places need to use the address and the contact way, the SAP has used the centralized maintenance to the address, recently has carried on the study to this, collected some information for everybody to consult, also asked everybody to give a lot of advice.
First, the relevant package
Szad

second, the related table (see Addr_save_intern function operation)
1 ADR2: Telephone number (business address service) (Addrnumber), Persnumber (10))
2.ADR3: Fax number (business address service) (Addrnumber), Persnumber (10))
3.ADR4: Telex number (Business address service) (Addrnumber), Persnumber (10))
4.ADR5: Telex number (Business address service) (Addrnumber), Persnumber (10))
5.ADR6:SMTP Number (Business address service) (Addrnumber), Persnumber (10))
6.ADR7: Remote Mail address (R/3-R/3; Business address service) (Addrnumber), Persnumber (10))
7.ADRC: Address (Business Address service) (Addrnumber (10))
8.ADCP: Personal/Address Assignment (Business address service) (Addrnumber, Persnumber (10)), record user which data is maintained as: FLAGCOMM3 for ' X ' means fax number is maintained;
9.ADRP: Personal (Office address Management) (Persnumber (10))

third, related BAPI
Bapi_addresspers_change
Bapi_addresspers_getdetail

Iv. get the next address auto-numbering (code)
1. Read the Supplier address
addr_ref-appl_table = ' Ekko '.
Addr_ref-appl_field = ' Adrnr '.
Addr_ref-appl_key (3) = Ekko-mandt.
Addr_ref-appl_key+3 (Ten) = 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. Customer's address


3. Get Partner Address number
Get the contact number first
reference-appl_table = ' knvk '.
Reference-appl_field = ' Prsnr '.
*person-key_content is the partner's number
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.
* In obtaining the address number
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.

v. How to read some common addresses
1. Customer Address
Read the customer address you first need to read the KNA1 table, find the customer corresponding address number (ADRNR) field, in accordance with this field to read the ADRC table, and then read the other related tables (ADR2.)
SELECT * from ADR2
Into TABLE <ft_temp>
WHERE Addrnumber = Iv_addrnumber
and Persnumber = Iv_persnumber.
2 Address of the partner of the SD
KNVK: Main Contact partner (Parnr (10)), the table contains a connection field: Adrnp_2 (ten), address number, Prsnr (ten) and the personnel number, and then according to these two numbers to read the relevant table data.

Six, address write code excerpt
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 movers 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.