Vorlage für Interaktive Liste

Dies ist Teil 3 von 11 der Serie Interaktive Liste

Hier steht im Prinzip das selbe Coding noch einmal. Allerdings haben wir alle spezifischen Funktionen herausgenommen und nur die in den meisten Reports nötigen Programmblöcke stehen gelassen. Sie können dieses Programm als einfache Vorlage für einen Interaktive Liste nehmen.

REPORT z_vorlage_interaktive_liste NO STANDARD PAGE HEADING
LINE-SIZE 132
LINE-COUNT 65.

***********************************************************************
***                                                                 ***
***                                                                 ***
***                  https://tricktresor.com                      ***
***                                                                 ***
***                                                                 ***
***********************************************************************

*---------------------------------------------------------------------*
*
* Programm:       [ ]
* Autor:          [ ]
* Datum:          [ ]
* Sinn und Zweck:
* ...
*---------------------------------------------------------------------*

TYPE-POOLS: icon.

*---------------------------------------------------------------------*
* Konstanten
*---------------------------------------------------------------------*

CONSTANTS:
  k_icon_status_a(4) VALUE icon_led_green,
  k_icon_status_b(4) VALUE icon_led_red,
  off                TYPE i         VALUE 0,
  on                 TYPE i         VALUE 1.

DATA:
  k_info_status_a(30),
  k_info_status_b(30).

*---------------------------------------------------------------------*
* Variablen
*---------------------------------------------------------------------*

DATA:
  t_head          TYPE STANDARD TABLE OF vbak,
  s_head          LIKE LINE OF t_head,

  t_item          TYPE STANDARD TABLE OF vbap,
  s_item          LIKE LINE OF t_item,

  l_status(4),                                              "Liststatus
  l_quickinfo(30),            "Infotext für das Icon
  l_hotspot,                  "Hotspot an/aus
  l_popup_aktiv,              "Popup aktiv ja/nein
  l_actual_line   TYPE systaro. "Aktuelle Zeile (für Refresh)

*---------------------------------------------------------------------*
* Selektionsbild
*---------------------------------------------------------------------*

SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE TEXT-t01.
SELECT-OPTIONS: s_vbeln FOR s_head-vbeln.
SELECT-OPTIONS: s_erdat FOR s_head-erdat.
*PARAMETERS:     ...
SELECTION-SCREEN END   OF BLOCK 1.

*---------------------------------------------------------------------*
* Init
*---------------------------------------------------------------------*

INITIALIZATION.
  k_info_status_a = 'Beschreibung Status "A"'(q0a).
  k_info_status_b = 'BEschreibung Status "B"'(q0b).

*---------------------------------------------------------------------*
* Programmstart
*---------------------------------------------------------------------*

START-OF-SELECTION.

  PERFORM selektion.
  PERFORM listausgabe.

*---------------------------------------------------------------------*
* User-Command
*---------------------------------------------------------------------*

AT USER-COMMAND.

  l_actual_line = sy-staro.

  CASE sy-ucomm.
    WHEN 'REFR'.
      PERFORM selektion.
      PERFORM listausgabe.
    WHEN 'LEGENDE'.
      PERFORM legende.
  ENDCASE.

*---------------------------------------------------------------------*
* Doppelklick
*---------------------------------------------------------------------*

AT LINE-SELECTION.
  CASE sy-lsind.
    WHEN 1.
      PERFORM detail_1.
    WHEN 2.
      PERFORM detail_2.
  ENDCASE.

*---------------------------------------------------------------------*
* Seitenkopf / Listüberschrift
*---------------------------------------------------------------------*

TOP-OF-PAGE.

  PERFORM top_of_page.

TOP-OF-PAGE DURING LINE-SELECTION.

  PERFORM top_of_page.

*---------------------------------------------------------------------*
*       FORM selektion                                                *
*---------------------------------------------------------------------*
FORM selektion.

  SELECT * FROM vbak
    INTO TABLE @t_head
   WHERE vbeln IN @s_vbeln
     AND erdat IN @s_erdat
    ORDER BY vbeln.

  IF sy-subrc = 0.
    SELECT * FROM vbap
      INTO TABLE @t_item
    FOR ALL ENTRIES IN @t_head
    WHERE vbeln = @t_head-vbeln
      ORDER BY PRIMARY KEY.
  ENDIF.

ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  listausgabe
*&---------------------------------------------------------------------*
FORM listausgabe.

*** Verzweigungslistenzähler muss auf Null gesetzt werden, damit nicht
*** beim Aktualisieren eine neue Verzweigungsliste erzeugt wird.
  sy-lsind = 0.

**** Liststatus setzen (falls eigener Status gewünscht [Bspw. "Legende"])
*  SET PF-STATUS 'LISTE'.

*** Ausgabe der Tabelle
  LOOP AT t_head INTO s_head.
    READ TABLE t_item INTO s_item WITH KEY vbeln = s_head-vbeln BINARY SEARCH.
    IF sy-subrc = 0.
      l_status    = k_icon_status_a.
      l_quickinfo = k_info_status_a.
      l_hotspot   = on.
    ELSE.
      l_status    = k_icon_status_b.
      l_quickinfo = k_info_status_b.
      l_hotspot   = off.
    ENDIF.

    WRITE: / l_status AS ICON QUICKINFO l_quickinfo HOTSPOT = l_hotspot,
      s_head-vbeln,
      s_head-auart,
      s_head-erdat.
    HIDE s_head.

  ENDLOOP.

  CLEAR s_head.

*** Liste bei Neuaufbau wieder positionieren
  SCROLL LIST TO FIRST PAGE LINE l_actual_line INDEX 1.

ENDFORM.                    " listausgabe

*---------------------------------------------------------------------*
*       FORM detail_1                                                 *
*---------------------------------------------------------------------*
FORM detail_1.

  CHECK NOT s_head IS INITIAL.
  LOOP AT t_item INTO s_item WHERE vbeln = s_head-vbeln.
    WRITE: /
      s_item-posnr,
      s_item-matnr,
      s_item-arktx,
      s_item-kwmeng UNIT s_item-vrkme,
      s_item-vrkme.
    HIDE s_item.
  ENDLOOP.
  CLEAR: s_head, s_item.

ENDFORM.

*---------------------------------------------------------------------*
*       FORM detail_2                                                 *
*---------------------------------------------------------------------*
FORM detail_2.

  CHECK NOT s_item IS INITIAL.

  WRITE: / 'ITEM DETAIL' COLOR COL_TOTAL.
  WRITE:
    / 'item number', AT 20 s_item-posnr,
    / 'material', AT 20 s_item-matnr,
    / 'description', AT 20 s_item-arktx,
    / 'quantity', AT 20 s_item-kwmeng UNIT s_item-vrkme, s_item-vrkme.
  IF s_item-abgru IS NOT INITIAL.
    FORMAT COLOR COL_NEGATIVE.
    WRITE: / 'item rejected:', s_item-abgru.
    FORMAT COLOR OFF.
  ENDIF.

ENDFORM.

*---------------------------------------------------------------------*
*       FORM top_of_page_header                                       *
*---------------------------------------------------------------------*
FORM top_of_page_header.

  WRITE: / 'HEADER', AT sy-linsz space.

ENDFORM.

*---------------------------------------------------------------------*
*       FORM top_of_page_detail_1                                     *
*---------------------------------------------------------------------*
FORM top_of_page_detail_1.

  WRITE: / 'Positionsdetail', AT sy-linsz space.

ENDFORM.

*---------------------------------------------------------------------*
*       FORM top_of_page_detail_2                                     *
*---------------------------------------------------------------------*
FORM top_of_page_detail_2.

  WRITE: / 'Detail 2', AT sy-linsz space.

ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  top_of_page
*&---------------------------------------------------------------------*
FORM top_of_page.

  CHECK l_popup_aktiv = space.
  ULINE.
  FORMAT COLOR COL_HEADING INTENSIFIED ON.

  CASE sy-lsind.
    WHEN 0.
      PERFORM top_of_page_header.
    WHEN 1.
      PERFORM top_of_page_detail_1.
    WHEN 2.
      PERFORM top_of_page_detail_2.
  ENDCASE.

  FORMAT COLOR OFF         INTENSIFIED OFF.
  ULINE.

ENDFORM.                    " top_of_page

*---------------------------------------------------------------------*
*       FORM legende                                                  *
*---------------------------------------------------------------------*
* Nur mit eigenem LIST Status
*---------------------------------------------------------------------*
FORM legende.

  DATA:
    l_popup_breite TYPE i VALUE 70,
    l_popup_hoehe  TYPE i VALUE 10,
    l_popup_x1     TYPE i VALUE 10,
    l_popup_x2     TYPE i,
    l_popup_y1     TYPE i VALUE 10,
    l_popup_y2     TYPE i.

  l_popup_x2 = l_popup_x1 + l_popup_breite.
  l_popup_y2 = l_popup_y1 + l_popup_hoehe.

  SET PF-STATUS space.
  SET TITLEBAR 'LEGENDE'.
  l_popup_aktiv = 'X'.

  WINDOW STARTING AT l_popup_x1 l_popup_y1
           ENDING AT l_popup_x2 l_popup_y2.
  NEW-PAGE LINE-SIZE l_popup_breite LINE-COUNT 0.
  WRITE AT /1(l_popup_breite) sy-uline.
  WRITE: / '|', 'Legende', AT l_popup_breite '|'.
  WRITE AT /1(l_popup_breite) sy-uline.
  WRITE: AT /2 k_icon_status_a AS ICON, k_info_status_a,
  AT /2 k_icon_status_b AS ICON, k_info_status_b.
  l_popup_aktiv = space.

ENDFORM.
Enno Wulff
Series Navigation<< Generelle TippsDatendefinition >>