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

Create table like SAP Query generated structure

prince_isaac
Active Participant
0 Likes
1,407

Hi guys

I am trying to enhance a SAP query by adding some code and i am failing to create a table to replicate the entries in the query generated table.  SAP generates a table %dtab which i found out by looking at the generated program.  Now i want to replicate the contents of that table in another table but i am failing to do so.  I have tried using the runtime type classes but i cannot seem to get it correct always getting a runtime error TYPE_NOT_FOUND.

what i have tried:


constants: lc_tab type string value '%dtab'.

data: lt_data type ref to data.

field-symbols: <lt_data> type any table.

create data lt_data like (lc_tab).

assign lt_data->* to <lt_data>. "crashes here if FS is typed to ANY TABLE

also tried


    lo_struc_type ?= cl_abap_tabledescr=>describe_by_name( lc-tab ).

data(lt_comp_tab) = lo_struc_type->get_components( ).

"dump TYPE_NOT_FOUND

Is there a way i could create a replica of the table?

regards

Prince Isaac

5 REPLIES 5
Read only

former_member188827
Active Contributor
0 Likes
1,139

What exactly is your requirement? Do you want to add additional columns in query or change contents of a field? you can write your code in infoset using tcode SQ02. Click on "Extras" button and go to tab "code". you can write your code at appropriate event.

Regards

Mehwish

Read only

0 Likes
1,139

My requirement is to create a replica of the SAP query generated internal table %dtab/%GOO

I am already in SQ02 in the code section under the event END-OF-SELECTION(After List).

regards

Read only

0 Likes
1,139

In the after list event. Use the following code :

DATA lv_tabname type tabname     value '%G00[]'.

field-symbol : <fs_tab> type standard table.

assign (lv_tabname) to <fs_tab>.

You will have the internal table in field symbol <fs_tab>. Now you can do whatever you want with it.

Read only

0 Likes
1,139

Hi Ashish

My issue is not having access to the generated table, i already done so prior, i need to create another internal table just like the generated one.

regards

Prince Isaac

Read only

0 Likes
1,139

step 1 : get the component list using RTTI.

step 2: create a field catalog with the fields.

step 3: create a table based on the field catalog using method CREATE_DYNAMIC_TABLE of class CL_ALV_TABLE_CREATE.