‎2009 Mar 11 10:15 AM
Hi
i have this problem
types : begin of stru,
workcenter type /bi0/oiworkcenter,
end of stru.
data:
tb_work1 type hashed table of stru with key workcenter,
tb_work2 type hashed table of stru with key workcenter.
But this code generate an error.
why?
‎2009 Mar 11 10:21 AM
‎2009 Mar 11 10:21 AM
Use Addition Unique key
Data: Itab like Hashed table of stru with Unique key workcenter.
Hashed table has to be declared with unique key.It will only have unique key entries
Regards,
Gurpreet
‎2009 Mar 11 10:28 AM
this is my error
You cannot use explicit or implicit index operations on tables with
types "HASHED TABLE" or "ANY TABLE". "TB_WORKGOOD_EP" has the type
"HASHED TABLE".
‎2009 Mar 11 10:34 AM
Index operation is not Possible with HASHED table.Only key operation is possible
Check in your code you have used INDEX to access data from hashed internal table.
Ex:
Delete itab index 5. " Not possible with Hashed table.
[ Hashed table|http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb35de358411d1829f0000e829fbfe/content.htm]
Regards,
Gurpreet
‎2009 Mar 11 2:53 PM
When I type in your code, I get the error:
"Use UNIQUE when declaring internal tables of type HSAHS for specification of the key type". Which means exactly what it says. You're not using the correct syntax for defining a table - you should declare the tables as:
TYPES : BEGIN OF stru,
workcenter TYPE /bi0/oiworkcenter,
END OF stru.
DATA:
tb_work1 TYPE HASHED TABLE OF stru WITH UNIQUE KEY workcenter,
tb_work2 TYPE HASHED TABLE OF stru WITH UNIQUE KEY workcenter.Now, the error you say your getting isn't related to the code you've pasted. Why not paste the code that has that problem.
( As an aside, I wouldn't declare the tables like that anyway - I'd use tb_work1 TYPE HASHED TABLE OF /bi0/oiworkcenter WITH UNIQUE KEY table_line. )
matt
‎2009 Mar 11 3:03 PM
> Delete itab index 5. " Not possible with Hashed table.
not necessary .... hash is fast.
@Matt
I see no advantage in your recommendation, it is adviable to define a structure which can be used as
a workarea.
Really advisable is the definition in the dictionary.
Siegfried
‎2009 Mar 11 3:27 PM
>
> @Matt
> I see no advantage in your recommendation, it is adviable to define a structure which can be used as
> a workarea.
Clarity, really. A structure with one element seems to me to be an unnecessary complication. For example:
FIELD-SYMBOLS: <l_workcenter> TYPE /bi0/oiworkcenter.
LOOP AT th_workcenter ASSIGNING <l_workcenter>.
" Do something with <l_workcenter>.seems to me more semantically obvious than:
FIELD-SYMBOLS: <ls_workcenter> TYPE workcenter_structure.
LOOP AT th_workcenter ASSIGNING <ls_workcenter>.
" Do something with <ls_workcenter>-workcenter.
‎2009 Mar 13 1:35 PM
You can use the following declaration.
Here you have an advantage of using stru as work area.
DATA: BEGIN OF stru,
workcenter TYPE /bi0/oiworkcenter,
END OF stru,
tb_work1 TYPE HASHED TABLE OF stru WITH UNIQUE KEY workcenter,
tb_work2 TYPE HASHED TABLE OF stru WITH UNIQUE KEY workcenter.