02-28-2017 4:22 AM
Hi,
I am trying to use secondary key with the reduce constructor operator. Below are the code lines.
data: lt_index TYPE STANDARD TABLE OF cmm_d_idx
WITH NON-UNIQUE SORTED KEY ik_obj_id COMPONENTS obj_id.
lt_index = VALUE cmm_t_idx(
FOR ls_root_extract IN lt_risk_root_extract
LET lv_obj_id = |{ ls_root_extract-fbuda DATE = USER }| & |{ '- ' && ls_root_extract-locid && '-' && ls_root_extract-ro_type+ 7(3) }|
IN ( key = ls_root_extract-key
obj_id = lv_obj_id
obj_item = REDUCE cmm_idx_obj_item(
INIT lv_itm = 1 FOR ls_idx IN lt_index
USING KEY ik_obj_id
WHERE ( obj_id = lv_obj_id )
NEXT lv_itm = ls_idx-obj_item + 1 )
obj_type = ls_root_extract-ro_type ) ).
These line are giving me syntax error as:-
However skipping the where condition giving me error free code. I have tried using the same logic with the old style and that is working fine, so I'm not sure what is missing here.
LOOP AT lt_index ASSIGNING FIELD-SYMBOL(<fs_idx>)
USING KEY ik_obj_id WHERE obj_id is INITIAL.
* <<Rest of the logic>>
ENDLOOP.
02-28-2017 7:30 AM
The error message for your expression is correct.
There is a type mismatch in the WHERE condition
Your
LET lv_obj_id = |{ ls ...
is of type string.
Put a CONV around the RHS, to make lv_obj_id the same type as obj_id.
02-28-2017 7:15 AM
In a simplified example both either give syntax errors or not:
TYPES itab TYPE STANDARD TABLE OF spfli
WITH EMPTY KEY
WITH NON-UNIQUE SORTED KEY mkey COMPONENTS cityfrom cityto.
DATA itab TYPE itab.
LOOP AT itab INTO DATA(wb) USING KEY mkey WHERE carrid = '...'. "Syntax error
ENDLOOP.
DATA(jtab) = VALUE itab( FOR wa IN itab USING KEY mkey "Syntax error
WHERE ( carrid = '...' )
( wa ) ).
TYPES itab TYPE STANDARD TABLE OF spfli
WITH EMPTY KEY
WITH NON-UNIQUE SORTED KEY mkey COMPONENTS cityfrom cityto.
DATA itab TYPE itab.
LOOP AT itab INTO DATA(wb) USING KEY mkey WHERE cityfrom = '...'. "No Syntax error
ENDLOOP.
DATA(jtab) = VALUE itab( FOR wa IN itab USING KEY mkey "No Syntax error
WHERE ( cityfrom = '...' )
( wa ) ).
Back to 7.40, SP08, Kernel Patch Level 14. And that is as documented.
02-28-2017 7:30 AM
The error message for your expression is correct.
There is a type mismatch in the WHERE condition
Your
LET lv_obj_id = |{ ls ...
is of type string.
Put a CONV around the RHS, to make lv_obj_id the same type as obj_id.
02-28-2017 8:52 AM