Skip to content

Instantly share code, notes, and snippets.

@TaylanUB
Created March 6, 2019 17:29
Show Gist options
  • Save TaylanUB/aeea411bdfaf44ef6c67c5a404eb83a6 to your computer and use it in GitHub Desktop.
Save TaylanUB/aeea411bdfaf44ef6c67c5a404eb83a6 to your computer and use it in GitHub Desktop.
select r.DocEntry as rdrDocId,
r1.LineNum as rdrLineId
into #orderLines
from rdr1 r1
join ordr r on r.DocEntry = r1.DocEntry
where r1.LineStatus = 'O' and r.DocStatus = 'O'
select U_KommNr as pklDocId,
max(cast(U_Space as int)) as maxPlace
into #picklistDetails
from [@PICKING]
where U_DeletedF = 'N'
group by U_KommNr
select p.AbsEntry as pklDocId,
case
when pd.maxPlace is null then 0
else pd.maxPlace
end as pklDocMaxPlace
into #picklistDocs
from opkl p
left join #picklistDetails pd on pd.pklDocId = p.AbsEntry
select AbsEntry as pklDocId,
PickEntry as pklLineId,
OrderEntry as rdrDocId,
OrderLine as rdrLineId
into #picklistDocLines
from PKL1
select p.pklDocMaxPlace
from #picklistDocs p
join #picklistDocLines p1 on p.pklDocId = p1.pklDocId
join #orderLines r1 on r1.rdrDocId = p1.rdrDocId
and r1.rdrLineId = p1.rdrLineId
drop table #picklistDocs, #picklistDocLines, #picklistDetails, #orderLines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment