Si trabajas con SAP Business One y manejas maquinaria o activos… esto te va a ahorrar MUCHOS dolores de cabeza 👇


🤯 El problema

Errores genéricos como:

❌ “Debe indicar el Odómetro al producto Aceite hidráulico”

Y tú:

  • 🤔 ¿Cuál línea?
  • 🤔 ¿Qué activo?
  • 🤔 ¿Dónde corrijo?

Resultado:

  • ⏳ Pierdes tiempo
  • 😤 Corriges mal
  • 🔁 El error vuelve a salir

💡 La solución

Ahora los mensajes muestran:

  • ✅ Código del activo
  • ✅ Nombre del activo
  • ✅ Línea exacta

🔥 Ejemplo:

Debe indicar el Odómetro al activo EQ-001 – Excavadora CAT (Línea 3)


🧠 ¿Qué se hizo?

  • ✔ Se usa el activo desde OcrCode
  • ✔ Se hace fallback al artículo si no hay activo
  • ✔ Se corrige LineNum + 1

🔧 Código completo listo para pegar

IF (:transaction_type = 'A') AND :object_type = '60' AND error_message = 'Ok'
THEN  

     select 
       max(
         case 

           when ifnull(t1."U_TypeMov",'') = '' 
                and ifnull(t1."BaseType",0) <> 202 then 
             'Seleccione el tipo de movimiento'

           when ifnull(t2."QryGroup11",'N') = 'Y' 
                and ifnull(t1."OcrCode",'') = '' 
                and ifnull(t1."U_TypeMov",'') = 'CONSUMO' then 
             'El articulo ' || t1."Dscription" || ' se especifico que debe seleccionarse la maquinaria'

           when ifnull(t4."QryGroup9",'N') = 'Y' 
                and ifnull(t2."QryGroup11",'N') = 'Y' 
                and ifnull(t1."U_Odometro",0) = 0 
                and ifnull(t1."U_TypeMov",'') = 'CONSUMO' then 
             'Debe indicar el Odometro al activo ' 
             || IFNULL(t4."ItemCode", t2."ItemCode")
             || ' - ' || IFNULL(t4."ItemName", t2."ItemName")
             || ' (Línea ' || (ifnull(t1."LineNum",0) + 1) || ')'

           when ifnull(t4."QryGroup9",'N') = 'N' 
                and ifnull(t1."U_Odometro",0) <> 0 then 
             'Quite el valor del campo Odometro en el activo ' 
             || IFNULL(t4."ItemCode", t2."ItemCode")
             || ' - ' || IFNULL(t4."ItemName", t2."ItemName")
             || ' (Línea ' || (ifnull(t1."LineNum",0) + 1) || ')'

           when ifnull(t4."QryGroup8",'N') = 'Y' 
                and ifnull(t2."QryGroup11",'N') = 'Y' 
                and ifnull(t1."U_Horometro",0) = 0  
                and ifnull(t1."U_TypeMov",'') = 'CONSUMO' then 
             'Debe indicar el Horometro al activo ' 
             || IFNULL(t4."ItemCode", t2."ItemCode")
             || ' - ' || IFNULL(t4."ItemName", t2."ItemName")
             || ' (Línea ' || (ifnull(t1."LineNum",0) + 1) || ')'

           when ifnull(t4."QryGroup8",'N') = 'N' 
                and ifnull(t1."U_Horometro",0) <> 0 then 
             'Quite el valor del campo Horometro en el activo ' 
             || IFNULL(t4."ItemCode", t2."ItemCode")
             || ' - ' || IFNULL(t4."ItemName", t2."ItemName")
             || ' (Línea ' || (ifnull(t1."LineNum",0) + 1) || ')'

           when ifnull(t2."QryGroup11",'N') = 'Y' 
                and (ifnull(t4."QryGroup8",'N') = 'Y' or ifnull(t4."QryGroup9",'N') = 'Y') 
                and ifnull(t1."U_Empleado",0) = 0  
                and ifnull(t1."U_TypeMov",'') = 'CONSUMO' then 
             'Debe indicar el empleado que recibe el producto ' || t1."Dscription"

           when ifnull(t2."QryGroup11",'N') = 'Y' 
                and (ifnull(t4."QryGroup8",'N') = 'Y' or ifnull(t4."QryGroup9",'N') = 'Y') 
                and ifnull(t1."U_HoraMovto",0) = 0  
                and ifnull(t1."U_TypeMov",'') = 'CONSUMO' then 
             'Debe indicar la hora en que se recibe el producto ' || t1."Dscription"

           when ifnull(t2."QryGroup11",'N') = 'Y' 
                and (ifnull(t4."QryGroup8",'N') = 'Y' or ifnull(t4."QryGroup9",'N') = 'Y') 
                and LENGTH(ifnull(t1."U_HoraMovto",0)) < 3  
                and ifnull(t1."U_TypeMov",'') = 'CONSUMO' then 
             'Verifique la hora del producto ' || t1."Dscription"

           else '' 
         end
       ) ERROR
     INTO error_message
     from OIGE t0
     inner join IGE1 t1 on t0."DocEntry" = t1."DocEntry"
     inner join OITM t2 on t2."ItemCode" = t1."ItemCode"
     left join OITM t4 on t4."ItemCode" = t1."OcrCode"
     left join "QUA_PermisosWhsUser" t3 
           on t3."WhsCode" = t1."WhsCode" 
          and t3."userId"  = t0."UserSign"
     where t0."DocEntry" = :list_of_cols_val_tab_del;

     IF IFNULL(:error_message, N'') <> N'' THEN 
        error := -10046;
     ELSE 
        error_message := N'Ok';
     END IF;
END IF;

📈 Beneficios

  • 🔥 Mensajes claros
  • 🔥 Menos errores
  • 🔥 Más productividad
  • 🔥 Mejor control de activos

🧩 Conclusión

Pequeño cambio… GRAN impacto 🚀

Tu sistema pasa de:

❌ Confuso
✅ Profesional y claro


💬 ¿Quieres más mejoras como esta?

Puedo ayudarte con:

  • ⚙️ Validaciones avanzadas
  • 🚀 Optimización de SQL
  • 🧠 Automatización en SAP

Solo dime 👇