on 03-22-2017 12:38 PM
I want to have dynamic number of wda alv column based on my input filed.
Like I have date in my input filed, if I give 3 months in my input i need 3 columns in my alv,
if i give 4 months as my input i need 4 columns in my alv.
Please do help.
Thanks
so you'd better use the RTS class to create dynamic internal table,the use the if_wd_context_node_info -> add_new_child_node to add new node to the root node
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kashiap,
Columns in ALV will be based ATTRIBUTEs in node i.e. each attribute of a node is linked to individual column in ALV table.
Now there can be multiple scenarios:
1. Columns in the ALV which you want to show are linked to some standard backend table/structure.
2. Columns in ALV are just for enduser perspective and are not mapped with any backend table/structure, data entered in ALV will be used further for some calculations are then dumped into DB table or else where.
In below example I have kept name of node as 'ND_TABLE'.
LIST_OF_ALL_FIELDS_OF_TBL_STR represents list of fields in any table/structure.
WA_OF_ALL_FIELDS_OF_TBL_STR represents workarea for above table/structure.
LV_COUNT is user input i.e. number of columns it want.
DATA lo_nd_nd_table TYPE REF TO if_wd_context_node.
DATA lo_nd_nd_table_info TYPE REF TO if_wd_context_node_info.
DATA lv_attribute TYPE wdr_context_attribute_info.
lo_nd_nd_table = wd_context->get_child_node( name = wd_this->wdctx_nd_table ).
lo_nd_nd_table_info = lo_nd_nd_table->get_node_info( ).
LOOP "LIST_OF_ALL_FIELDS_OF_TBL_STR" INTO "WA_OF_ALL_FIELDS_OF_TBL_STR".
lv_attribute-name = WA_OF_ALL_FIELDS_OF_TBL_STR-NAME
lv_attribute-type_name = WA_OF_ALL_FIELDS_OF_TBL_STR-TYPE_NAME.
CALL METHOD lo_nd_nd_table_info->add_attribute( EXPORTING attribute_info = lv_attribute ).
IF sy-tabix EQ LV_COUNT.
EXIT.
ENDIF.
ENDLOOP.
In case there is no linkage of any table or Structure to our ALV table, then instead of using LOOP statement, we can simply use DO statement, as shown below.
DATA lv_index TYPE c VALUE 1.
DO LV_COUNT TIMES.
CONCATENATE 'ATT' lv_index INTO lv_attribute-name SEPARATED BY '_'.
lv_attribute-type_name = 'CHAR30'.
CALL METHOD lo_nd_nd_table_info->add_attribute( EXPORTING attribute_info = lv_attribute ).
lv_index = lv_index + 1.
ENDDO.
Do let me know if this approach works for you.
Regards,
Harish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.