• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 518
  • Last Modified:

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
0
Humphrey1973
Asked:
Humphrey1973
1 Solution
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now