Getting all payment related to a invoice (Similar to the applied transac)

Hi expert,
I'm currently designing a sales report for POS employe. I'm trying to relate all incoming payment related to a invoice and i don't see where the relation is establish (wich table ?). I have make a query to list by the oInv.ReceiptNum relation to oCrt but what if there is two payment for a invoices?
This is my query:
SELECT [IncPay].[DocNum]
      ,[IncPay].[DocType]
      ,[IncPay].[Canceled]
      ,[IncPay].[DocDate]
      ,[IncPay].[CardCode]
      ,[IncPay].[CardName]
      ,[IncPay].[Address]
       ,[Invoice].[DocTotal] AS [Inv.Total]
       ,[NoteCredit].DocTotal AS [Cred.Total]
      ,[IncPay].[CashSum] AS Argent
      ,[IncPay].[CreditSum] AS Carte
      ,[IncPay].[CheckSum] AS Cheque
      ,[IncPay].[DocTotal] AS Total
      ,[IncPay].[Ref1] AS [IcDocNum]
      ,[IncPay].[Ref2]
      ,[IncPay].[Comments]
      ,[IncPay].[JrnlMemo]
      ,[IncPay].[TransId]
      ,[IncPay].[DocTime]
      ,[IncPay].[NoDocSumSy] AS [ICOrphelin]
      ,[IncPay].[ObjType]
      ,[IncPay].[BankCode]
      ,(SELECT User_Code FROM oUsr Where UserID = [IncPay].[UserSign]) AS [UserOrig]
      ,[IncPay].[CancelDate]
      ,[IncPay].[OpenBal]
      ,(SELECT User_Code FROM oUsr Where UserID = [IncPay].[UserSign]) AS [UserUpdate]
  FROM [Antirouille_PROD].[dbo].[ORCT] AS IncPay
          LEFT JOIN [Antirouille_PROD].[dbo].[oInv] AS Invoice
               ON Invoice.ReceiptNum = [IncPay].[DocNum]
          LEFT JOIN [Antirouille_PROD].[dbo].[oRin] AS NoteCredit
               ON NoteCredit.ReceiptNum = IncPay.DocNum
  WHERE [IncPay].[Canceled] = 'N' AND  Invoice.DocNum = 34453
Thanks for your help!
Manuel

Hi,
After a deep investigation in how sap make that relation. It apears that sap use the reconcile table to link to related transaction.
That query return the Invoice and the outgoing payment of a journal entry number (168693) made by an incoming payment...
SELECT    T1.[TransType]
          , T0.[ReconNum]
          , T1.[BaseRef]
          , T1.[TransId]
          , T1.[Line_ID]
          , T2.[ReconType]
          , T2.[ReconRule1]
          , T2.[ReconRule2]
          , T2.[ReconRule3]
          , T1.[RefDate]
          , T1.[DueDate]
          , T2.[ReconDate]
          , T1.[BatchNum]
          , T1.[CreatedBy]
          , T1.[Ref1]
          , T1.[Ref2]
          , T1.[Ref3Line]
          , T1.[ContraAct]
          , T1.[LineMemo]
          , T0.[CashDisSum]
          , T1.[Debit]
          , T1.[Credit]
          , T1.[BalDueDeb]
          , T1.[BalDueCred]
          , T0.[ReconSum]
          , T1.[SYSCred]
          , T1.[SYSDeb]
          , T1.[BalScDeb]
          , T1.[BalScCred]
          , T0.[ReconSumSC]
          , T1.[FCDebit]
          , T1.[FCCredit]
          , T1.[BalFcDeb]
          , T1.[BalFcCred]
          , T0.[ReconSumFC]
          , T2.[ReconNum]
          , T1.[ShortName]
          , T1.[Account]
          , T1.[FCCurrency]
          , T2.[ReconCurr]
          , T2.[ReconNum]
          , T0.[IsCredit]
          , T2.[OldMatNum]
     FROM  [dbo].[ITR1] T0 
          INNER  JOIN [dbo].[JDT1] T1 
               ON  T0.[TransRowId] = T1.[Line_ID]  AND  T0.[TransId] = T1.[TransId] 
          INNER  JOIN [dbo].[OITR] T2
               ON  T0.[ReconNum] = T2.[ReconNum]  
     WHERE  EXISTS     (
SELECT U0.[ReconNum]
     FROM  [dbo].[ITR1] U0 
WHERE U0.[TransId] = (168693) 
     AND  U0.[TransRowId] = (1) 
     AND  T2.[ReconNum] = U0.[ReconNum] 
     AND  (T1.[TransId] <> (168693) 
     OR T1.[Line_ID] <> (1) ) 
ORDER BY T2.[CreateDate]
Thankls a lot for your help!

Similar Messages

  • For an Org Unit, how do we get all Reporting Org units (Also employees reporting to the sub org unit) & Employees ?

    Hi Experts,
    I have a very common requirement in SAP HCM ABAP development.
    For an Org Unit, how do we get all Reporting Org units(Also employees reporting to the sub org unit) & Employees ?
    I have tried using RH_STRUC_GET_MULTIPLE_ROOTS and RHPH_STRUCTURE_READ, but the evaluation path is insufficient to get all objects under it. I tried with both O-S-P and O-O-S-P evaluation paths and as per some constraints, I can’t create a customized evaluation path for a reason.
    I am using PNPCE database for user selection screen and user would be advising the Org unit. I even referred the standard transaction ‘S_AHR_61016495’ which is using PCH logical database.
    I would really appreciate if anyone could provide a solution for this. (Rewards guranteed )
    Kindly help.
    Thank you.
    Regards,
    Mahesh Konade

    Hi Alexandre,
    Although I could not respond in time, thank you so much for your prompt reply.
    I had used the same RHPH_STRUCTURE_READ and passed the appropriate values to it, but it did not populate the required results. I cross checked the results manually, may be some relations issue. But later I tried using RH_STRUC_GET_MULTIPLE_ROOTS and it worked fine.
    Meanwhile I had done a workaround with PCH and RH_STRUC_GET and it served the purpose of getting all the Org units, it’s reporting sub-org-units, positions and persons (The deepest structure from the root org unit advised on selection screen).
    The solution I used is, I captured the org-units advised on selection screen by user using PCH logical database and then by looping on sub-org units reporting to the main org-unit I populated related positions and persons holding them and assigned it to the PNPCE logical database.
    Thank you so much for the help.
    Regards,
    Mahesh Konade

  • How can I get ALL of my Google Calendars to show on the iCal on my iPhone? I see all of my Google Calendars on the iCal on my Mac, but I do not see them in the iCal on my iPhone. I only see one Google Cal, but not the others.

    How can I get ALL of my Google Calendars to show on the iCal on my iPhone?
    I see all of my Google Calendars on the iCal on my Mac, but I do not see them in the iCal on my iPhone. I only see one Google Cal, but not the others.

    https://www.google.com/calendar/iphoneselect

  • I have a new computer. i signed into itunes but my music isn't there.  How do i get all my music off my old iphone to the new computer

    I have a new computer. i signed into itunes but my music isn't there.  How do i get all my music off my old iphone to the new computer so i can put all the music on my new one.
    The guy at att told me that icloud would sync everything i had in my notes, calendar, and text messages to my new phone, but it only synced some of my notes, none of my messages, or calendar info.

    Your music will only be where you put it.  It will not magically appear on a new computer.
    Copy everything from your old computer or your backup copy of your old computer to your new one.
    If for some reason you cannot do this, then you can transfer itunes purchases from an iphone:  Without syncing - File>Transfer Purchases
    You can also redownload itunes purchases from icloud in some countires:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • How do I get all my fonts to work. I upgraded the OS and the old fonts don't seem to work.

    How do I get all my fonts to work. I upgraded the OS and the old fonts don't seem to work.

    If the fonts are installed on the OS they should be there already. If they were only available to CS5 they are probably in the fonts folder in the Adobe section of the Common files (location will be OS dependent), or they may be in ID's own fonts folder.

  • Payment Card Order completely invoiced but in the order is still showing Overall Status as Blocked

    Payment Card Order completely invoiced but in the order is still showing Overall Status as Blocked

    Share the screen shot of payment card tab from that sale order.  Also what values are flowing in Status tab.
    G. Lakshmipathi

  • Query to get all tables related to a given table directly or indirectly

    Does anyone have a query to get a list of tables that are directly or indirectly related to a given table by foreign keys?
    I used a CONNECT BY clause to get a list of all child tables and their child tables and so forth by going against the ALL_CONSTRAINTS table. I then UNIONed the result with another query that got all the parents/grandparents etc. for this table.
    I realized that I then need to get all the other child tables of these parent tables and their children and it sort of ran into an endless number of unions because we're traversing up and down a tree and are starting out from the middle.
    Is there a better way to do this?
    Thanks,
    Mohit

    Hello!
    Do you know transaction SUIM. From there you can find all roles with a given authorization. If you need a function maybe you can look which functions are used behind SUIM. For the tables check the table behind the fields in the transaction with F1.
    Best regards,
    Peter

  • I have made the mistake of buying a new computer. How do I get all my accessabilty back? I also made the mistake of updating.

    Ok. So first of all I bought a new computer. The old one completely crashed no longer can get anything out of it. I threw it away.
    I backed up my Iphone on the new computer and did the sync. iTunes asked me to update so I did. Now I can not delete songs from my iPhone.
    I am using a windows system. This means if I open iTunes once and then close it I have to turn my computer off and start again.
    I admit having a huge rant on this forum before but I am getting really frustrated agian. On te old system it was easy to make songs into ring tones by making it into an aac version. Now it seems I have to buy ringtones????  What is up with that?????  
    Can anyone point me in the right direction???

    For ringtones, iTunes > Preferences > General >Import Settings... button > choose Import using AAC encoder to enable Create AAC version from .m4a and mp3 files.

  • Just bought a new mac air , my itunes is on my old computer,how do i get all my music ,tones , and apps on to the new iTunes from my iphone?

    Hi guys is there anyway of getting my information from my iphone into itunes ,e.g music, apps, tones?.
    I've bought a new mac air ,so my old itunes is on my old lap top,i have put the new itunes on to the mac but i need to transfer all the stuff from my phone to my new itunes on the mac , if that makes sense, would be great if someone could help me.

    DAMELISA wrote:
    Hi Anamusic thanks for getting back to me is there no way of just getting the info from the phone to the new i tunes ?, ...
    You can... but it is not as straight forward as the External drive method.
    See these 2 Links...
    Syncing to a New Computer...
    https://discussions.apple.com/docs/DOC-3141
    Recovering your iTunes library from your iPod or iOS device
    https://discussions.apple.com/docs/DOC-3991
    More info here...
    iTunes: How to move your music to a new computer

  • HT203511 Is there a way for me to get all 2,000 photos from my iphone onto the photos app on my macbook without having to delete anything? Currently it is only uploading the last 30 days.

    I have had my macbook for a few months, but have not really taken full advantage of it. I am trying to get my phone to communicate with my computer so my photos will be in two locations. I just set up the photos app on my computer, but it will only upload the last 30 days.

    Have you considered using iCloud Photo Library instead of Photo Stream? See iCloud Photo Library FAQ - Apple Support
    The following quote from that link has instructions on how to turn it on:
    If you want to turn on iCloud Photo Library on all of your devices, follow these steps:
    In iOS 8.3 or later, go to Settings > iCloud > Photos, then turn on iCloud Photo Library.
    In OS X 10.10.3 or later, go to System Preferences > iCloud > Options next to Photos, then select iCloud Photo Library.

  • Is there anyway to get all my picture and videos back? On the new iphone?

    Just went to put some music on my new as of Sunday iphone. It's the newest one, and I had some new pictures and a video on it. And I don't think there is any way to get texts back either. So not much data but it meant a lot to me. And then I accidently synced my old ipod touch data to it, and it erased all the contacts I had to already put in by hand the day I got it, because the transer machine wasn't working. So needless to say I just really, really want my data back. I'm crying right now because I don't think there's a way to fix it.

    Hmm, well, if you've been using iCloud, or if you've backed up your new iPhone to iTunes between Sunday and your data loss, then you should be able to recover.
    If not ... well, this was a learning opportunity.

  • HT4910 My iCloud contact list does not contain all the contacts that are in my phone.  If I delete one from my phone it will delete it instantly from the iCloud contacts.  But how do I get all those other contacts on my phone to the iCould on my Windows c

    My iCloud contact list does not contain all the contacts listed in my iPhone 5S.  If I delete a contact from the phone it instantly deletes it from the iCloud on my PC.  But my PC iCloud list is lacking many of the contacts on my phone.

    And which account did you enter these contacts in?
    On My Mac
    or
    iCloud?

  • How do I get all history when I click on it in the menu bar? My history shows just one day, and bookmarks folders.

    What shows up when I click on History is a window displaying a folder for history and a folder for bookmarks. In the history folder is listed only the current tabs that are open, that's all. The other folder is bookmarks, and it shows subfolders for all bookmarks, every one of them. The prior complete display disappeared just recently, a week or so ago.

    Are your using the '''Show All History''' menu item?

  • Please provide me all the t codes related to direct invoices , SRM...

    Hi All,
    Please provide me all the t codes related to direct invoices , SRM and Manual Purchase orders
    Thanx in advance,
    Ravi.

    Dear Ravi,
    use Transaction Se16 and write the table name as TSTC what you will get is a list of all T-codes with there description.
    Another method is using the Transaction-SDMO here you enter the text and you will get all transactions related to the text you enter.
    Using these two transactions I hope you would be able to find out all the t-codes.
    Cheers,
    Prafulla
    Message was edited by:
            prafulla singh

  • How to reconcile AR down payment Request with AR Invoice?

    Dear All,
    SAP B1 2007A SP01 PL07 version.
    I have created one AR down payment Request with total amount 1000.00, and then post incoming payment to paid the AR down payment Request, and the AR downpayment request then closed.
    Then, I add one AR Invoice with amount 1000.00.
    After that, I want to add incoming payment , then I select both (AR downpayment request & AR invoice), but cannot add the incoming payment because the total amount is zero (1000.00 - 1000.00=0.00).
    How can I solve this problem?
    Thanks in advance for any help.

    Hi Kerstin,
    Thank you for you reply.
    I did test your solution, but its only work for SAP 8.8. But now i'm working in SAP 2007A version. For 2007A version, downpayment request cannot be drawn to invoice.
    Anyway, i find out one way. If I add the payment together with another invoice, thats mean the total payment is not zero, then its work. The solution is, make sure the total payment is not zero then it should be ok.
    Thanks to everybody for your fast reply. Thank you so much and really appreciate your help.
    Regards,
    Mat

Maybe you are looking for