Application Development 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: 

Syntax error in ABAP SELECT statement - OFFSET is invalid ( due to grammar)

mitko1994
Participant
3,680

Hello,

I have the following SELECT statement in a program that is used productively.

SELECT (lv_header_line) FROM (i_view) WHERE (lv_where) 
ORDER BY (lv_header_line) INTO CORRESPONDING FIELDS OF TABLE @<gt_data>
OFFSET @( lv_skip_pkg_cnt  * pkg_size ) UP TO @pkg_size ROWS.

Today I wanted to make a modification to the code, and was surpised to see that the initial source code

which is currently active, doesn't compile.

It throws a syntax error:

"OFFSET" is invalid here (due to grammar). contains an invalid character or it is a

I'm not sure what is causing it now, because the same syntax was correct a few months ago and allowed me to activate the program.

This syntax error is also now present in the rest of the BW systems in the landscape when I execute a check on the code.

Any ideas how to resolve it?

Thanks,

Dimitar

18 REPLIES 18

Sandra_Rossi
Active Contributor
0 Kudos
3,289

Formatting issue (<BR> everywhere). Best formatting:

SELECT (lv_header_line)
FROM (i_view)
WHERE (lv_where)
ORDER BY (lv_header_line) 
INTO CORRESPONDING FIELDS OF TABLE @<gt_data>
OFFSET @( lv_skip_pkg_cnt  * pkg_size ) 
UP TO @pkg_size ROWS.

mitko1994
Participant
0 Kudos
3,289

sandra.rossi, thanks for following up. I tried copying your suggested formatting of the statement without success. I had also tried that prior to posting the question here but forgot to mention it. Pretty printer didn't help either.

0 Kudos
3,289

Use unformatted paste (Ctrl+Shift+V)

mitko1994
Participant
0 Kudos
3,289

sandra.rossi, (Ctrl+Shift+V) doesn't do anything in ADT nor in the GUI ABAP editor.

0 Kudos
3,289

Please use the COMMENT button for comments, asking for complements, adding details, replying to a comment or a proposed solution or to the OP question, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.

0 Kudos
3,289

In SAP forum, use unformatted paste (Ctrl+Shift+V)

abo
Active Contributor
0 Kudos
3,289

When the GUI editor is in edit mode, copypasting will give these artifacts. Switching to display mode before copying fixes the issue.

mitko1994
Participant
0 Kudos
3,289

I fixed it

0 Kudos
3,289

How come ?

0 Kudos
3,289

This was referring to the formatting issue you pointed out initially. I still have the syntax error.

0 Kudos
3,289

Be careful when choosing between Answer and Comment ("I fixed it" is not a solution for your question). Moderators would like you to choose carefully to avoid intervening.

Sandra_Rossi
Active Contributor
3,289

This code compiles in ABAP version 7.57. If it doesn't compile on your system, it means you are using an old version.

FIELD-SYMBOLS <gt_data> TYPE table.
DATA(lv_header_line) = ``.
DATA(i_view) = ``.
DATA(lv_where) = ``.
DATA(lv_skip_pkg_cnt) = 0.
DATA(pkg_size) = 0.

SELECT (lv_header_line)
    FROM (i_view)
    WHERE (lv_where)
    ORDER BY (lv_header_line)
    INTO CORRESPONDING FIELDS OF TABLE @<gt_data>
    OFFSET @( lv_skip_pkg_cnt  * pkg_size )
    UP TO @pkg_size ROWS.

0 Kudos
3,289

Yes, that's true. We don't have 757 installed, but why did the code compile in the first place? I have this code active and running across the landscape.

0 Kudos
3,289

It's difficult to help if you just say you "don't have ABAP 7.57".

If you want to know why the code compiled in the first place, there could be many reasons, SAP notes, kernel, activation forced, etc., but nobody can say without details, so better ask SAP Support to connect to your system.

Evaristo
Explorer
0 Kudos
2,527

Hello

I'm having the same problem. 
SAP 740 SP24

Just trying to do this simple example:

SELECT FROM demo_expressions
           FIELDS id, num1 AS number, numlong1 AS result
           ORDER BY id, num1
           INTO TABLE @DATA(itab)
           OFFSET @o
           UP TO @n ROWS.

When try to activate I have this error message:
"OFFSET" is invalid here (due to grammar). contains an invalid character or it is a keyword. (It might be possible to escape it using !). Or a space is missing or there is one space too many.

If any one knows something please share.

0 Kudos
2,434

OFFSET is not supported in ABAP 7.40. See the ABAP 7.40 documentation.

0 Kudos
2,233

Hi Sandra
Thank you for your answer.
Yes, I did. I was in doubt how this is can be true.
Just confirmed.
Thank you.

0 Kudos
2,207

In the version 7.51 release documentation : New Addition OFFSET in SELECT