Code: Alles auswählen.
*&---------------------------------------------------------------------*
*& Report ZTEST_LOOP_ABAPFORUM *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ztest_loop_abapforum.
TYPES: BEGIN OF t_info,
addrnumber TYPE ad_addrnum,
telefon TYPE ad_telnrlg,
fax TYPE ad_fxnmbr,
email TYPE ad_smtpadr,
END OF t_info.
DATA ls_accountcommunication TYPE t_info.
DATA et_communication TYPE TABLE OF t_info.
DATA lt_telefon TYPE TABLE OF bapiadtel.
DATA ls_telefon TYPE bapiadtel.
DATA lt_fax TYPE TABLE OF bapiadfax.
DATA ls_fax TYPE bapiadfax.
DATA lt_email TYPE TABLE OF bapiadsmtp.
DATA ls_email TYPE bapiadsmtp.
DATA lt_return TYPE TABLE OF bapiret2.
DATA ls_return TYPE bapiret2.
DATA ls_addressdata TYPE bapibus1006_address.
DATA is_account_compid TYPE bapibus1006_head-bpartner.
CALL FUNCTION 'BAPI_BUPA_ADDRESS_GETDETAIL'
EXPORTING
businesspartner = is_account_compid
IMPORTING
addressdata = ls_addressdata
TABLES
bapiadtel = lt_telefon
bapiadfax = lt_fax
bapiadsmtp = lt_email
return = lt_return.
* Fehler prüfung
CLEAR ls_return.
LOOP AT lt_return INTO ls_return WHERE type = 'E' OR type ='A'.
EXIT.
ENDLOOP.
* Wenn Fehler -> tschüss
CHECK ls_return IS INITIAL.
*** Auswertung
REFRESH et_communication.
CLEAR ls_accountcommunication.
* Standard Telefon des Kunden (gibt nur Eine oder keine)
LOOP AT lt_telefon INTO ls_telefon WHERE std_no = 'X'.
ls_accountcommunication-telefon = ls_telefon-tel_no.
ENDLOOP.
* Standard Fax des Kunden (gibt nur Eines oder keines)
LOOP AT lt_fax INTO ls_fax WHERE std_no = 'X'.
ls_accountcommunication-fax = ls_fax-fax.
ENDLOOP.
* Standard Email des Kunden
LOOP AT lt_email INTO ls_email WHERE std_no = 'X'.
ls_accountcommunication-email = ls_email-e_mail.
ENDLOOP.
APPEND ls_accountcommunication TO et_communication.