CSDN博客

img opparts

SAP ABAP/4学习---ALV的简单例子2-单击某行调用事务码

发表于2004/10/17 20:15:00  5838人阅读

分类: SAP ABAP

Report ZTEST .

TYPE-POOLS: SLIS.
DATA: FIELDCAT      TYPE   SLIS_T_FIELDCAT_ALV,
      FIELDCAT_LN   LIKE   LINE OF FIELDCAT,
      SORTCAT       TYPE   SLIS_T_SORTINFO_ALV,
      SORTCAT_LN    LIKE   LINE OF SORTCAT,
      EVENTCAT      TYPE   SLIS_T_EVENT,
      EVENTCAT_LN   LIKE   LINE OF EVENTCAT.
DATA: COL_POS TYPE I.


Tables: MARA.
data: begin of itab occurs 10,
        MATNR like MARA-MATNR,
        MTART LIKE MARA-MTART,
        BISMT LIKE MARA-BISMT,
      end of itab.

 

SELECT-OPTIONS: P_MATNR FOR MARA-MATNR.

START-OF-SELECTION.
SELECT MATNR
       MTART
       BISMT
  INTO CORRESPONDING FIELDS OF TABLE ITAB
  FROM MARA
 WHERE MATNR IN P_MATNR.


ADD  1  TO  COL_POS.
FIELDCAT_LN-REF_TABNAME  =  'MARA'.
FIELDCAT_LN-FIELDNAME     =  'MTART'.
FIELDCAT_LN-KEY             = SPACE.
FIELDCAT_LN-DO_SUM         = SPACE.
FIELDCAT_LN-COL_POS        = COL_POS.
FIELDCAT_LN-NO_OUT        = SPACE.
FIELDCAT_LN-QFIELDNAME   = SPACE.
FIELDCAT_LN-HOTSPOT       = SPACE.
APPEND  FIELDCAT_LN  TO FIELDCAT.

ADD  1  TO  COL_POS.
FIELDCAT_LN-REF_TABNAME = 'MARA'.
FIELDCAT_LN-FIELDNAME   = 'MATNR'.
FIELDCAT_LN-KEY          = SPACE.
FIELDCAT_LN-DO_SUM      = SPACE.
FIELDCAT_LN-COL_POS     = COL_POS.
FIELDCAT_LN-NO_OUT      = SPACE.
FIELDCAT_LN-QFIELDNAME  =  SPACE.
FIELDCAT_LN-HOTSPOT     = SPACE.
APPEND  FIELDCAT_LN  TO  FIELDCAT.

ADD 1 TO COL_POS.
FIELDCAT_LN-REF_TABNAME  =  'MARA'.
FIELDCAT_LN-FIELDNAME     =  'BISMT'.
FIELDCAT_LN-KEY            =  SPACE.
*DEFINE AN SUM
FIELDCAT_LN-DO_SUM        =  'X'.
FIELDCAT_LN-COL_POS        =  COL_POS.
FIELDCAT_LN-NO_OUT        =  SPACE.
FIELDCAT_LN-QFIELDNAME   =  SPACE.
FIELDCAT_LN-HOTSPOT       =  SPACE.
APPEND  FIELDCAT_LN  TO  FIELDCAT.


* DEFINE AN SORT TABLE
* ADD SORT INTO SORT INTERNAL TABLE.
SORTCAT_LN-SPOS         =  '1'.
* DEFINE AN SORT FIELD
SORTCAT_LN-FIELDNAME  =  'BISMT'.
SORTCAT_LN-UP           =  'X'.
SORTCAT_LN-DOWN       =  SPACE.
SORTCAT_LN-SUBTOT      =  'X'.
APPEND  SORTCAT_LN  TO  SORTCAT.

*  DEFINE EVENT LIST(Event Catalogs)
EVENTCAT_LN-NAME  =  'TOP_OF_PAGE'.
EVENTCAT_LN-form  =  'PAGE_HEADER'.
APPEND  EVENTCAT_LN  TO  EVENTCAT.

*  DEFINE ALV CALL Function Module
DATA:  PGM  LIKE  SY-REPID.
PGM = SY-REPID.

CALL  FUNCTION  'REUSE_ALV_LIST_DISPLAY'
EXPORTING
  I_CALLBACK_PROGRAM             =  PGM
  I_CALLBACK_USER_COMMAND        =  'USER_COMMAND'
  IT_FIELDCAT                    =  FIELDCAT
  IT_SORT                        =  SORTCAT
  I_SAVE                         =  'A'
  IT_EVENT                       = EVENTCAT
  TABLES
  T_OUTTAB  =  ITAB
EXCEPTIONS
  PROGRAM_ERROR  =  1
  OTHERS            =  2.


* DEFINE EVENT OF THE USER CLICKED KEYBOARD.

form USER_COMMAND USING UCOMM LIKE SY-UCOMM
  SELFIELD TYPE SLIS_SELFIELD.
  READ TABLE ITAB INDEX SELFIELD-TABINDEX.
  CHECK SY-SUBRC = 0.
    CASE UCOMM.
      WHEN '&IC1'.
        CASE SELFIELD-SEL_TAB_FIELD.
          WHEN  'ITAB-MATNR'.
            SET  PARAMETER  ID  'MAT'  FIELD  ITAB-MATNR.
            CALL  TRANSACTION  'MM03'  AND  SKIP  FIRST  SCREEN.
    ENDCASE.
  ENDCASE.
ENDform.

阅读全文
0 0

相关文章推荐

img
取 消
img