Application Development 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: 

how to change ITAB created with CL_ABAP_TABLEDESCR from hashed to std

Former Member
0 Kudos

Hello xperts,

Ive created an ITAB (copy from another table) over the statements:

" Create instances of dynamic structure and dynamic internal table

go_sdescr_new = cl_abap_structdescr=>create( P_COMPONENTS = gt_components p_strict = abap_false ).

go_tdescr = cl_abap_tabledescr=>create( go_sdescr_new ).

" Create data refence followed by table creation

CREATE DATA gdo_handle TYPE HANDLE go_tdescr.

ASSIGN gdo_handle->* TO <gt_itab_BCCMP07>.

Unfortunately it is hashed and now I need to change it to a standard table, but cant figure out the syntax.

Any ideas?

1 ACCEPTED SOLUTION

MarcinPciak
Active Contributor
0 Kudos

By default method cl_abap_tabledescr=>create(...) generates standard table, unless specified differently.

How do you know this generates hashed table? I suggest to check it like


case go_tdescr->TABLE_KIND.
when cl_abap_tabledescr=>TABLEKIND_STD.
   "your table is standard table
when cl_abap_tabledescr=>TABLEKIND_HASHED.
   "it is hashed one
endcase.

Regards

Marcin

5 REPLIES 5

MarcinPciak
Active Contributor
0 Kudos

By default method cl_abap_tabledescr=>create(...) generates standard table, unless specified differently.

How do you know this generates hashed table? I suggest to check it like


case go_tdescr->TABLE_KIND.
when cl_abap_tabledescr=>TABLEKIND_STD.
   "your table is standard table
when cl_abap_tabledescr=>TABLEKIND_HASHED.
   "it is hashed one
endcase.

Regards

Marcin

0 Kudos

Marcin,

thanks for your answer.

The reason for assuming it to be a hashed table is that the statement:

read table <gt_itab_BCCMP07> with table key

('0INFOPROV') = 'BCCMP07'

('0CALMONTH2') = <f_calmon2_ref>

('0CALYEAR') = <f_calyear_ref>

('BHFACTOR0') = <f_bhfactor0_ref>

('BHFUNCAG0') = <f_bhfuncag0_ref>

('BHPRODAP0') = <f_bhprodap0_ref>

('BHPSTEP0') = <f_bhpstep0_ref>

('BHSPC0') = <f_bhspc0_ref>

('BHVERSI0') = <f_bhversi0_ref>

('BLCUSTNO0') = <f_blcustno0_ref>

assigning <f_interim_data>.

Causes a dump which says:

Incomplete key specification when accessing a key table

An internal table was defined as a key table for quick direct access.

When a table of this type is accessed with "READ/DELETE ... WITH TABLE

KEY k1 = v1 ... kn = vn", the key specification "k1 = v1 ... kn = vn"

must contain values for precisely those fields k1, ... kn that are

listed in the table declaration.

In this particular case, the value for the component "0FISCVARNT" was missing

in

the key specification for the table "<GT_ITAB_BCCMP07>".

.....

I did as you suggested and indeed it is NOT a hashed table.

Why does it dump if it is a standard table???

0 Kudos

Martin,

The reason why you get dump is because you don't fully provide KEY of the table. When you use with table key all key fields must be listed. Dump says you have not listed this one '0FISCVARNT'.

If you don't want to provide it simply use with key instead of with table key . Here you can query any fields you want.

Regards

Marcin

0 Kudos

oh Im so stupid! ... you know the expression:

cant see the forest because all the trees ??? that's what happened to me.

BUT I am still curious to know the answer of my first question:

is there a way to change the table kind from standard to hashed???

0 Kudos

oh Im so stupid! ... you know the expression:

cant see the forest because all the trees ??? that's what happened to me.

is there a way to change the table kind from standard to hashed???

Assuming you have some already generated HASHED table, the only approach I see on this is gettting its line type -> from returned structure get all components with method get_components -> use these components to generated new standard table (as you did). So this is rather generating new STANDARD based on old HASHED then changing the original.

Regards

Marcin