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

Operations on Hashed Internal tables

Former Member
0 Likes
2,831

Hello,

If I want to add a few rows to a hashed internal table, is it not possible at all?

INSERT and APPEND are not allowed on hashed internal tables.

Has anybody faced a similar problem?

What I want to do is..

LOOP AT hashed_inttable into wa where a = b.

APPEND wa TO another_hashed_inttable."[APPEND not allowed]

ENDLOOP.

Cheers

Anoop.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,903

Hi Anoop,

Append definitely cant be used with hashed tables.

You need to use "insert" statement to insert records into ur hashed internal table.

For insert you need to use the following syntax..

INSERT <WA> INTO <b>TABLE</b> <ITAB>, as somebody pointed out.. The table keyword is important here. I think u wud have forgotten the Table keyword in your syntax.

Kinldy reward points to the reply that answered ur question, and close the thread if u have no other issues.

Prabhu.

Hello,

If I want to add a few rows to a hashed internal table, is it not possible at all?

INSERT and APPEND are not allowed on hashed internal tables.

Has anybody faced a similar problem?

What I want to do is..

LOOP AT hashed_inttable into wa where a = b.

APPEND wa TO another_hashed_inttable."[APPEND not allowed]

ENDLOOP.

Cheers

Anoop.

9 REPLIES 9
Read only

Former Member
0 Likes
1,903

Hi Anoop,

I think u can use INSERT command.Just try it.

TYPES: BEGIN OF LINE,

COL1,

COL2,

END OF LINE.

DATA: WA TYPE LINE,

ITAB TYPE HASHED TABLE OF LINE WITH UNIQUE KEY COL1,

KEY(4) VALUE 'COL1'.

WA-COL1 = 'X'. INSERT WA INTO TABLE ITAB.

WA-COL1 = 'Y'. INSERT WA INTO TABLE ITAB.

Hope this helps u.

Thanks&Regards,

Ruthra.R

Message was edited by: Ruthra

Read only

0 Likes
1,903

Hello Ruthra,

I've tried INSERT, INSERT with INDEX , APPEND.

None of them are allowed.

Thanks & Regards,

Anoop.

Read only

0 Likes
1,903

Hi Anoop,

U can't do index operation in Hashed Internal table.U can insert the values with out index.

With Regards,

Ranganathan

Read only

0 Likes
1,903

Hi ,

Insert command will work on HASHED tables on Key access.

Try with below code...

REPORT zhashtable_test .

TYPES :

BEGIN OF t_city,

city TYPE sgeocity-city,

country TYPE sgeocity-country ,

latitude TYPE sgeocity-latitude,

END OF t_city,

t_city_list TYPE HASHED TABLE OF t_city WITH UNIQUE KEY city country.

DATA : wa_itab TYPE t_city,

city_list TYPE t_city_list.

wa_itab-city = 'Coimbatore'.

wa_itab-country = 'INDIA'.

wa_itab-latitude = '150'.

INSERT wa_itab INTO TABLE city_list .

Read only

0 Likes
1,903

Hi, As far as I know you cannot add rows to a hashed table from within a loop structure. This is because the hash has to be calculated and with that the order of the rows can change which gives you an unreliable loop result.

Sometimes you can make a copy of the table which you use for looping while adding records to the "desired table".

Message was edited by: Bas Jansen

Read only

Former Member
0 Likes
1,903

Hi Anoop,

You cannot use index operation in HASHED table.

Use INSERT <WA> INTO TABLE <HAS_ITAB>.

Hashed tables

This is the most appropriate type for any table where the main operation is key access. You cannot access a hashed table using its index. The response time for key access remains constant, regardless of the number of table entries. Like database tables, hashed tables always have a unique key. Hashed tables are useful if you want to construct and use an internal table which resembles a database table or for processing large amounts of data.

Hope it helps u.

Thanks & Regards,

Ruthra.R

Read only

0 Likes
1,903

may be post your code then we can check where the issue is

Regards

Raja

Read only

Former Member
0 Likes
1,904

Hi Anoop,

Append definitely cant be used with hashed tables.

You need to use "insert" statement to insert records into ur hashed internal table.

For insert you need to use the following syntax..

INSERT <WA> INTO <b>TABLE</b> <ITAB>, as somebody pointed out.. The table keyword is important here. I think u wud have forgotten the Table keyword in your syntax.

Kinldy reward points to the reply that answered ur question, and close the thread if u have no other issues.

Prabhu.

Read only

Former Member
0 Likes
1,903

Anoop,

More than just this, there r a lot of dos and dont's with a hashed table... u need to be extremely careful when using a hashed table. read the sap docu on this to understand thsi clearly.

Reward suitable points if thsi post answered ur question.

Rgds,

Prabhu.