Query - target documents

Hi all.
I recently discovered a great query on this forum, it returns all deliveries and all invoices made from one sales order document. It basically lists all target documents for the given sales order. In addition to this, I was thinking it would be great to include returns and credit memos as well, and that is the reason for this post, I'm unable to do it my self. Anyone up for the task?
Here is the query as it is today:
SELECT distinct 'DN', D0.DocNum , D0.DocDate, D0.DocDueDate, D0.DocTotal,
'IN', I0.DocNum , I0.DocDate, I0.DocDueDate, I0.DocTotal, I0.PaidToDate
FROM ((ODLN D0 inner Join DLN1 D1 on D0.DocEntry = D1.DocEntry)
full outer join (OINV I0
inner join INV1 I1 on I0.DocEntry = I1.DocEntry) on (I1.BaseType=15
AND D1.DocEntry = I1.BaseEntry AND D1.LineNum=I1.BaseLine))
WHERE (D1.BaseType=17 AND D1.BaseRef=[%0])
OR (I1.BaseType=17 AND I1.BaseRef=[%0])
OR (I1.BaseType=15 AND I1.BaseEntry
IN (SELECT Distinct DocEntry FROM DLN1
WHERE BaseType=17 AND BaseRef=[%0]))
All help is much appreciated.
Thanks and regards,
Runar Wigestrand.

To get the target documents of a sales order including the returns and credit memos you can use this:
SELECT distinct
'DN', D0.DocNum , D0.DocDate, D0.DocDueDate, D0.DocTotal,
'Ret',R.DocNum,R.DocDate,
'Inv', I0.DocNum , I0.DocDate, I0.DocDueDate, I0.DocTotal, I0.PaidToDate,
'Cr',C.Docnum,C.DocDate
FROM ((ODLN D0 inner Join DLN1 D1 on D0.DocEntry = D1.DocEntry)
full outer join
     (OINV I0 inner join INV1 I1 on I0.DocEntry = I1.DocEntry)
      on (I1.BaseType=15 AND D1.DocEntry = I1.BaseEntry
                    AND D1.LineNum=I1.BaseLine)
left outer join (ORDN R inner join RDN1 R1 on R.DocEntry = R1.DocEntry)
      on (R1.BaseEntry=D1.DocEntry and D1.LineNum=R1.BaseLine)
left outer join (ORIN C inner join RIN1 C1 on C.DocEntry = C1.DocEntry)
      on (C1.BaseEntry=I1.DocEntry and I1.LineNum=C1.BaseLine and C1.BaseType=13))
WHERE (D1.BaseType=17 AND D1.BaseRef=[%0])
   OR (I1.BaseType=17 AND I1.BaseRef=[%0])
   OR (I1.BaseType=15
     AND I1.BaseEntry IN (SELECT Distinct DocEntry FROM DLN1
                    WHERE BaseType=17 AND BaseRef=[%0]))

Similar Messages

  • How to get Target document

    Dear Experts,
    Plz have a look on this query for Total Purchase Report. It's working fine.
    All I need is that Target Documents of A/P Invoice should also return on Report in front of A/P Invoice document with details like A/P Cr. Memo No, DocTotal.
    *SELECT T0.[DocNum], T1.[Seriesname], T0.[CardCode] As 'Vendor Code',T0.[CardName] As 'Vendor Name', T0.[NumAtCard] As 'Vendor Ref. No.', T0.[DocDate], T0.[TaxDate], T0.[DocTotal] - T0.[VatSum] As 'Basic Value of Goods', T0.[U_CENVAT] As 'CENVAT',  T0.[U_ECess], T0.[U_HSCess], T0.[U_VAT_4], T0.[U_Add_VAT1], T0.[U_VAT_12],
    T0.[U_Add_VAT2], T0.[U_CST2], T0.[U_CST4], T0.[U_CST5], T0.[U_Service_Tax], T0.[U_ST_ECess], T0.[U_ST_HSCess],T0.[TotalExpns] As 'Others',T0.[DocTotal] - T0.[VATSUM] As 'Total' FROM OPCH T0 inner join nnm1 t1 on t0.series = t1.series WHERE T0.[TaxDate] Between [%0] And [%1]*
    I don't have any idea how to do this.
    So Plz suggest me or provide query for same.
    Thanks in advance.
    Regards,
    Ravi

    Hi Ravi.......
    Try this.....
    SELECT T0.DocNum, T1.Seriesname, T0.CardCode As 'Vendor Code',T0.CardName As 'Vendor Name', T0.NumAtCard As 'Vendor Ref. No.', T0.DocDate, T0.TaxDate, T0.DocTotal - T0.VatSum As 'Basic Value of Goods', T0.U_CENVAT As 'CENVAT', T0.U_ECess, T0.U_HSCess, T0.U_VAT_4, T0.U_Add_VAT1, T0.U_VAT_12,
    T0.U_Add_VAT2, T0.U_CST2, T0.U_CST4, T0.U_CST5, T0.U_Service_Tax, T0.U_ST_ECess, T0.U_ST_HSCess,T0.TotalExpns As 'Others',T0.DocTotal - T0.VATSUM As 'Total', T3.DocNum 'Cr. Memo No.', T3.DocTotal 'Cr. Memo Total' FROM OPCH T0 inner join nnm1 t1 on t0.series = t1.series LEFT OUTER JOIN RPC1 T2 On T0.DocEntry=T2.BaseEntry LEFT JOIN ORPC T3 On T2.DocEntry=T3.DocEntry
    WHERE T0.TaxDate Between '[%0]' And '[%1]'
    Regards,
    Rahul

  • Table of Target Document in A/R Invoice

    I need to know what is the table or field that sap use for a Target Document.
    For example i need a query that show the DocNum A/R Invoices and know the docnum of A/R Credit Memo if the invoice was canceled. The same for DownPayment Invoice and Reserver Invoice.
    I try to find it, but still without know what is the table.
    Someone knows this?

    Thanks Syda, mmm can you explain how make inner join with A/R Credit Memo.
    I do this:
    SELECT T0.[DocNum], T0.[NumAtCard], T0.[DocDate], T0.[ObjType], T1.[TargetType] FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN RIN1 T2 ON T1.DocEntry = T2.DocEntry INNER JOIN ORIN T3 ON T2.DocEntry = T3.DocEntry
    But i dont know how get the DocNum of Credit Memo, example:    docnum invoice   -
    >   docnum credit memo

  • Precalculated query as document in KM

    I need to have precalculated query as document in KM for this I am done with repository manager ,my problem is i am not able to access a BI document via repository manager which i know is done by specifying Target field but am not sure what to put in that field and where it acctually exist(The BI document).

    Hello Anurupa,
    Here are some links which really fulfills your requirements.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b0bc8ea5-031d-2a10-d0a7-e9ee996f5bb7
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/c39fb990-0201-0010-abae-ba08ada8026b
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/fcf3ac90-0201-0010-cd8c-a591d58621c3
    These links will serve your purpose .If u find any problem please feel free to contact me .I will send you more documents if i get as per your requirements.
    If you find it worth please reward points.
    With Warm Regards,
    Rakesh Kumar Verma.

  • PO from SO via DI API:Base document card and target document card do not ..

    HI All,
    I am trying to create Purchase Order from Sales Order. This is possible by GUI (on Sales Order on logistics tabs Click On Purcase Orders CheckBox.
    I got the error message: -5002-Base document card and target document card do not match.
    The message itself can be understandable, because the Customer and Supplier has a different CardCode.
    I am sure I am using a correct code
    oPo.Lines.BaseType = BoObjectTypes.oOrders
    oPo.Lines.BaseEntry = sDocEntry
    oPo.Lines.BaseLine = iLineNum
    Where oPo is a Purchase Order document.
    sDocEntry is a Sales Order docentry and iLineNum is a Line number of Sales Order
    For other A/R to A/R and A/P to A/P documents are working fine.
    Has anybody found this error or has anybody created application like this?
    I am using sbo2007PL46
    Regards,
    J.

    Hi guys,
    this is still on the suggestion page:
    Link existing Purchase Orders to (Sales) Orders via DI API : View Idea
    I tryed with 9.1 PL 4 and it didn't work.

  • Freight  Amount not shown in Target Documents

    Hi ,
    I have created a Purchase order with Freight Charges , But when i m copying the PO to Targets Documents(i.e GRPO, Invoice) then Freight amount is Not appeared . Pls suggest what to do  in this case .
    Regards
    Raman Preet singh

    Hi raman.sap 
    Check this
    Administration -> General -> Setup ->Freight - Setup Window
    Drawing Method Specify the required calculation method of the freight per row. The calculation method you select becomes evident when you copy rows from a base document to a target document. The options are:
    None u2013 No freight will be copied to target document.
    Quantity u2013 The amount is divided into the item quantity and each unit carries the same amount of freight.
    Total u2013 SAP Business One calculates which part of the document total or row total is copied to the target document. It then adds the relative amount of the document or row freight to that target document.
    All u2013 Copies all the freight to the target document.

  • Copying a PageItem to Another Document, When the Color Name Already Exists in the Target Document

    (CS5 and ActionScript)
    I am trying to copy a PageItem from Document A to Document B.
    If the PageItem in Document A has a Color named "MyColor", and that Color already exists in Document B, then when I duplicate the PageItem from Document A to B, a new Color called "MyColor 2" is created in Document B.
    What I wanted was for the PageItem to simply take on the deifintion of "MyColor" which was already in Document A.
    If you perform this activity manually in the desktop UI, no duplicate color is created and the PageItem recieves de facto the original color values for the original "MyColor" in target document B.
    Any ideas?
    mlavie

    Sorry - mistake crept in. I meant:
    I am trying to copy a PageItem from Document A to Document B.
    If the PageItem in Document A has a Color named "MyColor", and a Color by that name already exists in Document B, then when I duplicate the PageItem from Document A to B, a new Color called "MyColor 2" is created in Document B.
    What I wanted was for the PageItem to simply take on the deifintion of "MyColor" which was already defined in Document B.
    If you perform this activity manually in the desktop UI, no duplicate color is created and the PageItem recieves de facto the original color values for the original "MyColor" in target document B.

  • How do I keep the source document open when linking to a target document using the destination option in Adobe X?

    How do I keep the source document open when linking to a target document using the destination option in Adobe X? Have several links to create in the source document and want to keep the source document and target document open at the same time.

    Go to Edit - Preferences - Documents and un-tick "Open cross-document links
    in the same window".

  • This.submitForm fails to download target document

    after some probs with certificate installation (http://www.adobeforums.com/webx/.59b87b22/3) I can now successfully submit form information via this.submitForm in a Linux (Ubuntu) environment.
    I had a problem where the following was displayed: "Cannot process response due to unknown content type". This was a MIME issue: running install_browser_plugin resolved this: I ensured the plugin was present in firefox. I also attempted to open an fdf via firefox and this routes correctly to Acrobat and displays a pdf.
    The problem I am experiencing now is when submitting I get the following messages displayed:
    1. Preparing for Submit.
    2. Sending/Receiving data
    3. Download target document...
    The target document is never downloaded and I cannot view the success/failure response.
    What am I doing wrong?

    As per confirmation from Ben, this issue is solved now. In essence, it was same as SSL Issue reported earlier by Ben.
    Confirmation comments -    "Now I can submit and receive responses from Linux. You have resolved this problem!"
    A workaround has been posted at http://blogs.adobe.com/acroread/  ( SSL Error on Linux Reader - Resolution)
    Thanks,
    Vaibhav

  • A/R Invoice closed without target documents

    Dear Experts,
    I have an A/R Invoice with 'Closed' status, and it does not have any Credit Memo or Incoming payment made agst. this invoice, I cant figure it out why without target document it get closed.
    Suggestion are welcome.
    Regards,
    Ravi

    Hi
    Please right button in the invoice and choose reconciled transactions.
    You can see you need.
    Kind regards.
    Agustín Marcos Cividanes

  • Based document series need to be copied to target document

    Hi,
    There are 4 document series for every marketing document as Manufacturing - Series 1, Trading - Series 2, Retail - Series 3, Wholesale - Series 4, Shoppers - Series 5.
    Now User A is been given permission / authorization for document series 1 and 2 which is for Manufacturing and Trading and user B is given permission for document series 3,4 and 5 for Retail, Wholesale and Shoppers. Now when user B makes a sales order in say Wholesale which is document series 4 and then makes a delivery based on the sales order it is seen that in delivery note he has to again select the document series manually which is series 4 Wholesale. Why it is not possible to copy the based document series to the target document.
    Again for example user A makes PO in series 1 which is Manufacturing and then makes a Good Reciept PO then again he has to select the document series in the target document as 1 manually.
    Is there any way by which the base document series can be copied to the target document without manually selecting the same as its creates a mess if the user forgets to select the document series in the target document....Means SO is made in in Wholesales and Delivery is done in Shoppers. No default series also can be done as in any series as per requirement the user does the base document and he wants that once he put the series in the base document then automatically while doing the target document the base document series should be selected.
    Kindly let me know is there any possibility in SBO 2005B.
    Regards,
    Kamlesh

    Dear Shamseer,
    Default series has been set for that particular user. But for that user only 2-3 series are defined as per clients requirement. Now user wants that once in the base document the series is selected. All the corresponding target document should come with the same series ( Note all marketing document has the same series name but have diffrent series number )
    Regards,
    Kamlesh

  • BP of Copied DP must be same as BP of Target Document.

    Hi Experts,
    We are using SAP B1 8.8 version. When we post the Service type AP Invoices direct from PO cannot be posted and display the error message of " Business Partner of copied down payment document must be same as Business partner of Target Document" Expecting your solution.
    Thanks in Advance
    Mangalarajan P

    Dear Manvendra,
    Thanks for your valuable reply.
    Normally, for the Service Cases, we will not post the GRPO's. But, we created the Service Purchase Order for those cases, and AP Invoice has been posted directly from the PO Document.
    When we posted for one Freight Bill, it shows the error message of the above. Afterthat, we cannot post the AP Invoice for other Service BP's also. I checked it, we are not changing any BP code.
    Seeking your solution on this.
    Regards
    Mangalarajan P

  • VPRS is not getting copied sometime to the target document.

    Hi,
    While creating Credit Memo Request with reference to Invoice, sometimes VPRS Condition Type is not copied from Invoice to Credit Memo Request.
    But, when Debit memo Request is created , VPRS is getting copied always from Invoice to Debit Memo Request.
    I have checked the Item Category, Copy Control as well as Pricing date in the target document (Cr memo Req). All those are fine.
    I am not able to find out the reason why sometimes the VPRS Condition type is not geting copied.
    Can anybody help me on this what can be the possible reason for it ?
    Edited by: pradyumna on Apr 20, 2011 5:53 PM

    Hi,
    Please check if the field 'Determine cost' is checked at Item category level.
    Regards,
    Peeyoosh.

  • "target document has a different depth than source document." help?

    as of yesterday i have been recieveing an alert when i try to move a jpeg into a new photoshop doc stating that my target document has a different depth than my source document and will (which it definiately does) result in lower than expected quality. i have no idea how to fix this. please help.
    Photoshop specs: CS6; RGB; 16 bit; Res 300 pixels/inches; size: letter; (advanced setting - don't know what these are) color profile: sRGB IEC61966-2.1; Pixel aspect ratio: square pixels
    don't know if i accidentally messed with something i shouldn't have or what. any help is appreciated. thank you in advance.

    There's GOT to be something to fix. I've been getting that message all night -- when I say "yes" and then try to SAVE the document, it won't give me the option to "save for web."
    I started completely from scratch, and still got the error window, and it still wouldn't let me "save for web."
    So -- let's begin again -- what needs to be fixed?

  • Update a system form with XML: empty screen when this is a target document.

    Hi,
    It is possible to update a system form with an xml file.
    In the UI_Application.LoadBatchActions(xmlDoc). In the xmldocuemnt I update a system form by adding controls on it. This all works fine, except one (big) problem.
    Assume that I Alter the 'Good Receipt PO'.
    This document can be the target document of a Purchase order document. When you open a PO and click the icon on the toolbar for going to the target document, you see the target document filled in, in OK (view) mode.
    When you alter the 'Goods Receipt PO' form with XML you get an empty goods receipt form, in Add mode.
    Is this a known problem, how can I solve it?
    Thanks in advance
    Eddy

    Hi Florian,
    The XML looks like:
    <?xml version="1.0" encoding="UTF-16"?>
    <Application>
       <forms>
          <action type="update">
             <form AutoManaged="1" BorderStyle="0" FormType="143" ObjectType="20" SupportedModes="15" appformnumber="143" client_height="424" client_width="570" color="0" default_button="1" height="458" left="207" mode="3" pane="1" title="Goederenontvangst (bestelling)" top="23" type="0" uid="F_233" visible="1" width="578">
                <items>
                   <action type="add">
                      <item AffectsFormMode="1" backcolor="-1" description="" disp_desc="0" enabled="1" font_size="0" forecolor="-1" from_pane="0" height="19" left="434" linkto="" right_just="0" supp_zeros="0" tab_order="830" text_style="0" to_pane="0" top="398" type="4" uid="100001" visible="1" width="85">
                         <AutoManagedAttribute>
                            <Attribute description="editable" id="2" modeAdd="1"/>
                         </AutoManagedAttribute>
                         <specific caption="Container"/>
                      </item>
                   </action>
                   <action type="update">
                      <item AffectsFormMode="1" backcolor="-1" description="" disp_desc="0" enabled="1" font_size="0" forecolor="-1" from_pane="0" height="19" left="315" linkto="2" right_just="0" supp_zeros="0" tab_order="1160" text_style="0" to_pane="0" top="398" type="4" uid="68" visible="1" width="114">
                         <AutoManagedAttribute>
                            <Attribute description="editable" id="2" modeAdd="1"/>
                         </AutoManagedAttribute>
                         <specific caption="Voorfactuur"/>
                      </item>
                   </action>
                </items>
             </form>
          </action>
       </forms>
    </Application>
    Thank you very much for trying this.
    Eddy

Maybe you are looking for

  • After upgrading to iOS 6, my text tone disappeared

    Ringer, voice memo, alarm work but no text tone.  Ringer volume icon comes up but no bars appear when adjusting volume buttons. any ideas?

  • Regarding dropdowns in Adobe forms

    Hi experts. I am trying to create an Adobe Form. I have 2 dropdown lists in there. Depending on the value selected in the 1st dropdown i want to populate data in 2nd dropdown list. Can i do this using javascript..If yes , how. Or is there any other a

  • HT204053 Is there a way of merging two AppleIDs?

    Obviously a beginners mistake, but I have created a second AppleID instead of changing the email address of the first one. And now I have purchases in itunes from both accounts. Is there a way to merge the two accounts? Thanks in advance for any tips

  • Hi, about w700 raid 0

    Hi everyone I'm now using a w700 and using 2 hard drives to make a raid 0. i'm wondering does w700 support to build a raid 0 with 3 hard drives, which one of them is in the cd-rom hard drive adaptor? Thanks!!

  • X301 42T4520 LiPo down to 63% capacity after 125 cycles

    Hi everybody, subject says it all - is this normal? TiA, Florian