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

ABAP Syntax error in this code - Could anyone help?

former_member195355
Participant
0 Likes
4,995

Hi,

I have this code which runs fine in our non-unicode SAP system.


REPORT  ECC5_OFFSETS.

DATA: W_KONV TYPE KONV.

DATA: TKOMK LIKE STANDARD TABLE OF KOMK
                 WITH KEY KEY_UC
                 INITIAL SIZE 2
                 WITH HEADER LINE.

DATA: TKOMK2 type STANDARD TABLE OF KOMK
                 WITH KEY KEY_UC
                 INITIAL SIZE 2.

* Get some test data
SELECT SINGLE * INTO W_KONV FROM  KONV
       WHERE  KNUMV  = '0000000061'.

MOVE-CORRESPONDING W_KONV TO TKOMK.
APPEND TKOMK.
tkomk2[] = TKOMK[].

* Original non-Unicode compliant code
DATA: LENGTH_KEY_TKOMK(3) TYPE P.

FIELD-SYMBOLS: <TKOMK_KEY> like TKOMK2.

DESCRIBE DISTANCE BETWEEN TKOMK-MANDT AND TKOMK-SUPOS
          INTO LENGTH_KEY_TKOMK
* ( Original Unicode syntax fix! )
          IN BYTE MODE.

* Copy all the fields between these two into TKOMK_KEY field-symbol.
* ( In Unicode this assignment fails, causing short dump at read )
ASSIGN TKOMK2(LENGTH_KEY_TKOMK) TO <TKOMK_KEY>.
* Read the current record.
READ TABLE TKOMK2 WITH KEY <TKOMK_KEY>.

But I get the following error message in our UNICODE complaint SAP system:

<b>"<TKOMK_KEY>" cannot be a table, a reference, a string, or contain any of these objects.</b>

Does anyone know how I could get around this/suggest a solution?

Thanks in advance!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,486

Try this:

<b>FIELD-SYMBOLS: <TKOMK_KEY> TYPE TABLE.</b>

8 REPLIES 8
Read only

Former Member
0 Likes
2,487

Try this:

<b>FIELD-SYMBOLS: <TKOMK_KEY> TYPE TABLE.</b>

Read only

0 Likes
2,486

Hi Sam,

I tried your suggestion and the exact same error came up

Any other ideas...

Read only

0 Likes
2,486

Ok...the problem is in this line:

<b>READ TABLE tkomk2 WITH KEY <tkomk_key>.</b>

You have to do:

READ TABLE tkomk2 WITH KEY fieldname = somevalue.

Read only

0 Likes
2,486

Hi Sam,

Yep that's as far as I got. This code works fine in 4.6b but in ECC5, that line you mentioned failes the syntax check.

The only reason why I don't waht to do what you suggest is becasue I'll have to code each of the 283 fields that it currently uses in the read!

I was hoping that there would be an easier way to do the same thing...

Any other ideas...?

Read only

0 Likes
2,486

Can you please explain what is your exact requirement?

Read only

0 Likes
2,486

Hi,

Sorry if I'm being unclear.

My requirements are twofold:

1)the line of code:

ASSIGN TKOMK2(LENGTH_KEY_TKOMK) TO <TKOMK_KEY>

does not assign anything to the fields symbol <TKOMK_KEY>

2)The read statement does not like the fields symbol <TKOMK_KEY> being used as a key.

Both these bits of code worked in our 4.6b system but now in the ECC5 environemtn I get syntax errors.

Let me know if you need anything else!

Read only

0 Likes
2,486

Do this change in your code:


DATA: tkomk2 TYPE STANDARD TABLE OF komk
                 WITH KEY key_uc
                 INITIAL SIZE 2
                 <b>WITH HEADER LINE</b>.

Read only

former_member183804
Active Contributor
0 Likes
2,486

The solution is to type the Field-Symbol with the table type:


FIELD-SYMBOLS: <TKOMK_KEY> like line of TKOMK2.

Best Regards

Klaus