diff --git a/import_944s.py b/import_944s.py index cd6d771..617d8ac 100644 --- a/import_944s.py +++ b/import_944s.py @@ -85,15 +85,20 @@ DETAIL_STATEMENT = """ """ SUBDETAIL_STATEMENT = """ - select distinct - [S] - ,[sta] - ,[pcu] - ,[qtypcu] - ,[lot] - ,[bpslot] - ,[sernum] + select + 'S' [S], + 'A' [sta], + [STJ].[PCU_0] [pcu], + cast(cast(-1*[STJ].[QTYSTU_0] as int) as nvarchar) [qtypcu], + [STJ].[LOT_0] [lot], + '' [bpslot], + '' [sernum] from [staging].[dbo].[shandex_receipt_details] + left join x3.PROD.STOJOU STJ + on STJ.VCRNUM_0 = [shandex_receipt_details].sdhnum + and STJ.ITMREF_0 = [shandex_receipt_details].itmref + and STJ.LOT_0 = [shandex_receipt_details].lot + and STJ.VCRLIN_0 = [shandex_receipt_details].sddlin where sdhnum = :sdhnum and itmref = :itmref """