2023 Jan 18 9:01 PM
why do I get above runtime error with below code?
DATA: gv_kunnr TYPE kunnr.
SELECT-OPTIONS: s_kunnr FOR gv_kunnr. "Passed 5 Customer Nos here
TYPES: BEGIN OF kunnr_type,
kunnr TYPE kunnr,
END OF kunnr_type.
DATA: kunnr_input TYPE STANDARD TABLE OF kunnr_type.
START-OF-SELECTION
kunnr_input = VALUE #( FOR l_kunnr IN s_kunnr
( kunnr = l_kunnr-low )
). "Works well
kunnr_input = CORRESPONDING #( s_kunnr MAPPING kunnr = low ). ">>>>>>>>>>RUNTIME ERROR
I believe something due to type mismatch but I need clarity.
2023 Jan 19 7:06 AM
Any variable name corresponding to a SELECT-OPTIONS (S_KUNNR in your case) may express both a Ranges Table (internal table with components SIGN, OPTION, LOW, HIGH) AND a Header Line (a structure with type same as one line of the internal table).
e.g.
kunnr_input = CORRESPONDING #( s_kunnr[] MAPPING kunnr = low ).
The header lines are obsolete because it's prone to errors. SELECT-OPTIONS and TABLES parameters (when seen from inside the procedure) are the only non-obsolete cases where a header line is generated by the kernel.
More information: Internal Tables with a Header Line
2023 Jan 18 9:04 PM
2023 Jan 19 2:09 AM
Hi Shailesh,
Use the square bracket [] after S_KUNNR while doing corresponding, it will work. See the below code snippet.
DATA: gv_kunnr TYPE kunnr.kunnr_input = CORRESPONDING #( s_kunnr[] MAPPING kunnr = low ). ">>>>>>>>>>RUNTIME ERROR
Regards
Sunil Mani
2023 Jan 19 7:06 AM
Any variable name corresponding to a SELECT-OPTIONS (S_KUNNR in your case) may express both a Ranges Table (internal table with components SIGN, OPTION, LOW, HIGH) AND a Header Line (a structure with type same as one line of the internal table).
e.g.
kunnr_input = CORRESPONDING #( s_kunnr[] MAPPING kunnr = low ).
The header lines are obsolete because it's prone to errors. SELECT-OPTIONS and TABLES parameters (when seen from inside the procedure) are the only non-obsolete cases where a header line is generated by the kernel.
More information: Internal Tables with a Header Line
2023 Jan 19 10:34 AM