Posted: Sat Apr 26, 2008 5:57 pm Post subject: BAPI_BUPA_ADDRESSES_GET
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.
* 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.
*&--------------------------------------------------------------------
*& 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.
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.
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.