Hi All,
I have 200 fields in ITAB, ....THOSE 200 FIELDS WILL BE DISPLAYED IN selctions-screen output....
user will select only 10 fields...
Now my requirement is to download only those 10 fields and that too the fields with data...Please advise..I am searching from 1 week and couldnt able to get the exact output what i am looking for ........Today I need to deliver this..Thanks in advanse
Regard
Sas
Which ALV methods are you using ? If you use CL_SALV_TABLE then it could be done using the column object and the descriptor classes.
wa_table in below example is the structure (WORK AREA) of your output table, lt_table is the output TABLE.
DATA: l_rcl_struc TYPE REF TO cl_abap_structdescr.
gr_table TYPE REF TO cl_salv_table,
gr_columns_table TYPE REF TO cl_salv_columns_table,
gr_column TYPE REF TO cl_salv_column.
FIELD-SYMBOLS: TYPE abap_compdescr.
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = lt_table.
CATCH cx_salv_msg INTO lcx_salv_msg.
ENDTRY.
.
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( 'X' ).
l_rcl_struc ?=
cl_abap_structdescr=>describe_by_data( wa_table ).
gr_columns_table = gr_table->get_columns( ).
LOOP AT l_rcl_struc->components ASSIGNING <components>.
lv_name = <components>-name.
read table lt_names with key name = lv_name
show = 'X'
if sy-subrc = 0.
TRY.
gr_column = gr_columns_table->get_column( columnname = lv_name ).
gr_column->set_optimized( 'X' ).
lv_text = lv_textm = lv_textl = lv_tip = lv_name.
gr_column->set_short_text( lv_text ).
gr_column->set_medium_text( lv_textm ).
gr_column->set_long_text( lv_textl ).
gr_column->set_tooltip( lv_tip ).
CATCH cx_salv_not_found .
ENDTRY.
else.
TRY.
gr_column = gr_columns_table->get_column( columnname = lv_name ).
gr_column->set_technical( 'X' ). "this will delete the field from the output display.
CATCH cx_salv_not_found .
ENDTRY.
endif.
ENDLOOP.
gr_table->display( ).
The table lt_names have to be filled according to what the user selected in selection screen. Offcourse the names used in this table need to be the same as the names used in the type definition of your output table. (in this example wa_table)
For dynamic internal table you can follow this link which is very good to understand.
Dynamic Internal Table iIlustrated with an example of creating the transpose of internal table
Hi,
Please find the logic to provide the output of your requirement.
1. Create a three dynamic table with same structure, in your case 200 fields.
2. While updating 2 table ITAB & JTAB, use the selected field to update the data.
Use "ASSIGN COMPONENT selected field name of structure <field Symbol> To <VAL-FS>.
here the selected field name would be user selected fields from the select-option.
3. After that, do the comparison, and then if as you mentioned and append into the 3ed table of only value field require,
so for that you can use the flag logic.
4. And finally only display those fields in Output, which is selected by user and having the value (Use Flag Value with respect to selected Field ) and hide the rest of the fields.
Regards.
Praveer.
Add a comment