Total in order documents

Hi,
Im trying to add an order document using the DI API.My problem is that i can't display the DocTotal and the LineTotal ...i select these properties after the add() , and it displays 0 always ...
here is my code:
long RetVal;
int ErrCode;
string ErrMsg;
SAPbobsCOM.Documents vOrder;
vOrder = (Documents)vCmp.GetBusinessObject(BoObjectTypes.oOrders);
vOrder.CardCode = (string)list.SelectedItem;
vOrder.CardName=customerName.Text;
vOrder.HandWritten =BoYesNoEnum.tNO;
vOrder.PaymentGroupCode = -1;
vOrder.DocDate = System.DateTime.Parse(postingDate.Text);
vOrder.DocDueDate=System.DateTime.Parse(deliveryDate.Text);
vOrder.Reference1=reference.Text;
vOrder.DocType=BoDocumentTypes.dDocument_Items;
                         vOrder.Lines.ItemCode = (string)listItems.SelectedItem;
                    vOrder.Lines.ItemDescription = descItem.Text;
                    vOrder.Lines.Price=  Convert.ToDouble(priceItem.Text);
                    vOrder.Lines.Quantity = Convert.ToDouble(quantityItem.Text);
                    vOrder.Lines.Currency = "Eur";
                   taxItem.Text=vOrder.Lines.TaxCode;
                    //'Add the Order
                    RetVal =vOrder.Add();
                    //Check the result
                    mess.Visible=true;
                    if (RetVal != 0 )
                         vCmp.GetLastError (out ErrCode,out ErrMsg);
                         mess.Text=ErrCode + " " + ErrMsg;
                    else
                         mess.Text="Commande Rajoutée Avec Succès:d";
//here i consult the totals i have 0 as a result
                 totalItem.Text=vOrder.Lines.LineTotal.ToString();
                 total.Text=vOrder.DocTotal.ToString();
                  baseAmount.Text=vOrder.BaseAmount.ToString();
Another question how to get the DocEntry of this document so i can do a GetByKey afterward, because when i consult it in this code i got 0 also...
Thanks you in advance...
Ola

After you call the Add method, the vOrder object will no longer contain the data you specified - it will just be a new blank order object.
You can get the reference for the Order you have just added by calling the GetNewObjectKey method of the Company object.  The result of this function can be used with the GetByKey function.
John.

Similar Messages

  • How to see customers total sales orders value

    Dear all,
    How can I create a query to see all customers total sales orders value.
    I have tried MC+E transaction, it is not giving accurate values when compare for a customer with VA05N report.
    moreover it doesn't have filter option.
    Please help me to resolve the issue. Your suggestion will be highly appreciated.
    Best regards,
    Raghu ram

    Hi,
    Try S_ALR_87012171  and S_ALR_87012186.   or
    S_ALR_87012160, select customer lite items only, enter customer number.
    Click on dynamic selection (Shift+F4). enter RV in document type field and press execute.
    Regards,
    Chandra

  • Change data in matrix of order document

    hi
    i developing the add-on for sap 9.0 (c#). And i have a problem.
    i need to write in the matrix of order document the warehouse/project/Profit Center code for each item that user add.
    maybe someone can give me a example code.
    thanks.

    hi..
    yes u can update after adding the
       Try
                If (pVal.FormMode = "3" And pVal.ItemUID = "1" And pVal.BeforeAction = False And pVal.FormTypeEx = "139" And pVal.ActionSuccess = True And pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) Then
                    oForm = SBO_Application.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount)
    ------ here u have to add the  code what u want to do...ok
       Catch ex As Exception
                SBO_Application.MessageBox(ex.Message)
            End Try
    The above code will be fire after adding the sales order success fully..
    ================================================
    This is the sample  program i have done after adding successfully...
    Try
                If (pVal.FormMode = "3" And pVal.ItemUID = "1" And pVal.BeforeAction = False And pVal.FormTypeEx = "139" And pVal.ActionSuccess = True And pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) Then
                    oForm = SBO_Application.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount)
                    Dim SDocNo As Integer = oForm.Items.Item("8").Specific.value
                    Dim ORec11 As SAPbobsCOM.Recordset
                    ORec11 = ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
                    Rsql = "select max(DocEntry) as DocEntry from ordr"
                    ORec11.DoQuery(Rsql)
                    Dim RDocNo As Integer = ORec11.Fields.Item("DocEntry").Value
                    Dim sitem As String
                    Dim orec As SAPbobsCOM.Recordset
                    orec = ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
                    Dim sql As String
                    sql = "select * from RDR1"
                    orec.DoQuery(sql)
                    Dim i12 As Integer = orec.RecordCount
                    ' SBO_Application.SetStatusBarMessage("Document Added  Successfully")
                    Dim RetVal As Long
                    Dim ErrCode As Long
                    Dim ErrMsg As String
                    'Create the Documents object
                    Dim OSorder As SAPbobsCOM.Documents
                    OSorder = ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders)
                    If OSorder.GetByKey(RDocNo) Then
                        Dim ORec1 As SAPbobsCOM.Recordset
                        ORec1 = ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
                        Rsql = "select COUNT(*) as total from RDR1  where rdr1.DocEntry =" & RDocNo & ""
                        ORec1.DoQuery(Rsql)
                        Dim Total_Lines As Integer = ORec1.Fields.Item("total").Value - 1
                        For i As Integer = 0 To Total_Lines
                            Dim ORec2 As SAPbobsCOM.Recordset
                            ORec2 = ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
                            Rsql = "select  rdr1.ItemCode   from RDR1  where  rdr1.DocEntry =" & RDocNo & " and rdr1.LineNum=" & i & ""
                            ORec2.DoQuery(Rsql)
                            Dim Line_Item As String
                            Line_Item = ORec2.Fields.Item(0).Value
                            Dim oRec3 As SAPbobsCOM.Recordset
                            oRec3 = ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
                            Rsql = "select oitm.TreeType  from OITM where  oitm.ItemCode ='" & Line_Item & "'"
                            oRec3.DoQuery(Rsql)
                            Dim Typ As String = oRec3.Fields.Item(0).Value
                            OSorder.Lines.SetCurrentLine(i)
                            If (Typ = "P" Or Typ = "A" Or Typ = "T" Or Typ = "S") Then
                                OSorder.Lines.UserFields.Fields.Item("U_BomSno").Value = "P" & p1
                                p1 = p1 + 1
                                c1 = 1
                            Else
                                OSorder.Lines.UserFields.Fields.Item("U_BomSno").Value = "C" & c1
                                c1 = c1 + 1
                            End If
                        Next
                        'Add the Invoice
                        RetVal = OSorder.Update
                        'Check the result
                        If RetVal <> 0 Then
                            ocompany.GetLastError(ErrCode, ErrMsg)
                            SBO_Application.MessageBox(ErrCode & " " & ErrMsg)
                        Else
                            SBO_Application.StatusBar.SetText("Document Updated Successfully....", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success)
                        End If
                    End If
                End If
            Catch ex As Exception
                SBO_Application.MessageBox(ex.Message)
            End Try
        End Sub
    =====
    here what it is having is..
    after adding successully the above code will be fire... ok..
    immediatly u have to catch the  max sales order docentry
    in it u have to check it..how many row items(rdr1)  are thee..
    u use for loop
    and update it..
    and also change the fields
    like  as per the ur requirement... ok..
           OSorder.Lines.ProjectCode
                            OSorder.Lines.DiscountPercent
                            OSorder.Lines.WarehouseCode

  • Creating a sales order document

    Hi,
    When I create a sales order document in one company I want to automatically create a purchase order document (in the same company), and when this one is created I want to create a sales order document (in another company) with the same data as the purchase order. The purchase order is created via DIAPI and it works fine, but the problem is when creating the sales order in the second company. When I add the itemcode to the line , it doesn't write automatically any data of that itemcode, the vatgroup neither. So I have to introduce this field. The thing is that althought introducing the vatgroup manually, it doesn't calculate the vatsum, so in the doctotal isn't added. I've tried writing it manually but the problem is that the vatsum field is readonly.
    Why can this be? How can I solve it?
    The code is the next (in vb.net):
    Dim oPedidoCompra As Documents
    Dim oPedidoCompraLineas As Document_Lines
    oPedidoCompra = oCompany.GetBusinessObject(BoObjectTypes.oPurchaseOrders)
    If Not oPedidoCompra.GetByKey(DocEntry) Then
        oApplication.MessageBox(oCompany.GetLastErrorDescription)
    End If
    oPedidoCompraLineas = oPedidoCompra.Lines
    oPedidoVentaB = oCompanyB.GetBusinessObject(BoObjectTypes.oOrders)
    oPedidoVentaLineasB = oPedidoVentaB.Lines
    oPedidoVentaB.CardCode = ValorSql(s, oCompanyB)
    oPedidoVentaB.DocDate = Date.Now.Day.ToString + "/" + Date.Now.Month.ToString + "/" + Date.Now.Year.ToString
    oPedidoVentaB.DocDueDate = Date.Now.Day.ToString + "/" + Date.Now.Month.ToString + "/" + Date.Now.Year.ToString
    oPedidoVentaB.DocType = BoDocumentTypes.dDocument_Items
    oPedidoVentaB.UserFields.Fields.Item("U_NR").Value = oPedidoCompra.DocNum
    For i As Integer = 0 To oPedidoCompraLineas.Count - 1
      oPedidoCompraLineas.SetCurrentLine(i)
      oPedidoLineas.ItemCode = Codigoarticulo
      oPedidoLineas.Quantity = Cantidad
      oPedidoLineas.Price = Precio
      s = "select WhsCode from OWHS where WhsName like '%" & oCompanyB.CompanyDB & "%'"
      oPedidoVentaLineasB.WarehouseCode = ValorSql(s, oCompanyB)
      oPedidoVentaLineasB.ItemDescription = oPedidoCompraLineas.ItemDescription
      oPedidoVentaLineasB.Price = oPedidoCompraLineas.Price
      oPedidoVentaLineasB.Currency = oPedidoCompraLineas.Currency
      s = "select vatgourpsa from oitm where itemcode = '" & oPedidoVentaLineasB.ItemCode & "'"
      oPedidoVentaLineasB.VatGroup = ValorSql(s, oCompanyB)
      oPedidoVentaLineasB.LineTotal = oPedidoCompraLineas.LineTotal
      s = "select rate from ovtg where code = (select VatGourpSa from OITM where ItemCode = '" & oPedidoVentaLineasB.ItemCode & "')"
      oPedidoVentaLineasB.TaxPercentagePerRow = ValorSql(s, oCompanyB)
      s = "select suppCatNum from oitm where itemcode = '" & oPedidoVentaLineasB.ItemCode & "'"
      oPedidoVentaLineasB.VendorNum = ValorSql(s, oCompanyB)
      oPedidoVentaLineasB.PriceAfterVAT = oPedidoCompraLineas.PriceAfterVAT
      If i < oPedidoCompraLineas.Count - 1 Then
        oPedidoVentaLineasB.Add()
      End If
    Next
    n = oPedidoVentaB.Add
    If n <> 0 Then
    oApplication.MessageBox(oCompanyB.GetLastErrorDescription)
    End If
    Thanks in advance,
    vanesa

    Hi Vanesa
    When makin the sales order you must just select a vat group.It will then calculate it using the settings for that vat group. So, is the vatgroups set up in your other company?? Don't calcualte everyhting like line total. Just do itemcode, price,itemcode, vatgroup, warehouse and then the system will calculate the rest. Dont do PriceAfterVAT and all the extra's.
    If you did it through the front end would you enter all that? No, you would just select item,qty,price and wh. The system calculates the rest for you.....same goes for di api. Do this to minimize errors.
    Hope this helps

  • Status of an Order document

    what are the different status available for an order document.
    what is the table field that refers to?

    if you meant a sales order,  there are many like..  (look table VBUK, and VBUP)
    Reference document header status
    Total reference status of all items
    Confirmation status
    Delivery status
    Overall delivery status for all items
    Total goods movement status
    Billing status
    Billing status (order-related billing document)
    Posting Status of Billing Document
    Overall rejection status of all document items
    Overall processing status of document
    Overall picking / putaway status
    Overall status of warehouse management activities
    Total incompletion status of all items in general
    Total incompletion status of all items: Delivery
    Total incompletion status of all items: Billing

  • Requirement Standard SAP Report on Total Purchase Order Value

    Dear Friends,
    Could u please suggest is there any standard SAP report. Requirement has given belwo.
    I required if we have account assignment  Category A as one of inputs, we will get the reqd output  " Total Purcchase order value."
    Note 1) Total Purchase Order Value means - Basic price + taxes + Charges (Freight + Other charges - Discounts etc)
    Note 2) My requirement standard SAP report only.
    Thanks and regrds,
    Vijay Kumar TVN

    Hi,
    T code : ME80FN
    Select :Edit->Dynamic selections>Purchasing document item> Acct. assignment cat.>select A(f4)->execute
    select Material no., PO Number in program selections
    Hope it shall resolve your query....
    regards
    rahul

  • Document Currency vs Local Currency in Purchase Order document

    Hi Guru
    User have created PO with foreign currency in EUR (Local currency = USD) and release strategic is completed in this PO.
    Then, buyer increased exchange rate and fix the exchange rate at PO header. The PO net value in EUR still remain the same, system still trigger release strategic reset and manager need to re-approve and set release strategic as completed.
    Can you tell me how to check this setting in SPRO? Is it a natural behavoir in SAP system? User asked if this option could be disabled as increase exchange rate but then the whole PO total net value still remain the same in foreign currency. Why should release strategic reset?
    Please advise

    Closing this Thread as I found the answer
    Within the Purchase Order, when the new TOTAL NET ORDER VALUE is higher than the old one, release strategy will be triggered once release charateristic is set for checking rule
    System will check through The total net order value which is linked to CEKKO-GNETW for a purchase order.
    In purchase order, the currency conversion will act as below:
    Purchasing documents: Header currency converted to company code currency.
    Company currency converted to characteristic currency
    Hence, eventhough the exchange rate is increased but document currency is remained unchanged, the company code currency is increased and hence trigger release strategy.
    for more information, please refer to http://wiki.sdn.sap.com/wiki/display/ERPSCM/RELEASE+PROCEDURE

  • Problems creating an order document

    Hi,
    I'm creating an order document via DIAPI. My problem is with document lines, the data I want to introduce is ItemCode, Discount, Quantity and Price. The thing is that my price is the price before discount, but in DIAPI there is no way to add data to the field pricebefdi and the only price you can add is price after discount, so my total and the one shown in SBO is not the same.
    What I do at the moment is calculate the price after discount and assign it to the field price, but with this operation I loose decimals.
    Any idea of how to do it?
    Thanks in advance,
    vane

    Hi,
    This is a major flaw in DI API currently. I don't think there's much you can do about it in addition to what you've already done. In 2005 SP1, there will be available some new ways of calculating price/discounts. You might want to check it out.
    Henry

  • Purchase order document row is not change (document stutas is OPEN)

    Hi all,
    I am created one purchase order that are not any base or targeted document ,not any approval   procedure and  purchase order document status is steel open . Then how  I a cannot change the document row.
    thanks
    arabinda pal

    Hi Deepa,
    I think if you want to restrict the further editing of a particular row, then you just need to follow the simple procedure.
    1. create the purchase order with your desired items & vendor & add this document
    2. Now reopen it & goto that row which you want to restrict. Right click on that row & select "Close Row".
    3. Select yes to confirmation message.
    4.Now update the document.
    Now you an check it out, in that document you will not be able to edit that row contents.
    I hope this solves your issue.
    Regards.
    ShriX.

  • Sale order document flow-u0091Service Documentsu0092 is coming which should't aper

    New Issue with Sales order document flow:
    When linking from a sales order in document flow, we were reviewing why the description information varied.  In looking at different values, we clicked on a new item within document flow that allows you to like to ‘Service Documents’.   This is new in 6.0, or it was previously deactivated in 4.6C.  If you link from a sales order to a service document, in ECC 6.0, you will get a short dump because the document flow is so great (viewing order #any in VA03 and use document flow and then select the service documents button    as seen on the screen below
    A Short dump will occur in program SAPLDOCUMENT_FLOW_ALV.
    Here in ECC 6.0 is how it looks from sales order 9806:
    Documents created from 2004 through 2007 are coming up as linked to this sales order and that is incorrect.  There is some type of linkage issue.  In the 4.6 C environments, the ‘service documents’ link is not visible from document flow.
    Can any body functional / technical Help on this urgent???

    Hi Sanjay,
    Go to the order VA03 --> Environment --> status overview. The exact status of the header and item can be found here. You may have chances to know why the status is being processed.
    Also 
    Check whether you have checked 'document flow update' field at item level in copy control
    Check your settings for completion rule in item category
    If it is due to incorrect status message, run report SDVBUK00. That might fix the error. It is recommended to run this first in test mode.
    Br, Sats.

  • PO Release Strategy not triggerred for particular Total Net Order Value

    Dear,
    I am currently facing the issue where release strategy for purchase orders is not getting triggered for a particular value or lower.
    For order value 1 INR or less, no release strategy is triggered for new created PO. And for value > 1 INR release strategy is getting triggered.
    All otehr PO characterstics are the same, I mean to say the values for other characterstics such as plant material group are identical.
    But the characterstics for release for Total net order value are <= 30000 INR. There are two system copies, where in one system the same release strategy is working as expected. But in other system the above mentioned issue occurs. There is no differnce which I can see in the release strategy setup.
    Please suggest for solution.
    Thank you.
    Warm Regards.

    Dear All,
    While looking further into the issue by going into debugging mode, we have found that in include LCLSCF2I, Internal table p_selection_criteria_tab , the value for ATFLV (Internal Floating point from) gets different values in the two systems. For example, in the affected system, for PO with 1INR tottal value, for one of the Total value chaaracterstics before INR characterstic, ATFLV value is 0,0000000000000000E+00, hence it gets out of loop and doesn't trigger release strategy.
    But in another system for same PO values and release setup, ATFLV value is 1,0000000000000000E+00 for that characterstic.
    May I know how the value for this field gets calculated.
    Thank you.
    Warm Regards.

  • Commit error while transferring Sales order Document to GTS

    Hello,
    We faced a transfer error while transferring sales order document to GTS.
    When I debugged the code function /SAPSLL/API_6800_SYNCH is called. In this function, /SAPSLL/CUHD_MAINTAIN_SINGLE is called with parameter lv_no_commit = 'X'. When I checked why its value is 'X', I saw that if the RFC destination and the current system are the same, then lv_no_commit = 'X', (means if the R3 and the GTS are in the same server, same client.) In debug mode I set the value of lv_no_commit to space, and then it works. It creates the GTS document.
    We are also transferring billing documents and it works fine. When I checked what is the difference between transferring sales order document and transferring Billing document, I saw that in the transferring billing document there is another function is called /SAPSLL/API_6800_CSD_SYNCH, and it's calling parameters(in background, as seperate unit) are different from calling parameters of /SAPSLL/API_6800_SYNCH. You can see the difference below.
    For sales document transfer :
        CALL FUNCTION '/SAPSLL/API_6800_SYNCH'
          DESTINATION cs_transfer-rfc_dest
    For billing document transfer :
        CALL FUNCTION '/SAPSLL/API_6800_CSD_SYNCH'
          IN BACKGROUND TASK
          DESTINATION cs_transfer-rfc_dest
          AS SEPARATE UNIT
    So my question is, do you think is it a sap standard program error, or is there any suitable settings in the customizing or SM59 to fix this error?
    Thanks in advance
    Serhat
    Edited by: Serhat Dirihan on Jan 22, 2009 11:46 AM

    Dear Serhat,
    I don't think this is an RFC problem or an error. But you wrote:
    When I checked why its value is 'X', I saw that if the RFC destination and the current system are the same, then lv_no_commit = 'X', (means if the R3 and the GTS are in the same server, same client.)
    It is impossible to have GTS and R/3 on the same system and same client. At least the client should be different. So try to check why the call is performed like that.
    Balazs

  • Creation of sales order document

    How to create a sales order document using VA01?Give me the steps?

    Hi,
    Please search before posting any thread,
    [http://help.sap.com/saphelp_ides/helpdata/en/47/ef8c7c124811d2806f0000e8a495b3/content.htm]
    Regards,
    Durgesh.

  • Sales order document flow error

    we do credit memo for one sales order, in the sales order document flow, the credit memo accounting document's status is not cleared. how can we changed it to be cleared?

    Hi,
    Clearing will be done by finance after the payment is given to the customer. This clearing is done by transaction F-22.
    VKM3 is used for releasing document blocked for credit management and not for clearing the accounting document.
    Regards
    Karan

  • Contract not visible in sales order document flow

    Hi
    I am supposed to create sales order from Contract.The requirement is that only header data should be copied.Thus  In Copy Control configuration I did not maintain item level and schedule line level settings for these document types. The issue is that after running the whole cycle from Contract -->SO --> Delivery --> Invoice when I see the Sales Order document flow I can see all other documents but not the contract.Also In Contract document flow I can see only sales order but not delivery and invoice.Please guide.

    Hello,
    Update Document Flow option is available only at Item Level in copy control setting from Contract to Sales Order.
    Check out your Copy Control Records at Item Level. There would be "2" mentioned in "pdate document flow" box.
    2 means Create doc. flow records except for dely/goods issue/billdoc. Here you to maintain "X" for Complete Document flow.
    Hope this helps,
    Thanks,
    Jignesh Mehta

Maybe you are looking for

  • Anyone getting the rare random error bug since 10.5.7?

    I am not sure if I got one or not since 10.5.7 If you don't know what I refer to, you can search for my other posts on this issue. I usually ask it each time an update comes, hoping it will get mended. Usually right after I ask, it happens Message wa

  • Portal, Identity & app server issue

    Hi all. I am getting a weird response when trying to access a protected web application using Identity Policy Agent and Application server 7. I have Sun Portal Server 6.1, (with it's Identity Server), App Server 7 & Identity Policy Agent running on t

  • Regex: Multiple pattern flags

    hi, in java.util.regex.Pattern, to create a new Pattern, i have to use compile(String pattern, int flags) method and i need to use it with several flags ... but how ? is it something like : Pattern.compile(pattern, Pattern.MULTILINE + Pattern.CASE_IN

  • Search page don't work after moving VO under another VO (by creating VL)

    Hi, all! I need Your help and explaining... So, please let me discuss my problem. I had my Search page. In my search page I search for records using APasesDati VO. On day I deside to move APasesDati VO under LVAIKolekcijaDati VO (created 1 to 1 VL).

  • Video conference gets corrupted about 2 minutes in.  iChat 3 and 4 both.

    I've been experiencing this with my mom and we can't figure out what the trick is. She can video conference with my sister for a long time and never run into this issue. I can video conference with anyone else for a long time and never run into this