SAP ABAP4 Learning - Simple Example of ALV 3 - Click a line call transaction code

xiaoxiao2021-03-06  108

Report ZTEST_102_Alv_3.

* & ------------------------------------------------ --------------------- ** & Report: Alv ** & Creation Date: 2004.09.01 ** & created by: ** & description: ALV TEST. ** & --------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------- **** Define avl parameters.

* Define An Type PoolType-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.

Tables: mara.

* Internal Table for Storing Line Item Data Per Document NumberData: Begin of Itab Occurs 10, Matnr Like Mara-Matnr, Mtart Like Mara-Matart, Bismt Like Mara-Bism, End of Itab.

START-OF-Selection.Selection-Screen Begin of Block Ba with frame title ttl1. Select-options: p_matnr for mara-matnr.selection-screen end of block ba.

* & ------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------- * Initialization. TTL1 = ' INPUT CONDition '.

* & ------------------------------------------------ -------------------- ** At Selection-Screen. * & --------------------- --------------------------------------------- ** Check INPUT VALUE OF USERAT SELECTION-SCREEN. * SELECT single ** bukrs INTO t001-bukrs * FROM t001 * WHERE bukrs IN bukrs. * PERform authority_check (zscfiglr003) USING t001-bukrs. * butxt = t001-butxt. * ENDSELECT. * & -------------------------------------------------- ----------------- ** Start-of-selection. * & -------------------------------------------------------------------------------------------------------------- ---------------------------------------------- *

Start-of-selection.

* DEFINE PAGE LEFT MARGIN AND TOP MARGIN SET MARGIN 7 5. * DEFINE PIRNT FORMATE PRINT-CONTROL FUNCTION: 'SABLD' LINE 1, 'SAOFF' LINE 2, 'SAULN' LINE 3. * The above sentence print-control function used to Define Print Format * Find Document Header Data and Line Item Data from Given Parameters. Perform ALVDISPLAY.

* --------------------------------------------------- * GET DATA from Some System Table * Then, Put these Data INTO INTERTERTERTER TABLE. * ---------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------- * Form Find_Document. SELECT MATNR Matart Bismt Into Corresponding Fields of Table Itab Mara where matnr in p_matnr.ere matnr in p_matnr.endform. * ---------- ----- Alv Disply function -------------------- * form alvdisplay. Data: col_pos Type I. Data: PGM Like Sy-repid. Pgm = SY -REPID * Add The 1th column:. company code .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.fieldc AT_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 ​​SUMFIELDCAT_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.

Sortcat_ln-spos = '1'.Sortcat_ln-fieldName =' matnr'.sortcat_ln-up = 'x'sortcat_ln-down = Space.Sortcat_ln-subtot =' X'.Append Sortcat_ln to Sortcat. **** Call Function To response user command event .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 = EVENTCATTABLES T_OUTTAB = ITABEXCEPTIONS PROGRAM_ERROR 1 OTHERS = 2.endform =.

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.

转载请注明原文地址:https://www.9cbs.com/read-105151.html

New Post(0)