‎2006 Jan 10 12:34 PM
Hi all,
I need to create an internal table with deep structure dynamically. I've already created tables with method 'create_dynamic_table' but I'm struggling with the deep structure.
I would need an internal table with the following structure:
DATA: BEGIN OF lt_t1,
s1 TYPE REF TO data,
s2 TYPE REF TO data,
END OF lt_t1.
S1 and S2 have to be tables.
It might be possible with RTTS but all the examples in the forums (that I've found so far) are related to at least one DDIC-structure. And that's my problem because both tables are created during runtime.
Thank you in advance
Nicola
‎2006 Jan 10 12:45 PM
hi,
Look if this weblog gives you any help for creating a deep structure dynamic table.
/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table
Thanks,
Bhaskar
‎2006 Jan 10 12:46 PM
Hi Nicola,
maybe you could read the source code of Create_Dynamic_Table. In fact, SAP create a report, launch this report in memory and make a field-symbols on the table create in this report.
Maybe you could create your own program generator ?
Rgd
Frédéric
‎2006 Jan 10 3:50 PM
Bhaskar,
I've already found this weblog while searching the forum but I can't find a solution there for my problem.
Frédéric,
this will be a lot of work but might be a solution; I've checked the method - in the end is SAP creating a subroutine pool. But I'm sure that there must be an easier way to create a deep structure table.
Thanks for your replies!
Regards
Nicola
‎2006 Jan 10 3:59 PM
Just a question,
why do you need that ? maybe the solution is to change your requierement ?
two dynamic table couldn't be a solution ?
‎2006 Jan 10 4:20 PM
Hi Frédéric,
I hope my english is good enough to explain it correctly:
We use a function builder for SEM-BPS which copies data from one Cube to another. This Cube is transactional, so you can't easily read a structure out of DDIC.
The export parameter of this function builder is a table with type 'any table'.
Until today we used a fixed definition e.g.:
TYPES:
BEGIN OF xtyp_chas,
/sie/sr_ocomp TYPE /b52/oisr_ocomp,
/sie/ts_03psp TYPE /b52/oits_03psp,
0activity TYPE /bi0/oiactivity,
0acty_elemt TYPE /bi0/oiacty_elemt,
0costelmnt TYPE /bi0/oicostelmnt,
0co_area TYPE /bi0/oico_area,
0creditor TYPE /bi0/oicreditor,
0currency TYPE /bi0/oicurrency,
0curtype TYPE /bi0/oicurtype,
0db_cr_ind TYPE /bi0/oidb_cr_ind,
0fiscper TYPE /bi0/oifiscper,
0fiscper3 TYPE /bi0/oifiscper3,
0fiscyear TYPE /bi0/oifiscyear,
0metype TYPE /bi0/oimetype,
0network TYPE /bi0/oinetwork,
0part_actty TYPE /bi0/oipart_actty,
0part_cctr TYPE /bi0/oipart_cctr,
0piobjsv TYPE /bi0/oipiobjsv,
0project TYPE /bi0/oiproject,
0unit TYPE /bi0/oiunit,
0vtdetail TYPE /bi0/oivtdetail,
0vtstat TYPE /bi0/oivtstat,
0vtype TYPE /bi0/oivtype,
0bus_area TYPE /bi0/oibus_area,
0cashdetail TYPE /bi0/oicashdetail,
0cashtype TYPE /bi0/oicashtype,
0comp_code TYPE /bi0/oicomp_code,
0coorder TYPE /bi0/oicoorder,
0cs_dimen TYPE /bi0/oics_dimen,
0cs_unit TYPE /bi0/oics_unit,
0int_bus TYPE /bi0/oiint_bus,
0part_abcpr TYPE /bi0/oipart_abcpr,
0part_coord TYPE /bi0/oipart_coord,
0part_wbsel TYPE /bi0/oipart_wbsel,
0piovalue TYPE /bi0/oipiovalue,
0profit_ctr TYPE /bi0/oiprofit_ctr,
0ps_obj TYPE /bi0/oips_obj,
0statussys0 TYPE /bi0/oistatussys0,
zfbwheroj TYPE /bic/oizfbwheroj,
END OF xtyp_chas,
BEGIN OF xtyp_kyfs,
0amount TYPE /bi0/oiamount,
0quantity TYPE /bi0/oiquantity,
zf03oaws TYPE /bic/oizf03oaws,
zf03oqty TYPE /bic/oizf03oqty,
zf03ozsta TYPE /bic/oizf03ozsta,
END OF xtyp_kyfs,
BEGIN OF xtyp_zf03g003,
s_chas TYPE xtyp_chas,
s_kyfs TYPE xtyp_kyfs,
END OF xtyp_zf03g003,
xtyp_zf03g003_t TYPE HASHED TABLE OF xtyp_zf03g003
WITH UNIQUE KEY s_chas.
DATA: lt_ibm_data TYPE xtyp_zf03g003_t,
ls_ibm_data TYPE xtyp_zf03g003.
So one table (s_chas) contains the characteristics of the Cube and the other (s_kyfs) contains the keyfigures. That's exactly the format we need for the export parameter. At the end of the program, we use the following coding to fill the export table (eto_chas):
loop at lt_ibm_data into ls_ibm_data.
collect ls_ibm_data-s_chas into eto_chas.
endloop.
So in this moment I give this table the structure that is needed to move the data into the cube. I can't change the requirement because it is a standard interface.
I would like to change that coding to be dynamically. Because if somebody changes a charasteristic or a keyfigure in the cube, we would have to change the function builder too. I don't think that the SEM-BPS department will let us know every time they've changed something anyway.
So I hope that my explanation wasn't too confusing
Nicola
‎2006 Jan 12 9:57 AM
Hi Nicola,
I was little busy, but, I thought about your problem. Does this solution help you ? :
report ztestfg0003.
data : it_dyn_table1 type ref to data ,
it_dyn_table2 type ref to data ,
it_fieldcatalog type lvc_t_fcat ,
begin of is_pwet ,
t000 type ref to data ,
t001 type ref to data ,
end of is_pwet .
field-symbols : <it_t000> type standard table ,
<it_t001> type standard table ,
<it_pwet> type any.
* Get fieldcatalog of first table.
refresh it_fieldcatalog.
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = 'T000'
i_bypassing_buffer = 'X'
changing
ct_fieldcat = it_fieldcatalog.
* Create a dynamic internal table for T000.
call method cl_alv_table_create=>create_dynamic_table
exporting it_fieldcatalog = it_fieldcatalog
importing ep_table = is_pwet-t000.
assign is_pwet-t000->* to <it_t000>.
* Get fieldcatalog of second table.
refresh it_fieldcatalog.
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = 'T001'
i_bypassing_buffer = 'X'
changing
ct_fieldcat = it_fieldcatalog.
* Create a dynamic internal table for T001.
call method cl_alv_table_create=>create_dynamic_table
exporting it_fieldcatalog = it_fieldcatalog
importing ep_table = is_pwet-t001.
assign is_pwet-t001->* to <it_t001>.
* Set data into T000 / T001.
select *
into table <it_t000>
from t000.
select *
into table <it_t001>
from t001.
break siebec.
assign is_pwet to <it_pwet>.
Regards
Frédéric
‎2006 Jan 12 10:20 AM
Hi Frédéric,
thank you so much for your help, I've rewarded you points. I tried your solution and it works pretty well, the only problem I have is that I don't know how to move the data into my internal table eto_chas. Table contains the reference of the data not the data itself.
Again, many thanks
Nicola
‎2006 Jan 12 10:32 AM
Yes, <IT_PWET> contains reference, and you need to assign this reference to others field-symbols type standard table to be able to set data inside.
I try to find another solution, but, it's little hard
Fred
‎2007 Apr 26 3:37 PM
Hi All,
I am also having the similar requirement.
In my case, number of internal tables can be determined on runtime.
Please could you people help me out with the approach to be followed for this.
Thanks in advance.
Piyush