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

Filter Operator : ABAP 740 New Syntax

KumarVishal
Participant
0 Likes
2,305

Hello All

Getting error with Filter Operator.

I assume USING KEY is mandatory but with Default Key option Using Key can't be used.


And If I change the Default Key to Unique Key my VALUE operator starts to give error.

How to fix this ?

TYPES:
BEGIN OF lty_ord,
vbeln TYPE vbeln_va,
posnr TYPE posnr_va,
auart TYPE vbak-auart,
END OF lty_ord,

lty_ord_tab TYPE TABLE OF lty_ord WITH DEFAULT KEY.

* Prepare a Structure and a table using VALUE constructor operator.

DATA(wa_ord) = VALUE lty_ord( vbeln = '0000000001' posnr = '000010' auart = 'DT' ).


DATA(li_ord) = VALUE lty_ord_tab( ( vbeln = '0000000001' posnr = '000010' auart = 'TS' )
( vbeln = '0000000002' posnr = '000010' auart = 'TS' )
( vbeln = '0000000002' posnr = '000010' auart = 'TS' )
( vbeln = '0000000003' posnr = '000020' auart = 'FS' ) ).

DATA(li_ord_fliter) = FILTER lty_ord_tab( li_ord WHERE vbeln = '0000000001' AND posnr = '000010' AND auart = 'TS' ) .

Hello All

Getting error with Filter Operator.

I assume USING KEY is mandatory but with Default Key option Using Key can't be used.


And If I change the Default Key to Unique Key my VALUE operator starts to give error.

How to fix this ?

TYPES:
BEGIN OF lty_ord,
vbeln TYPE vbeln_va,
posnr TYPE posnr_va,
auart TYPE vbak-auart,
END OF lty_ord,

lty_ord_tab TYPE TABLE OF lty_ord WITH DEFAULT KEY.

* Prepare a Structure and a table using VALUE constructor operator.

DATA(wa_ord) = VALUE lty_ord( vbeln = '0000000001' posnr = '000010' auart = 'DT' ).


DATA(li_ord) = VALUE lty_ord_tab( ( vbeln = '0000000001' posnr = '000010' auart = 'TS' )
( vbeln = '0000000002' posnr = '000010' auart = 'TS' )
( vbeln = '0000000002' posnr = '000010' auart = 'TS' )
( vbeln = '0000000003' posnr = '000020' auart = 'FS' ) ).

DATA(li_ord_fliter) = FILTER lty_ord_tab( li_ord WHERE vbeln = '0000000001' AND posnr = '000010' AND auart = 'TS' ) .

3 REPLIES 3
Read only

FredericGirod
Active Contributor
1,733
posnr = conv posnr_va( '000010' )    

field = CONV data_element( value ).

and if you field is already typed, you could simply do a

posnr = conv #( '000010' )
Read only

KumarVishal
Participant
1,733

Thanks frdric.girod

Read only

BiberM
Contributor
1,733

The Filter Argument requires a sorted or hashed key.

lty_ord_tab TYPE SORTED TABLE OF lty_ord WITH DEFAULT KEY.
lty_ord_tab TYPE HASHED TABLE OF lty_ord WITH DEFAULT KEY.