Skip to Content

Add ochp -chapter id in query???

select distinct T0.DocNum,T1.U_jobno,T0.CardCode,T0.CardName,T0.DocDate, T1.ItemCode,T1.Quantity, T1.OpenQty ,T1.LineTotal as 'PendValue',

case when T3.BR<>'' then 'BR' when T3.PKG<>'' then 'PKG' when T3.QC<>'' then 'QC' else 'SIP' end Division ,null AS Trans,dbo.OHEM.firstName as 'Executive', T0.DocStatus as 'docstatus'

from ORDR T0 inner join RDR1 T1 on T0.docentry=T1.docentry LEFT OUTER JOIN

dbo.OHEM ON T0.OwnerCode = dbo.OHEM.empID left outer join

(

select C.U_jobno, C.ItemCode,C.Dscription, C.WhsCode as 'QC',B.WhsCode as 'PKG',A.WhsCode as 'BR', C.Quantity,B.Jrnlmemo from (

(SELECT distinct t0.docnum,T0.docdate,T1.ItemCode, T1.Dscription, T1.U_jobno, t0.filler,T1.WhsCode, T1.Quantity,T0.Jrnlmemo FROM OWTR T0 INNER JOIN WTR1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode INNER JOIN OWHS T3 ON T0.Filler = T3.WhsCode INNER JOIN OITW T4 ON T2.ItemCode = T4.ItemCode where t0.filler='SIP' and T1.WhsCode='QC')C left outer join

(SELECT distinct t0.docnum,T0.docdate,T1.ItemCode, T1.Dscription, T1.U_jobno, t0.filler,T1.WhsCode, T1.Quantity,T0.Jrnlmemo FROM OWTR T0 INNER JOIN WTR1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode INNER JOIN OWHS T3 ON T0.Filler = T3.WhsCode INNER JOIN OITW T4 ON T2.ItemCode = T4.ItemCode where t0.filler='QC' and T1.WhsCode='PKG' )B on C.U_jobno=B.U_jobno

left outer join

(SELECT distinct t0.docnum,T0.docdate,T1.ItemCode, T1.Dscription, T1.U_jobno, t0.filler,T1.WhsCode, T1.Quantity,T0.Jrnlmemo FROM OWTR T0 INNER JOIN WTR1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode INNER JOIN OWHS T3 ON T0.Filler = T3.WhsCode INNER JOIN OITW T4 ON T2.ItemCode = T4.ItemCode where t0.filler='PKG' and T1.WhsCode='BR' ) A on C.U_jobno=A.U_jobno

)

) T3 on T3.U_jobno=T1.U_jobno

where T1.U_Urgcard='01' and T0.DocStatus='O' and T0.CANCELED='N'and T1.Price<>0 and T1.LineStatus='O' and T0.series=399

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Jul 24, 2012 at 09:46 AM

    Hi Vinayak

    Final i believe.. :-)

    select distinct T0.DocNum,T1.U_jobno,T0.CardCode,T0.CardName,T0.DocDate, T1.ItemCode,T1.Quantity, T1.OpenQty ,T1.LineTotal as 'PendValue',

    case when T3.BR<>'' then 'BR' when T3.PKG<>'' then 'PKG' when T3.QC<>'' then 'QC' else 'SIP' end Division ,null

    AS Trans,dbo.OHEM.firstName as 'Executive', T0.DocStatus as 'docstatus',

    x2.ChapterID

    from ORDR T0 inner join RDR1 T1 on T0.docentry=T1.docentry

    LEFT OUTER JOIN dbo.OHEM ON T0.OwnerCode = dbo.OHEM.empID

    Inner join OITM x1 on x1.ItemCode=t1.ItemCode

    left outer join ochp x2 on x2.AbsEntry=x1.ChapterID

    left outer join

    (

    select C.U_jobno, C.ItemCode,C.Dscription, C.WhsCode as 'QC',B.WhsCode as 'PKG',A.WhsCode as 'BR', C.Quantity,B.Jrnlmemo from (

    (SELECT distinct t0.docnum,T0.docdate,T1.ItemCode, T1.Dscription, T1.U_jobno, t0.filler,T1.WhsCode, T1.Quantity,T0.Jrnlmemo FROM OWTR T0 INNER JOIN WTR1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode INNER JOIN OWHS T3 ON T0.Filler = T3.WhsCode INNER JOIN OITW T4 ON T2.ItemCode = T4.ItemCode where t0.filler='SIP' and T1.WhsCode='QC')C left outer join

    (SELECT distinct t0.docnum,T0.docdate,T1.ItemCode, T1.Dscription, T1.U_jobno, t0.filler,T1.WhsCode, T1.Quantity,T0.Jrnlmemo FROM OWTR T0 INNER JOIN WTR1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode INNER JOIN OWHS T3 ON T0.Filler = T3.WhsCode INNER JOIN OITW T4 ON T2.ItemCode = T4.ItemCode where t0.filler='QC' and T1.WhsCode='PKG' )B on C.U_jobno=B.U_jobno

    left outer join

    (SELECT distinct t0.docnum,T0.docdate,T1.ItemCode, T1.Dscription, T1.U_jobno, t0.filler,T1.WhsCode, T1.Quantity,T0.Jrnlmemo FROM OWTR T0 INNER JOIN WTR1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode INNER JOIN OWHS T3 ON T0.Filler = T3.WhsCode INNER JOIN OITW T4 ON T2.ItemCode = T4.ItemCode where t0.filler='PKG' and T1.WhsCode='BR' ) A on C.U_jobno=A.U_jobno

    )

    ) T3 on T3.U_jobno=T1.U_jobno

    where T1.U_Urgcard='01' and T0.DocStatus='O' and T0.CANCELED='N'and T1.Price<>0 and T1.LineStatus='O'

    and T0.series=399

    Regards

    Kennedy

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 24, 2012 at 07:29 AM

    Hi Vinayak,

    Try This

    select distinct T0.DocNum,T1.U_jobno,T0.CardCode,T0.CardName,T0.DocDate, T1.ItemCode,T1.Quantity, T1.OpenQty ,T1.LineTotal as 'PendValue',

    case when T3.BR<>'' then 'BR' when T3.PKG<>'' then 'PKG' when T3.QC<>'' then 'QC' else 'SIP' end Division ,null

    AS Trans,dbo.OHEM.firstName as 'Executive', T0.DocStatus as 'docstatus',

    x2.ChapterID

    from ORDR T0 inner join RDR1 T1 on T0.docentry=T1.docentry

    LEFT OUTER JOIN dbo.OHEM ON T0.OwnerCode = dbo.OHEM.empID

    Inner join OITM x1 on x1.ItemCode=t1.ItemCode

    left outer join ochp x2 on x2.ChapterID=x1.ChapterID

    left outer join

    (

    select C.U_jobno, C.ItemCode,C.Dscription, C.WhsCode as 'QC',B.WhsCode as 'PKG',A.WhsCode as 'BR', C.Quantity,B.Jrnlmemo from (

    (SELECT distinct t0.docnum,T0.docdate,T1.ItemCode, T1.Dscription, T1.U_jobno, t0.filler,T1.WhsCode, T1.Quantity,T0.Jrnlmemo FROM OWTR T0 INNER JOIN WTR1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode INNER JOIN OWHS T3 ON T0.Filler = T3.WhsCode INNER JOIN OITW T4 ON T2.ItemCode = T4.ItemCode where t0.filler='SIP' and T1.WhsCode='QC')C left outer join

    (SELECT distinct t0.docnum,T0.docdate,T1.ItemCode, T1.Dscription, T1.U_jobno, t0.filler,T1.WhsCode, T1.Quantity,T0.Jrnlmemo FROM OWTR T0 INNER JOIN WTR1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode INNER JOIN OWHS T3 ON T0.Filler = T3.WhsCode INNER JOIN OITW T4 ON T2.ItemCode = T4.ItemCode where t0.filler='QC' and T1.WhsCode='PKG' )B on C.U_jobno=B.U_jobno

    left outer join

    (SELECT distinct t0.docnum,T0.docdate,T1.ItemCode, T1.Dscription, T1.U_jobno, t0.filler,T1.WhsCode, T1.Quantity,T0.Jrnlmemo FROM OWTR T0 INNER JOIN WTR1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode INNER JOIN OWHS T3 ON T0.Filler = T3.WhsCode INNER JOIN OITW T4 ON T2.ItemCode = T4.ItemCode where t0.filler='PKG' and T1.WhsCode='BR' ) A on C.U_jobno=A.U_jobno

    )

    ) T3 on T3.U_jobno=T1.U_jobno

    where T1.U_Urgcard='01' and T0.DocStatus='O' and T0.CANCELED='N'and T1.Price<>0 and T1.LineStatus='O'

    and T0.series=399

    Regards

    Kennedy

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.