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
0 Kudos

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

14 REPLIES 14

Sandra_Rossi
Active Contributor
0 Kudos

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

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

Use unformatted paste (Ctrl+Shift+V)

mitko1994
Participant
0 Kudos

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

0 Kudos

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

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

abo
Active Contributor
0 Kudos

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

I fixed it

0 Kudos

How come ?

0 Kudos

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

0 Kudos

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
0 Kudos

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

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

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.