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: 

AMDP: ABAP SQLSCRIPT message: return type mismatch

rachidroughi
Explorer
0 Kudos
1,313

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

5 REPLIES 5

raymond_giuseppi
Active Contributor
0 Kudos
1,189

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.

rachidroughi
Explorer
0 Kudos
1,189

Hello Raymond,

there is no " INTO CORRESPONDING FIELDS " in AMDP syntax.

Sandra_Rossi
Active Contributor
0 Kudos
1,189

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).

1,189
  • The problem comes from this OP's statement: I don't want to create a specific DDIC table [type] for this or select all data with a SELECT *
  • As you rightly assume PPH_MKAL_TAB is a standard table of the whole MKAL table.

Sunny_J
Explorer
0 Kudos
1,189

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.