cancel
Showing results for 
Search instead for 
Did you mean: 

SAP HANA SQL SCRIPT ALPHA conversion

alexander_stettler
Participant
9,033

Hello,

Since a view weeks we are operating an SAP BW on HANA system and - of cource - we are trying to use the new functionalities the system is providing us (e.g. AMDP based field routines, HANA Calculation Views, ...). We regognized that sometimes, if we assign a field (e.g. CHAR12) to another field (e.g. CHAR13) we are running into some issues which are related to a missing conversion alpha: The BW backend as well as the BW Queries requires a correct converted field.

Of course there are possibilities to work with concatenates functionalities, adding some leading 0 values if required (e.g. if( strlen("DS_QMLNF8") = 12, '0' + "DS_QMLNF8", '')), ... But this seems quite ugly to me. Isn't there a smooth way use an inbuild alpha conversion function in an AMDP based field outine as well as in an HANA Calculation View?

Best Regards,
Alex

View Entire Topic
alexander_stettler
Participant

As always , immediately after I've clicked on send I found the function "LPAD":

lpad("DS_QMLNF8", 13, '0')

https://help.sap.com/viewer/4fe29514fd584807ac9f2a04f6754767/2.0.02/en-US/20e40bdb75191014bc66f14fa7...

Sometimes it's also necessary to check if the content is numeric and not empty:

CASE WHEN ( LENGTH(LTRIM("CHARACTERISTIC",' 0123456789')) = 0 and LTRIM("CHARACTERISTIC",' ') <> '' )
  THEN LPAD( "CHARACTERISTIC", 18,'0' )
  ELSE "CHARACTERISTIC" END as "CHARACTERISTIC"<br>

https://xc1b.wordpress.com/2019/06/06/alpha-conversion-in-hana-sql/

But maybe the following variant is the more simple one:

ABAP_ALPHANUM( <string>, <chars> )

2800346 - Consulting: Handling of fields with conversion exits in AMDP routines
https://launchpad.support.sap.com/#/notes/2800346

ABAP_ALPHANUM Function (String):
https://help.sap.com/viewer/4fe29514fd584807ac9f2a04f6754767/2.0.01/en-US/e4887a42a3eb4d5d88bf84da66...