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

Creating a table at runtime from a parameter(Work area)

Former Member
0 Likes
596

Hi Experts,

In a global class method i have a parameter cs_data type ref to data. At the run time I am getting some value in this work area.

Now my requirement is to call another method which will receive this cs_data in one internal table.

So how to make that internal table from cs_data?

Thanks and Regards,

Ajeet 

1 ACCEPTED SOLUTION
Read only

adam_krawczyk1
Contributor
0 Likes
567

Hi,

Try this:

DATA lt_data LIKE TABLE OF cs_data.

APPEND cs_data TO lt_data.

method_that_need_table( it_table = lt_data ).     " call your method here

Regards

Adam

4 REPLIES 4
Read only

adam_krawczyk1
Contributor
0 Likes
568

Hi,

Try this:

DATA lt_data LIKE TABLE OF cs_data.

APPEND cs_data TO lt_data.

method_that_need_table( it_table = lt_data ).     " call your method here

Regards

Adam

Read only

0 Likes
567

Hi Adam,

I am getting below error while doing so.

The field "CS_DATA" specified under LIKE either has no type or a generic type.

In parameter list cs_data has been declared as CS_DATA Changing Type DATA.

Regards,

Ajeet

Read only

0 Likes
567

Hi Ajeet,

Ok I thought you are just saying about data example. In case of generic data type, solution is more complicated. Try this:

FIELD-symbols <fs_table> type standard table.

DATA l_ref TYPE REF TO data.

CREATE DATA l_ref like table of cs_data.

ASSIGN l_ref->* to <fs_table>.

APPEND cs_data TO <fs_table>.

Then your <fs_table> is a table that contains single row.

Hope it helps.

Regards

Adam

Read only

0 Likes
567

Thanks Adam,

It's working according to my requirement.

Thanks and Regards,

Ajeet Pratap Singh