Skip to end of metadata
Go to start of metadata

ADDR1_EXTRACT_TABLES - Function Module for Address data of Cusomter/Vendor

Summary

This Function module can be used to extract Address details of Customers & Vendors stored in different tables.  This function module extract the data related to all the address tables like ADRC,ADR2,ADR6 Etc.

Author(s):  Vinod Kumar T

   
Company:     NIIT Technologies Limited
Created on:    23.07.2010
Author(s) Bio
Vinod Kumar is an ABAP Consultant working with NIIT Technologies Limited.

Sample Program using ADDR1_EXTRACT_TABLES for extracting Customer Address Details


*&---------------------------------------------------------------------*
*& Report  ZVK_ADDR1_EXTRACT_TABLES
*&
*&---------------------------------------------------------------------*
*&Purpose : Extract All address related tables of given customer list
*&---------------------------------------------------------------------*

REPORT  zvk_addr1_extract_tables.

TABLES : kna1.

** Type declaration for KNA1
TYPES : BEGIN OF ty_kna1,
          kunnr TYPE kunnr,
          adrnr TYPE adrnr,
        END OF ty_kna1.

** Internal table and Workarea Declarations
DATA : it_kna1 TYPE STANDARD TABLE OF ty_kna1,
       is_kna1 TYPE ty_kna1.

DATA : it_address_keys TYPE STANDARD TABLE OF addr_key,
       is_address_keys TYPE addr_key,
       it_adrc         TYPE STANDARD TABLE OF adrc,
       it_adrct        TYPE STANDARD TABLE OF adrct,
       it_adr2         TYPE STANDARD TABLE OF adr2,
       it_adr3         TYPE STANDARD TABLE OF adr3,
       it_adr4         TYPE STANDARD TABLE OF adr4,
       it_adr5         TYPE STANDARD TABLE OF adr5,
       it_adr6         TYPE STANDARD TABLE OF adr6,
       it_adr7         TYPE STANDARD TABLE OF adr7,
       it_adr8         TYPE STANDARD TABLE OF adr8,
       it_adr9         TYPE STANDARD TABLE OF adr9,
       it_adr10        TYPE STANDARD TABLE OF adr10,
       it_adr11        TYPE STANDARD TABLE OF adr11,
       it_adr12        TYPE STANDARD TABLE OF adr12,
       it_adr13        TYPE STANDARD TABLE OF adr13,
       it_adrt         TYPE STANDARD TABLE OF adrt.

SELECTION-SCREEN BEGIN OF BLOCK b1.
SELECT-OPTIONS : p_kunnr FOR kna1-kunnr.
SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.
  PERFORM refresh_tables.
  PERFORM extract_address_nos.
  PERFORM populate_fm_input.
  PERFORM call_fm.
*&---------------------------------------------------------------------*
*&      Form  refresh_tables
*&---------------------------------------------------------------------*
FORM refresh_tables.
  REFRESH : it_kna1, it_address_keys,
            it_adrc, it_adrct, it_adr2, it_adr3,
            it_adr4, it_adr5, it_adr6, it_adr7,
            it_adr8, it_adr9, it_adr10, it_adr11,
            it_adr12, it_adr13, it_adrt.
ENDFORM.                    "refresh_tables

*&---------------------------------------------------------------------*
*&      Form  extract_address_nos
*&---------------------------------------------------------------------*
FORM extract_address_nos.
  SELECT kunnr adrnr
    FROM kna1
    INTO TABLE it_kna1
    WHERE kunnr IN p_kunnr.
ENDFORM.                    "extract_address_nos

*&---------------------------------------------------------------------*
*&      Form  populate_fm_input
*&---------------------------------------------------------------------*
FORM populate_fm_input.
  IF it_kna1[] IS NOT INITIAL.
    LOOP AT it_kna1 INTO is_kna1.
      CLEAR : is_address_keys.
      MOVE is_kna1-adrnr TO is_address_keys-addrnumber.
      MOVE '1'           TO is_address_keys-addr_type.
      APPEND is_address_keys TO it_address_keys.
    ENDLOOP.
  ENDIF.
ENDFORM.                    "populate_fm_input

*&---------------------------------------------------------------------*
*&      Form  call_fm
*&---------------------------------------------------------------------*
FORM call_fm.
  IF it_address_keys[] IS NOT INITIAL.
    CALL FUNCTION 'ADDR1_EXTRACT_TABLES'
      TABLES
        t_address_keys = it_address_keys
        t_adrc         = it_adrc
        t_adrct        = it_adrct      "Comment is Details not required"
        t_adr2         = it_adr2       "Comment is Details not required"
        t_adr3         = it_adr3       "Comment is Details not required"
        t_adr4         = it_adr4       "Comment is Details not required"
        t_adr5         = it_adr5       "Comment is Details not required"
        t_adr6         = it_adr6       "Comment is Details not required"
        t_adr7         = it_adr7       "Comment is Details not required"
        t_adr8         = it_adr8       "Comment is Details not required"
        t_adr9         = it_adr9       "Comment is Details not required"
        t_adr10        = it_adr10      "Comment is Details not required"
        t_adr11        = it_adr11      "Comment is Details not required"
        t_adr12        = it_adr12      "Comment is Details not required"
        t_adr13        = it_adr13      "Comment is Details not required"
        t_adrt         = it_adrt       "Comment is Details not required"
      EXCEPTIONS
        empty_table    = 1
        OTHERS         = 2.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
  ENDIF.
ENDFORM.                    


Important Instructions

This function module works for extracting data for address type: 1 (company address) like customer& vendor.  For Address type 2 (Person address), Function module ADDR2_EXTRACT_TABLES and for Address type 3 ( contact Person in company), Function module ADDR3_EXTRACT_TABLES is used.  Input parameter table remain same for these function module.  Only difference is in the address type field ( structure IT_ADDRESS_KEYS-ADDR_TYPE) which is to be changed based on the address type.

In addition to this, it is not mandatory to specify all the address tables while calling this function module.  For example if the user doesn't need the Email related data of the address, then the line T_ADR6 = IT_ADR6 can be commented while calling the function module. 

Details of Address table data extracted using this FM

FM Structure Name

Table Name

Table Short Text

T_ADRC

ADRC

Addresses (Business Address Services)

T_ADRCT

ADRCT

Address Texts (Business Address Services)

T_ADR2

ADR2

Telephone Numbers (Business Address Services)

T_ADR3

ADR3

Fax Numbers (Business Address Services)

T_ADR4

ADR4

Teletex Numbers (Business Address Services)

T_ADR5

ADR5

Telex Numbers (Business Address Services)

T_ADR6

ADR6

E-Mail Addresses (Business Address Services)

T_ADR7

ADR7

Remote Mail Addresses (R/3 - R/3; Business Address Services)

T_ADR8

ADR8

X.400 Numbers (Business Address Services)

T_ADR9

ADR9

RFC Destinations (Business Address Services)

T_ADR10

ADR10

Printer (Business Address Services)

T_ADR11

ADR11

SSF (Business Address Services)

T_ADR12

ADR12

FTP and URL (Business Address Services)

T_ADR13

ADR13

Pager (Business Address Services)

T_ADRT

ADRT

Communication Data Text (Business Address Services)


Related Content

Please include at least three references to SDN documents or web pages.
http://help.sap.com/saphelp_glossary/en/35/c9acf7a13a56ebe10000009b38f982/content.htm
http://wiki.sdn.sap.com/wiki/display/ERPLO/LO-MD-BP