SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Address | Адрес



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Function Modules | Функциональные модули
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Fri Sep 14, 2007 1:33 pm    Post subject: Address | Адрес Reply with quote

ADDR_GET - Get address data by address number
Code:

    DATA: sel LIKE addr1_sel,
          sadr LIKE sadr,
          name1 LIKE lfa1-name1,
          name2 LIKE lfa1-name2.

    SELECT SINGLE adrnr name1 name2 FROM lfa1
      INTO (sel-addrnumber, name1, name2)
      WHERE lifnr = I_VALUE.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
         EXPORTING
              input  = sel-addrnumber
         IMPORTING
              output = sel-addrnumber.

    sel-nation = sy-langu.
    CALL FUNCTION 'ADDR_GET'
         EXPORTING
              address_selection = sel
         IMPORTING
              sadr              = sadr
         EXCEPTIONS
              parameter_error   = 1
              address_not_exist = 2
              version_not_exist = 3
              internal_error    = 4
              OTHERS            = 5.

    IF sy-subrc IS INITIAL.
      name1 = sadr-name1.
      name2 = sadr-name2.
    ENDIF.


ADDR_COMM_GET - Get communication data for address number.
Possible TABLE_TYPE:
ADTEL, ADFAX, ADTTX, ADTLX, ADSMTP, ADRML, ADX400, ADRFC, ADPRT, ADSSF, ADURI, ADPAG

ADDRESS_INTO_PRINTFORM - Address format according to Post Office guidelines.
Note. It's enough to import two parameters:
- ADDRESS_TYPE = 1 (Firm or Organization, SAP Address)
- ADDRESS_NUMBER

ADDRESS_SHOW_PRINTFORM - Formats an address for printing.

see tables:
ADRC - Addresses (central address admin.)

BAPI_ADDRESSORG_CHANGE - BAPI to change organization addresses
The organization address is determined from the specified object type and object key, and updated with the specified address and communication data, if required.
This module differs from a standard change BAPI in that not only can existing entries be changed, but address attribute telephone numbers, fax numbers, etc. can also be deleted or inserted.
Reference structures (checkboxes) are used to select entries to be changed.

Code:
* Change an organization address:
* Change, delete and add a telephone number

DATA: objtype LIKE bapi4001_1-objtype,
obj_id LIKE bapi4001_1-objkey,
obj_id_ext LIKE bapi4001_1-extension,
context LIKE bapi4001_1-context,
address_number LIKE adrc-addrnumber,
bapiadtel LIKE bapiadtel OCCURS 0 WITH HEADER LINE,
bapiadtel_x LIKE bapiadtelx OCCURS 0 WITH HEADER LINE,
return LIKE bapiret2 OCCURS 0.

* Assign the following object type and object key to a main customer
* address
objtype = 'KNA1'.
obj_id = <customer number>.
obj_id_ext = ' '.
context = '0001'.

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

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

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_ADDRESSORG_CHANGE'
EXPORTING
obj_type = objtype
obj_id = obj_id
obj_id_ext = obj_id_ext
context = context
IMPORTING
address_number = address_number
TABLES
bapiadtel = bapiadtel
bapiadtel_x = bapiadtel_x
return = return.

* Errors and warnings are in the RETURN table. If successful, the
* organization address and its communication data are now updated
* in the system.
* The adress number is in the ADDRESS_NUMBER field.

BAPI_ADDRESSORG_GETDETAIL - BAPI to read organization addresses
The address data of the organization address for the specified object type and key is returned.
The address number used in the current system is also returned.

Code:
REPORT  zprueba.

data: l_objtype     like BAPI4001_1-OBJTYPE,
     l_objid       like BAPI4001_1-OBJKEY,
     l_addrno      LIKE BAPI4001_1-ADDR_NO,
     t_bapiad1vl   type standard table of BAPIAD1VL,
     w_bapiad1vl   type BAPIAD1VL,
     t_bapiad1vl_x type standard table of BAPIAD1VLX,
     w_bapiad1vl_x type BAPIAD1VLX,
     t_bapiret  type standard table of BAPIRET2,
     w_bapiret  type BAPIRET2.

l_objtype = 'KNA1'.
l_objid   = '0030000004'.

CALL FUNCTION 'BAPI_ADDRESSORG_GETDETAIL'
 EXPORTING
   OBJ_TYPE             = l_objtype
   OBJ_ID               = l_objid
   OBJ_ID_EXT           = ' '
   CONTEXT              = 1
 IMPORTING
   ADDRESS_NUMBER       = l_addrno
 TABLES
   BAPIAD1VL            = t_bapiad1vl
   RETURN               = t_bapiret.

read table t_bapiad1vl index 1 into w_bapiad1vl.
w_bapiad1vl-STR_SUPPL1 = 'CALLE NUMERO 2'.
w_bapiad1vl-STR_SUPPL2 = 'CALLE NUMERO 3'.
w_bapiad1vl-STR_SUPPL3 = 'CALLE NUMERO 4'.
modify t_bapiad1vl from w_bapiad1vl index 1.

w_bapiad1vl_x-STR_SUPPL1 = 'U'.
w_bapiad1vl_x-STR_SUPPL2 = 'I'.
w_bapiad1vl_x-STR_SUPPL3 = 'I'.
append w_bapiad1vl_x to t_bapiad1vl_x.

CALL FUNCTION 'BAPI_ADDRESSORG_CHANGE'
 EXPORTING
   OBJ_TYPE               = l_objtype
   OBJ_ID                 = l_objid
   OBJ_ID_EXT             = ' '
   CONTEXT                = 1
   ACCEPT_ERROR           = ' '
   SAVE_ADDRESS           = 'X'
   IV_CHECK_ADDRESS       = 'X'
 IMPORTING
   ADDRESS_NUMBER         = l_addrno
 TABLES
   BAPIAD1VL              = t_bapiad1vl
   BAPIAD1VL_X            = t_bapiad1vl_x
   RETURN                 = t_bapiret.

check t_bapiret[] is initial.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
 EXPORTING
   WAIT   = 'X'
 IMPORTING
   RETURN = w_bapiret.


ADDR_GET_COMPLETE - The function module gets all addresses for an address number or address handle, including all their communication types and notes about the address or communication type.
The currently valid communication types are defined in the table TSAC(T).

Code:
REPORT zlistacli .
data: begin of i_listado occurs 10,
       lifnr like lfa1-lifnr,
       name1 like lfa1-name1,
       email(70),
       fax   like ADFAX-FAX_NUMBER,
     end of i_listado.

START-OF-SELECTION.

 TABLES: ADDR1_SEL, KNA1.

 TYPE-POOLS: SZADR.
 DATA: addr1_complete TYPE szadr_addr1_complete.
 DATA: adsmtp_line TYPE szadr_adsmtp_line,
       addr1_line  TYPE szadr_addr1_line,
       adtel_line TYPE szadr_adtel_line,
       adfax_line TYPE szadr_adfax_line.

 DATA: l_address_selection LIKE addr1_sel,
       l_lfa1 LIKE lfa1.

 SELECT * FROM lfa1 into l_lfa1.
   clear i_listado.
   move-corresponding l_lfa1 to i_listado.
   l_address_selection-addrnumber = l_lfa1-adrnr.
   addr1_sel-addrnumber = l_address_selection.
   CALL FUNCTION 'ADDR_GET_COMPLETE'
        EXPORTING
             addrnumber        = addr1_sel-addrnumber
        IMPORTING
             addr1_complete    = addr1_complete
        EXCEPTIONS
             parameter_error   = 1
             address_not_exist = 2
             internal_error    = 3
             OTHERS            = 4.

   IF sy-subrc = 0.
     READ TABLE addr1_complete-addr1_tab INDEX 1 INTO addr1_line.
     IF sy-subrc = 0.
        loop at addr1_complete-adsmtp_tab into adsmtp_line.
        i_listado-email = adsmtp_line-ADSMTP-SMTP_ADDR.
        exit.
        endloop.
     loop at addr1_complete-adfax_tab  INTO adfax_line.
         i_listado-fax = adfax_line-ADFAX-FAX_NUMBER.
         exit.
     endloop.
     ENDIF.
   ENDIF.
   append i_listado.
 ENDSELECT.


ADDR_COMM_GET - Get Address-Independent Communication Data Records
Code:
CALL FUNCTION 'ADDR_COMM_GET'
  EXPORTING
    address_handle = g_address_handle
    address_number = lfa1-adrnr
    table_type = 'ADSMTP'
  IMPORTING
    returncode = returncode
  TABLES
    comm_table = smtp_table
    error_table = error_table
  EXCEPTIONS
    parameter_error = 1
    address_not_exist = 2
    internal_error = 3
    OTHERS = 99.


ADDR_COMM_MAINTAIN - Change Address-Independent Communication Data Records

Code:
* Actualizar email
 DATA: xadsmtp  LIKE adsmtp OCCURS 0 WITH HEADER LINE.

 LOOP AT addr1_complete-adsmtp_tab INTO adsmtp_line.
   xadsmtp = adsmtp_line-adsmtp.
   APPEND xadsmtp.
 ENDLOOP.

 READ TABLE xadsmtp INDEX 1.
 IF sy-subrc NE 0.
   xadsmtp-smtp_addr = i_listado-email.
   xadsmtp-flgdefault = 'X'.
   xadsmtp-updateflag = 'I'.
   APPEND xadsmtp.
 ELSE.
   xadsmtp-smtp_addr = i_listado-email.
   xadsmtp-updateflag = 'U'.
   MODIFY xadsmtp INDEX 1.
 ENDIF.

 CALL FUNCTION 'ADDR_COMM_MAINTAIN'
      EXPORTING
           address_handle           = addr1_complete-addrhandle
           address_number           = addr1_complete-addrnumber
           table_type               = 'ADSMTP'
           substitute_all_comm_data = 'X'
      TABLES
           comm_table               = xadsmtp
      EXCEPTIONS
           parameter_error          = 1
           address_not_exist        = 2
           internal_error           = 3
           OTHERS                   = 4.
 IF sy-subrc = 0.
   CALL FUNCTION 'ADDR_MEMORY_SAVE'
*    EXPORTING
*         EXECUTE_IN_UPDATE_TASK = ' '
       EXCEPTIONS
            address_number_missing = 1
            person_number_missing  = 2
            internal_error         = 3
            database_error         = 4
            reference_missing      = 5
            OTHERS                 = 6.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Function Modules | Функциональные модули All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.