Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Dynamic table

Former Member
0 Likes
609

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.

4 REPLIES 4
Read only

former_member156446
Active Contributor
0 Likes
568

[How to create a Dynamic Internal Table|http://www.sap-img.com/ab030.htm]

Read only

0 Likes
568

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.

Read only

0 Likes
568

hi,

can any one who has an idea please suggest on this .

Read only

0 Likes
568

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