Overblog Folge diesem Blog
Edit post Administration Create my blog
SAPManDoo - SAP Resource

Sachkontenverzeichnis im ALV mit mehrspachigen Texten

17. Februar 2011 , Geschrieben von sapmandoo Veröffentlicht in #SAP Reports, #FI

Der nachfolgende Report erstellt ein Sachkontenverzeichnis im ALV-Grid, wobei ggf. auch Texte in verschiedenen Spachen nebeneinander ausgegeben werden können. Dies erleichtert z.B. das Übersetzen bzw. die Kontrolle der verschiedenen Texte in internationalen SAP-Installationen/Projekten. Zudem ist die ALV-Liste doppelklick-sensitiv, d.h. es kann vor hier direkt in die Sachkontenpflege zentral (FS00) angesprungen werden.

 

Quelltext:

 

 

**********************************************************************
** REPORT  Z_GL_LIST
*--------------------------------------------------------------------*
** AUTHOR:             
** LAST UPDATE:        
** DEVELOPMENT REQUEST:   
**
**********************************************************************
** CONTENT DESCRIPTION
*--------------------------------------------------------------------*
*  List of accounts with texts in different languages
*                   :
*
**********************************************************************
** CHANGE HISTORY
*--------------------------------------------------------------------*
* DATE     | USER        | DESCRIPTION
* -------------------------------------------------------------------*
* <DATE>   | <USERNAME>  | <short description of change>
* <DATE>   | <USERNAME>  | <short description of change>
*    :     |     :       |                 :
*
**********************************************************************

REPORT  z_gl_list.

**********************************************************************
** DECLARATIONS
**********************************************************************

* TYPE DECLARATIONS
*--------------------------------------------------------------------*
TYPES: BEGIN OF gt_acclist,
         ktopl TYPE ska1-ktopl,
         saknr TYPE ska1-saknr,
         bilkt TYPE ska1-bilkt,
         bukrs TYPE skb1-bukrs,
         altkt TYPE skb1-altkt,
         txt20_e TYPE skat-txt20,
         txt50_e TYPE skat-txt50,
         txt20_d TYPE skat-txt20,
         txt50_d TYPE skat-txt50,
         txt20_f TYPE skat-txt20,
         txt50_f TYPE skat-txt50,

 * add textfields for addt'l languages here...
         ktoks TYPE ska1-ktoks,
         xbilk TYPE ska1-xbilk,
         mwskz TYPE skb1-mwskz,
         mitkz TYPE skb1-mitkz,
         xopvw TYPE skb1-xopvw,
         xmwno TYPE skb1-xmwno,
         fstag TYPE skb1-fstag,

*             add addt'l fields here...
       END OF gt_acclist.

* CONSTANTS
*--------------------------------------------------------------------*

* INTERNAL TABLES
*--------------------------------------------------------------------*
DATA: git_acclist TYPE TABLE OF gt_acclist.

* STRUCTURES
*--------------------------------------------------------------------*
DATA: gs_ska1 TYPE ska1,
      gs_skb1 TYPE skb1,
      gs_skat TYPE skat.
DATA: gs_acclist TYPE gt_acclist.

* VARIABLES
*--------------------------------------------------------------------*
TYPE-POOLS: slis.
DATA:   g_repid   LIKE   sy-repid.
DATA:    git_fieldcat   TYPE   slis_t_fieldcat_alv,
  wa_feldkatalog     TYPE   LINE OF slis_t_fieldcat_alv,
  gs_layout    TYPE   slis_layout_alv,
  wa_aktuelle_zeile  LIKE LINE OF git_acclist
  .


* SELECTION CRITERIA (PARAMETERS AND SELECT-OPTIONS)
*--------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE text-b01.
SELECT-OPTIONS: so_ktopl FOR gs_ska1-ktopl OBLIGATORY MEMORY ID kpl,
                so_saknr FOR gs_ska1-saknr,
                so_bukrs FOR gs_skb1-bukrs MEMORY ID buk.
SELECTION-SCREEN END OF BLOCK b01.


**********************************************************************
** EVENTS
**********************************************************************

* START-OF-SELECTION
*--------------------------------------------------------------------*
START-OF-SELECTION.

  SET PARAMETER ID 'BUK' FIELD so_bukrs-low.
  SET PARAMETER ID 'KPL' FIELD so_ktopl-low.

  PERFORM read_glmaster_records.

  IF git_acclist[] IS INITIAL.
*   No list generated
    CALL FUNCTION 'POPUP_NO_LIST'.
  ELSE.
*   ALV-Ouput
    PERFORM display_alv.
  ENDIF.

**********************************************************************
** FORMS
**********************************************************************

*&---------------------------------------------------------------------*
*&      Form  READ_GLMASTER_RECORDS
*&---------------------------------------------------------------------*
*       Selection of GL master records and filling of internal table
*----------------------------------------------------------------------*
FORM read_glmaster_records .

  DATA: ls_skat TYPE skat.

  SELECT * FROM ska1 INTO CORRESPONDING FIELDS OF gs_acclist
         WHERE ktopl IN so_ktopl
           AND saknr IN so_saknr.
    SELECT * FROM skb1 INTO CORRESPONDING FIELDS OF gs_acclist
         WHERE saknr = gs_acclist-saknr
           AND bukrs IN so_bukrs.
      SELECT SINGLE * FROM skat INTO ls_skat
             WHERE ktopl = gs_acclist-ktopl
               AND saknr = gs_acclist-saknr
               AND spras = 'EN'.
      IF sy-subrc = 0.
        gs_acclist-txt20_e = ls_skat-txt20.
        gs_acclist-txt50_e = ls_skat-txt50.
      ELSE.
        gs_acclist-txt20_e = gs_acclist-txt50_e = 'No English text'.
      ENDIF.
      SELECT SINGLE * FROM skat INTO ls_skat
             WHERE ktopl = gs_acclist-ktopl
               AND saknr = gs_acclist-saknr
               AND spras = 'DE'.
      IF sy-subrc = 0.
        gs_acclist-txt20_d = ls_skat-txt20.
        gs_acclist-txt50_d = ls_skat-txt50.
      ELSE.
        gs_acclist-txt20_d = gs_acclist-txt50_d = 'K. deutscher Text'.
      ENDIF.
      SELECT SINGLE * FROM skat INTO ls_skat
             WHERE ktopl = gs_acclist-ktopl
               AND saknr = gs_acclist-saknr
               AND spras = 'FR'.
      IF sy-subrc = 0.
        gs_acclist-txt20_f = ls_skat-txt20.
        gs_acclist-txt50_f = ls_skat-txt50.
      ELSE.
        gs_acclist-txt20_f = gs_acclist-txt50_f = 'No french text'.
      ENDIF.

 *   Repeat for addt'l languages...
      APPEND gs_acclist TO git_acclist.
    ENDSELECT.
  ENDSELECT.

ENDFORM.                    " READ_GLMASTER_RECORDS

*&---------------------------------------------------------------------*
*&      Form  DISPLAY_ALV
*&---------------------------------------------------------------------*
*       Give internal table as ALV
*----------------------------------------------------------------------*
FORM display_alv .

* Feldkatalog fuellen.
  PERFORM feldkatalog_fuellen.
* Layout bestimmen.
  PERFORM layout_allg_build USING gs_layout.

  g_repid = sy-repid.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program      = g_repid
      i_callback_user_command = 'HANDLE_DOUBLE_CLICK'
*     i_grid_title            = sy-title
      i_save                  = 'U'
      it_fieldcat             = git_fieldcat
      is_layout               = gs_layout
    TABLES
      t_outtab                = git_acclist.
  IF sy-subrc <> 0.
    MESSAGE e600(fr) WITH 'Error in ALV generation'.
  ENDIF.


ENDFORM.                    " DISPLAY_ALV

*---------------------------------------------------------------------
* Unterprogramm fuer Reaktion auf Doppelklick
*---------------------------------------------------------------------
FORM handle_double_click USING i_ucomm
    i_selfield TYPE slis_selfield.

  CASE i_ucomm.
    WHEN '&IC1'. "bei Doppelklick
      READ TABLE git_acclist INTO wa_aktuelle_zeile
        INDEX i_selfield-tabindex.
      PERFORM maintain_glaccount USING wa_aktuelle_zeile-bukrs
                                       wa_aktuelle_zeile-saknr.
  ENDCASE.
ENDFORM.  "REAKTION_AUF_DOPPELKLICK

*---------------------------------------------------------------------
* Unterprogramm fuer Layoutangaben
*---------------------------------------------------------------------
FORM layout_allg_build USING ls_layout TYPE slis_layout_alv.
  ls_layout-zebra  = 'X'.
  ls_layout-colwidth_optimize = 'X'.
ENDFORM.  "layout_allg_build.


*---------------------------------------------------------------------
*  Unterprogramm fuer das Fuellen des Feldkatalogs
*---------------------------------------------------------------------
FORM feldkatalog_fuellen.

  DATA: ls_dfies TYPE dfies.

  CLEAR git_fieldcat.

  DEFINE add_field_2_cat.
    clear wa_feldkatalog.
    wa_feldkatalog-fieldname  = &1.
    wa_feldkatalog-ref_fieldname  = &3.
    wa_feldkatalog-ref_tabname  = &2.
    append wa_feldkatalog to git_fieldcat.
  END-OF-DEFINITION.

  add_field_2_cat:
    'KTOPL' 'SKA1' 'KTOPL',
    'SAKNR' 'SKA1' 'SAKNR',
    'BILKT' 'SKA1' 'BILKT',
    'BUKRS' 'SKB1' 'BUKRS',
    'ALTKT' 'SKB1' 'ALTKT',
    'TXT20_E' 'SKAT' 'TXT20',
    'TXT50_E' 'SKAT' 'TXT50',
    'TXT20_D' 'SKAT' 'TXT20',
    'TXT50_D' 'SKAT' 'TXT50',
    'TXT20_F' 'SKAT' 'TXT20',
    'TXT50_F' 'SKAT' 'TXT50',

 *     add your addt'l text fields here
    'KTOKS' 'SKA1' 'KTOKS',
    'XBILK' 'SKA1' 'XBILK',
    'MWSKZ' 'SKB1' 'MWSKZ',
    'MITKZ' 'SKB1' 'MITKZ',
    'XOPVW' 'SKB1' 'XOPVW',
    'XMWNO' 'SKB1' 'XMWNO',
    'FSTAG' 'SKB1' 'FSTAG'.

* add your addt'l field here...

ENDFORM.  "feldkatalog_fuellen.

*&---------------------------------------------------------------------*
*&      Form  MAINTAIN_GLACCOUNT
*&---------------------------------------------------------------------*
*       Maintain GL Acct (CALL TRANSACTION)
*----------------------------------------------------------------------*
*      -->P_BUKRS  Company Code
*      -->P_SAKNR  G/L AccountNo
*----------------------------------------------------------------------*
FORM maintain_glaccount  USING    p_bukrs TYPE bukrs
                                  p_saknr TYPE saknr.

* NOTE: doesn't work when tree-display is activated

  SET PARAMETER ID 'BUK' FIELD p_bukrs.
  SET PARAMETER ID 'SAK' FIELD p_saknr.
  CALL TRANSACTION 'FS00' AND SKIP FIRST SCREEN.

ENDFORM.                    " MAINTAIN_GLACCOUNT

Diesen Post teilen

Repost 0
Um über die neuesten Artikel informiert zu werden, abonnieren:

Kommentiere diesen Post