2023 May 04 2:08 PM
Dear everyone,
Basic question: I am trying to select some fields from MKAL.
My returned type is also a MKAL table. And I would like to select only few fields from the table, but I got a: "SQLSCRIPT message: return type mismatch".
I don't want to create a specific DDIC table for that or... to select all the data with a SELECT *.....
CLASS-METHODS : get_list_versions_fabrication
AMDP OPTIONS READ-ONLY
CDS SESSION CLIENT current
IMPORTING VALUE(iv_client) TYPE symandt
VALUE(iv_matnr) TYPE matnr
VALUE(iv_werks) TYPE werks_d
EXPORTING VALUE(rt_result) TYPE pph_mkal_tab.
METHOD get_list_versions_fabrication BY DATABASE PROCEDURE FOR HDB
LANGUAGE SQLSCRIPT
OPTIONS READ-ONLY USING mkal.
rt_result = SELECT MATNR, WERKS, VERID from mkal WHERE mandt = :iv_client and
matnr = :iv_matnr and
werks = :iv_werks ;
ENDMETHOD.
What is the correct syntax to fix it?
Thank you in advance,
Cheers,
Rachid
2023 May 04 3:50 PM
If you want to select only a few fields in the whole structure (this is your choice and you must assume it) you should use some INTO CORRESPONDING FIELDS option.
2023 May 05 8:32 AM
Hello Raymond,
there is no " INTO CORRESPONDING FIELDS " in AMDP syntax.
2023 May 05 10:10 AM
SQLscript is HANA SQL scripting language.
AMDP is the way to call SQLscript from ABAP.
Your question is about "why does the type PPH_MKAL_TAB have a mismatch with a table type containing the 3 columns MATNR, WERKS, VERID".
Please show the definition of PPH_MKAL_TAB. Probably it contains other columns or not in same order.
By the way, why don't you define your own custom stable table type in your class (instead of DDIC), which contains exactly to MATNR, WERKS, VERID? (relying on stability of SAP internal objects is dangerous).
2023 May 05 10:52 AM
2023 Jul 20 11:59 AM
You need to define new type for AMDP.
TYPES:
BEGIN OF ts_mkal,
matnr TYPE mkal-matnr,
werks TYPE mkal-werks,
verid TYPE mkal-verid,
END OF ts_mkal,
tt_mkal TYPE STANDARD TABLE OF ts_mkal.
CLASS-METHODS get_list_versions_fabrication AMDP OPTIONS READ-ONLY
CDS SESSION CLIENT current
IMPORTING VALUE(iv_client) TYPE symandt
VALUE(iv_matnr) TYPE matnr
VALUE(iv_werks) TYPE werks_d
EXPORTING VALUE(rt_result) TYPE tt_mkal.