Report Anzeigen Smart Forms Texte und Textbausteine aus Tabelle STXFTXT

Aus SAP-Wiki
Zur Navigation springenZur Suche springen

Siehe Textbausteine

Siehe Tabelle STXFTXT Textbausteininhalt

Siehe Kategorie:Übersetzung.

Mit diesem Report lassen sich Smart Forms-Textbausteine und Texte aus Smart Forms-Formularen anzeigen.

Beide stehen in der SAP-Tabelle STXFTXT.

Mit Objektname = %TEXT1 werden Smart Forms Textbausteine selektiert. Alle anderen Objektnamen selektieren Texte aus dem Smart Forms-Formular. ´

Smart Forms Texte

ALV-Report Selektionsbildschirm

SmartFormsTexte1.jpg


ALV-Report Ergebnisliste

SmartFormsTexte2.jpg

Smart Forms Textbaustein

ALV-Report Selektionsbildschirm

STXFTXT1.jpg

ALV-Report Ergebnisliste

Die Textbausteine /SMBA0/AA_FOOTER existiert hier in den Sprache DE und EN und hat jeweils 6 Zeilen und meist das Zeilenformat N2.

STXFTXT2.jpg


Anzeige Textbaustein in Transaktion SMARTFORMS

Aus ALV-Anzeige kann man per Doppelklick in den Smart Forms-Textbaustein oder in das Smart Forms-Formular springen per Batch-Input (Transaktion = SMARTFORMS).

Die Textbausteine und Formulare werden allerdings hier immer in der Anmeldesprache angezeigt, da dies per Default genommen wird in der Transaktion SMARTFORMS.

STXFTXT3.jpg

ALV-Report Coding

*&---------------------------------------------------------------------*
*& Report  ZREBSMARTFORMS
*& Autor = René Eberstein, Eberstein Consulting
*&---------------------------------------------------------------------*
*& Durchsuchen und Darstellung von Smart Forms Texten in Formularen
*& und Smart Forms Textbausteine
*&---------------------------------------------------------------------*

REPORT  ZREBSMARTFORMS.

****************
* DATA & TYPES *
****************
Types: begin of ty_itab,
       spras    type STXFTXT-spras,
       txtype   type STXFTXT-txtype,
       formname type STXFTXT-formname,
       iname    type STXFTXT-iname,
       linenr   type STXFTXT-linenr,
       tdformat type STXFTXT-tdformat,
       tdline   type STXFTXT-tdline,
       color    Type LVC_CIFNM,
       end of ty_itab.

Types: tty_itab type standard table of ty_itab.

Data: gt_itab type Standard table of ty_itab.

Constants: true  type xfeld value 'X',
           false type xfeld value space.

Tables: stxftxt.

*************
* PARAMETER *
*************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001. "Selektion
select-options: s_spras  for  stxftxt-spras    default sy-langu,
                s_form   for  STXFTXT-formname default '/SMBA0/AA_FOOTER',
                s_iname  for  STXFTXT-iname default '%TEXT1',
                s_tdline for  STXFTXT-tdline.
SELECTION-SCREEN END OF BLOCK b1.


***********************
* AT SELECTION-SCREEN *
***********************
at selection-screen.

**********************
* START-OF-SELECTION *
**********************
start-of-selection.

  perform select_data
    changing gt_itab.

  perform set_color_line
    changing gt_itab.

************************
* Aufruf der ALV-Liste *
************************
  perform alv_itab
      using gt_itab.


**&---------------------------------------------------------------------
**& Form alv_itab
*&---------------------------------------------------------------------
* ALV Function Mod. 'REUSE_ALV_GRID_DISPLAY_LVC'
*----------------------------------------------------------------------
FORM alv_itab
     using it_itab type tty_itab.

  type-pools: slis.

  data: l_repid    type sy-repid,
        lt_fcat    type LVC_T_FCAT,
        ls_layout  type LVC_S_LAYO,
*       ls_sort    type LVC_S_SORT,
*       lt_sort    type LVC_T_SORT,
        lt_events  type slis_t_event.

  l_repid = sy-repid.

***************
* Fill Layout *
***************

* ls_layout-zebra      = 'X'.        "Liste wird im Zebra-Look ausgegeben
* LS_LAYOUT-BOX_FNAME  = 'SELKZ'.    "Zeilen der Liste können markiert werden mit Spalte SELKZ
* ls_layout-no_toolbar = 'X'.        "Keine Toolbar
* ls_layout-EXCP_FNAME = 'AMPEL'.    "'1'=rot, '2'=gelb, '3'=grün
* ls_layout-TOTALS_BEF = 'X'.        "Summen vor Einzelsätzen
  ls_layout-INFO_FNAME = 'COLOR'.
  LS_LAYOUT-CWIDTH_OPT = 'A'.        "Spaltenbreite wird optimiert

*************
* Fill Sort *
*************
*  CLEAR ls_sort.                    "Liste wird nach Feldern sortiert
*  ls_sort-fieldname = ' '.          "Identische Werte, die übereinander stehen, werden
*  ls_sort-spos      = '1'.          "verbunden und nur der oberste Wert wird angezeigt
*  ls_sort-up        = 'X'.
*  ls_sort-group     = 'UL'.
*  ls_sort-subtot    = 'X'.          "Zwischensummen
*  APPEND ls_sort TO lt_sort.

***************
* Fill Events *
***************
  perform alv_itab_events            "Definition Events und Form-Routinten für
    changing lt_events.              "User-Command, Top-Of-List und Status

*****************
* Fill Fieldcat *
*****************
  perform alv_itab_fcat              "Definition Felder, die ausgegeben werden sollen
    changing lt_fcat.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
    EXPORTING
      i_interface_check  = 'I'
      i_callback_program = l_repid
      is_layout_lvc      = ls_layout    "Layout ALV
      it_fieldcat_lvc    = lt_fcat      "Tabellen mit Feldern der Liste
                            "it_sort_lvc                = lt_sort      "Sortierung
      i_default          = 'X'          "Default Variante kann abgespeichert werden
      i_save             = 'A'          "Benutzerabhängige Varianten können gespeichert werden
      IT_EVENTS          = lt_events    "Event-Tabelle
                            "i_screen_start_column      = 10
                            "i_screen_start_line        = 10
                            "i_screen_end_column        = 50
                            "i_screen_end_line          = 50
    TABLES
      t_outtab           = it_itab    "Daten Ausgabetabelle
    EXCEPTIONS
      program_error      = 1
      OTHERS             = 2.

  IF sy-subrc <> 0.
    message i531(0u) with 'Problem beim Fuba REUSE_ALV_GRID_DISPLAY_LVC'.
  ENDIF.

ENDFORM. " alv_itab
*&---------------------------------------------------------------------*
*&      Form  pf_status_set
*&---------------------------------------------------------------------*
*       Kopie des Standardstatus STANDARD aus der Funktionsgruppe SALV
*----------------------------------------------------------------------*
form alv_itab_pf_status_set
    using rt_extab type slis_t_extab.                       "#EC CALLED

  set pf-status 'STATUS_ITAB' excluding rt_extab.
  set TITLEBAR 'TITLE_ITAB'.

endform.                    "pf_status_set
*&---------------------------------------------------------------------*
*&      Form  alv_itab_events
*&---------------------------------------------------------------------*
*       ALV-Events
*----------------------------------------------------------------------*
form alv_itab_events
   changing p_ct_events type SLIS_T_EVENT.

  Data: ls_events   type slis_alv_event.

  ls_events-name = 'USER_COMMAND'.
  ls_events-form = 'ALV_ITAB_USER_COMMAND'.
  append ls_events to p_ct_events.

  ls_events-name = 'TOP_OF_PAGE'.
  ls_events-form = 'ALV_ITAB_TOP_OF_PAGE'.
  append ls_events to p_ct_events.

*ls_events-name = 'PF_STATUS_SET'.
*ls_events-form = 'ALV_ITAB_PF_STATUS_SET'.
*append ls_events to p_ct_events.

endform.                    " alv_itab_events
*&---------------------------------------------------------------------*
*&      Form  alv_itab_fcat
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form alv_itab_fcat
  changing ct_fcat type LVC_T_FCAT.

  data: ls_fcat type LVC_S_FCAT.

* Field = Sprache
  ls_fcat-fieldname   = 'SPRAS'.
  ls_fcat-rollname    = 'SPRAS'.
  ls_fcat-key         = true.
  append ls_fcat to ct_fcat.
  clear ls_fcat.

* Field = Texttyp
  ls_fcat-fieldname   = 'TXTYPE'.
  ls_fcat-rollname    = 'TDTXTYPE'.
  ls_fcat-key         = true.
  append ls_fcat to ct_fcat.
  clear ls_fcat.

* Field = Textbaustein/Formular
  ls_fcat-fieldname   = 'FORMNAME'.
  ls_fcat-rollname    = 'TDSFNAME'.
  ls_fcat-key         = true.
  append ls_fcat to ct_fcat.
  clear ls_fcat.

* Field = Typ
  ls_fcat-fieldname   = 'INAME'.
  ls_fcat-rollname    = 'TDOBJNAME'.
  ls_fcat-key         = true.
  append ls_fcat to ct_fcat.
  clear ls_fcat.

* Field = Typ
  ls_fcat-fieldname   = 'LINENR'.
  ls_fcat-rollname    = 'TDLINNR'.
  ls_fcat-key         = true.
  append ls_fcat to ct_fcat.
  clear ls_fcat.

* Field = Formatspalte
  ls_fcat-fieldname   = 'TDFORMAT'.
  ls_fcat-rollname    = 'TDFORMAT'.
  ls_fcat-key         = false.
  append ls_fcat to ct_fcat.
  clear ls_fcat.

* Field = Textzeile
  ls_fcat-fieldname   = 'TDLINE'.
  ls_fcat-rollname    = 'TDLINE'.
  ls_fcat-reptext     = 'Zeile'.
  ls_fcat-seltext     = 'Zeile'.
  ls_fcat-key         = false.
  append ls_fcat to ct_fcat.
  clear ls_fcat.

** Field = Original Language
*ls_fcat-fieldname    = ' '.
*ls_fcat-rollname     = ' '.
*ls_fcat-reptext      = ' '.
*ls_fcat-seltext      = ' '.
*ls_fcat-outputlen    = 10.
*ls_fcat-emphasize    = 'C300'.  "zrebconstants=>cv_color_fcat_gelb
*ls_fcat-edit         = 'X'.
*ls_fcat-do_sum       = 'X'.
*APPEND ls_fcat TO lt_fcat.
*CLEAR ls_fcat.

endform.                    " alv_KNA1_fcat
*&---------------------------------------------------------------------
*& Form USER_COMMAND
*&---------------------------------------------------------------------
*  User Command
*----------------------------------------------------------------------
form alv_itab_user_command                                  "#EC CALLED
  using r_ucomm     type sy-ucomm
        rs_selfield type slis_selfield.

  Data: ls_itab type ty_itab.

  DATA: l_ref_alv TYPE REF TO cl_gui_alv_grid,
        l_valid   TYPE c.                                   "#EC NEEDED

* geänderte Daten holen
* Referenz auf ALV holen
  CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
    IMPORTING
      e_grid = l_ref_alv.

* Gibt die geänderte ITAB zurück
  CALL METHOD l_ref_alv->check_changed_data
    IMPORTING
      e_valid = l_valid.

* Prüfe ob ein Doppelklick auf eine Zeile erfolgte
  case r_ucomm.

    WHEN 'NEWLINE'.
      CALL METHOD l_ref_alv->APPEND_ROWS
        EXPORTING
          I_ROW_COUNT = 1.

    when '&IC1'.

*     Read line of clicked item
      read table gt_itab index rs_selfield-tabindex
      into ls_itab.

      DATA: ls_bdcdata  TYPE bdcdata,
            lt_bdcdata  TYPE TABLE OF bdcdata,
            lt_itab_msg TYPE TABLE OF bdcmsgcoll.           "#EC NEEDED

*     Einstiegsbildschirm aufrufen
      ls_bdcdata-program = 'SAPMSSFO'.
      ls_bdcdata-dynpro = '0100'.
      ls_bdcdata-dynbegin = 'X'.
      APPEND ls_bdcdata TO lt_bdcdata.
      CLEAR ls_bdcdata.

      case ls_itab-iname.
        when '%TEXT1'.

          "Bildschirm füllen
          ls_bdcdata-fnam = 'RB_SF'.
          ls_bdcdata-fval = space.
          APPEND ls_bdcdata TO lt_bdcdata.
          CLEAR ls_bdcdata.

          "Bildschirm füllen
          ls_bdcdata-fnam = 'RB_TX'.
          ls_bdcdata-fval = 'X'.
          APPEND ls_bdcdata TO lt_bdcdata.
          CLEAR ls_bdcdata.

          "OK-Code übergeben
          CLEAR ls_bdcdata.
          ls_bdcdata-fnam = 'BDC_OKCODE'.
          ls_bdcdata-fval = '=RB'.
          APPEND ls_bdcdata TO lt_bdcdata.

          ls_bdcdata-program = 'SAPMSSFO'.
          ls_bdcdata-dynpro = '0100'.
          ls_bdcdata-dynbegin = 'X'.
          APPEND ls_bdcdata TO lt_bdcdata.
          CLEAR ls_bdcdata.

          "Bildschirm füllen
          ls_bdcdata-fnam = 'SSFSCREEN-TNAME'.
          ls_bdcdata-fval = ls_itab-formname.
          APPEND ls_bdcdata TO lt_bdcdata.
          CLEAR ls_bdcdata.

        when others.
          "Bildschirm füllen
          ls_bdcdata-fnam = 'RB_SF'.
          ls_bdcdata-fval = 'X'.
          APPEND ls_bdcdata TO lt_bdcdata.
          CLEAR ls_bdcdata.

          ls_bdcdata-fnam = 'SSFSCREEN-FNAME'.
          ls_bdcdata-fval = ls_itab-formname.
          APPEND ls_bdcdata TO lt_bdcdata.
          CLEAR ls_bdcdata.

      endcase.

*     OK-Code übergeben
      CLEAR ls_bdcdata.
      ls_bdcdata-fnam = 'BDC_OKCODE'.
      ls_bdcdata-fval = '=DISPLAY'.
      APPEND ls_bdcdata TO lt_bdcdata.

*     Transaktion ausführen
      CALL TRANSACTION 'SMARTFORMS'
        USING lt_bdcdata
         MODE 'E'                    "E = Stoppen nur bei Error, A = Anzeige (für Test)
         MESSAGES INTO lt_itab_msg.  "Fehlertabelle

  endcase.

endform. " USER_COMMAND_ITAB
*---------------------------------------------------------------------
*      FORM top_of_page
*---------------------------------------------------------------------
*      Fülle Header für ALV-Listen
*----------------------------------------------------------------------
FORM alv_itab_top_of_page.                                  "#EC CALLED

  DATA: listheader TYPE slis_t_listheader,
        w_listheader TYPE slis_listheader,
        l_datum(10) TYPE c,
        l_lines TYPE i.

* Schreibe Anzahl Datensätze Reporte in Grid Titel
  DESCRIBE TABLE gt_itab LINES l_lines.

* Datum in Ausgabeform bringen
  WRITE sy-datum TO l_datum.

  w_listheader-typ = 'S'.
  w_listheader-key = 'Datum'.
  w_listheader-info = l_datum.
  APPEND w_listheader TO listheader.

  w_listheader-typ = 'S'.
  w_listheader-key = 'Anzahl Datensätze'.
  w_listheader-info = l_lines.
  APPEND w_listheader TO listheader.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary = listheader.
*          I_LOGO             =
*          I_END_OF_LIST_GRID =

ENDFORM.


*&---------------------------------------------------------------------*
*&      Form  SELECT_DATA
*&---------------------------------------------------------------------*
*       Selektieren Zeilen von Tabelle STXFTXT
*----------------------------------------------------------------------*
FORM SELECT_DATA
  CHANGING CT_ITAB type tty_itab.

  SELECT
    SPRAS
    TXTYPE
    FORMNAME
    INAME
    LINENR
    TDFORMAT
    TDLINE
    into table ct_itab
    from stxftxt
    WHERE spras    in s_spras
      AND formname in s_form
      AND iname    in s_iname
      AND tdline   in s_tdline.

ENDFORM.                    " SELECT_DATA


*&---------------------------------------------------------------------*
*&      Form  SET_COLOR_LINE
*&---------------------------------------------------------------------*
*       Färbe Zeile ein bei jedem neuen Textbaustein
*----------------------------------------------------------------------*
FORM SET_COLOR_LINE
    CHANGING PCT_ITAB type tty_itab.

  Field-Symbols: <fs_itab> type ty_itab.

  loop at pct_itab ASSIGNING <fs_itab>.
    at new formname.
      <fs_itab>-color = 'C300'.
    ENDAT.
  endloop.

ENDFORM.                    " SET_COLOR_LINE

Web-Links