Ayuda SAP

Metodo de aprobacion

Buen dia

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)
1 me gusta

Buenas Diego,

Recuerda que debes indicar a que programa haces referencia.

Gracias!

buen dia

que pena es para SAP HANNA VESION 9.3

Buen dia Diego

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.

hola alex como estas

que pena he tenido este error pero no se como postear en la secion correcta agradezco si me pueden indicar

saludos

Que tal Diego Buen dia

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.

BUEN DIA

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

Que tal Diego

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

mil gracias por tu colaboracion

1 me gusta

buen dia colegas

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

buen dia

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)

Diego, si no has logrado resolver, valida quitando el END que esta justo antes del ENDIF.
Saludos

buen dia

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;

@diego1986 procura formatear el código sql adecuadamente, por favor.

Estas trabajando con SQL o Hana? por favor, recuérdame que error te da