Monday, December 20, 2010
This program illustrates how to create dynamic sorted table with the help of class CL_ABAP_TABLEDESCR and method CREATE.
REPORT ztest_program. *&--------------------------------------------------------------------------* * Declarations *&--------------------------------------------------------------------------* DATA: lineType TYPE REF TO cl_abap_structdescr, tableType TYPE REF TO cl_abap_tabledescr, key TYPE abap_keydescr_tab, lt_table TYPE REF TO data. DATA: gv_dref TYPE REF TO data. FIELD-SYMBOLS: <lt_table> type ANY TABLE, <lt_std_tab> TYPE STANDARD TABLE. *&--------------------------------------------------------------------------* * Selection Screen *&--------------------------------------------------------------------------* PARAMETERS: p_table TYPE rsrd1-tbma_val. *&--------------------------------------------------------------------------* * Start of selection *&--------------------------------------------------------------------------* START-OF-SELECTION. lineType ?= cl_abap_typedescr=>describe_by_name( p_table ). APPEND 'CARRID' TO key. APPEND 'CONNID' TO key. tableType = cl_abap_tabledescr=>create( p_line_type = lineType p_table_kind = cl_abap_tabledescr=>tablekind_sorted p_unique = abap_true p_key = key ). CREATE DATA lt_table TYPE HANDLE tableType. ASSIGN lt_table->* TO <lt_table>. SELECT * FROM (p_table) INTO TABLE <lt_table> UP TO 10 ROWS. CREATE DATA gv_dref TYPE TABLE OF (p_table). ASSIGN gv_dref->* TO <lt_std_tab>. <lt_std_tab> = <lt_table>. CALL FUNCTION 'GUI_DOWNLOAD' EXPORTING filename = 'C:\temp\test.txt' filetype = 'ASC' WRITE_FIELD_SEPARATOR = 'X' TABLES data_tab = <lt_std_tab>. IF sy-subrc = 0. WRITE 'successfully downloaded'. ENDIF.
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
ReplyDeleteThat's really cool buddy.....Obviously the lady was logical.
SAP Consultants in London