Reputation: 531
Error at modify table clause. What is wrong here. I suspect it has something to do with having a unique key- colb.
DATA : BEGIN OF line1,
cola TYPE i,
colb TYPE i,
END OF line1.
DATA mytable1 LIKE HASHED TABLE OF line1 WITH UNIQUE KEY colb.
DO 4 TIMES.
line1-cola = sy-index.
line1-colb = sy-index ** 2.
INSERT line1 INTO TABLE mytable1.
ENDDO.
line1-colb = 80.
**MODIFY TABLE mytable1 FROM line1 TRANSPORTING colb
where (colb > 2) and (cola < 5).**
LOOP AT mytable1 INTO line1.
WRITE :/ line1-cola, line1-colb.
ENDLOOP.
Error:
".", "ASSIGNING <fs>", "REFERENCE INTO data-reference", or "ASSIGNING
<fs> CASTING" expected after "COLB".
Note: Error line is in bold. The error is shown in red.
Upvotes: 0
Views: 4536
Reputation: 5564
@vwegert is right, you can't change the key values in HASHED and SORTED tables. On the other hand your error is syntactical. If you change:
MODIFY TABLE mytable1 FROM line1 TRANSPORTING colb where colb > 2 and cola < 5.
For
MODIFY mytable1 FROM line1 TRANSPORTING colb where colb > 2 and cola < 5. "'TABLE' word omitted
It is also a syntactical error, however, SAP will show you the error more clearly:
You cannot change the search key using "MODIFY". "COLB" is contained in the table key of "MYTABLE1".
Check the documentation. When specifying a condition (or including a 'WHERE') in 'MODIFY' statement you should not use the word 'TABLE'.
If you still want to modify the key field then change the internal table as 'STANDARD' like this:
DATA mytable1 LIKE STANDARD TABLE OF line1 WITH KEY colb.
Hope it helps.
Upvotes: 0
Reputation: 18493
This has been in the documentation for a very long time:
You may not use a key field as a TRANSPORTING field with HASHED or SORTED tables.
Upvotes: 1