Hotspot,Double click,Move to transaction

REPORT ZSAPN_ALV_INTERACTIVE.
TYPE-POOLS SLIS .
TYPES : BEGIN OF TY_MARA,  "User defined internal table type
        MATNR TYPE MARA-MATNR,
        MTART TYPE MARA-MTART,
        MBRSH TYPE MARA-MBRSH,
        MEINS TYPE MARA-MEINS,
      END OF TY_MARA.

DATA : IT_MARA TYPE TABLE OF TY_MARA ."internal table
DATA : WA_MARA TYPE TY_MARA . "work area

DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV . "field catalog table
DATA : WA_FCAT LIKE LINE OF IT_FCAT . "field catalog work area
PARAMETERS : P_MTART TYPE MARA-MTART. "material type input

START-OF-SELECTION.
**get table data
  SELECT MATNR MTART MBRSH MEINS FROM MARA "get data from MARA
      INTO TABLE IT_MARA UP TO 50 ROWS
      WHERE MTART = P_MTART.
*** generate field catalogue
  WA_FCAT-COL_POS = '1' . "column position
  WA_FCAT-FIELDNAME = 'MATNR' . "column name
  WA_FCAT-TABNAME = 'IT_MARA' . "table
  WA_FCAT-SELTEXT_M = 'Material' . "Column label
  WA_FCAT-KEY = 'X' . "is a key field
  WA_FCAT-HOTSPOT = 'X' . "Set hotspot for matnr
  APPEND WA_FCAT TO IT_FCAT . "append to fcat
  CLEAR WA_FCAT .
  WA_FCAT-COL_POS = '2' .
  WA_FCAT-FIELDNAME = 'MBRSH' .
  WA_FCAT-TABNAME = 'IT_MARA' .
  WA_FCAT-SELTEXT_M = 'Industry Sec' .
  APPEND WA_FCAT TO IT_FCAT .
  CLEAR WA_FCAT .

  WA_FCAT-COL_POS = '3' .
  WA_FCAT-FIELDNAME = 'MTART' .
  WA_FCAT-TABNAME = 'IT_MARA' .
  WA_FCAT-SELTEXT_M = 'Material Type' .
  APPEND WA_FCAT TO IT_FCAT .
  CLEAR WA_FCAT .

  WA_FCAT-COL_POS = '4' .
  WA_FCAT-FIELDNAME = 'MEINS' .
  WA_FCAT-TABNAME = 'IT_MARA' .
  WA_FCAT-SELTEXT_M = 'Base.Unit' .
  WA_FCAT-REF_TABNAME = 'MARA' .
  APPEND WA_FCAT TO IT_FCAT .
  CLEAR WA_FCAT .
**display ALV
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_CALLBACK_PROGRAM      = SY-REPID
      I_CALLBACK_USER_COMMAND = 'USER_COMMAND' "user command form
      IT_FIELDCAT             = IT_FCAT "PASS FIELD CATALOG TO ALV
    TABLES
      T_OUTTAB                = IT_MARA. "output table

**for to handle user command
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
                        RS_SELFIELD TYPE SLIS_SELFIELD.
  CASE R_UCOMM.
    WHEN '&IC1'. "standard Function code for doubel click
      READ TABLE IT_MARA INTO WA_MARA INDEX RS_SELFIELD-TABINDEX.
      IF SY-SUBRC = 0.
        SET PARAMETER ID 'MAT' FIELD WA_MARA-MATNR. "set parameter id
        CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN. "call transaction
      ENDIF.
  ENDCASE.
ENDFORM.                    "user_command

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source