Code: Alles auswählen.
* Verarbeitung Receiver von ZCOGIEMAIL
LOOP AT lt_cogi_daten ASSIGNING <lf_cogi_daten>.
AT NEW msgid_key.
* Verarbeitung Receiver von ZCOGIEMAIL
READ TABLE lt_cogi_mail
WITH KEY msgid = <lf_cogi_daten>-msgid
msgno = <lf_cogi_daten>-msgno
INTO ls_cogi_mail.
MOVE-CORRESPONDING ls_cogi_mail TO gs_receivers.
APPEND gs_receivers TO gt_receivers.
CLEAR gt_doc_content[].
ENDAT.
* Aufbereitung Email
DESCRIBE TABLE gt_doc_content LINES gv_entries.
READ TABLE gt_doc_content INTO gs_doc_content INDEX gv_entries.
gs_doc_data-doc_size = ( gv_entries - 1 ) * 255 + strlen( gs_doc_content ).
Code: Alles auswählen.
* Select zcogiemal
SELECT * FROM zcogiemail
INTO CORRESPONDING FIELDS OF TABLE lt_cogi_mail.
* Select auf AFFW
SELECT * FROM affw
INTO CORRESPONDING FIELDS OF TABLE lt_cogi_daten.
**********************************************************************
* Verarbeitung der Daten ZCOGIEMAIL und AFFW auf Key MSGNO
**********************************************************************
* Verarbeitung AFFW
LOOP AT lt_cogi_daten ASSIGNING FIELD-SYMBOL(<lf_cogi_daten>).
<lf_cogi_daten>-msgid_key = <lf_cogi_daten>-msgid.
<lf_cogi_daten>-msgno_key = <lf_cogi_daten>-msgno.
<lf_cogi_daten>-msgty_key = <lf_cogi_daten>-msgty.
<lf_cogi_daten>-msgv1_key = <lf_cogi_daten>-msgv1.
<lf_cogi_daten>-msgv2_key = <lf_cogi_daten>-msgv2.
<lf_cogi_daten>-msgv3_key = <lf_cogi_daten>-msgv3.
<lf_cogi_daten>-msgv4_key = <lf_cogi_daten>-msgv4.
<lf_cogi_daten>-weblnr_key = <lf_cogi_daten>-weblnr.
ENDLOOP.
SORT lt_cogi_daten.
https://www.tricktresor.de/blog/gruppenwechsel/ hat geschrieben: Anmerkung:
Der ABAP-Interpreter erkennt auch Gruppenwechsel in den hinteren Feldern automatisch! Bei einer Tabelle mit FELD1, FELD2, FELD3 können Sie getrost ein
AT NEW feld3.
programmieren, ohne auf die vorderen Felder einzugehen. Selbst Wenn FELD3 gleich bleibt, sich aber FELD 2 ändert, wird der Gruppenwechsel erkannt.
Code: Alles auswählen.
CONCATENATE 'Belegnummer = '
<lf_cogi_daten>-weblnr_key
INTO gs_doc_content-line SEPARATED BY space.
Code: Alles auswählen.
CONCATENATE 'Belegnummer = '
<lf_cogi_daten>-weblnr_key
INTO gs_doc_content-line SEPARATED BY space.
Code: Alles auswählen.
*&---------------------------------------------------------------------*
*& Report Z_COGI_EMAIL
*&
*&---------------------------------------------------------------------*
*& 19.02.2019
*&
*&---------------------------------------------------------------------*
REPORT z_cogi_email_kopie.
**********************************************************************
* Datendeklaration aus der ZTABELLE ZCOGIEMAIL und AFFW
**********************************************************************
* Data für Email-Versand
DATA gt_doc_content TYPE TABLE OF solisti1.
DATA gs_doc_content TYPE solisti1.
DATA gt_receivers TYPE TABLE OF somlreci1.
DATA gs_receivers TYPE somlreci1.
DATA gs_doc_data TYPE sodocchgi1.
DATA gv_entries TYPE sy-tabix.
DATA lt_cogi_mail TYPE TABLE OF zcogiemail.
DATA ls_cogi_mail TYPE zcogiemail.
* Data AFFW
DATA lt_cogi_daten TYPE zosc_t_cogi.
DATA ls_cogi_daten TYPE zosc_s_cogi.
* Data Messagetype
DATA lv_message TYPE solisti1.
* Data Range Table
*DATA zosc_rt_cogi_mail TYPE RANGE OF arbgb.
*DATA zosc_rs_cogi_mail like LINE OF zosc_rt_cogi_mail.
**********************************************************************
* Start of Selection
**********************************************************************
* Select zcogiemal
SELECT * FROM zcogiemail
INTO CORRESPONDING FIELDS OF TABLE lt_cogi_mail.
* Select auf AFFW
SELECT * FROM affw
INTO CORRESPONDING FIELDS OF TABLE lt_cogi_daten.
* Range Table
* DATA lv_msgid type zosc_s_cogi-msgid_key.
*zosc_rs_cogi_mail-sign = 'I'.
*zosc_rs_cogi_mail-option = 'BT'.
*zosc_rs_cogi_mail-low = 'M7'.
*zosc_rs_cogi_mail-high = 'M7'.
*APPEND zosc_rs_cogi_mail to zosc_rt_cogi_mail.
**********************************************************************
* Verarbeitung der Daten ZCOGIEMAIL und AFFW auf Key MSGNO
**********************************************************************
* Verarbeitung AFFW
LOOP AT lt_cogi_daten ASSIGNING FIELD-SYMBOL(<lf_cogi_daten>).
<lf_cogi_daten>-msgid_key = <lf_cogi_daten>-msgid.
<lf_cogi_daten>-msgno_key = <lf_cogi_daten>-msgno.
<lf_cogi_daten>-msgty_key = <lf_cogi_daten>-msgty.
<lf_cogi_daten>-msgv1_key = <lf_cogi_daten>-msgv1.
<lf_cogi_daten>-msgv2_key = <lf_cogi_daten>-msgv2.
<lf_cogi_daten>-msgv3_key = <lf_cogi_daten>-msgv3.
<lf_cogi_daten>-msgv4_key = <lf_cogi_daten>-msgv4.
<lf_cogi_daten>-weblnr_key = <lf_cogi_daten>-weblnr.
ENDLOOP.
SORT lt_cogi_daten.
**********************************************************************
* Start Arbeitsbereich Email-verarbeitung
**********************************************************************
* Verarbeitung Receiver von ZCOGIEMAIL
LOOP AT lt_cogi_daten ASSIGNING <lf_cogi_daten>.
AT NEW msgno_key.
* Verarbeitung Receiver von ZCOGIEMAIL
READ TABLE lt_cogi_mail
WITH KEY msgno = <lf_cogi_daten>-msgno
msgid = <lf_cogi_daten>-msgid
INTO ls_cogi_mail.
MOVE-CORRESPONDING ls_cogi_mail TO gs_receivers.
APPEND gs_receivers TO gt_receivers.
CLEAR gt_doc_content []. <---Eckige Klammer wird hier im Forum leider nicht so ausgegeben.
ENDAT.
**********************************************************************
* Email Body (Ausgabe Inhalt der Meldung in der Email
**********************************************************************
CONCATENATE 'Belegnummer = '
<lf_cogi_daten>-weblnr_key
INTO gs_doc_content-line SEPARATED BY space.
APPEND gs_doc_content TO gt_doc_content.
CLEAR gs_doc_content.
**********************************************************************
* Message behandlung
**********************************************************************
MESSAGE ID <lf_cogi_daten>-msgid_key TYPE <lf_cogi_daten>-msgty_key NUMBER <lf_cogi_daten>-msgno_key
WITH <lf_cogi_daten>-msgv1_key <lf_cogi_daten>-msgv2_key <lf_cogi_daten>-msgv3_key <lf_cogi_daten>-msgv4_key
INTO lv_message.
CONCATENATE ' ' lv_message into
gs_doc_content-line SEPARATED BY space.
append gs_doc_content to gt_doc_content.
**********************************************************************
* Email Header
**********************************************************************
gs_doc_data-obj_descr = 'Fehler bei der Transaktion COGI'.
gs_doc_data-sensitivty = 'O'.
AT END OF msgno_key.
**********************************************************************
* Email verarbeiten
DESCRIBE TABLE gt_doc_content LINES gv_entries.
READ TABLE gt_doc_content INTO gs_doc_content INDEX gv_entries.
gs_doc_data-doc_size = ( gv_entries - 1 ) * 255 + strlen( gs_doc_content ).
**********************************************************************
* Ende Arbeitsbereich Email-verarbeitung
**********************************************************************
* Funktionsbaustein SO_NEW_DOCUMENT_SEND_API1
**********************************************************************
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = gs_doc_data
DOCUMENT_TYPE = 'RAW'
* PUT_IN_OUTBOX = ' '
commit_work = 'X'
* IP_ENCRYPT =
* IP_SIGN =
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
TABLES
* OBJECT_HEADER =
object_content = gt_doc_content
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
receivers = gt_receivers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
* Implement suitable error handling here
IF sy-subrc <> 0.
ENDIF.
REFRESH gt_receivers.
ENDAT.
ENDLOOP.
Code: Alles auswählen.
*&---------------------------------------------------------------------*
*& Report Z_COGI_EMAIL
*& Björn Heidke
*&---------------------------------------------------------------------*
*& 19.02.2019
*&
*&---------------------------------------------------------------------*
REPORT z_cogi_email_kopie.
**********************************************************************
* Datendeklaration aus der ZTABELLE ZCOGIEMAIL und AFFW
**********************************************************************
* Data für Email-Versand
DATA gt_doc_content TYPE TABLE OF solisti1.
DATA gs_doc_content TYPE solisti1.
DATA gt_receivers TYPE TABLE OF somlreci1.
DATA gs_receivers TYPE somlreci1.
DATA gs_doc_data TYPE sodocchgi1.
DATA gv_entries TYPE sy-tabix.
DATA lt_cogi_mail TYPE TABLE OF zcogiemail.
DATA ls_cogi_mail TYPE zcogiemail.
* Data AFFW
DATA lt_cogi_daten TYPE zosc_t_cogi.
DATA ls_cogi_daten TYPE zosc_s_cogi.
* Datendeklaration Messagetype
DATA lv_message TYPE solisti1.
**********************************************************************
* Start of Selection
**********************************************************************
* Select zcogiemal
SELECT * FROM zcogiemail
INTO CORRESPONDING FIELDS OF TABLE lt_cogi_mail.
* Select auf AFFW
SELECT * FROM affw
INTO CORRESPONDING FIELDS OF TABLE lt_cogi_daten.
**********************************************************************
* Verarbeitung der Daten ZCOGIEMAIL und AFFW auf Key MSGNO
**********************************************************************
* Verarbeitung AFFW
LOOP AT lt_cogi_daten ASSIGNING FIELD-SYMBOL(<lf_cogi_daten>).
<lf_cogi_daten>-msgid_key = <lf_cogi_daten>-msgid.
<lf_cogi_daten>-msgno_key = <lf_cogi_daten>-msgno.
<lf_cogi_daten>-msgty_key = <lf_cogi_daten>-msgty.
<lf_cogi_daten>-msgv1_key = <lf_cogi_daten>-msgv1.
<lf_cogi_daten>-msgv2_key = <lf_cogi_daten>-msgv2.
<lf_cogi_daten>-msgv3_key = <lf_cogi_daten>-msgv3.
<lf_cogi_daten>-msgv4_key = <lf_cogi_daten>-msgv4.
<lf_cogi_daten>-weblnr_key = <lf_cogi_daten>-weblnr.
ENDLOOP.
SORT lt_cogi_daten.
**********************************************************************
* Start Arbeitsbereich Email-verarbeitung
**********************************************************************
* Verarbeitung Receiver von ZCOGIEMAIL
LOOP AT lt_cogi_daten ASSIGNING <lf_cogi_daten>.
AT NEW msgno_key.
* Verarbeitung Receiver von ZCOGIEMAIL
READ TABLE lt_cogi_mail
WITH KEY msgno = <lf_cogi_daten>-msgno
msgid = <lf_cogi_daten>-msgid
INTO ls_cogi_mail.
MOVE-CORRESPONDING ls_cogi_mail TO gs_receivers.
APPEND gs_receivers TO gt_receivers.
CLEAR gt_doc_content[].
ENDAT.
**********************************************************************
* Email Body (Ausgabe Inhalt der Meldung in der Email
**********************************************************************
CONCATENATE
'Belegnummer:' <lf_cogi_daten>-weblnr_key
INTO gs_doc_content-line SEPARATED BY CL_ABAP_CHAR_UTILITIES=>newline.
APPEND gs_doc_content TO gt_doc_content.
CLEAR gs_doc_content.
**********************************************************************
* Message behandlung
**********************************************************************
MESSAGE ID <lf_cogi_daten>-msgid_key TYPE <lf_cogi_daten>-msgty_key NUMBER <lf_cogi_daten>-msgno_key
WITH <lf_cogi_daten>-msgv1_key
<lf_cogi_daten>-msgv2_key
<lf_cogi_daten>-msgv3_key
<lf_cogi_daten>-msgv4_key
INTO lv_message.
CONCATENATE 'Meldung:' lv_message INTO
gs_doc_content-line SEPARATED BY cl_abap_char_utilities=>newline.
APPEND gs_doc_content TO gt_doc_content.
**********************************************************************
* Email Header
**********************************************************************
gs_doc_data-obj_descr = 'Fehler bei der Transaktion COGI'.
gs_doc_data-sensitivty = 'O'.
AT END OF msgno_key.
**********************************************************************
* Aufbereitung Email
DESCRIBE TABLE gt_doc_content LINES gv_entries.
READ TABLE gt_doc_content INTO gs_doc_content INDEX gv_entries.
gs_doc_data-doc_size = ( gv_entries - 1 ) * 255 + strlen( gs_doc_content ).
**********************************************************************
* Ende Arbeitsbereich Email-verarbeitung
**********************************************************************
* Funktionsbaustein SO_NEW_DOCUMENT_SEND_API1
**********************************************************************
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = gs_doc_data
* DOCUMENT_TYPE = 'RAW'
* PUT_IN_OUTBOX = ' '
commit_work = 'X'
* IP_ENCRYPT =
* IP_SIGN =
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
TABLES
* OBJECT_HEADER =
object_content = gt_doc_content
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
receivers = gt_receivers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
REFRESH gt_receivers.
ENDAT.
ENDLOOP.
Code: Alles auswählen.
* Verarbeitung Receiver von ZCOGIEMAIL
READ TABLE lt_cogi_mail
WITH KEY msgno = <lf_cogi_daten>-msgno
msgid = <lf_cogi_daten>-msgid
INTO ls_cogi_mail.
Code: Alles auswählen.
ASSIGN lt_cogi_mail{ msgno = <lf_cogi_daten>-msgno
msgid = <lf_cogi_daten>-msgid } TO FIELD-SYMBOL(<lf_cogi_mail>).
Code: Alles auswählen.
MSGID|MSGNO|Email|REC_TYPE