0

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.
1
  • 2
    What is the error message you're getting, and what part of it don't you understand? It should be pretty obvious. Commented Aug 4, 2015 at 13:22

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I changed my code to : MODIFY TABLE mytable1 FROM line1 TRANSPORTING cola where (colb > 2) and (cola < 5). however, the error persists.
0

@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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.