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

Failure in creating a dynamic structure

Former Member
0 Likes
1,262

Hi Guys,

i get a strange failure while creating a structure from components.

lr_out_tab ?= cl_abap_tabledescr=>describe_by_data( it_outtab ).

lr_out_struc ?= lr_out_tab->get_table_line_type( ).

lt_out_comp = lr_out_struc->get_components( ).

lr_new_struc = cl_abap_structdescr=>create( lt_out_comp ). <-- cx_sy_struct_comp_name exception

I get this failure, when i have component-names like xxx-yyyy. Does somebody have an idea how to slove this.

Greetings

André

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
742

Hello Andre,

You're getting the error message because the param P_STRICT of the method CREATE( ) is set to TRUE(by default).

If you set the creation mode as "strict"(P_STRICT = CL_ABAP_STRUCTDESCR=>TRUE), no special characters are allowed in the column names! Since your component names contain a '-' you're getting the exception CX_SY_STRUCT_COMP_NAME.

If you set the creation mode as "non-strict"(P_STRICT = CL_ABAP_STRUCTDESCR=>FALSE), following spl. characters are allowed:

#$%&*-/;<=>?@^{ | }

So in your call you need to set the "non-strict" mode while creating the dynamic structure:

*   Get the Dynamic structure definition
    TRY.
        lo_structdescr =
          cl_abap_structdescr=>create(
              p_components = lt_struc_comp
              p_strict     = cl_abap_structdescr=>false ).
      CATCH cx_sy_struct_creation .                     "#EC NO_HANDLER
    ENDTRY.

Hope i'm clear.

BR,

Suhas

PS: Check the source code of CREATE( ) if you want to validate

Hi Guys,

i get a strange failure while creating a structure from components.

lr_out_tab ?= cl_abap_tabledescr=>describe_by_data( it_outtab ).

lr_out_struc ?= lr_out_tab->get_table_line_type( ).

lt_out_comp = lr_out_struc->get_components( ).

lr_new_struc = cl_abap_structdescr=>create( lt_out_comp ). <-- cx_sy_struct_comp_name exception

I get this failure, when i have component-names like xxx-yyyy. Does somebody have an idea how to slove this.

Greetings

André

1 REPLY 1
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
743

Hello Andre,

You're getting the error message because the param P_STRICT of the method CREATE( ) is set to TRUE(by default).

If you set the creation mode as "strict"(P_STRICT = CL_ABAP_STRUCTDESCR=>TRUE), no special characters are allowed in the column names! Since your component names contain a '-' you're getting the exception CX_SY_STRUCT_COMP_NAME.

If you set the creation mode as "non-strict"(P_STRICT = CL_ABAP_STRUCTDESCR=>FALSE), following spl. characters are allowed:

#$%&*-/;<=>?@^{ | }

So in your call you need to set the "non-strict" mode while creating the dynamic structure:

*   Get the Dynamic structure definition
    TRY.
        lo_structdescr =
          cl_abap_structdescr=>create(
              p_components = lt_struc_comp
              p_strict     = cl_abap_structdescr=>false ).
      CATCH cx_sy_struct_creation .                     "#EC NO_HANDLER
    ENDTRY.

Hope i'm clear.

BR,

Suhas

PS: Check the source code of CREATE( ) if you want to validate