[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
Solved

# SQL QUERY FOR APPROVAL PROCEDURE IN SAP B'ONE

Posted on 2008-11-12
Medium Priority
514 Views
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
Question by:Humphrey1973
1 Comment

LVL 30

Accepted Solution

nmcdermaid earned 2000 total points
ID: 23074784
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

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
###### Suggested Courses
Course of the Month18 days, 14 hours left to enroll