Posteingang über Tabellen lesen

Lesen des SAP-Office „Posteingangs“ über Tabellen. Je vielfältiger die Meldungen im Posteingang sind, desto aufwendiger wird zwar die Programmierung, aber um einfache Textnachrichten auszulesen — und die Berechtigungsprüfung zu umgehen!!! — reicht das Programm aus.

REPORT zposteingang.
*** —————————————————————-
*** Lesen Posteingang über Tabellen
*** Keine Berechtigungsprüfung!!!!!
*** —————————————————————-

TYPE-POOLS icon.

DATA:

  hex_0d        TYPE x VALUE ‚0D‘,
  hex_0a        TYPE x VALUE ‚0A‘,
  hex_return(2) TYPE x VALUE ‚0D0A‘,

  BEGIN OF t_test OCCURS 0,
    line(255),
  END OF t_test,

  l_souc        LIKE souc,
  l_soud        LIKE soud,
  l_sood        LIKE sood,
  t_sofm        LIKE sofm OCCURS 0 WITH HEADER LINE,

  t_docs        LIKE sood4 OCCURS 0 WITH HEADER LINE,
  l_docs        LIKE sood4,

  t_folder_cont LIKE somt  OCCURS 0 WITH HEADER LINE,
  t_object_cont LIKE soli  OCCURS 0 WITH HEADER LINE,
  t_object_head LIKE soli  OCCURS 0 WITH HEADER LINE,
  t_object_para LIKE selc  OCCURS 0 WITH HEADER LINE,
  t_object_parb LIKE soop1 OCCURS 0 WITH HEADER LINE,
  l_object_id   LIKE soodk.

PARAMETERS: p_uname TYPE xubname DEFAULT sy-uname.

START-OF-SELECTION.

*– Benutzerinformation lesen
  SELECT SINGLE * FROM souc INTO l_souc WHERE sapnam = p_uname.

*– Mappen-Information des Benutzers lesen
  SELECT SINGLE * FROM soud INTO l_soud
   WHERE usrtp = l_souc-usrtp
     AND usryr = l_souc-usryr
     AND usrno = l_souc-usrno.

*– Posteingangsmappe zur weiteren Verarbeitung auswählen
  l_object_id-objtp = ‚FOL‘.
  l_object_id-objyr = l_soud-inbyr.
  l_object_id-objno = l_soud-inbno.

*– Alle Inhalte dieser Mappe lesen
  SELECT * FROM sofm INTO TABLE t_sofm
   WHERE foltp = ‚FOL‘
     AND folyr = l_soud-inbyr
     AND folno = l_soud-inbno.

  LOOP AT t_sofm.
*– Header-Information zu dieser Mappe lesen
    SELECT SINGLE * FROM sood INTO l_sood
     WHERE objtp = t_sofm-doctp
       AND objyr = t_sofm-docyr
       AND objno = t_sofm-docno.

*– Überschrift ausgeben
    FORMAT COLOR COL_TOTAL.
    WRITE: / l_sood-objnam, l_sood-objdes.
*– Status
    CASE t_sofm-objrd.
      WHEN ‚X‘.
*– Dokument wurde gelesen
        WRITE icon_mail_sap_read AS ICON.
      WHEN space.
*– Dokument wurde noch nicht gelesen
        WRITE icon_mail_sap_unread AS ICON.
    ENDCASE.
    FORMAT COLOR OFF.

    MOVE-CORRESPONDING t_sofm TO l_docs.
    MOVE-CORRESPONDING l_sood TO l_docs.

    l_object_id-objtp = t_sofm-doctp.
    l_object_id-objyr = t_sofm-docyr.
    l_object_id-objno = t_sofm-docno.

*– Dokumenteninhalt lesen (Ohne Berechtigungsprüfung)
    PERFORM data_select(sapfsso1) TABLES t_object_head
                                         t_object_cont
                                         t_object_para
                                         t_object_parb
                                   USING l_object_id
                                         sy-subrc.
*– Dokument ausgeben
    LOOP AT t_object_cont.
      DO.
*– CarriageReturn + NewLine herausfiltern
        REPLACE hex_return WITH ‚~‘ INTO t_object_cont-line.
        IF sy-subrc > 0.
          EXIT.
        ENDIF.
      ENDDO.
*– Zeilenumbruch
      SPLIT t_object_cont-line AT ‚~‘ INTO TABLE t_test.
      LOOP AT t_test.
        WRITE: /4 t_test-line.
      ENDLOOP.
    ENDLOOP.
    SKIP 1.

  ENDLOOP.

 

Enno Wulff
follow me