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 internal table problem

Former Member
0 Likes
686

Hi All,

my requirement is i should calculate the variance and should display. and also in the result display i should provide 17 buttons (represents fields in a table). when the user clicks any button it should include that field and should calculate variance again and should display the result.

iam able to create the dynamic internal table and able to display using the following method

cl_alv_table_create=>create_dynamic_table (this method is creating quan field having 17 with 3 decimals with P(16) 3 decimals)

but the problem is it is going to dump(generate subroutine directory full) some where around 14th button since there are 17 buttons

i didnt use the below method

lo_new_type = cl_abap_structdescr=>create( lt_tot_comp ).

*

  • 4. New Table type

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 ).

above method is creating the quan field with P(9) 3 decimels but the field which i have to create has QUAN 17 with 3 decimals.

Can anyone help me regarding the above.

4 REPLIES 4
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
642

Hello,

How are you populating the components table LT_TOT_COMP? This is what you should be doing:


    TRY .
        lo_elemdescr =
          cl_abap_elemdescr=>get_p( p_length = 16 p_decimals = 3 ).
      CATCH cx_parameter_invalid_range.
        RAISE ex_dyntab_creation_falied.
    ENDTRY.

    lwa_struc_comp-name = gc_profile_heading-col3.
    lwa_struc_comp-type = lo_elemdescr.
    APPEND lwa_struc_comp TO lt_struc_comp.
    CLEAR: lwa_struc_comp-name.

My suggestion to you is while dealing with dynamic tables, structure make use of the RTTC classes.

CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE use the GENERATE SUBROUTINE POOL method to create the dynamic tables. SAP doesn't recommend using this technique,

... GENERATE SUBROUTINE POOL should only be used in exceptional cases in application programs. ABAP offers many other methods for dynamic programming, which generally render the creation of source code unnecessary (see the list under processing dynamic programs) ...

BR,

Suhas

Read only

Former Member
0 Likes
642

Hi Suhas,

I have written the code in the following way

TYPES: BEGIN OF ty_kstar,

/BIC/GPRODGRP TYPE /BIC/OIGPRODGRP,

/BIC/ZOGORDDMD type /BIC/AZDPLAWEK00-/BIC/ZOGORDDMD, " QUAN field with 17 and 3 decimals

/BIC/ZSTATFCST type /BIC/AZDPLAWEK00-/BIC/ZSTATFCST, " QUAN field with 17 and 3 decimals

/BIC/ZENCHFCST TYPE /BIC/AZDPLAMON00-/BIC/ZENCHFCST, " QUAN field with 17 and 3 decimals

/BIC/ZUCTDMD TYPE /BIC/AZDPLAMON00-/BIC/ZUCTDMD, " QUAN field with 17 and 3 decimals

END OF ty_kstar.

START-OF-SELECTION.

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

lt_comp = lo_struct->get_components( ).

APPEND LINES OF lt_comp TO lt_tot_comp.

lo_new_type = cl_abap_structdescr=>create( lt_tot_comp ).

*

  • 4. New Table type

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 ).

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
642

Hello Shankar,

Looks like there is a limitation while creating TYPE p elements having Length > 16 in the runtime using RTTC classes!

If you want to use the RTTC classes you need to use this workaround:


  FIELD-SYMBOLS <lwa_comp>  TYPE cl_abap_structdescr=>component.

  lo_struct ?= cl_abap_typedescr=>describe_by_name( 'TY_KSTAR' ).
  lt_comp = lo_struct->get_components( ).

  LOOP AT lt_comp ASSIGNING <lwa_comp>
    WHERE name = '/BIC/ZOGORDDMD' OR
          name = '/BIC/ZSTATFCST' OR
          name = '/BIC/ZENCHFCST' OR
          name = '/BIC/ZUCTDMD'.
    CLEAR <lwa_comp>-type.
    TRY .
        <lwa_comp>-type =
          cl_abap_elemdescr=>get_p( p_length = 16 p_decimals = 3 ).
      CATCH cx_parameter_invalid_range.
    ENDTRY.
  ENDLOOP.

  APPEND LINES OF lt_comp TO lt_tot_comp.

Let me know if you've any questions.

BR,

Suhas

PS: I remember using this workaround myself

Read only

Former Member
0 Likes
642

Thanks for providing the useful information which is helpful