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

Error in creating dynamic structure?

satish_kumar127
Participant
0 Likes
1,602

Hi Guys,

i'm getting  an error while creating a structure from components.

   lo_struct ?= cl_abap_typedescr=>describe_by_name( 'TY_FINAL' ).

   lt_comp  = lo_struct->get_components( ).

   APPEND LINES OF lt_comp TO lt_tot_comp.

   LOOP AT it_ztqm_unit_hygien INTO wa_ztqm_unit_hygien.

    la_comp-name = wa_ztqm_unit_hygien-zarea.

     lo_element ?= cl_abap_elemdescr=>describe_by_data( lv_zhygiene_score ).

     la_comp-type = cl_abap_elemdescr=>get_p( p_length   = lo_element->length

                       p_decimals = lo_element->decimals ).

     APPEND la_comp TO lt_tot_comp.

     CLEAR: la_comp, wa_ztqm_unit_hygien.

   ENDLOOP.

   lo_new_type = cl_abap_structdescr=>create( p_components lt_tot_comp     //  this is the place where i'm getting error

                                               p_strict = space  ).                              

   lo_new_tab = cl_abap_tabledescr=>create(

                   p_line_type  = lo_new_type

                   p_table_kind = cl_abap_tabledescr=>tablekind_std

                   p_unique     = abap_false ).

   CREATE DATA lo_data TYPE HANDLE lo_new_tab.

   ASSIGN lo_data->* TO <table>.

I'm getting the following error..

Component Name 'BOILER HOUSE' of the Component 6 Contains an Invalid Character

I'm having the components like "xxx,yyy  "  , " LAB." , " RM & PM STORE" , "WASTE STORAGE YARD".

Does somebody have an idea how to slove this.


Thanks in Advance


Regards


satish

5 REPLIES 5
Read only

deependra_shekhawat3
Contributor
0 Likes
1,040

Hi Satish,

Please elaborate something more in your example like what do you have in it_ztqm_unit_hygien.

And also tell me data type of  lv_zhygiene_score .

Thanks

Deependra

Read only

Former Member
0 Likes
1,040

Hi,

And what "error" do you get?

Don't you have any space in some component name?

Br,

Manu.

Edit: Didn't read your post completely Please remove the spaces in your component name...

e.g: "WASTE_STORAGE_YARD" and no "WASTE STORAGE YARD".

Read only

Former Member
0 Likes
1,040

Hi Satish,

have you checked these links below?

Btw, you likely use incorrect component name. In order to check where the error is you are to go to the method CL_ABAP_STRUCTDESCR=>CREATE( ). You will see the method  CHECK_COMPONENT_TABLE( ) inside. It checks for the correct component names of the structure you use. It seems to me your case is here: line 85


if comp-name+off cn 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789#$%&*-/;<=>?@^{|}'.
*        illegal character in component name
          raise exception type CX_SY_STRUCT_COMP_NAME
            exporting textid = CX_SY_STRUCT_COMP_NAME=>illegal_char_in_name
                      component_name = comp-name
                      component_number = comp_no.

endif.

But you can put a break point inside and check by your own.

Regards,

Aliaksei

Read only

satish_kumar127
Participant
0 Likes
1,040

Hi deependra,

My internal table is having the following values

Area                                                 Hygiene Score

_____                                                ___________

ADMIN.67.00
BOILER HOUSE97.00
BOTTLING78.00
BREW HOUSE78.00
EMPTY BOTTLE YARD67.00
ETP67.00
FERMENTATION,LAGERING, UNITANK87.00
FILTERATION AND BBT80.00
FUEL STORAGE AREA80.00
LAB.98.00
MALT FEEDING86.00
RM & PM STORE96.00
TOILET100.00
UTILITIES56.00
WAREHOUSE87.00
WASTE STORAGE YARD89.00
WTP67.00

lv_hygiene_score type is Decimal.

Regards

satish

Read only

0 Likes
1,040

Hi,

Have you tried what I suggested.... no empty space in components names

Manu.