Sunday, December 26, 2010
CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE is used to convert column of itab to Column headers of the report.
REPORT ztest_program. *&--------------------------------------------------------------------* *& Declaration *&--------------------------------------------------------------------* TYPE-POOLS:slis. *Internal tables DATA: it_fcat TYPE STANDARD TABLE OF lvc_s_fcat, wa_fcat LIKE LINE OF it_fcat, it_fcatalog TYPE STANDARD TABLE OF slis_fieldcat_alv, wa_fcatalog LIKE LINE OF it_fcatalog. *Type reference DATA: it_dyn_tab TYPE REF TO data, wa_newline TYPE REF TO data. *Filed symbols FIELD-SYMBOLS: <it_data> TYPE STANDARD TABLE, <wa_data> TYPE ANY. *Variables DATA: l_fieldname TYPE lvc_s_fcat-fieldname, l_tabname TYPE lvc_s_fcat-tabname, l_fieldtext TYPE lvc_s_fcat-seltext, l_index TYPE char2. DATA: BEGIN OF it_data OCCURS 0, bukrs TYPE t001-bukrs, butxt TYPE t001-butxt, ort01 TYPE t001-ort01, END OF it_data. *&--------------------------------------------------------------------* *& Start of selection *&--------------------------------------------------------------------* START-OF-SELECTION. SELECT * FROM t001 INTO CORRESPONDING FIELDS OF TABLE it_data UP TO 10 ROWS. LOOP AT it_data. wa_fcat-fieldname = it_data-bukrs. wa_fcat-tabname = ''. wa_fcat-seltext = it_data-bukrs. APPEND wa_fcat TO it_fcat. CLEAR wa_fcat. ENDLOOP.. CALL METHOD cl_alv_table_create=>create_dynamic_table EXPORTING it_fieldcatalog = it_fcat IMPORTING ep_table = it_dyn_tab. ASSIGN it_dyn_tab->* TO <it_data>. * Create dynamic work area and assign to FS CREATE DATA wa_newline LIKE LINE OF <it_data>. ASSIGN wa_newline->* TO <wa_data>. DEFINE fieldcat. wa_fcatalog-fieldname = &1. wa_fcatalog-tabname = &2. wa_fcatalog-seltext_m = &3. append wa_fcatalog to it_fcatalog. clear wa_fcatalog. END-OF-DEFINITION. LOOP AT it_fcat INTO wa_fcat. fieldcat: wa_fcat-fieldname wa_fcat-tabname wa_fcat-seltext. ENDLOOP. CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY' EXPORTING i_callback_program = sy-repid it_fieldcat = it_fcatalog TABLES t_outtab = <it_data>.
Followers
Popular Posts
- ABAP - ALV Report example with steps
- ABAP - Step by step tutorial on Smart Forms - Template Node
- ABAP - Sending email with pdf attachment
- SAP Adobe Form - Steps to create simple ADOBE Form and calling it from ABAP Program
- SAP ABAP - CL_ABAP_CHAR_UTILITIES class usage
- ABAP - Multiple value selection from F4 help for SELECT-OPTIONS
- Execute ABAP Report using SUBMIT statement
- ABAP - Select all or Deselect all in ALV or Check box handling in ALV
- Web Dynpro ABAP ALV - ON_CLICK event
- ABAP - Dynamic WHERE clause
very use full at project.
ReplyDelete