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

Please help

Former Member
0 Likes
4,750

Hi,

I want to add records to a hashed table.

my code is:

data: ipn_pc_zoba type hashed table of tpn_pc_zoba with unique key vbeln,

wpn_pc_zoba like line of ipn_pc_zoba.

loop at izoba into wzoba.

clear wpn_pc_zoba .

read table ipn_pc_zoba into wpn_pc_zoba with key vbeln = wzoba-LS_KDAUF.

if sy-subrc ne 0.

wpn_pc_zoba-vbeln = wzoba-LS_KDAUF.

append wpn_pc_zoba to ipn_pc_zoba.

endif.

endloop.

The Error is : You cannot use explicit or implicit index operations on tables with types "HASHED TABLE" or "ANY TABLE". "IPN_PC_ZOBA" has the type "HASHED TABLE". It is possible that .

I TRIED WITH INSERT INSTEAD OF APPEND BUT STILL IT IS NOT WORKING.

How to write the code to solve this?

Please reply ASAP.

Regards,

SRI

6 REPLIES 6
Read only

Former Member
0 Likes
1,846

use collect in place of insert or Append.

may be it will helpful for u

Read only

Former Member
0 Likes
1,846

I'm not sure you can modify a HASHed table. I would be possible to copy to a STANDARD table and then reload the HASHed table from it.

From SAP Docs


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. 

More...


When working with single table lines, we must distinguish between the operators that are possible for all table types, and those that are only possible with index tables. Index tables (standard and sorted tables) have an internal index, making linear access possible. Hashed tables have no linear index. Consequently, only key access is possible. The operations that are permitted for all table types do not use indexes. They can also be used in procedures or with field symbols , where the internal table type is not fully typed. These operations are known as generic operations. 

The statements used to access lines of any type of table differ from those used to access index tables mainly through the TABLE addition following the corresponding keyword. For example, you would use MODIFY to change lines in index tables, but MODIFY TABLE to change lines in any type of table. 

Read only

Former Member
0 Likes
1,846

HI,

You can only access a hashed table using the generic key operations or other generic operations ( SORT, LOOP, and so on). Explicit or implicit index operations (such as LOOP ... FROM oe INSERT itab within a LOOP) are not allowed.

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
1,846

You can use the operatin MODIFY TABLE <internal_table> FROM <structure>... this is because the hash has to be computed

Read only

Former Member
0 Likes
1,846

Hi,

try this way

TYPES: BEGIN OF idline,

id TYPE i,

END OF idline.

DATA: lt_name_keys TYPE HASHED TABLE OF idline WITH UNIQUE KEY id,

ls_name_key LIKE LINE OF lt_name_keys.

ls_unique_name_key-id = 1.

INSERT ls_name_key INTO TABLE lt_name_keys

Thanks & regards.

Read only

0 Likes
1,846

Note the date of the OP

Rob