Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9159

Special SP_TransactionNotification Migration

$
0
0

Hi everybody, can someone help me to convert the following code block from T-SQL to SQL Hana Script?

 

The purpose of this code block, is to avoid to make inventory movements affecting the same accounts financial that i have configured in the inventory item.

 

 

 

Best Regards.

 

IF @OBJECT_TYPE IN ('59') AND @TRANSACTION_TYPE IN ('A', 'U') 

BEGIN

------------------------

DECLARE @DOCENTRY INT

DECLARE @LINENUM  INT

DECLARE @ITEMCODE NVARCHAR (50)

DECLARE @ACCT_MOV NVARCHAR (20)

DECLARE @ACCT_CNF NVARCHAR (20)

DECLARE @GLMETHOD NCHAR (2)

DECLARE @WHSCODE  NVARCHAR (20)

DECLARE @GRPCODE  NVARCHAR (20)

DECLARE @CUENTAS TABLE (LINENUM INT

, ITEMCODE NVARCHAR(50)

, ERROR NCHAR (2))

 

 

DECLARE @BASE TABLE (DocEntry  INT, LineNum  INT, ItemCode NVARCHAR(50), AcctCode NVARCHAR(50)

, AcctCnf NVARCHAR(50), GLMethod NCHAR (2), WhsCode NVARCHAR(16), ItmsGrpCod NVARCHAR(20))

 

 

 

INSERT INTO @BASE

SELECT A.DocEntry, B.LineNum, B.ItemCode, B.AcctCode, '' AS AcctCnf, C.GLMethod, B.WhsCode, D.ItmsGrpCod

FROM OIGN AS A INNER JOIN IGN1 AS B ON A.DocEntry = B.DocEntry

INNER JOIN OITM AS C ON B.ItemCode = C.ItemCode

INNER JOIN OITB AS D ON C.ItmsGrpCod = D.ItmsGrpCod

WHERE @list_of_cols_val_tab_del = A.DocEntry

AND @num_of_cols_in_key = 1

 

 

---------------------------------------------------------------------------------------------

 

 

DECLARE C CURSOR FOR

SELECT DocEntry, LineNum, ItemCode, AcctCode, AcctCnf, GLMethod, WhsCode, ItmsGrpCod

FROM @BASE

 

OPEN C

FETCH NEXT FROM C

INTO @DOCENTRY, @LINENUM, @ITEMCODE, @ACCT_MOV, @ACCT_CNF, @GLMETHOD, @WHSCODE, @GRPCODE

WHILE @@fetch_status = 0

BEGIN

IF @GLMETHOD = 'W'

BEGIN

/* 1 */

PRINT 'W'

SET @ACCT_CNF =

(SELECT  C.BalInvntAc

FROM OITM AS A INNER JOIN OITW AS B ON A.ItemCode = B.ItemCode

  INNER JOIN OWHS AS C ON B.WhsCode  = C.WhsCode

WHERE A.ItemCode   = @ITEMCODE

AND  B.WhsCode    = @WHSCODE)

 

 

IF @ACCT_CNF = @ACCT_MOV

BEGIN

/* 1A */

INSERT INTO @CUENTAS

VALUES (@LINENUM, @ITEMCODE, 'SI')

/* 1A */

END

ELSE

BEGIN

/* 1B */

INSERT INTO @CUENTAS

VALUES (@LINENUM, @ITEMCODE, 'NO')

/* 1B */

END

/* 1 */

END

ELSE IF @GLMETHOD = 'C'

BEGIN

/* 2 */

SET @ACCT_CNF =

(SELECT B.BalInvntAc

FROM OITM AS A INNER JOIN OITB AS B ON A.ItmsGrpCod = B.ItmsGrpCod

WHERE A.ItemCode   = @ITEMCODE

AND B.ItmsGrpCod = @GRPCODE)

 

IF @ACCT_CNF = @ACCT_MOV

BEGIN

/* 2A */

INSERT INTO @CUENTAS

VALUES (@LINENUM, @ITEMCODE, 'SI')

/* 2A */

END

ELSE

BEGIN

/* 2B */

INSERT INTO @CUENTAS

VALUES (@LINENUM, @ITEMCODE, 'NO')

/* 2B */

END

/* 2 */

END

-- Avanzamos otro registro

FETCH NEXT FROM C

INTO @DOCENTRY, @LINENUM, @ITEMCODE, @ACCT_MOV, @ACCT_CNF, @GLMETHOD, @WHSCODE, @GRPCODE

END

 

--cerramos el cursor

CLOSE C

DEALLOCATE C

 

IF (SELECT COUNT(*)

FROM @CUENTAS

WHERE [ERROR] = 'SI'

) > 0

BEGIN

SET @ERROR = 10

SET @ERROR_MESSAGE = 'It's not possible make movements affecting the inventory account configured'    END

END


Viewing all articles
Browse latest Browse all 9159

Trending Articles



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