‎2009 Nov 05 1:23 AM
HI ,
i am creating a class which should be resuable for our project,it has a method with a importing parameter of type table.
my problem is how can i code with this table,lets for example i am sending the table contents to app server,if i use this method in different programs it will have diff number of fields and different fields.how can i code this i tried using super class CL_ABAP_TYPEDESCR but not sure how can i go ahead with this,any suggestions or any code example would be highly appreciated and helpful.
thanks in advance.
‎2009 Nov 05 1:30 AM
[How to create a Dynamic Internal Table|http://www.sap-img.com/ab030.htm]
‎2009 Nov 05 1:44 AM
hi you can create a dynamic internal table by creating fieldcatalog and passing it to a cl_alv_table_create=>create_dynamic_table.
here in my question for the import parameter i had given type as table.
when i call from any program and pass the internal table of that program.this import parameter will be having that internal table structure.in that case i have to code for a dynamic internal table Rt.please suggest.
‎2009 Nov 05 5:06 AM
‎2009 Nov 05 5:22 AM
HI ,
U can follow the following steps:
Create instances of class cl_rs_where, Use the method add_line for building select and where clause dynamically.
For example
Create object for SELECT
CREATE OBJECT lr_select.
CALL METHOD lr_select->add_line
EXPORTING
i_line = rv_fieldname.
Create object for WHERE
CALL METHOD l_r_where->add_line
EXPORTING
i_line = rv_lang_field.
CALL METHOD l_r_where->add_line
EXPORTING
i_line = '='.
CALL METHOD l_r_where->add_line
EXPORTING
i_line = 'SY-LANGU'.
Call the select query
TRY.
SELECT (lr_select->n_t_where)
FROM (lv_table)
INTO CORRESPONDING FIELDS OF TABLE <itab>
WHERE (l_r_where->n_t_where).
CATCH cx_sy_dynamic_osql_semantics INTO l_r_excp.
ENDTRY.
Finally build the required internal table
IF <itab> IS NOT INITIAL.
LOOP AT <itab> ASSIGNING <row>.
ASSIGN COMPONENT rv_fieldname OF STRUCTURE <row> TO <fieldname>.
lw_value-key_value = <fieldname>.
ASSIGN COMPONENT rv_text_field OF STRUCTURE <row> TO <textfield>.
lw_value-text = <textfield>.
ENDIF.
APPEND lw_value TO rt_values.
ENDLOOP.
Thanks
shambhu