Skip to Content
0

ABAP Dynamic where statement with table of ranges

Feb 12 at 06:02 PM

156

avatar image
Former Member

I am building a dynamic where statement (inside a share method) that could have 0 to N sub statements. So I have coded ABAP to fill a table of tables of ranges. Then I want the where statement to refer to one of the rows in the top level table.

The problem is that the dynamic where is giving an error " An error has occurred while parsing a dynamic entry." Any ideas how to write a dynamic where statement where the variables reference the index of a table?

Here is the where statement:

( ( ( ( ( ( LOGDATE in @LR_WHERE[ 1 ] ) and ( LOGDATE in @LR_WHERE[ 2 ] ) ) and ( PLANT in @LR_WHERE[ 3 ] ) )

LR_Where is a Table Type /IWBEP/T_COD_SELECT_OPTIONS which is a table type

/IWBEP/S_COD_SELECT_OPTION which is a range (Sign, Option, Low, High).

Any help would be greatly appreciated.

10 |10000 characters needed characters left characters exceeded
Former Member

So I've tried a simplified version, here are the ones I've tried. Reminder LR_where is a Table of range tables.

PLANT in @LR_WHERE[3]

PLANT in @LR_WHERE[ 3 ]

PLANT in @(LR_WHERE[3])

PLANT in @( LR_WHERE[3] )

PLANT in @( LR_WHERE[ 3 ] )

I am still getting "An error has occurred while parsing a dynamic entry."

0

Please do a very small report with your code (so, the relevant parts only, of course), and post it so that we can copy/paste it, and correct it for you.

0
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
avatar image
Former Member Feb 20 at 10:49 PM
0

It looks like you are not able to reference an index of a table in a where statement. So I ended up having to do this:

( ( ( ( ( ( LOGDATE in @LR_01 ) and ( LOGDATE in @LR_02 ) ) and ( PLANT in @LR_03 ) )

Not ideal but you do what you have to.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

I found the reference in the ABAP documentation why LOGDATE IN @( LR_WHERE[ 3 ] ) is not permitted (@( ... ) is called a host expression):

https://help.sap.com/http.svc/rc/abapdocu_752_index_htm/7.52/en-US/index.htm?file=abenopen_sql_host_expressions.htm

  • The operand positions for host expressions are the following reading positions:
  • Right sides of SQL conditions (except LIKE and IN).
0
Horst Keller
Feb 15 at 06:36 AM
2

Tipp: First write it statically to see the syntax errors, then transfer to the dynamic token.

Share
10 |10000 characters needed characters left characters exceeded
Jacques Nomssi Feb 12 at 07:38 PM
1

1) you should be able to use a single clause for all those entries, e.g. LOGDATE IN @LR_WHERE if LR_WHERE is a range table.

2) check if open and close parenthesis match

JNN

Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member
I tried both of these statements and get the same error :-(.
  • ( ( ( LOGDATE in @( LR_WHERE[ 1 ] ) ) and ( LOGDATE in @( LR_WHERE[ 2 ] ) ) ) and ( PLANT in @( LR_WHERE[ 3 ] ) ) )
  • PLANT in @( LR_WHERE[ 3 ] )
0

what is your ABAP version?

0

Excuse me, but did you say that /IWBEP/T_COD_SELECT_OPTIONS is a table type, and its line type is /IWBEP/S_COD_SELECT_OPTION, which is a structure with the 4 components SIGN, OPTION, LOW, HIGH ?

If yes, then you must declare your variable as a table of /IWBEP/T_COD_SELECT_OPTIONS:

DATA LR_WHERE TYPE STANDARD TABLE OF /IWBEP/T_COD_SELECT_OPTIONS WITH EMPTY KEY.

so that you can use

LOGDATE IN @( LR_WHERE[ 1 ] )

0