Posteingang mit Standardbausteinen lesen

Lesen des Posteingangs mit Standardbausteinen. Hier sind Sie auf der sicheren Seite, wenn es um die Aufbereitung der Meldungen geht. Auch Berechtigungen und Vertreter-Einstellungen werden hier überprüft.

REPORT zz_posteingang_lesen.
*** —————————————————————-
*** Lesen Posteingang mit Standardfunktionsbausteinen und
*** dementsprechend auch mit Berechtigungsprüfung…
*** —————————————————————-

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,

  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
  CALL FUNCTION ‘SO_DOCUMENTS_MANAGER’
       EXPORTING
            activity    = ‘READ’
            office_user = p_uname
       TABLES
            documents   = t_docs.

  LOOP AT t_docs.

    l_object_id-objtp = t_docs-foltp.
    l_object_id-objyr = t_docs-folyr.
    l_object_id-objno = t_docs-folno.

*– Mappeninformation lesen
    CALL FUNCTION ‘SO_FOLDER_READ’
         EXPORTING
              object_id                  = l_object_id
              owner                      = p_uname
         TABLES
              folder_cont                = t_folder_cont
         EXCEPTIONS
              active_user_not_exist      = 1
              communication_failure      = 2
              component_not_available    = 3
              folder_not_exist           = 4
              operation_no_authorization = 5
              owner_not_exist            = 6
              substitute_not_active      = 7
              substitute_not_defined     = 8
              system_failure             = 9
              x_error                    = 10
              OTHERS                     = 11.
    IF sy-subrc <> 0.
*– Fehler beim Lesen der Mappe
      WRITE: / ‘Fehler’, l_object_id-objtp,
                         l_object_id-objyr,
                         l_object_id-objno.

    ELSE.
*– Inhalt der Mappe “Posteingang”
      LOOP AT t_folder_cont.

*– Dokumentinformation ausgeben
        FORMAT COLOR COL_TOTAL.
        WRITE: / t_folder_cont-docnam,
                 t_folder_cont-docdes.
        FORMAT COLOR OFF.

*– Lesen des Inhalts vorbereiten
        l_docs-foltp = t_folder_cont-foltp.
        l_docs-folyr = t_folder_cont-folyr.
        l_docs-folno = t_folder_cont-folno.
        l_docs-objtp = t_folder_cont-doctp.
        l_docs-objyr = t_folder_cont-docyr.
        l_docs-objno = t_folder_cont-docno.

*– Inhalt des Dokuments lesen
        CALL FUNCTION ‘SO_DOCUMENT_REPOSITORY_MANAGER’
             EXPORTING
                  method   = ‘GETCONTENT’
             TABLES
                  objcont  = t_object_cont
                  objhead  = t_object_head
             CHANGING
                  document = l_docs.
*– Inhalt ausgeben
        LOOP AT t_object_cont.
          DO.
*– CarriageReturn + LineFeed 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.
*– Textzeilen ausgeben
            WRITE: /3 t_test-line.
          ENDLOOP.
        ENDLOOP.

      ENDLOOP.
    ENDIF.

  ENDLOOP.

Enno Wulff
Letzte Artikel von Enno Wulff (Alle anzeigen)