on ‎2021 Mar 11 6:58 PM
Hi,
Underlying native SQL executes the correct result - CDS Table Function does not ?
CDS AMDP based Table Function delivers the wrong result while making a SPACE Replacement:
Native SQL :
SELECT
D2T.TABNAME,
D2T.DDTEXT,
SUBSTR ( REPLACE ( D2T.DDTEXT, ' ', '' ), 1, 30) AS TABLE_ALIAS_BLANK,
SUBSTR ( REPLACE ( D2T.DDTEXT, ' ', NULL ), 1, 30) AS TABLE_ALIAS_NULL
FROM SAPHANADB.DD02T AS D2T
WHERE D2T.DDLANGUAGE = 'E'
AND D2T.TABNAME = 'MARA' OR D2T.TABNAME = 'ACDOCA'
-> Result native SQL:

->Correct: no Blanks
AMDP Class and Method Implementation
( The same name for the AMDP Method and the CDS TabeleFunction):
CLASS zy_rep_fi_read DEFINITIONPUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_amdp_marker_hdb .
CLASS-METHODS ZY_I_NAMETEST for TABLE function ZY_I_NAMETEST.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
*********************************************************
CLASS zy_rep_fi_read IMPLEMENTATION.
METHOD ZY_I_NAMETEST
by database function
for hdb language sqlscript
options read-only
USING DD02T.
RETURN
SELECT D2T.TABNAME,
D2T.DDTEXT,
SUBSTR ( REPLACE ( D2T.DDTEXT, ' ', '' ), 1, 30) AS TABLE_ALIAS_BLANK,
SUBSTR ( REPLACE ( D2T.DDTEXT, ' ', NULL ), 1, 30) AS TABLE_ALIAS_NULL
FROM DD02T AS D2T
WHERE D2T.DDLANGUAGE = 'E'
AND D2T.TABNAME = 'MARA' OR D2T.TABNAME = 'ACDOCA'
ORDER BY D2T.TABNAME
;
ENDMETHOD.
ENDCLASS.
CDS Table Function:
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'ZY_I_NAMETEST'
@VDM.viewType: #CONSUMPTION
@ClientHandling.type: #CLIENT_INDEPENDENT
define table function ZY_I_NAMETEST
returns
{TABNAME : abap.char( 100 )
;DDTEXT : abap.char( 100 )
;TABLE_ALIAS_BLANK : abap.char( 100 )
;TABLE_ALIAS_NULL : abap.char( 100 )
;}
//
implemented by method ZY_REP_FI_READ=>ZY_I_NAMETEST
->Result CDS Table Function:
->Wrong: Blanks still present
->Same Statement - Blanks are NOT replaced by the CDS Table Function.
Underlying native SQL executes the correct result - ABAP on top scrambles ?
What's going on there ?
...and how is it going correct...:)
Best Martin
Request clarification before answering.
Dear Martin,
Unfortunately, it seems to be taking longer than usual for your question to be answered. You might want to try an alternative route to speed things up.
Please check if a similar question has already been asked in the Community. We have found that sometimes questions that have been answered before are no longer receiving responses.
The easiest way to do this, is to visit the All Questions page and search for your specific topic.
You could also check the SAP Support Portal and search for SAP Notes, SAP Knowledge Base Articles and more.
If all of this doesn’t work, I would suggest that you create a support ticket. All you need to do is log onto the SAP Support Portal with your S-user ID and password: http://service.sap.com/message
Thanks,
Mozi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 53 | |
| 29 | |
| 21 | |
| 10 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.