24 Eylül 2011 Cumartesi

SAP/ABAP: REUSE_ALV_FIELDCATALOG_MERGE & REUSE_ALV_GRID_DISPLAY

DATA: BEGIN OF GT_ITAB OCCURS 0,
.
.
.
.
 END OF GT_ITAB.

DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE ,
      GS_LAYOUT   TYPE SLIS_LAYOUT_ALV                      .
  PERFORM ALV
    USING 'GT_ITAB'.
*&---------------------------------------------------------------------*
*&      Form  ALV
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM ALV USING P_TABNAME.

  FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
  DATA LV_CHAR(15).
  CONCATENATE P_TABNAME '[]' INTO LV_CHAR.
  ASSIGN (LV_CHAR) TO <TABLE>.

  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      I_PROGRAM_NAME         = SY-REPID
      I_INCLNAME             = SY-REPID
      I_INTERNAL_TABNAME     = P_TABNAME
    CHANGING
      CT_FIELDCAT            = GT_FIELDCAT[]
    EXCEPTIONS
      INCONSISTENT_INTERFACE = 1
      PROGRAM_ERROR          = 2
      OTHERS                 = 3.

 GS_LAYOUT-COLWIDTH_OPTIMIZE     = 'X' .
  GS_LAYOUT-ZEBRA                 = 'X'.
  GS_LAYOUT-DETAIL_INITIAL_LINES  = 'X'.


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_CALLBACK_PROGRAM       = SY-REPID
      IS_LAYOUT                = GS_LAYOUT
      IT_FIELDCAT              = GT_FIELDCAT[]
      I_SAVE                   = 'A'
      I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
      I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
    TABLES
      T_OUTTAB                 = <TABLE>
    EXCEPTIONS
      PROGRAM_ERROR            = 1
      OTHERS                   = 2.

  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
      WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDFORM.                    " ALV
*&---------------------------------------------------------------------*
*&      Form  set_pf_status
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->RT_EXTAB   text
*----------------------------------------------------------------------*
FORM SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
  SET PF-STATUS 'BUTTONS'.
ENDFORM.                    "set_pf_status

*&---------------------------------------------------------------------*
*&      Form  user_command
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->R_UCOMM      text
*      -->RS_SELFIELD  text
*----------------------------------------------------------------------*
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
                        RS_SELFIELD TYPE SLIS_SELFIELD.
  CASE R_UCOMM.
    WHEN '&BACK'.
      LEAVE TO SCREEN 0.
    WHEN '&EXIT'.
      LEAVE PROGRAM.
    WHEN 'BAPI'.
      PERFORM BAPI.

  ENDCASE.
ENDFORM.                    "user_command

Hiç yorum yok:

Yorum Gönder

İnsdroid

Sabahtan beri çatada çutada çatada çutada… Bitmedi yine de… Neyse, yolumuz uzun, toparlıyorum çantamı, adaptörü falan tıkıştırıyorum bir şe...