Quantcast
Channel: SCN : Discussion List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 6412

SSCC label function - SAP HANA

$
0
0

Hi all,

 

I located the following tSQL function to generate SSCC label number including check digit (for ASN).

I have not yet been able to convert this function to SAP SQLScript using the documentation available.

Has anyone done anything similar using SAP HANA?

My HANA version is 1.00.74.03.392810.

 

Thanks,

John

 

 

 

CREATE FUNCTION dbo.fnGetSSCC

(

       @SSCC VARCHAR(17)

)

RETURNS VARCHAR(18)

AS

BEGIN

       DECLARE @Index TINYINT,

              @Multiplier TINYINT,

              @Sum SMALLINT

 

       SELECT @Index = LEN(@SSCC), @Multiplier = 3, @Sum = 0

 

       WHILE @Index > 0

           

              SELECT

                     @Sum = @Sum + @Multiplier * CAST(SUBSTRING(@SSCC, @Index, 1) AS TINYINT),

                     @Multiplier = 4 - @Multiplier,

                     @Index = @Index - 1

 

       RETURN CASE @Sum % 10

                     WHEN 0 THEN @SSCC + '0'

                     ELSE @SSCC + CAST(10 - @Sum % 10 AS CHAR(1))

       END

END


Viewing all articles
Browse latest Browse all 6412

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>