estimados tengo la siguiente consulta y es para bloquear que se valla autorización cuando el SN esta excedido en credito y/o dias de vencimiento pero necesito agregar que solo lo tome para cuando la solcitud de traslado (OWTQ tenga destino almacén 02 en cabecera
necesito agregar esta parte
SELECT DISTINCT 'TRUE' FROM DUMMY
WHERE $[OWTQ."ToWhsCode"] = '02'
agrdaezco su ayuda
mil gracias
Select distinct
'TRUE'
FROM DUMMY
Where ((Select COUNT(*)
From (Select
"Estado"
From (SELECT
CASE
WHEN DAYS_BETWEEN (MIN(I."DocDueDate"),CURRENT_TIMESTAMP) BETWEEN 17 AND 104 THEN 'Vencido ' || DAYS_BETWEEN (MIN(I."DocDueDate"),CURRENT_TIMESTAMP) || ' días'
ELSE '0'
END "Estado"
FROM OINV I
WHERE I."DocStatus" = 'O'
AND (I."DocTotal" - I."PaidSum") <> 0
AND I."CardCode" = $[$4.0.0]
) DATOS
Where "Estado" <> '0'))>0)
OR
((SELECT COUNT(*) FROM OCRD T0 WHERE T0."CardCode" =$[$4.0.0] AND T0."Balance"+ $[OWTQ."DocTotal".NUMBER] > T0."CreditLine")>0
AND
(Select COUNT(*) From (Select "Estado" From (
SELECT CASE WHEN DAYS_BETWEEN (I."DocDueDate",CURRENT_TIMESTAMP) > 81 THEN 'Vencido ' || DAYS_BETWEEN (I."DocDueDate",CURRENT_TIMESTAMP) || ' días' ELSE '0' END "Estado"
FROM
OINV I INNER JOIN OSLP L on L."SlpCode" = I."SlpCode"
WHERE I."DocStatus"='O' and (I."DocTotal" - I."PaidSum")<> 0 and I."CardCode" = $[$4.0.0]
) DATOS
Where "Estado" <> '0'))=0)
En tu presentacion dices que es SAP HANNA Bussines One, se te invita nuevamente que coloques tus consultas en la seccion de Bussines One te pido amablemente que coloques tus dudas en la seccion de bussines one para no reportar tu post, lo voy a mover a esa seccion, gracias.
Del lado derecho de tu pantalla justo junto a tu imagen para tu usuario del foro te aparecen tres rayas en ese cuando le das clic aparecen las secciones la señalas le das clic y te lleva a la seccion para que postees (te anexo imagen)
En este caso cada seccion viene con un color el de bussines one es de color azul claro (tiene 3 porque hay 3 posteos), si necesitas algo mas me dices, saludos.
muchas gracias entendido y tu sabes como podria resolver mi problema?
intente asi pero tampoco
DECLARE SOL_TRAS
SELECT (SELECT $[OWTQ.ToWhsCode.0] FROM DUMMY) INTO SOL_TRAS FORM DUMMY;
IF SOL_TRS = 02
THEN
BEGIN
Select distinct
'TRUE'
FROM DUMMY
Where ((Select COUNT(*)
From (Select
"Estado"
From (SELECT
CASE
WHEN DAYS_BETWEEN (MIN(I."DocDueDate"),CURRENT_TIMESTAMP) BETWEEN 17 AND 104 THEN 'Vencido ' || DAYS_BETWEEN (MIN(I."DocDueDate"),CURRENT_TIMESTAMP) || ' días'
ELSE '0'
END "Estado"
FROM OINV I
WHERE I."DocStatus" = 'O'
AND (I."DocTotal" - I."PaidSum") <> 0
AND I."CardCode" = $[$4.0.0]
) DATOS
Where "Estado" <> '0'))>0)
OR
((SELECT COUNT(*) FROM OCRD T0 WHERE T0."CardCode" =$[$4.0.0] AND T0."Balance"+ $[OWTQ."DocTotal".NUMBER] > T0."CreditLine")>0
AND
(Select COUNT(*) From (Select "Estado" From (
SELECT CASE WHEN DAYS_BETWEEN (I."DocDueDate",CURRENT_TIMESTAMP) > 81 THEN 'Vencido ' || DAYS_BETWEEN (I."DocDueDate",CURRENT_TIMESTAMP) || ' días' ELSE '0' END "Estado"
FROM
OINV I INNER JOIN OSLP L on L."SlpCode" = I."SlpCode"
WHERE I."DocStatus"='O' and (I."DocTotal" - I."PaidSum")<> 0 and I."CardCode" = $[$4.0.0]
) DATOS
Where "Estado" <> '0'))=0)
END
IF
Una disculpa mi expertiz no es SAP Bussines One por eso te dije que lo postees aqui para que otros compañeros que tiene esa expertiz te apoyen pronto, un saludo
he estado trabajando todo el dia en esta consulta que me urge y tengo la siugiente pero me generar error en un END y no veo cual sea el problema
objetivo: si la solciitud de traslado en cabecera tiene almacen 02 revise si esta vencido y/o supero limite de crédito si alguna de las dos cumple se enviara a autorización
agradezco su ayuda
DECLARE SOL_TRAS NVARCHAR(15);
SELECT (SELECT '02' FROM DUMMY) INTO SOL_TRAS FROM DUMMY;
SELECT SOL_TRAS FROM DUMMY;
IF :SOL_TRAS = '02' THEN
BEGIN
Select distinct
'TRUE'
FROM DUMMY
Where ((Select COUNT(*)
From (Select
"Estado"
From (SELECT
CASE
WHEN DAYS_BETWEEN (MIN(I."DocDueDate"),CURRENT_TIMESTAMP) BETWEEN 17 AND 104 THEN 'Vencido ' || DAYS_BETWEEN (MIN(I."DocDueDate"),CURRENT_TIMESTAMP) || ' días'
ELSE '0'
END "Estado"
FROM OINV I
WHERE I."DocStatus" = 'O'
AND (I."DocTotal" - I."PaidSum") <> 0
AND I."CardCode" = $[$4.0.0]
) DATOS
Where "Estado" <> '0'))>0)
OR
((SELECT COUNT(*) FROM OCRD T0 WHERE T0."CardCode" =$[$4.0.0] AND T0."Balance"+ $[OWTQ."DocTotal".NUMBER] > T0."CreditLine")>0
AND
(Select COUNT(*) From (Select "Estado" From (
SELECT CASE WHEN DAYS_BETWEEN (I."DocDueDate",CURRENT_TIMESTAMP) > 81 THEN 'Vencido ' || DAYS_BETWEEN (I."DocDueDate",CURRENT_TIMESTAMP) || ' días' ELSE '0' END "Estado"
FROM
OINV I INNER JOIN OSLP L on L."SlpCode" = I."SlpCode"
WHERE I."DocStatus"='O' and (I."DocTotal" - I."PaidSum")<> 0 and I."CardCode" = $[$4.0.0]
) DATOS
Where "Estado" <> '0'))=0)
END
END IF
me sale este error
[SAP AG][LIBODBCHDB DLL][HDBODBC] Syntax error or access violation;257 sql syntax error: incorrect syntax near “END”: line 42 col 1 (at pos 1478)
mira lo intente asi como me dices y sigue el mismo error
consulta
DECLARE SOL_TRAS NVARCHAR(15);
SELECT (SELECT '02' FROM DUMMY) INTO SOL_TRAS FROM DUMMY;
SELECT SOL_TRAS FROM DUMMY;
IF :SOL_TRAS = '02' THEN
BEGIN
Select distinct
'TRUE'
FROM DUMMY
Where ((Select COUNT(*)
From (Select
"Estado"
From (SELECT
CASE
WHEN DAYS_BETWEEN (MIN(I."DocDueDate"),CURRENT_TIMESTAMP) BETWEEN 17 AND 104 THEN 'Vencido ' || DAYS_BETWEEN (MIN(I."DocDueDate"),CURRENT_TIMESTAMP) || ' días'
ELSE '0'
END "Estado"
FROM OINV I
WHERE I."DocStatus" = 'O'
AND (I."DocTotal" - I."PaidSum") <> 0
AND I."CardCode" = 'C860517500'
) DATOS
Where "Estado" <> '0'))>0)
OR
((SELECT COUNT(*) FROM OCRD T0 WHERE T0."CardCode" ='C860517500' AND T0."Balance"+ 2765462.000000 > T0."CreditLine")>0
AND
(Select COUNT(*) From (Select "Estado" From (
SELECT CASE WHEN DAYS_BETWEEN (I."DocDueDate",CURRENT_TIMESTAMP) > 81 THEN 'Vencido ' || DAYS_BETWEEN (I."DocDueDate",CURRENT_TIMESTAMP) || ' días' ELSE '0' END "Estado"
FROM
OINV I INNER JOIN OSLP L on L."SlpCode" = I."SlpCode"
WHERE I."DocStatus"='O' and (I."DocTotal" - I."PaidSum")<> 0 and I."CardCode" = 'C860517500'
) DATOS
Where "Estado" <> '0'))=0)
END IF.
DECLARE SOL_TRAS NVARCHAR(15);
SELECT (SELECT '02' FROM DUMMY) INTO SOL_TRAS FROM DUMMY;
SELECT SOL_TRAS FROM DUMMY;
IF :SOL_TRAS = '02' THEN
BEGIN
Select distinct
'TRUE'
FROM DUMMY
Where ((Select COUNT(*)
From (Select
"Estado"
From (SELECT
CASE
WHEN DAYS_BETWEEN (MIN(I."DocDueDate"),CURRENT_TIMESTAMP) BETWEEN 17 AND 104 THEN 'Vencido ' || DAYS_BETWEEN (MIN(I."DocDueDate"),CURRENT_TIMESTAMP) || ' días'
ELSE '0'
END "Estado"
FROM OINV I
WHERE I."DocStatus" = 'O'
AND (I."DocTotal" - I."PaidSum") <> 0
AND I."CardCode" = 'C860517500'
) DATOS
Where "Estado" <> '0'))>0)
OR
((SELECT COUNT(*) FROM OCRD T0 WHERE T0."CardCode" ='C860517500' AND T0."Balance"+ 2765462.000000 > T0."CreditLine")>0
AND
(Select COUNT(*) From (Select "Estado" From (
SELECT CASE WHEN DAYS_BETWEEN (I."DocDueDate",CURRENT_TIMESTAMP) > 81 THEN 'Vencido ' || DAYS_BETWEEN (I."DocDueDate",CURRENT_TIMESTAMP) || ' días' ELSE '0' END "Estado"
FROM
OINV I INNER JOIN OSLP L on L."SlpCode" = I."SlpCode"
WHERE I."DocStatus"='O' and (I."DocTotal" - I."PaidSum")<> 0 and I."CardCode" = 'C860517500'
) DATOS
Where "Estado" <> '0'))=0)
END IF
DECLARE SOL_TRAS NVARCHAR(15);
SELECT (SELECT$[OWTQ."ToWhsCode".0] FROM DUMMY) INTO SOL_TRAS FROM DUMMY;
SELECT SOL_TRAS FROM DUMMY;
IF :SOL_TRAS = '02' THEN
BEGIN
Select distinct
'TRUE'
FROM DUMMY
Where ((Select COUNT(*)
From (Select
"Estado"
From (SELECT
CASE
WHEN DAYS_BETWEEN (MIN(I."DocDueDate"),CURRENT_TIMESTAMP) BETWEEN 17 AND 104 THEN 'Vencido ' || DAYS_BETWEEN (MIN(I."DocDueDate"),CURRENT_TIMESTAMP) || ' días'
ELSE '0'
END "Estado"
FROM OINV I
WHERE I."DocStatus" = 'O'
AND (I."DocTotal" - I."PaidSum") <> 0
AND I."CardCode" = 'C860517500'
) DATOS
Where "Estado" <> '0'))>0)
OR
((SELECT COUNT(*) FROM OCRD T0 WHERE T0."CardCode" ='C860517500' AND T0."Balance"+ 2765462.000000 > T0."CreditLine")>0
AND
(Select COUNT(*) From (Select "Estado" From (
SELECT CASE WHEN DAYS_BETWEEN (I."DocDueDate",CURRENT_TIMESTAMP) > 81 THEN 'Vencido ' || DAYS_BETWEEN (I."DocDueDate",CURRENT_TIMESTAMP) || ' días' ELSE '0' END "Estado"
FROM
OINV I INNER JOIN OSLP L on L."SlpCode" = I."SlpCode"
WHERE I."DocStatus"='O' and (I."DocTotal" - I."PaidSum")<> 0 and I."CardCode" = 'C860517500'
) DATOS
Where "Estado" <> '0'))=0);
END IF;