Monday, December 20, 2010
This programs is used to create dynamic fieldcatat. We will give number of columns to be displayed on selection screen.
REPORT ztest_notepad. TYPE-POOLS:slis. DATA: it_fcat TYPE STANDARD TABLE OF lvc_s_fcat, it_fcatalog TYPE STANDARD TABLE OF slis_fieldcat_alv, wa_fcat TYPE lvc_s_fcat, wa_fcatalog TYPE slis_fieldcat_alv. DATA: it_dyn_tab TYPE REF TO data, wa_newline TYPE REF TO data. FIELD-SYMBOLS: <gt_table> TYPE STANDARD TABLE, <fs_dyntable>, <fs_fldval> TYPE ANY, <l_field> TYPE ANY. DATA: l_fieldname TYPE lvc_s_fcat-fieldname, l_fieldtext TYPE lvc_s_fcat-seltext, l_index TYPE char2. PARAMETERS:columns TYPE i. START-OF-SELECTION. DEFINE fieldcat. wa_fcat-fieldname = &1. wa_fcat-tabname = '<GT_TABLE>'. wa_fcat-seltext = &2. append wa_fcat to it_fcat. clear wa_fcat. END-OF-DEFINITION. DO columns TIMES. CLEAR l_index. l_index = sy-index. CONCATENATE 'FIELD' l_index INTO l_fieldname. CONCATENATE 'Field' l_index INTO l_fieldtext. wa_fcat-fieldname = l_fieldname. wa_fcat-tabname = '<GT_TABLE>'. wa_fcat-seltext = l_fieldtext. APPEND wa_fcat TO it_fcat. CLEAR wa_fcat. ENDDO. 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 <gt_table>. CREATE DATA wa_newline LIKE LINE OF <gt_table>. ASSIGN wa_newline->* TO <fs_dyntable>. DO 20 TIMES. DO columns TIMES. l_index = sy-index. CONCATENATE 'FIELD' l_index INTO l_fieldname. ASSIGN COMPONENT l_fieldname OF STRUCTURE <fs_dyntable> TO <l_field>. <l_field> = sy-index. ENDDO. INSERT <fs_dyntable> INTO TABLE <gt_table>. ENDDO. LOOP AT it_fcat INTO wa_fcat. wa_fcatalog-fieldname = wa_fcat-fieldname. wa_fcatalog-tabname = wa_fcat-tabname. wa_fcatalog-seltext_m = wa_fcat-seltext. APPEND wa_fcatalog TO it_fcatalog. CLEAR wa_fcatalog. ENDLOOP. CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY' EXPORTING i_callback_program = 'ZTEST_NOTEPAD' it_fieldcat = it_fcatalog TABLES t_outtab = <gt_table>.
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
Thanks alot.i found good report.
ReplyDeleteIt's very good.direct report
ReplyDelete