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

BAPI_BUPA_ADDRESSES_GET



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы -> BAPI
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sat Apr 26, 2008 5:57 pm    Post subject: BAPI_BUPA_ADDRESSES_GET Reply with quote

BAPI_BUPA_ADDRESSES_GET - Determine All Addresses for Business Partner

Code:
TABLES : but000.

DATA: BEGIN OF t_output OCCURS 0,
bp LIKE but000-partner,
home_phone LIKE bapiadtel-telephone,
mobile_phone LIKE bapiadtel-telephone,
fax LIKE bapiadtel-telephone,
work_phone LIKE bapiadtel-telephone,
END OF t_output.

DATA: workphone LIKE bapiadtel-telephone.

DATA: BEGIN OF t_bp OCCURS 0,
partner LIKE but000-partner,
END OF t_bp.

DATA: w_addressguid LIKE bapibus1006_addresses_int-addrguid,
w_addrnr LIKE bapibus1006_addresses_int-addrnumber,
w_addressdata LIKE bapibus1006_address,
t_address LIKE bapibus1006_addresses OCCURS 0 WITH HEADER LINE,
t_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
t_tel LIKE bapiadtel OCCURS 0 WITH HEADER LINE,
t_fax LIKE bapiadfax OCCURS 0 WITH HEADER LINE.

*bdc declaration
* Batchinputdata of single transaction
DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
* messages of call transaction
DATA: messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
* error session opened (' ' or 'X')
DATA: e_group_opened.
* message texts
TABLES: t100.

*bdc
START-OF-SELECTION.
  SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-105.
*Business Partner Number
  SELECT-OPTIONS: s_bp FOR but000-partner, " obligatory,
  s_bpkind FOR but000-bpkind, " obligatory,
  s_bptype FOR but000-type. " obligatory.

  SELECTION-SCREEN END OF BLOCK b2.

END-OF-SELECTION.

* get the basic data

  SELECT partner
  FROM but000
  INTO TABLE t_bp
  WHERE partner IN s_bp AND
  bpkind IN s_bpkind AND
  type IN s_bptype.

  LOOP AT t_bp.
    WRITE :/1 t_bp-partner.

* get the address guids.

    CALL FUNCTION 'BAPI_BUPA_ADDRESSES_GET'
      EXPORTING
        businesspartner       = t_bp-partner
        addresstype           = 'HOME'
      IMPORTING
        standardaddressguid   = w_addressguid
        standardaddressnumber = w_addrnr
      TABLES
        addresses             = t_address
        return                = t_return.

*Get Address Detail
    CALL FUNCTION 'BAPI_BUPA_ADDRESS_GETDETAIL'
      EXPORTING
        businesspartner = t_bp-partner
        addressguid     = t_address-addressguid
      IMPORTING
        addressdata     = w_addressdata
      TABLES
        bapiadtel       = t_tel
        bapiadfax       = t_fax.

*  populate the data in the output table
    t_output-bp = t_bp-partner.

*  home and mobile phone
    LOOP AT t_tel.
      IF t_tel-telephone IS NOT INITIAL.
        IF t_tel-r_3_user = '1'. "Home Phone
          PERFORM format_phone USING t_tel-telephone.
          t_output-home_phone = t_tel-telephone.
        ELSE. "Mobile Phone
          PERFORM format_phone USING t_tel-telephone.
          t_output-mobile_phone = t_tel-telephone.
        ENDIF.
      ENDIF.
    ENDLOOP.

*Get fax number
    LOOP AT t_fax.
      IF t_fax-fax IS NOT INITIAL.
        PERFORM format_phone USING t_fax-fax.
        t_output-fax = t_fax-fax.
      ENDIF.
    ENDLOOP.

*Get work number
    SELECT SINGLE adext FROM but020 INTO workphone
    WHERE partner = t_bp-partner
    AND addrnumber = w_addrnr.

    IF workphone IS NOT INITIAL.
      PERFORM format_phone USING workphone.
    ENDIF.

    t_output-work_phone = workphone.

    CLEAR: t_tel, t_fax, workphone.
    APPEND t_output.
    CLEAR: t_output.
  ENDLOOP.

  WRITE :/1 ' bp ', 20 ' home_phone ', 35 ' mobile_phone ',
  50 'fax', 75 'workphone'.

*&--------------------------------------------------------------------
*& Form format_phone
*&--------------------------------------------------------------------
*text
*---------------------------------------------------------------------
*-->P_PHONE text
*---------------------------------------------------------------------
FORM format_phone USING p_phone.

  DATA: w_strlen TYPE i,
  w_offset TYPE i.

  CLEAR w_offset. CLEAR w_strlen.

  w_strlen = STRLEN( p_phone ).
  DO w_strlen TIMES.
    IF p_phone+w_offset(1) NA '0123456789 '.
      p_phone+w_offset(1) = ' '.
    ENDIF.
    w_offset = w_offset + 1.
  ENDDO.
  CONDENSE p_phone NO-GAPS.

  CLEAR w_offset. CLEAR w_strlen.

  w_strlen = STRLEN( p_phone ).
  IF w_strlen GT '10'.
    w_offset = w_strlen - 10.
  ENDIF.
  p_phone = p_phone+w_offset(10).

  w_strlen = STRLEN( p_phone ).
  IF w_strlen NE '10'.
    MESSAGE
    'Please enter 10 digit phone number in the format'
    TYPE 'E'.
  ELSE.
    CONCATENATE p_phone(3) '.' p_phone+3(3) '.' p_phone+6(4) INTO
    p_phone.
  ENDIF.

ENDFORM. " format_phone
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 -> Interfaces | Интерфейсы -> BAPI 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.