‎2015 Apr 23 8:25 AM
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
‎2015 Apr 23 9:05 AM
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
‎2015 Apr 23 10:30 AM
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
‎2015 Apr 23 11:10 AM
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.
‎2015 Apr 23 2:26 PM
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
‎2015 Apr 27 10:56 AM
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.