Outgoing payment based on CreditNote

Hi,
How do I create an Outgoing payment for customer based on a fresh CreditNote  with the DI API in C# please ?
I did try many combination from many different BoObjectTypes to many different BoRcptInvType and the code bellow is the last one I did try and I know it doesn't work
// Maybe it's not the one for CreditMemo
SAPbobsCOM.Payments Payment = (SAPbobsCOM.Payments)oCompany.GetBusinessObject(BoObjectTypes.oVendorPayments);
Payment.DocObjectCode =  BoPaymentsObjectType.bopot_OutgoingPayments;
Payment.CardCode = Document.CardCode;
Payment.DocDate = DateTime.Now;
Payment.DocCurrency = Document.DocCurrency;
Payment.LocalCurrency = BoYesNoEnum.tYES;
Payment.DocType = BoRcptTypes.rCustomer;
Payment.HandWritten = BoYesNoEnum.tNO;
Payment.CashSum = double.Parse(HeadersTable.Field["pos_DocTotal"].ToString());
Payment.DocRate = 0;
Payment.TaxDate = DateTime.Now;
Payment.ContactPersonCode = Document.ContactPersonCode;
Payment.ApplyVAT = BoYesNoEnum.tYES;
Payment.JournalRemarks = Document.JournalMemo;
Payment.Invoices.AppliedFC = 0;
Payment.Invoices.DocEntry = int.Parse(ObjectCode);           // The CreditMemo I just created...
Payment.Invoices.InvoiceType = BoRcptInvTypes.it_Return;  // MUST BE WRONG HERE
Payment.Invoices.SumApplied = Payment.CashSum;
Payment.Invoices.Add();
if (Payment.Add() != 0)
    oCompany.GetLastError(out ErrorCode, out ErrorMsg);
    LogError(ErrorCode.ToString() + " : " + ErrorMsg);
    oCompany.EndTransaction(BoWfTransOpt.wf_RollBack);
else
    oCompany.EndTransaction(BoWfTransOpt.wf_Commit);

here the entire method that creates my CreditMemo which works fine and have no error on it.
private void CreateCreditMemo()
            try
                SAPbobsCOM.Documents Document = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oCreditNotes);
                SAPbobsCOM.BusinessPartners bp = (SAPbobsCOM.BusinessPartners)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners);
                SAPbobsCOM.Items Items = (SAPbobsCOM.Items)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems);
                string CardCode = HeadersTable.Field["pos_CardCode"].ToString();
                // The business partner is necessary
                if (bp.GetByKey(CardCode))
                    Document.CardCode = CardCode;
                    Document.HandWritten = BoYesNoEnum.tNO;
                    Document.PaymentGroupCode = -1;
                    Document.DocDate = DateTime.Parse(HeadersTable.Field["pos_DocDate"].ToString());
                    Document.DocType = BoDocumentTypes.dDocument_Items;
                    Document.DocCurrency = bp.Currency;
                    Document.NumAtCard = HeadersTable.Field["pos_Ref1"].ToString();
                    Document.Series = GetSeriesFromCardCode(CardCode, DOCTYPE.RETURN);
                    // Now adding the detail for this credit memo
                    while (!DetailsTable.EOF)
                        // I did it this way to debug variables faster.  That's all
                        string ItemCode = DetailsTable.Field["detail_ItemCode"].ToString();
                        string ItemDescription = DetailsTable.Field["detail_ItemDesc"].ToString();
                        double PriceAfterVAT = double.Parse(DetailsTable.Field["detail_PriceOfVat"].ToString());
                        double Price = double.Parse(DetailsTable.Field["detail_Price"].ToString());
                        double Quantity = double.Parse(DetailsTable.Field["detail_Quantity"].ToString());
                        string WhsCode = DetailsTable.Field["detail_WhsCode"].ToString();
                        if (!Items.GetByKey(ItemCode))
                            LogError("The ItemCode " + ItemCode + " doesn't exist");
                            return;
                        else
                            Document.Lines.ItemCode = ItemCode;
                            Document.Lines.ItemDescription = ItemDescription;
                            Document.Lines.PriceAfterVAT = PriceAfterVAT;
                            Document.Lines.Price = Price;
                            Document.Lines.Quantity = Quantity;
                            Document.Lines.WarehouseCode = WhsCode;
                            Document.Lines.TaxCode = SAP.GetTaxCodeFromAddresses(bp.Addresses);
                            DetailsTable.MoveNext();
                            if (!DetailsTable.EOF)
                                Document.Lines.Add();
                    if (Document.Add() != 0)
                        oCompany.GetLastError(out ErrorCode, out ErrorMsg);
                        LogError(ErrorCode.ToString() + " : " + ErrorMsg + " when adding the credit memo " + CardCode);
                    else
                        CreateOutgoingPayment(Document);
                else
                    LogError("The business partner " + CardCode + " doesn't exist in SAP Business Partners");
            catch (Exception ex)
                LogError(ex.Message + " when creating credit memo for " + blabla + " on " + DateTime.Now.ToString());

Similar Messages

  • Outgoing Payment with journal Entry

    Hi guys I need your help
    I need to be able to do an outgoing payment based on a journal entry. This is my code but I get this error:
    "Base document card & target document card do not match"
    The journal is based on an incoming payment that was over paid and has a remaining balance.
    Thanks
                oOutPay.DocTypte = SAPbobsCOM.BoRcptTypes.rCustomer;
                oOutPay.CardCode = "CC0001";
               //oOutPay.Invoices.Add();
                oOutPay.Invoices.DocEntry = 106;
                oOutPay.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_JournalEntry;
                oOutPay.TransferAccount = globals.bankTrAccOP;
                oOutPay.TransferSum = 80;
                int lRetCode;
                lRetCode = oOutPay.Add();

    Hi Costas,
    In order to based the payment on Journal Entry,
    You have to set the docline of the Payment to Journal Entry Line which has the same cardcode as your payment card code like this
    oPay.Invoices.DocLine = oJE.Lines.Line_ID
    What I do is I iterate through the Journal Entry to look for the line like this :
    If .Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_JournalEntry _
                                        Or .Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_PaymentAdvice Then
        Dim oJE As SAPbobsCOM.JournalEntries
        oJE = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries)
        oJE.GetByKey(.Invoices.DocEntry)
        For iLines As Integer = 0 To oJE.Lines.Count - 1
        oJE.Lines.SetCurrentLine(iLines)
        If oJE.Lines.ShortName = .CardCode Then
        'If the line card equal payment card code, then assign the docline id
              oPay.Invoices.DocLine = oJE.Lines.Line_ID
              System.Runtime.InteropServices.Marshal.ReleaseComObject(oJE)
              oJE = Nothing
              Exit For
         End If
        Next
    End If

  • TDS on Outgoing Payment

    Hi All,
    I have gone through many threads but not able to find proper solution for a general scenario which will be requirement of many customer.
    Scenario:
    Is very simple. I have make Payment to Vendor on Acount ( Advance Payment) on which i need to deduct TDS.
    As per TDS Manual nothing is mentioned how to manage this scenario.
    While defining TDS code in WT window there are 2 options ( Invoice / Payment). If the payment option is selected and Payment is made nothing happens
    I am aware i have to make AP downpayment for this and then make outgoing payment which unnecessaryliy increase one step for user.
    Just want to confirm is there any direct way to apply TDS while making pyament on account.
    Response will be appreciated.

    Hi,
    3.6 Payment on Account
    Navigation: - Banking  Outgoing Payment TDS on advance payment can be deducted through outgoing payment based on u201CPayment on Accountu201D selection.
    Points to remember:-
    Vendor (Subject to Withholding Tax) should be selected.
    WTCode of u201CPu201D type should be chosen.
    u201CPayment on Accountu201D check box should be checked.
    These are the lines from TDS add on manual -2007B if you make above settings then while posting the on account payment when you enter the amount in amount field in the header automatically the withholding tax fields are enabled and when you chose the category the witholding tax will be calculated and posted when you add the document
    Please check it,This scenario is addressed by the manual
    thanks
    Md.nazeer Shaikh

  • Credit Memo missing in Outgoing Payment

    Dear Experts,
    Credit memos are not showing in Outgoing Payment. I created A/P Credit Memo of A/P Invoice in part quantity. In Outgoing Payment A/P invoice Total is showing Total amount - A/P Credit memo amount but not showing in difference row.
    Any suggestions would be helpful.
    Thanks & Regards in Advance,
    Ravi

    Hello Ravi,
    If you will make A/P credit memo based on A/p invoice then outgoing payment show only rest amount it will not show all amount.
    it is right Outgoing Payment A/P invoice Total is showing Total amount - A/P Credit memo amount
    And if you goto standalone credit memo then it will show in outgoing payment
    Thanks
    Manvendra

  • Issue in Outgoing Payments

    Hi
    I have an issue in Outgoing payments. Our client books the invoice at gross level through MIRO. Then there are deductions which are made based on various parameters like quality, volume, trade and other such parameters. Now They have a process in Legacy, where in the user after booking the invoice selects same and enters the various discounts in the system. System then generates the payment advise with the details of deductions and the invoice details, which is sent to the vendor. A payment advise document number is also generated.
    While preparing the outgoing payment in legacy, the user just selects the payment advise number and the bank name and the system creates the cheque and passes the accounting entries.
    We suggested the user to pass the deductions through MIRO. Then the accounting entries for outgoing payment could be passed through F110 /F-53/F-58, where in the invoice and the bank have to be selected. Thereafter, with reference to the outgoing payment document, a cheque is perpared manually if using T code F-58 or F-53 or automatically, if using F110. We suggested to the client to develop an ABAP form which would give the out put in the same way as legacy.
    However, the client is insisting that the process should be mapped exactly as in legacy.
    Pls suggest
    Regards
    Sanil

    Hi
    The clinet is getting discounts. However, they are paying the vendor with the net amount only (I.e, after discounts). However, the process should work in the same way as legacy
    Regards
    Sanil

  • Discount in Outgoing Payment  and Cheque for payment PLD

    Hi,
    Using SBO2007A PL30
    I have tried to find whether there are system variables for amount outstanding and discount which show amounts in foreign and local currency.
    I can't find any references in the .xls document how to use system variables in SBO 2007., and strangely there is no reference in that document to the system variables which already exist in the in- built layouts
    Cheque for Payment
    - total amount paid ( variable 97 )
    Outgoing Payment
    - posting date ( variable 202)
    - Doc Ref ( var 200)
    - Your Ref ( var 201)
    - amount paid ( var 63)
    This leads me to suspect that system variables for outstanding amount and discount may well exist.
    In the meantime I have had to do this using references to database fields Outgoing Payments - Invoices: Discount Amount and Outgoing Payments - Invoices : Amount before Discount with formulae to determin whether the document is in local or foreign currency.
    A further downside to this is that a credit memo is displayed from the latter database field without a negative sign
    Does anyone have any suggestions here?
    Thanks

    Managed to figure out most of it but for the record I have discovered an additional 4 system variables in use for paid document details at line level. Here is the complete list so far:
    outgoing Payment
    PostingDate 202
    our Ref        200
    your Ref      201
    o/S Amt       ?     ( used formula based on db fields instead)
    Discount       ?    (  used formula based on db fields instead)
    Payment       63
    Cheque for Payment
    posting Date  104
    our ref            101
    your ref          100
    O/s amt         96
    Discount           ? ( use formula :difference between 96 and 97)
    Payment        97
    If anyone can supply the missing variables if they exist, I'd be grateful.

  • Outgoing payment vs invoice due date

    Dear Forum,
    Our management wants to get historical due date outgoing payment compare to invoice due date. So we know if out finance paid accordingly based on the invoice due date. 
    The fields ;
    Invoice Number     
    Invoice Date     
    Invoice Value     
    Invoice Due date     
    Outgoing Payment Number     
    Outgoing Payment Date     
    Type of Payment ( check / cash /bank transfer)     
    Due Date Check/Cash/Bank Transfer
    Out Going Value
    If any experts can help me to get the query? thanks

    Hai!
    Run this Query in SAP Query Manager.
    Declare @FromDate datetime
    Declare @Todate datetime
    set @FromDate = (select min(S0.DocDate) from OPCH S0 where S0.DocDate >= '[%0]')
    set @ToDate = (select max(S1.DocDate) from OPCH S1 where S1.DocDate <= '[%1]')
    Select
    P0.DocNum as 'Invoice Number',
    P0.DocDate as 'Invoice Date ',
    P0.DocTotal as 'Invoice Value ',
    P0.DocDueDate as 'Outgoing Payment Number',
    V0.DocNum as 'Outgoing Payment Date ',
    V0.DocDate,
    (case
    when V0.CashSum > 0 then 'Cash'
    when V0.CheckSum > 0 then 'Check'
    when V0.TrsfrSum > 0 then 'Bank transfer'
    end) as 'Payment Type',
    V0.DocDueDate as 'Due Date Check/Cash/Bank Transfer',
    V0.DocTotal as 'Out Going Value'
    From OPCH P0, OVPM V0, VPM2 V2
    Where
    V0.Docentry=V2.DocNum and
    V2.Docentry = P0.Docentry and
    P0.DocDate >= @FromDate and
    P0.DocDate <= @ToDate
    Regards,
    Thanga Raj.K

  • Outgoing Payment (Check) via DI API SDK

    Hey everyone, I'm trying to create an outgoing payment to a customer as a check through the DI API and I'm getting this error "[ORCT] , 'Error (-1004) encountered.'". I believe this is the incoming payment table so I'm not sure why it's part of the message.
    The payment object I am creating is "GetBusinessObject(oIncomingPayments)" so that may be part of it but there isn't an "oOutgoingPayments" for me to use. I've only completed the required fields to reduce the chance of errors being caused by something else (except for object code indicating it's an outgoing payment but maybe outgoing payments require more info). Also, these checks aren't based on any invoices.
    I noticed there is an "oVendorPayments" object as well so I'm not sure if I should be using this one or not.
    Here's the code I am using:
    Payments _payment = (Payments)SBOCompany.GetBusinessObject(BoObjectTypes.oIncomingPayments);
    _payment.CardCode = "C0001";
    _payment.CashSum = 19.95;
    _payment.TransferAccount = "112200-01";
    _payment.TransferSum = 19.95;
    payment.DocObjectCode = BoPaymentsObjectType.bopotOutgoingPayments;
    _payment.Checks.BankCode = "CBT-GA";
    _payment.Checks.CheckSum = 19.95;
    _payment.Checks.Add();
    if (_payment.Add() != 0)
      //failed

    Hi Barend,
    Thanks for the help. I'm now able to create outgoing payments after much trial and error ;). My only question now is how can I use the GL Account number (eg. 112200) instead of the internal account code (_SYS00000000004)? If I switch to 112200 or 112200-01 I get an error "[OACT] , 'No matching records found (ODBC -2028)'" but when I look in the OACT table, the SYS00000000004 record has 112200 for Segment0 and 01 for Segment_1. All the samples I've seen just use the GL account number so I'm not sure what I'm doing wrong.
    Payments _payment = (Payments)SBOCompany.GetBusinessObject(BoObjectTypes.oVendorPayments);
    _payment.CardCode = "C0001";
    _payment.DocDate = DateTime.Now;
    _payment.DocType = BoRcptTypes.rCustomer;
    payment.CheckAccount = "SYS00000000004";
    _payment.Checks.BankCode = "TEST";
    _payment.Checks.CheckSum = 19.95;
    _payment.Checks.Add();
    if (_payment.Add() != 0)
      //failed

  • Outgoing payment with Zero amount when Full adance is paid

    I am making A/P down payment request based on purchase order, then I make full payment of PO (full advance payment - no amount of payment left with) through "Outgoing payment" which creates negative amount in Business partner balance and shows a negative entry in "outgoing payment" screen. Moving further, I make Goods receipt PO and then I make A/P invoice of regular amount based on goods receipt PO / Purchase order.
    Up till now, the full payment has been made in advance through A/P down payment request and upon receiving goods the A/P invoice of regular amount is received. Now when I go to "outgoing payments" I have no amount left to pay (i.e. It displays 2 entries of same amount, one with positive amount of A/P invoice and the other one with negative amount of A/P down payment request to show the due balance = zero)  So I am trying to clear the vendor "outgoing payments" by paying with Zero amount, but the system shows the error "The confirmation amount should be greater than Zero".
    How can I clear the vendor "Outgoing payments" with zero amount ?? as it's payment has been made in advance.
    Note: Please give me the solution by keeping in mind that I have to pay full amount in advance.
    Solution to this problem would be highly appreciated.
    Thanks and regards,
    Farhan Sufi

    Hi Farhan Sufi,
                  For Cases where full Advance is paid initially, You Follow these procedure, I have tested in my DB its working fine.
    Step 1: Raise a Purchase order Say Rs 1000/-
    Step 2: Raise a GR(PO) of Rs 1000/-
    Step 3: Go To A/P Down Pmt -
    Select the Vendor -
    Say copy from GR(PO), And select te One you wanted. At the bottom in the DPM Field give 100% and Add the Document.
    Step 4: Raise Out Going Payment by linking to the A/P Down Pmt what you have posted. ie., Go To Out Going Pmt Screen---Select the Vendor, This will display all invoices, Down pmts, Credit Memos, and JE's. Select the A/P Down Pmt what you have posted and go to payment means fill in the respective field and add the document.
    Step 5: Go To A/P Invoice Screen, select the vendor. And  click on Copy from GR(PO), Select the respective GR(PO) document.
    And At the Bottom double click on Total Down Payment Button, This will display the list of all Down Payments for which Out going payments are also posted. Here Select the respective Down payment and add the document.
    When you add this A/P Invoice document gets added and the status of the document will be closed. As you have made full payment in the A/P Down Payment Screen.
    And This Invoice will not appear in the Out Going Screen as the document is closed.
    Cheers,
    Sree.

  • Displaying G/L account name when doing a Bank transfer Outgoing payment

    Hi all,
    When designing a print layout for outgoing payments, using bank transfer, the G/L accout name is not being displayed.  The G/L account code(trfsAmt) can be retrieved from OVPM(outgoing payment table) but is displace in '_sys000' format.  The normal step here would be to link a database field from OACT(G/L account table) and select the 'account name' field. 
    However when priting, i am getting this message 'No matching records found from table OVPM'.
    Any help on this would be greatly appreciated
    Thanks
    Christian
    Edited by: Rui Pereira on Jul 8, 2008 6:00 PM

    Hi Christian
    Hope all is well in Mauritius. Suda's suggestion will only work for payments direct to a General Ledger Account. For Vendor or Customer payments the VPM4 table is not used. The other problem is that both the CashAcc and TrfAcc are automatically populated in the OVPM table based on defaults (if they exist). In order to determine which G/L account name to use you will also need to look at the payment method of the payment.
    I also noticed that if I try to run a query on any of the two account fields against OACT and OVPM, the system tries to map to WTAccount, which is the With Holding Tax Account. This might be the problem also on the layout designer, that SAP Business One is not mapping the query correctly for the added field referring to AccName from OACT.
    I would suggest pulling the account name from the journal file using line 0 (JDT1). The outgoing payment seems to always post the bank account line first, although this is no guarantee.
    Let me know if this resolves the issue.
    Kind regards
    Peter Juby

  • Outgoing Payment Check Payment Means

    Hi all
    Is it possible to have a default outgoing payment Bank Name in Check Payment Means?
    I am able to get a default incoming payment Bank Name in Check Payment Means based on the BP Master Data House Bank under Payment Terms.
    Kedalene

    Hi,
    Yes possible.  Add default bank details at Company details---Basic initialization tab.
    Thanks & Regards,
    Nagarajan

  • Invalid Check Number in the Outgoing Payment SAP 8.8

    Hi Experts,
    Can somebody help me give the reason why system was not able to accept manual check number 31234578910 in the Outgoing Payment?. System message is "Numeric Value deviates from legal range". Based on the system information displayed Cheque Number (Number from -2147483648 to 2147483648. Is there set up for the valid check number in SAP 8.8 UK Localization?
    Hope to hear from you soon
    Sandra

    Sorry it's supposed to be 3123456789.  Data Type for checkNum is int, null.  As per system message in the status bar, allowable number is -2147483648 to 2147483647.  I was wondering, if it's an integer then why is it there is number range allowed.
    Thanks
    Sandra

  • Payment on Account in Incoming/Outgoing Payments

    Please tell me what is the purpose of Payment on Account in Incoming/Outgoing Payments forms and also in what all combinations I can use this feature.

    Hello,
    Basically it is used to accept the payment not based on certain invoice (open invoices) if you tick the field (tick box field). You must manually reconcile the payment to the invoices using automatic internal reconciliation or link invoice to payment feature that is available in banking module --> bank statements and reconciliations --> link invoices to payment. If you use the reconciliation option, you will also must create balancing journal before reconcile the transaction (i.e. open transaction in debit and credit side reconciliation balancing journal).
    let me know if you need further explanation.
    Rgds,

  • How to deduct TDS while making an Outgoing Payment

    Company wants to deduct TDS while making an outgoing payments to Contractors / Jobworkers / Transporters.... can anyobody guide me
    Edited by: Marc Riar on Feb 19, 2008 10:23 AM

    Hi sanjay,
    For deducting the with holding tax, First you have to define some withholding tax codes with the percentages of the amount.
    For creating the with holding codes
    go to
    Administration>Setup>Financials>Tax>WithHolding Tax>
    There a create tax code
    Now Go to A/P Invoice. Select a vendor and change Itrem/service type to Service
    Then give the details of g/l and make WTax Liable to yes. There you can set the with holding tax code that was created. Based on that you can see the Wtax amount in the footer of the form..
    When you make the payment to particular vendor it automatically creates ledger entry for with holding tax also..
    Regards,
    Jagadeesh.V

  • Stop Outgoing payment from particular users if BP credit balance is less

    Hi Experts
    Please help me with the following issues
    I want to be able to stop 3-4 specific users from generating outgoing payment if the following applies
    1. the BP ledger Balance is Less than outgoing payment i.e if there is Rs. 100 credit balance then those users cannot make outgoing payment to BP more than Rs. 100
    2. they also cannot make outgoing payments more than a set limit. for ex. if i say that user A has Rs. 50 as limit then he can generate only those payments where the outgoing payment amount is MAximum rs.50 even though the ledger balance is Rs. 150
    I feel that this can be done through sp_transaction notification please help me with the SQL code for the same 
    thanks
    regards
    Pradipta

    Please use the following code as a guideline and test it.   In the code below the first select statement gets the User Code of the user adding the Outgoing Payment.  this is your starting point to validate this transaction further.
    In the first IF statement I am checking if the user code = 1 and checking the outgoing payment total against the BP balance and if it is greater message will be displayed.
    In the Second if I am checking if the Outgoing payment amount is great than 100 and displaying a message.
    This code does not use your current limit stored at the user table but has been constructed based on your future interest to hardcode values.
    Please get the user codes corresponding to the users by running this query either in SQL or in SBO
    SELECT T0.UserID, T0.U_NAME AS 'User Name' FROM  [dbo].[OUSR] T0
    SBO_SP_TransactionNotifiation code is below
    IF @object_type = '46' AND @transaction_type = 'A'
    BEGIN
         declare @usercode int
        select @usercode = t0.usersign
        from [dbo].[ovpm] t0 where t0.docentry = @list_of_cols_val_tab_del
         if @usercode = 1
         begin
              if exists (select t0.docnum from [dbo].[ovpm] t0
                  inner join [dbo].[ocrd] t1 on t0.cardcode = t1.cardcode
                    where t0.doctotal > -1*t1.balance AND t0.docentry = @list_of_cols_val_tab_del)
              begin
                   select @error = 1, @error_message = 'Payment total cannot be greater than BP balance'
              end
         end
         if @usercode = 5
         begin
              if exists (select t0.docnum from [dbo].[ovpm] t0
                  inner join [dbo].[ocrd] t1 on t0.cardcode = t1.cardcode
                    where t0.doctotal > 100 AND t0.docentry = @list_of_cols_val_tab_del)
              begin
                   select @error = 1, @error_message = 'Payment total is greater than permitted limit'
              end
         end
    END
    All the very best
    Suda

Maybe you are looking for