Skip to Content
author's profile photo Former Member
Former Member

DI: How to retrieve / set basedocument

Hi all,

When I create a new document through sbo that is based on another document (e.g. an order based on a quotation), sbo maintains that link somehow. I can navigate through these using the icons for basedocument and targetdocument on the iconbar on top.

I always supposed this was some property of the documents object, but I can't find which one?!

If that is not the case, van anyone tell me how to set/retrieve this properly?

Thanx,

Jacques

Add comment
10|10000 characters needed characters exceeded

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jul 22, 2004 at 09:00 AM

    I know it is somewhere in there...

    Take a look at the fields baseref and docnum. Maybe this helps. Sorry for the mess, no time tio clear this up.

    The query gets purchases and lines then up with goods returns and payments, if i recall correctly. It does make use of linking documents, though not on the sales side.

    HTH Lutz Morrien

    select * from

    (

    SELECT T0.DocNum, null as RefDocNum,0 as DocTypeNum, 'ER' as DocType ,T0.DocDate,

    T0.CardCode,T0.CardName, T1.PymntGroup, T0.DocTotal,

    T0.TotalExpSC, T0.VatSum, T0.VatSumSy, T0.VatPercent

    FROM OPCH T0

    INNER JOIN OCTG T1

    ON T0.GroupNum = T1.GroupNum

    union all

    SELECT T1.BaseRef, T0.DocNum as DocRefNum,1 as DocTypeNum, 'GUT' as Belegart,T0.DocDate,

    T0.CardCode, T0.CardName, Null as PaymentGroup, t1.OpenCreQtyT1.PriceAfVat-1 as DocTotal,

    T0.TotalExpSC, T0.VatSum, T0.VatSumSy, T0.VatPercent

    FROM ORPC T0 inner join RPC1 T1 ON T0.DocEntry = T1.DocEntry

    union all

    SELECT T2.DocNum as DocNum,T0.Docnum as DocRefNum,2 as DocTypeNum,'AZ' as DocType,T0.DocDate,

    T0.CardCode, T0.CardName,null as PaymentGroup, (t1.DcntSum + T1.AppliedSys)*-1 as DocTotal,

    null as TotalExpSC, T0.VatSum, T0.VatSumSy, null as VatPercent

    FROM OVPM T0 INNER JOIN VPM2 T1 ON T0.DocNum = T1.DocNum INNER JOIN OPCH T2 ON T1.DocEntry = T2.DocEntry

    ) test

    order by docnum,doctypenum

    Add comment
    10|10000 characters needed characters exceeded