Creating dynamic internal table to display ALV

REPORT ZSAN_RFCTEST.
DATA : IT_FCAT TYPE LVC_T_FCAT.
PARAMETERS: P_TABLE TYPE DD02L-TABNAME.
DATA : WA_TABLE TYPE DD02L.

AT SELECTION-SCREEN.
  IF P_TABLE IS NOT INITIAL.
    SELECT SINGLE * FROM DD02L INTO WA_TABLE WHERE TABNAME = P_TABLE AND TABCLASS = 'TRANSP'.
  ELSE.
    MESSAGE 'Please enter a table' TYPE 'E'.
    STOP.
  ENDIF.
  IF WA_TABLE IS INITIAL.
    MESSAGE 'Table Dosent exit or is not transparent table' TYPE 'E'.
    STOP.
  ENDIF.

START-OF-SELECTION.
  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      I_STRUCTURE_NAME = P_TABLE
    CHANGING
      CT_FIELDCAT      = IT_FCAT.

  DATA : FS_TAB TYPE REF TO DATA.
  CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
    EXPORTING
*     I_STYLE_TABLE   =
      IT_FIELDCATALOG = IT_FCAT
*     I_LENGTH_IN_BYTE          =
    IMPORTING
      EP_TABLE        = FS_TAB.

  FIELD-SYMBOLS: <FS_TAB> TYPE STANDARD TABLE.
  ASSIGN FS_TAB->* TO <FS_TAB>.
*data : it_tab type TABLE OF p_table.
  SELECT * FROM (P_TABLE) INTO CORRESPONDING FIELDS OF TABLE <FS_TAB> UP TO 50 ROWS.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_STRUCTURE_NAME = P_TABLE
    TABLES
      T_OUTTAB         = <FS_TAB>.
  IF SY-SUBRC <> 0.
* Implement suitable error handling here
  ENDIF.

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