[ABAP] Verarbeitungsprotokoll zu Nachrichten lesen (NAST, CMFK, CMFP)

* https://www.berater-wiki.de/Access_Tabellenbeziehung_Fehlerprotokoll

DATA: lv_kappl TYPE nast-kappl.
DATA: lv_objky TYPE nast-objky.
DATA: lv_kschl TYPE nast-kschl.
DATA: lv_erdat TYPE nast-erdat.
DATA: lv_eruhr TYPE nast-eruhr.
DATA: lv_usnam TYPE nast-usnam.

SELECT-OPTIONS: so_kappl FOR lv_kappl.
SELECT-OPTIONS: so_objky FOR lv_objky.
SELECT-OPTIONS: so_kschl FOR lv_kschl.
SELECT-OPTIONS: so_erdat FOR lv_erdat.
SELECT-OPTIONS: so_eruhr FOR lv_eruhr.
SELECT-OPTIONS: so_usnam FOR lv_usnam.

INITIALIZATION.

* Applikation für Nachrichtenkonditionen ('EF' = Bestellungen)
  so_kappl[] = VALUE #( ( sign = 'I' option = 'EQ' low = 'EF' high = '' ) ).
* Nachrichtenart
  so_kschl[] = VALUE #( ( sign = 'I' option = 'EQ' low = 'NEU' high = '' ) ).

START-OF-SELECTION.

* NAST (Nachrichtenstatus)
* CMFK (Speicherstruktur für den Kopf des Fehlerprotokolls)
* CMFP (Speicherstruktur für die gesammelten Fehler)
  SELECT FROM nast AS na
         LEFT OUTER JOIN cmfk AS ck ON na~cmfpnr = ck~nr
         LEFT OUTER JOIN cmfp AS cp ON na~cmfpnr = cp~nr
         FIELDS na~kappl,
                na~objky,
                na~kschl,
                na~parnr,
                na~erdat,
                na~eruhr,
                na~nacha,
                na~vsztp,
                na~usnam,
                na~tcode,
                na~ldest,
                na~tdreceiver,
                na~tdcovtitle,
                na~tdarmod,
                na~objtype,
                na~cmfpnr,
                ck~aplid,
                ck~nr,
                ck~datum,
                ck~uzeit,
                ck~uname,
                ck~objid,
                cp~msgcnt,
                cp~arbgb,
                cp~msgty,
                cp~msgnr,
                cp~msgv1,
                cp~msgv2,
                cp~msgv3,
                cp~msgv4,
                cp~logsys
         WHERE na~kappl IN @so_kappl
           AND na~objky IN @so_objky
           AND na~kschl IN @so_kschl
           AND na~erdat IN @so_erdat
           AND na~eruhr IN @so_eruhr
           AND na~usnam IN @so_usnam
         INTO TABLE @DATA(it_nast).

  IF sy-subrc = 0.
    cl_demo_output=>write_data( it_nast ).
* HTML-Code vom Demo-Output holen
    DATA(lv_html) = cl_demo_output=>get( ).
* Daten im Inline-Browser im SAP-Fenster anzeigen
    cl_abap_browser=>show_html( EXPORTING
                                  title        = 'Verarbeitungsprotokoll Nachrichten'
                                  html_string  = lv_html
                                  container    = cl_gui_container=>default_screen ).

* cl_gui_container=>default_screen erzwingen
    WRITE: space.
  ENDIF.