SQL QUERY FOR APPROVAL PROCEDURE IN SAP B'ONE

HELLO

I HAVE A QUESTION
I HAVE CREATED 3 FIELDS CALLED U_ZCONSO, U_ZCONSO2, U_ZCONSO3 ALL ARE ALPHANUMERIC FIELDS BECAUSE NUMERIC IS LIMITED TO 11 DIGITS AND THE FIELDS ARE MORE SO I NEED 18 DIGITS.

I HAVE A QUERY FOR U_ZCONSO AND U_ZCONSO 2 WHICH MUST GIVE ME A NUMBER
1 WHEN ZCONSO3 IS EMPTY
I HAVE MADE THE FOLOWING QUERY I DO NOT HAVE ANY ERROR MESSAGE BUT THE RESULT IS NOT WHAT I WANT BECUASE IT SI EMPTY

IF $[ORDR.U_ZCONSO3] IS NULL
SELECT '0'
ELSE
SELECT SUM(T0.Balance) from OCRD T0 Where T0.U_SCONSO=$[ORDR.U_ZCONSO3]

2 WHEN ZCONSO3 IS NOT EMPTY I NEED TO COMPARE ZCONSO AND ZCONSO2 AND MAKE THEM NUMERIC VALUE THE ISSUE IS THE NUMERIC VALUE COMES WITH COMA IN THE FELDS AND THE QUERY DOES NOT CONVERT THE NVARCHAR INTO A NUMERIC FORMAT

THE QUERY IS BELOW

DECLARE @CRED AS numeric(19,6)
DECLARE @FACT AS numeric(19,6)
SET @CRED=$[ORDR.U_ZCONSO]
SET @FACT=$[ORDR.U_ZCONSO2]
SELECT DISTINCT 'TRUE' WHERE @CRED<@FACT
Humphrey1973Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nmcdermaidCommented:
MY EYES HURT
 Numeric is not limited to 11 digits.
Use NUMERIC(19,0) to be able to store a number with 19 digits (and no decimal places)
You second issue about converting NVARCHAR will go away when you use this datatype.
SELECT ISNULL(ZCONSO3 ,0) will give the contents of that field, or zero if that field is NULL
 
 
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Enterprise Software

From novice to tech pro — start learning today.