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 structure creation failure for only some structures.

Former Member
0 Likes
523

I have some code to dynamically create a structure and table based on some sap how to... documentation. It works perfectly for a number of structures but fails on the structure I wish to create.

'l_c_cube_write' in the code is the variable that defines which structure. This code is in BW, if I have an InfoCube YINFOCUBE then the code should create a structure and table based on structure /BIC/VYINFOCUBE2.

This code works fine when based on structure /BIC/VYINFOCUBEI but fails when based on structure /BIC/VYINFOCUBE2. These structures are generated for each InfoCube created in BW.

Looking at the two structure definitions in SE11 there are a few differences but it is not clear to me if these differences are causing the error.

Does anyone know why the error occurs and whether there is a way to avoid it.

The code is as follows.

data:

l_c_cubestruct type string,

l_r_cubestrudesc type ref to cl_abap_structdescr,

l_r_cubedatadesc type ref to cl_abap_tabledescr,

l_v_cubedatastru type ref to data,

l_v_cubedatatabl type ref to data,

l_v_cubecomp type cl_abap_structdescr=>component_table,

l_c_comp type string.

field-symbols:

<l_fs_anytabl> type standard table,

<l_fs_anystru> type any.

  • no need to dynamically create data object as the program is created dynamically

  • concatenate '/BIC/V' l_c_cube_write 'I' into l_c_cubestruct. "this works

concatenate '/BIC/V' l_c_cube_write '2' into l_c_cubestruct. "this does not

l_r_cubestrudesc ?= cl_abap_structdescr=>describe_by_name( l_c_cubestruct ).

l_v_cubecomp = l_r_cubestrudesc->get_components( ).

l_r_cubestrudesc = cl_abap_structdescr=>create( l_v_cubecomp ).

l_r_cubedatadesc = cl_abap_tabledescr=>create( l_r_cubestrudesc ).

create data l_v_cubedatastru type handle l_r_cubestrudesc.

create data l_v_cubedatatabl type handle l_r_cubedatadesc.

  • create a data object for the datapackage and the dataackage structure

assign l_v_cubedatastru->* to <l_fs_anystru>.

assign l_v_cubedatatabl->* to <l_fs_anytabl>.

Differences between structures:

The structure that fails also includes components 0INFOPROV and 1ROWCOUNT.

The structure that fails has components in the format 0MATERIAL, 0CALMONTH, etc. The structure that does not fail has components in the format MATERIAL, CALMONTH, etc.

2 REPLIES 2
Read only

Former Member
0 Likes
431

Should anyone else have the same problem it appears that it is not possible to dynamically create work area's and tables with field names that begin with 0 using a component list.

If I simply append a '_' character to the begining of the field name in the components list the work area and table can be created dynamically without problem.

Not exactly what I required but a work around non-the-less.

Read only

matt
Active Contributor
0 Likes
431

I encountered the above problem recently. It is a pain because it means you can't use MOVE-CORRESPONDING.

It's also not possible to define a structure statically with components beginning with numbers - though it is ok in the data dictionary.

e.g.

TYPES: BEGIN OF my_struc,
         0COMPONENT TYPE...
       END OF MY_struc.

Seems to me to be rather inconsistent!

matt