Creating a Purchase Order

Hi there,
i need to create an purchase order, heres my code:
Private Sub Gerarcompra()
        Dim i As Integer
        Dim RetVal As Long
        Dim ErrCode As Long
        Dim ErrMsg As String
        ErrMsg = "Ocorreu um erro..."
        Dim vDrafts As SAPbobsCOM.Documents
        vDrafts = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders)     
        oForm = SBO_Application.Forms.Item("analprocform")
        oMatrix = oForm.Items.Item("MatrixProc").Specific
        For i = 1 To oMatrix.RowCount
            oCheck = oMatrix.Columns.Item("select").Cells.Item(i).Specific
            If oCheck.Checked = True Then
                'Set values to the fields
                vDrafts.CardCode = "V8000"
                vDrafts.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO
                vDrafts.DocDate = System.DateTime.Now
                'Invoice Lines - Set values to the first line
                oEditText = oMatrix.Columns.Item("NArtigo").Cells.Item(i).Specific
                vDrafts.Lines.ItemCode = oEditText.Value
                vDrafts.Lines.ItemDescription = ""
                oEditText = oMatrix.Columns.Item("Quantidade").Cells.Item(i).Specific
                vDrafts.Lines.Quantity = Double.Parse(oEditText.Value)
                oEditText = oMatrix.Columns.Item("Preco").Cells.Item(i).Specific
                vDrafts.Lines.UnitPrice = Double.Parse(oEditText.Value)
                vDrafts.Lines.Add()
            End If
        Next
        'Add the Invoice
        RetVal = vDrafts.Add
        'Check the result
        If RetVal <> 0 Then
            oCompany.GetLastError(ErrCode, ErrMsg)
            MsgBox(ErrCode & " " & ErrMsg)
        End If
    End Sub
But in the end i got an error: "Nº Article missing...".
Thank you all for your support.
Luis Barros

change the code as
Private Sub Gerarcompra()
Dim i As Integer
Dim RetVal As Long
Dim ErrCode As Long
Dim ErrMsg As String
ErrMsg = "Ocorreu um erro..."
Dim vDrafts As SAPbobsCOM.Documents
vDrafts = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders)
oForm = SBO_Application.Forms.Item("analprocform")
oMatrix = oForm.Items.Item("MatrixProc").Specific
dim x as integer
x = 0
For i = 1 To oMatrix.RowCount
oCheck = oMatrix.Columns.Item("select").Cells.Item(i).Specific
If oCheck.Checked = True Then
x = x + 1
if x > 1 then
vDrafts.Lines.Add()
end if
'Set values to the fields
vDrafts.CardCode = "V8000"
vDrafts.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO
vDrafts.DocDate = System.DateTime.Now
'Invoice Lines - Set values to the first line
oEditText = oMatrix.Columns.Item("NArtigo").Cells.Item(i).Specific
vDrafts.Lines.ItemCode = oEditText.Value
vDrafts.Lines.ItemDescription = ""
oEditText = oMatrix.Columns.Item("Quantidade").Cells.Item(i).Specific
vDrafts.Lines.Quantity = Double.Parse(oEditText.Value)
oEditText = oMatrix.Columns.Item("Preco").Cells.Item(i).Specific
vDrafts.Lines.UnitPrice = Double.Parse(oEditText.Value)
End If
Next
'Add the Invoice
RetVal = vDrafts.Add
'Check the result
If RetVal 0 Then
oCompany.GetLastError(ErrCode, ErrMsg)
MsgBox(ErrCode & " " & ErrMsg)
End If
End Sub

Similar Messages

  • Create a Purchase order using the BAPI using the data in the XML file.

    Hello Gurus,
    here is the scenario can anyone help me how to proceed explaining the procedure?
    Create a Purchase order using the BAPI using the data in the XML file.
    comprehensive explanations are appreciated.
    thanks in advance.

    hi,
      first use fm "bapi_po_create".
      then use fm "BAPI_ACC_GL_POSTING_POST"
    The demo environment was made with real business scenario in mind, but following subjects need to be addressed in a live implementation:
    •     No exceptions and error handling is implemented, except the order rejection (e.g. partly delivery);
    •     In Navision both XML Ports and the XML DOM has been used to integrate with SAP XI, because XML ports has some drawbacks regarding to Namespaces in XML Documents (mandatory in SAP XI);
    •     A minimum of SAP and Navision customization is required to implement this solution. (e.g. user exit in SAP, Navision XML DOM).

  • Create another purchase order for a material ordered in full

    Hello friends,
    I have a little MM question for you.
    I've created a purchase requisition with a material A and quantity 100 UN
    I've then created a purchase order in reference to this PR.
    This PO has been released.
    Is it possible, in standard SAP, to create another purchase order in reference to the same purchase requisition for the same material and the same quantitiy ?
    How does SAP control that ? (customizing path ??)
    Regards,
    Bahia.

    Dear,
    Is it possible, in standard SAP, to create another purchase order in reference to the same purchase requisition for the same material and the same quantitiy ?  Yes it is possible in SAP
    How does SAP control that ? (customizing path ??): SAP controls in that way, when ever you create purchase requisition with a material A and quantity 100 UN...Now PO created and released...
    Now again if you try to create PO wrt PR, you can observe this time you will get all deatils in PO without quantity...reason behind that is, you have already released an order for full qty w.r.t. that PR...So this time qty field will be empty..You have to manually enter this field.
    Now the same you can see in the the PR status in ME53N Tcode.
    Regards
    Utsav

  • Creating a purchase order in web dynpro for java.........

    hello all,
    i am new to web dynpro for java.i have already done an application
    "Creating a Web Dynpro Application Accessing ABAP Functions" this application
    have good document on sdn.
    this application is working fine .
    Now i got an requiremnt for creating a purchase order in web dynpro for java.
    in normal report when i call  the bapi the parameter are the header, headerx,item, itemx is an internal table.
    CALL FUNCTION 'BAPI_PO_CREATE1'
      EXPORTING
        POHEADER                     = HEADER
        POHEADERX                    = HEADERX
      POADDRVENDOR                 =
      TESTRUN                      =
    IMPORTING
      EXPPURCHASEORDER             =
      EXPHEADER                    =
      EXPPOEXPIMPHEADER            =
    TABLES
       RETURN                       = RETURN
       POITEM                       = ITEM
       POITEMX                      = ITEMX.
    i just want to know how can i fill these internal table in web dynpro
    for java to create an application accessing "Bapi_po_create" .
    Thanks

    Hi Gopal,
    I'm not sure what is your issue, it seems you're not really understanding how the Model structure works in WDP.
    I'll assume few things here, like you know how to Import the Model into the WDP, and you know a little bit about what Java Classes will represent this Model in the Project.
    Try these steps:
    1. Import your Model into the Project;
    2. Open your Component Modeler, create a Data Link between your Model / Component (Or Custom Controller, as you prefer)
      - You can also use the "Apply Template -> Service Controler"
    3. Map the Input of your Model as the Main Node, check the Input Tables (you prob. will have two, POITEM = ITEM - POITEMX = ITEMX)
    4. Also, check the Return box, since this is BAPI return (You can use to display Backend messages)
    Now you have the Model mapped into your Controller, you need to develop the Java function to execute it.
    1. Create a new Input class, like
    BAPI_PO_CREATE1_Input purchaseOrderCreateInput = new BAPI_PO_CREATE1_Input();
    2. Bind your Input Node, in the Controller, with your Input Class;
    wdContext.nodeBAPI_PO_CREATE1().bind(purchaseOrderCreateInput);
    3. Set any Import parameters you need:
    purchaseOrderCreateInput.setEXPPURCHASEORDER(XXXX);
    4. To Add references to the Table, you will perform something like:
    First, you need to know what "Structure" you need to add (POItem Structure) - You have a Java class that represents that Structure..
    POITEM_Element poItemElement = new POITEM_Element();
    poItemElement.setPROPERTY();   /// Set your Properties
    purchaseOrderCreateInput.getPOITEM().add(poItemElement);
    5. Execute your Input,
    purchaseOrderCreateInput .execute();
    Hope it helps,
    Regards,
    Daniel

  • Is it possible to create a Purchase order wrt a Scheduling agreement?

    Is it possible to create a Purchase order wrt a Scheduling agreement?

    Hi,
    It is not possible to create PO wrt a Scheduling Agreement. Po is basically a formal instruction given to the supplier by the purchasing dept. It is non-binding. Delivery of the goods is not mandatory for a PO. However, in the case of SA, we create SA
    and maintain SA Schedule lines (ME38) with reference to SA. The agreement created with vendor is binding and fixed.
    Hope it clarifies.
    Regards,
    Bijoy Kumar S.P.

  • Error while creating a Purchase Order

    Hi Friends,
    I am new to SAP MM. I am getting a problem while creating a purchase order. I created Purchase Info Record, Source List, but while creating Purchase Order, price is not picking from the purchase order. I am getting an error i.e. Net Value must be greater than 0. I checked all the settings, but getting same error.
    Could you please solve this

    Hi,
    Give some price at the item level for the item in the PO.
    And check the Pricing procedure in PO
    Hope it helps you.
    Thanks.

  • GOS while creating a Purchase order

    Hi,
    I have a requirement to attach documents in item level while creating a purchase order ME21N. I know that we can have GOS functionality available but, only after document is created.
    Is there a alternative solution for this?
    Thanks in advance

    Hi,
    Give some price at the item level for the item in the PO.
    And check the Pricing procedure in PO
    Hope it helps you.
    Thanks.

  • User id while  creating a purchase order

    Hello all,
    I would like to know whether there is any option to enter the user id or user name while creating a purchase order. If so could anyone post on how to do that.
    Thanks,
    Maxx

    If you are creating PO in foreground, you dont have the option of giving user id.
    But if you create POs in background using a scheduled job, then when you are scheduling the job, you can overwrite the default user id and give the user id you want. In this case all the POs created by the job, will have the user id created by you.
    But if you have to create a PO through background job, you have to give the inputs to PO through some programs may be BDCs or LSMW.
    Reward if this helps. you

  • Budget Exceed Error during creating of Purchase order in reference to PR

    Hi,
    I am getting the subject error (Budget Exceed Error) every time when I want to create a purchase order related to purchase requisition of my project.
    Issue is that after release the project when the purchase requisition has created for non stock item under activity I found in transaction CJ31 the assign value has already updated.
    Let say my budget is 400 US$, and the purchase requisition has created for 380 US$. Now when I check with CJ31I found the assigned value is 380. Now If I create a purchase order it throws an error that budget exceed.
    The tolerance limits are following:
    SA     ZSA01     Budget Profile Overall AVAC     ++     1     90,00
    SA     ZSA01     Budget Profile Overall AVAC     ++     3     100,00
    SA     ZSA01     Budget Profile Overall AVAC     01     1     90,00
    SA     ZSA01     Budget Profile Overall AVAC     01     3     100,00
    Please advice what will be the proposed solution for the above issue.
    Thanks in advance.
    With Regards,

    Your budget is 400$ and PR value is 380$ but you have not mentiond what is the tax value ?
    when u r creating PO at that time system will check the budget against PO value considering taxes also.
    eg. 380$+tax value.
    after considering taxes your total PO value imay be getting updated more that 400$.
    Explre you error by clicking on error information you get the exact diffrence in budget and PO value.
    Hope this will sove your problem, reply after doing this.

  • Get a wrong price  when creating a Purchase Order in order recommendation

    Dear all
        I meet a strange problem .I have already set a gross price list for Item 'A' . When I create a purchase order in Purchase Order Window,It will calculate a unit price (net price) according to the  gross price list  automatically .But when I create a purchase order in Order Recommendation Window,It will get a unit price as same as the gross price in predefined gross price list.They should not be equal in fact.

    Dear Anna Shao 
    1 .Our SBO is version 2007B
    2. The Decimal of Amount is 2 and that of Price is 6
    3. Vat rate is 17%
    4. The gross price is not small,the problem is that the difference is not small either.Sometimes  it's bigger than 0.1 RMB.I can give you the example.
    LineNo     ItemCode  Quantity  UnitPrice       VatRate      GrossPrice     LineTotal     GrossTotal
    1            A     10         299.145299    J1(17%)      349.995299      2991.45      3499.95
    2            A     10         299.150000    J1(17%)      350.000000      2991.45      3500.00
    3            A     10         299.150000    J1(17%)      350.010000      2991.50      3500.10
    If you set the unit price list for ItemCode 'A', you will get the result like row 1 above.
    If you set the gross price list for ItemCode 'A' ,you will get the result like row 2 above.
    If you do not set any price list for ItemCode 'A'  and you just set the unit price 299.150000 in the purchase order,you will get the result like row 3 above.
    The perfect one is row 2.It is just what  our customer needs.So they set the gross price list for ItemCode 'A'.  But another problem occured when using MRP order recommendation. It is the one why I post a thread,just as I have descripted at first
    Edited by: Jianzhong Zhang on Feb 25, 2009 3:53 AM

  • DBIF_RSQL_INVALID_RSQL when creating a Purchase Order (ME21N)

    Hi,
    The system is generating a short dump DBIF_RSQL_INVALID_RSQL when a user tries to create a purchase order.
    what could be the cause of this? i have analysed the short dump in st22 and looked at sm21 and st11 and they are giving very little detaill.
                                                                                    Error in the module RSQL accessing the database interface.                                                                               
    What happened?                                                                               
    Error in ABAP application program.                                                                               
    The current ABAP program "SAPLZMM_GET_ACT" had to be terminated because one of    
    the                                                                               
    statements could not be executed.                                                                               
    This is probably due to an error in the ABAP program.                                                                               
    What can you do?                                                                               
    Print out the error message (using the "Print" function)                          
    and make a note of the actions and input that caused the                          
    error.                                                                               
    To resolve the problem, contact your SAP system administrator.                    
    You can use transaction ST22 (ABAP Dump Analysis) to view and administer          
    termination messages, especially those beyond their normal deletion              
    date.                                                                               
    Error analysis                                                                               
    An exception occurred. This exception is dealt with in more detail below  
    . The exception, which is assigned to the class 'CX_SY_OPEN_SQL_DB', was  
    neither                                                                  
    caught nor passed along using a RAISING clause, in the procedure          
    "ZMM_GET_ACT_PLN" "(FUNCTION)"                                           
    Since the caller of the procedure could not have expected this exception  
    to occur, the running program was terminated.                            
    The reason for the exception is:                                          
    The SQL statement generated from the SAP Open SQL Statement violates a    
    restriction imposed by the database system used in R/3.                                                                               
    Possible errors:                                                          
    o The maximum size of an SQL statement has been exceeded.                
    o The statement contains too many input variables.                       
    o The space needed for the input data exceeds the available memory.      
    o ...                                                                               
    You can usually find details in the system log (SM21) and in the          
    developer trace of the work process (ST11).                               
    If an error occurs the developer trace often informs you about the        
    current restrictions.                                                                               
    How to correct the error                                                                               
    The exception must either be prevented, caught within the procedure             
    "ZMM_GET_ACT_PLN"                                                              
    "(FUNCTION)", or declared in the procedure's RAISING clause.                    
    To prevent the exception, note the following:                                   
    The SAP Open SQL statement must be divided into several smaller units.          
    If the problem occurred due to the use of an excessively large table            
    in an IN itab construct, you can use the addition FOR ALL ENTRIES               
    instead.                                                                        
    When you use this addition, the statement is split into smaller units           
    according to the restrictions of the database system used.                                                                               
    You may able to find an interim solution to the problem                         
    in the SAP note system. If you have access to the note system yourself,         
    use the following search criteria:                                                                               
    "DBIF_RSQL_INVALID_RSQL" CX_SY_OPEN_SQL_DBC                                     
    "SAPLZMM_GET_ACT" or "LZMM_GET_ACTU01"                                          
    "ZMM_GET_ACT_PLN"                                                               

    Hi,
    Wherever you have used SQL statement please do check all the fields here as some of the fields are not in correct order as they are required per the actual table in dictonary, to just verify that you can use addition of "INTO CORRESPONDING FIELDS OF INTERNALTABLE" in your SQL statement as this will not require the fields to be in order but this may cause performance issue.
    Thanks and Regards
    Sudharshan

  • Creating a Purchase Order for the Asset

    Hi,
    Please see the following steps:
    1.Create a purchase order for the asset.
    2. Post a goods receipt from this PO.
    3. Quantity of asset will be transfered from goods receipt.
    But I find quantity of asset(AS02) was not be transfered and still was equal to 0.
    Could you help me?
    Thanks and Regards,
    Colin.

    see the field status varient for the gl account see the qty field is optional field or not
    and check in the asset group also qty field is the optional field
    Assign point if useful
    Regards
    A.k

  • Creating a Purchase Order using ORDERS05 Idoc

    Hi Experts,
    I need to create a purchase order using ORDERS05 Idoc, with the data I am using a sales order is gettig created but I need to create a PO insted of SO.
    Please let me know what is difference between a PO and SO while using ORDERS05. Also please let me know what are all the fields that needs to chaged in the Idoc.
    Thanks,
    Suma

    Hi,
       I'm looking at a similar problem, can we use ORDERS05 IDOC basic type to create a Purchase Order?
       What is the inbound processing FM?  I tried IDOC_INPUT_ORDRSP, but it seem to only allow changes to a PO, and not creation of a PO.
       For IDOC_INPUT_ORDERS FM this one seem to only create Sales Orders?
       Which inbound FM should i be using?
    Regards.

  • Creating a purchase order, cost price?

    hi, when im creating a purchase order and also producing an invoice for it obviously i want the item cost to be used rather the the selling price. however, for some reason the system continues to uses selling price, so when it comes to paying an invoice i need to change all the prices to the cost, which is very annoying.
    many thanks.

    Hi........
    Please check I guess you have assigned sepping price list to the vendors. Please unassign Price List from Vendors.......
    Regards,
    Rahul

  • Creating a Purchase Order, is there any help out there?

    I am creating a purchase order for our sales team that can be utilized on iOS. I have two issues:
    1) Some of our sales will be exempt and will need to be toggled off. How do you go about doing this while not destroying the end total?
    2) Our sales tax varies due to county's jurisdiction. Is there a way to change that once the form is ready to be filled out?
    Thanks Guys
    Below is how my form is being set up, mind you this is an import from excel.

    I don't see a way for you to currently specify that an item is exempt...
    Maybe add another column with check-boxes for the exempt status. However,
    implementing this in the calculation will require a custom-made script.
    As for the sales tax, you can place that in a text field as well and use it
    in your calculation directly. It's even possible to set it up so that a
    selection in a county drop-down will automatically populate the Sales Tax
    field with the correct value.

Maybe you are looking for

  • Clearing of Service entry sheet and Invoice -GRIR

    Hi In  a Purchase order,the service entry sheets, it has multiple line items. It can now happen that a invoice is only received for the first line item and must be paid. When the line item is selected in MIRO, it however clears the total value of the

  • Safari and aol won't download anything. What can i do to fix that?

    My internet browsers seem to be in a funk. For some reason i can't download anything off the internet. However, My iTunes can dowload songs fine and i can still dowload updates for all the applications i already have. I just can't download any new ap

  • Sound disappeared from Sample Editor?

    Can anyone help? The sound has completely disappeared from my Sample Editor window and also the Audio bin. I can't audition any loops in the list now, but if I drag them to a track in the main Arrange page they play fine. Then double clicking on that

  • I have a problem with my iPod

    I have a problem with my ipod, it's all started during my visit to my cousin's house. My songs suddenly skip around 200 songs within 40 second, and i can't play my songs and my video. I already Restore my iPod but nothing changes. it just keep skippi

  • Looking for advice to maximize my iMovie productivity.

    Here's the hardware I have been using... iMac with iMovie Acer PC laptop Logitech QuickCam Pro 3000 Blue Snowball Mic InstantVideo To-Go video xfer accelerator from ADS The QuickCam is something I like to use because I've had it for years and it work