Hola @Diego_Achury muchas gracias por tu ayuda, mira… este es el query, si lo pruebo desde crystal si funciona y me pide los parámetros, pero cuando lo importo a SAP y doy previsualizar layouts no funciona.
SELECT CASE WHEN T0."Printed"='Y' THEN 'DUPLICADO' END AS "MSJ-PRINT",T0."CardCode",T1."ItemCode" AS "Producto"
,case when T9."U_GVS_CantProv">0 THEN SUM(T1."Quantity"/T9."U_GVS_CantProv") else 0 END AS "PACAS",SUM(T1."Quantity") AS "Cantidad", T0."DocEntry",T0."DocNum", T0."CardName", T0."VatSum", T0."DocTotal", T1."PriceBefDi", T0."DocDate",T0."TaxDate", T0."DocDueDate"
, T0."Address", T0."Comments" , T0."WTSum", T0."NumAtCard", T0."DocType" , T0."DocCur"
, CASE T0."DocCur" WHEN '$' THEN sum(T0."VatSum") ELSE sum(T0."VatSumFC") END "Total IVA "
, CASE T0."DocCur" WHEN '$' THEN T0."DiscPrcnt" ELSE T0."DiscSum" END "Total Descuento"
, CASE T0."DocCur" WHEN '$' THEN round(T0."Max1099") ELSE round(T0."DocTotalFC") END "Total Documento"
, CASE T0."DocCur" WHEN '$' THEN T0."WTSum" ELSE T0."WTSumFC" END "Total Retenciones"
, CASE T0."DocCur" WHEN '$' THEN 1 ELSE 2 END "Total ", sum(T1."Quantity") as "Quantity", T1."ItemCode",T1."Dscription"
, CASE WHEN T1."Price" = 0 THEN SUM(T10."Price" * T1."Quantity") ELSE sum(T1."LineTotal") END as "LineTotal" ,T1."VatPrcnt",T1."DiscPrcnt"
, CASE T1."BaseType" WHEN 17 THEN ' - ' END "Numero Pedido",T1."UseBaseUn" AS "Unidad Medida"
, CASE WHEN T1."Price"=0 THEN T10."Price" ELSE T1."Price" END AS "Precio Und",CASE WHEN T1."Price" = 0 THEN ((T10."Price" * T7."Rate")/100)+T10."Price" ELSE ((T1."Price" * T7."Rate")/100)+T1."Price" END AS "Precio Und IVA"
, T1."TaxCode"
, T2."LicTradNum", T5."U_GVS_Telefono" AS "Phone1", T5."U_GVS_Celular" AS "Phone2", t2."City"
, T3."SlpName" -----------------------------------------
,T3."Telephone"
, T4."PymntGroup"
, T5."Street" "Direccion Entrega"
,T5."Block" as "t5.Block", T5."U_GVS_CdPtoVta" as "t5.U_GVS_CdPtoVta",T5."U_GVS_CodRelacionado" as "t5.U_GVS_CodRelacionado", t5."City" as "t5.City"
, T6."Street" "Direccion Factura"
,T6."Block" as "t6.Block", T6."U_GVS_CdPtoVta" as "t6.U_GVS_CdPtoVta",T6."U_GVS_CodRelacionado" as "t6.U_GVS_CodRelacionado", t5."City" as "t5.City_2"
, T7."Rate"
, T8."U_NAME"
,T9."InvntryUom",T9."SWeight1",T1."DiscPrcnt" AS "PROMO",CASE WHEN T1."DiscPrcnt"=100 THEN SUM(T10."Price" * T1."Quantity") ELSE 0 END AS "VLDESCU"
,T0."Max1099" AS "Totsinret"
,T0."DiscSum",T0."DocTotalFC",T0."DiscPrcnt",T0."WTSumFC"
,T1."BaseType",T1."UseBaseUn",T1."Price", T7."Rate",T1."TaxCode",T2."LicTradNum",T5."U_GVS_Telefono" AS "Phone1",T5."U_GVS_Celular" "Phone2"
,T2."City",T3."SlpName",T3."Telephone" , T4."PymntGroup" , T5."Street",T5."Block", T5."U_GVS_CdPtoVta",T5."U_GVS_CodRelacionado", t5."City"
, T6."Street",T6."Block",T6."U_GVS_CdPtoVta",T6."U_GVS_CodRelacionado",T8."U_NAME",T9."InvntryUom",T9."SWeight1",T0."CardCode",T10."Price"
,T0."Max1099",T9."U_GVS_CantProv"
FROM {?Schema@}.OINV T0
LEFT JOIN {?Schema@}.INV1 T1 ON T1."DocEntry"=T0."DocEntry"
LEFT JOIN {?Schema@}.OCRD T2 ON T0."CardCode"=T2."CardCode"
LEFT JOIN {?Schema@}.OSLP T3 ON T0."SlpCode"=T3."SlpCode"
LEFT JOIN {?Schema@}.OCTG T4 ON T2."GroupNum"=T4."GroupNum"
LEFT JOIN {?Schema@}.CRD1 T5 ON T2."CardCode" = T5."CardCode" and T0."ShipToCode"=T5."Address" AND T5."AdresType"='S'
LEFT JOIN {?Schema@}.CRD1 T6 ON T2."CardCode" = T6."CardCode" and T0."PayToCode"=T6."Address" AND T6."AdresType"='B'
LEFT JOIN {?Schema@}.OSTC T7 ON T1."TaxCode" = T7."Code"
LEFT JOIN {?Schema@}.OUSR T8 ON T0."UserSign" = T8.USERID
LEFT JOIN {?Schema@}.OITM T9 ON T9."ItemCode" = T1."ItemCode"
LEFT JOIN {?Schema@}.ITM1 T10 ON T10."ItemCode" = T1."ItemCode" AND T10."PriceList" = T2."ListNum"
LEFT JOIN {?Schema@}.OUSR T11 ON T11."USERID" = {?UserCode@}
WHERE T0."DocType" ='I' and T0."DocEntry"={?DocKey@}
GROUP BY T0."Printed",T0."CardCode",T1."ItemCode",T9."U_GVS_CantProv",T0."DocEntry",T0."DocNum", T0."CardName"
, T0."VatSum", T0."DocTotal", T1."PriceBefDi", T0."DocDate",T0."TaxDate", T0."DocDueDate"
, T0."Address", T0."Comments" , T0."WTSum", T0."DocEntry", T0."NumAtCard", T0."DocType" , T0."DocCur",T0."VatSumFC"
,T0."DiscSum",t0."DiscPrcnt",t0."DocTotalFC",T0."Max1099",T0."WTSumFC",T1."Dscription",T1."Price",T1."VatPrcnt",T1."DiscPrcnt"
,T1."BaseType",T1."UseBaseUn",T10."Price",T7."Rate"
, T1."TaxCode"
, T2."LicTradNum", T5."U_GVS_Telefono", T5."U_GVS_Celular", t2."City"
, T3."SlpName"
,T3."Telephone"
, T4."PymntGroup"
, T5."Street"
,T5."Block", T5."U_GVS_CdPtoVta",T5."U_GVS_CodRelacionado", t5."City"
, T6."Street"
,T6."Block", T6."U_GVS_CdPtoVta",T6."U_GVS_CodRelacionado", t5."City"
, T7."Rate"
, T8."U_NAME"
,T9."InvntryUom",T9."SWeight1",T1."DiscPrcnt"
,T0."Max1099"