Hi guys,
I have a SQL connection created in Excel - second code below. I use fixed cells as parameters for this. When I run this connection manually it is relatively fast. However when I use VBA (first code below) to run it, it is extremnly slow or stuck. Could you pls advise if you know the reason for it and how to fix it?
Thank you
I have a SQL connection created in Excel - second code below. I use fixed cells as parameters for this. When I run this connection manually it is relatively fast. However when I use VBA (first code below) to run it, it is extremnly slow or stuck. Could you pls advise if you know the reason for it and how to fix it?
Thank you
Code:
Sheets("Frontsheet SNs").Select
ActiveSheet.Unprotect
Range("Table_Query_from_DM_EMEA_IT[[#Headers],[COUNTRY]]").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
Code:
SELECT DISTINCT ZOH_BLS08_IDL.COUNTRY,
ZOH_BLS08_IDL.DOC_NUMBER AS 'SAP Order No',
ZOH_BLS08_IDL.GT_BSTKD AS 'PO',
ZOH_BLS08_IDL.MATERIAL AS 'PN',
ZOH_SDS46_IDL.SERNO AS 'SN',
ZOH_MDS32_IDL.ZSUBSER_D AS 'PN Description',
ZOH_BLS08_IDL.DOC_TYPE AS 'Order Type',
ZOH_BLS08_IDL.NETVAL_INV AS 'Net Item Line Value',
ZOH_BLS08_IDL.INV_QTY AS 'Item Qty',
ZOH_BLS08_IDL.TAX_AMOUNT AS 'VAT',
ZOH_BLS08_IDL.DOC_CURRCY AS 'Currency',
ZOH_MDS32_IDL.LENGHT AS 'Lenght',
ZOH_MDS32_IDL.WIDTH AS 'Width',
ZOH_MDS32_IDL.HEIGHT AS 'Height',
ZOH_MDS32_IDL.UNIT_DIM AS 'Unit Dim',
ZOH_MDS32_IDL.GROSS_WT AS 'Gross WT',
ZOH_MDS32_IDL.UNIT_OF_WT AS 'Unit of GW',
ZOH_BLS08_IDL.REFER_DOC AS 'Delivery No',
ZOH_BLS08_IDL.BILL_NUM AS 'Invoice No',
convert(varchar(8),ZOH_BLS08_IDL.BILL_DATE,112) AS 'Invoice Date',
cast(ZOH_BLS08_IDL.SOLD_TO as int) AS 'Sold to ID',
ZOH_BLS08_IDL.BILLTOPRTY AS 'Bill to ID',
ZOH_BLS08_IDL.SHIP_TO, ZOH_BLS08_IDL.SHIP_POINT AS 'Shipping point',
ZOH_BLS08_IDL.SALES_OFF AS 'Sales Office',
ZOH_BLS08_IDL.ZBPNAME AS 'Customer name',
ZOH_BLS08_IDL.BP_TYPE AS 'Customer Type',
ZOH_BLS08_IDL.ZEND_CUST AS 'End Customer ID',
ZOH_BLS08_IDL.ZVATRATE AS 'VAT Rate',
ZOH_BLS08_IDL.BBP_CTC_ID AS 'Contract No',
ZOH_SDS46_IDL.SHIPPTYP AS 'Shipping Type',
ZOH_BLS08_IDL.BILL_TYPE AS 'Billing Type',
ZOH_BLS08_IDL.PAYER AS 'Payer ID',
ZOH_BLS08_IDL.DIVISION AS 'Division',
ZOH_BLS08_IDL.VAT_REG_NO AS 'VAT ID',
ZOH_BLS08_IDL.SALESORG AS 'Sales Org',
ZOH_BLS08_IDL.DISTR_CHAN AS 'Distr Channel',
ZOH_BLS08_IDL.ZTERM AS 'Payment Term Code',
ZOH_MDS32_IDL.SIZE_DIM,
ZOH_MDS32_IDL.NET_WEIGHT,
ZOH_MDS32_IDL.ZSYSOPT
FROM DM_EMEA_IT.dbo.ZOH_BLS08_IDL ZOH_BLS08_IDL, DM_EMEA_IT.dbo.ZOH_MDS32_IDL ZOH_MDS32_IDL, DM_EMEA_IT.dbo.ZOH_SDS46_IDL ZOH_SDS46_IDL
WHERE ZOH_BLS08_IDL.MATERIAL = ZOH_SDS46_IDL.ZMAT AND ZOH_BLS08_IDL.REFER_DOC = ZOH_SDS46_IDL.DELIV_NUMB AND ZOH_BLS08_IDL.MATERIAL = ZOH_MDS32_IDL.ZMAT AND
(
(ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
OR (ZOH_BLS08_IDL.GT_BSTKD Like ?) AND (ZOH_BLS08_IDL.MATERIAL Like ?) AND (ZOH_SDS46_IDL.SERNO Like ?) AND (ZOH_BLS08_IDL.BILL_TYPE In ('YBF2','YBG2','YBL2','YBRE','YBFG')) AND (ZOH_BLS08_IDL.SOLD_TO Like '1%') AND (ZOH_BLS08_IDL.AB_FKSTO<>'x') AND (ZOH_SDS46_IDL.ZACT_DAT Is Not Null)
)