Creating purchase order from code

I am importing an excel file and then for each row,trying to create purchase order through coding by using document object. I am successful in creating Order Headers but how can i create Lines if the excel sheet is having Same order but different Item codes????

I was trying to import excel file in purchase order by following way:-
I read each row and for each row, call function for creating order. This is my sample code---
(var30 is previous excel value of order no. & var1 is current value)
public sub createorder()
odocs = GOD_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders)
            If irow = 2 Then
                odocs.CardCode = "200173"
                odocs.Lines.ItemCode = var16
                odocs.Lines.Add()
            Else
                If var1 = var30 Then
                    odocs.CardCode = "200173"
                    odocs.Lines.ItemCode = "3231015"
                    odocs.Lines.Add()
                Else
                    lRetCode = odocs.Add()
                    odocs.CardCode = "200173"
                    odocs.Lines.ItemCode = var16
                    odocs.Lines.Add()
                End If
            End If
            lRetCode = odocs.Add()
            Dim x As String
            GOD_Company.GetNewObjectCode(x)
            If lRetCode <> 0 Then
                GOD_Company.GetLastError(lErrCode, sErrMsg)
                MsgBox(sErrMsg)
            Else
                MsgBox("Order Created with no " & x & ".")
            End If
            var30 = var1
This code is giving error as "Item No. is missing(OPOR.ObjType)", But Item no. is not present in Purchase Order. Please check whether Code is proper or i need to make any changes???????/

Similar Messages

  • Update was terminated while creating purchase order from ME21N

    Hi Experts,
    We are getting this dump when try to create purchase order from ME21N;
    Our system ECC 6.0 and IS-AFS (Apparel & Footwear Solution) V600 component has installed,
    How can we prevent this error,
    Regards
    Here is the dump and sm21 log,
    Runtime Errors         LOAD_PROGRAM_NOT_FOUND
    Exception              CX_SY_PROGRAM_NOT_FOUND
    Date and Time          10.10.2008 10:22:03
    Short text
         Program "RMCMS431 " not found.
    What happened?
         There are several possibilities:
         Error in the ABAP Application Program
         The current ABAP program "SAPLMCS4" had to be terminated because it has
         come across a statement that unfortunately cannot be executed.
         or
         Error in the SAP kernel.
         The current ABAP "SAPLMCS4" program had to be terminated because the
         ABAP processor detected an internal system error.
    What can you do?
         Note down which actions and inputs caused the error.
         To process the problem further, contact you SAP system
         administrator.
        Using Transaction ST22 for ABAP Dump Analysis, you can look
        at and manage termination messages, and you can also
        keep them for a long time.
    Error analysis
        An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_SY_PROGRAM_NOT_FOUND', was not
         caught in
        procedure "TMC2F_FROUT_CALL" "(FORM)", nor was it propagated by a RAISING
         clause.
        Since the caller of the procedure could not have anticipated that the
        exception would occur, the current program is terminated.
        The reason for the exception is:
        On account of a branch in the program
        (CALL FUNCTION/DIALOG, external PERFORM, SUBMIT)
        or a transaction call, another ABAP/4 program
        is to be loaded, namely "RMCMS431 ".
        However, program "RMCMS431 " does not exist in the library.
        Possible reasons:
        a) Wrong program name specified in an external PERFORM or
           SUBMIT or, when defining a new transaction, a new
           dialog module or a new function module.
        b) Transport error
    How to correct the error
        Check the last transports to the R/3 System.
        Are changes currently being made to the program "SAPLMCS4"?
        Has the correct program been entered in table TSTC for Transaction "ME21N "?
        If the error occures in a non-modified SAP program, you may be able to
        find an interim solution in an SAP Note.
        If you have access to SAP Notes, carry out a search with the following
        keywords:
        "LOAD_PROGRAM_NOT_FOUND" "CX_SY_PROGRAM_NOT_FOUND"
        "SAPLMCS4" or "LMCS4F10"
        "TMC2F_FROUT_CALL"
        If you cannot solve the problem yourself and want to send an error
        notification to SAP, include the following information:
        1. The description of the current problem (short dump)
           To save the description, choose "System->List->Save->Local File
        (Unconverted)".
        2. Corresponding system log
           Display the system log by calling transaction SM21.
           Restrict the time interval to 10 minutes before and five minutes
        after the short dump. Then choose "System->List->Save->Local File
        (Unconverted)".
        3. If the problem occurs in a problem of your own or a modified SAP
        program: The source code of the program
           In the editor, choose "Utilities->More
        Utilities->Upload/Download->Download".
        4. Details about the conditions under which the error occurred or which
        actions and input led to the error.
        The exception must either be prevented, caught within proedure
        "TMC2F_FROUT_CALL" "(FORM)", or its possible occurrence must be declared in the
        RAISING clause of the procedure.
        To prevent the exception, note the following:
    sm21 log ;
    Transaction Canceled 00 671 ( LOAD_PROGRAM_NOT_FOUND 20081010102203saptest_TET_00 EYUCE 100
    Update terminated
    > Update key: F39796DD5421F1509233001E0BD601E0
    > Update module: MCE_STATISTICS_UPD_V2
    Run-time error "LOAD_PROGRAM_NOT_FOUND" occurred

    Please follow the oss note 800335
    V2 Update terminations in Purchasing transactions after upgrading or installing AFS 5.0 release.
    Other terms
    AFS, LIS, MIGO, ME22N, OLI3, S433, S431
    Reason and Prerequisites
    AFS Purchasing infostructure S431 is no longer used. S433 is the valid infostructure for the release AFS 5.0.
    Solution
    Please do the following.
    For customers upgrading to AFS 5.0 only:
    > Rebuild Infostructure S433.
    - Goto transaction: OLI3 (Statistical Set up of Infostructures)
    - Info structure to be compile: S433
    - Specify the 'Name of run'.
    - Execute.
    > Please also follow the instructions given below.
    For both Upgrade and Non-upgrade Customers:
    > Create the report 'ZDELS431'.
    - Transaction: SE38
    - Give Program name as ZDELS431.
    - Create (F5).
    - Title : 'Program to delete S431'.
    - Type  : 1 (Executable Program).
    - Status: T (Test Program).
    > Copy the program text from the note and paste in the program.
    > Save and activate the program.
    > Execute the report for all clients in Update mode.
      (Two check-boxes will appear: P_ALL_CL, P_UPDATE.
       Please check both of them).
    This report will delete all the references to infostructure S431.

  • Create purchase order from shipment cost document

    Hi Experts,
    I would like to know how a purchase order type is linked to a shipment cost document so as to create purchase orders automatically when I do transfer posting to the vendor from the shipment cost document. How system automatically finds out the PO type and creates purchase order.
    Thanks,
    Emaya

    Hi,
    Thanks. I have made all those mentioned changes already, and infact I am able to create purchase orders(PO Type NB) automatically when I do transfer posting, but I would like to know, why NB type only? why not some other purchase order types? Suppose if I create a new PO type by copying NB with new number ranges, how to link it to my shipment cost document?
    Please comment.
    Regards,Emaya
    Edited by: Emayavaramban S on Dec 11, 2008 3:06 PM
    Edited by: Emayavaramban S on Dec 11, 2008 5:12 PM

  • Create Purchasing Order from Purchasing Requisition

    Hi,
    I need to create in a report a Purchasing Order from Purchasing Requisition. I have seen the Bapi BAPI_PO_CREATE; Can I create order from requisition without fill all field and only 
    the requisition and ther obligatory field?
    Thanks
    Francesco

    Hi
    Try out what all parameters are obligatory in case of Purchase Requsition using the FM - 'BAPI_REQUISITION_CREATE' in R/3 back-end..
    and then try creating PO using 'BAPI_PO_CREATE1' or 'BAPI_PO_CREATE' Function modules.
    Also try creating P Req manually using ME51N / ME51 Transactions and debug the process to get further details, if any.
    Regards
    - Atul

  • DI: Create Purchase Order from Multiple Sales Order - Lines

    Hi all,
    I am trying to group multiple lines from multiple Sales orders concerning One given Vendor/Supplier so as to generate One Purchase order for this Vendor/Supplier
    oSalesOrder = (Documents)B1Connections.diCompany.GetBusinessObject(BoObjectTypes.oOrders);
    oPurchaseOrder = (Documents)B1Connections.diCompany.GetBusinessObject(BoObjectTypes.oPurchaseOrders);
    oPurchaseOrder.CardCode = 'Vendor1'
    oSalesOrder.getByKey("13");
    oSalesOrder.Lines.SetCurrentLine("4");
    oPurchaseOrder.Lines.BaseEntry = oSalesOrder.DocEntry;
    oPurchaseOrder.Lines.BaseLine = oSalesOrder.Lines.LineNum;
    oPurchaseOrder.Lines.BaseType = (int)BoObjectTypes.oOrders;
    oPurchaseOrder.Lines.Add();
    oSalesOrder.getByKey("14");
    oSalesOrder.Lines.SetCurrentLine("2");
    oPurchaseOrder.Lines.BaseEntry = oSalesOrder.DocEntry;
    oPurchaseOrder.Lines.BaseLine = oSalesOrder.Lines.LineNum;
    oPurchaseOrder.Lines.BaseType = (int)BoObjectTypes.oOrders;
    if (oPurchaseOrder.Add()!=0)
        MessageBox(B1Connections.diCompany.GetLastErrorDescription());     
    I get the following Error: <i>Base Document Card and Target Document Card do not match</i>.
    What more Should I do to avoid This?
    Regards,
    Emmanuel.

    Hi Emmanuel,
    As far as I know you cannot create a purchase order based on a sales order using the DI API. I know in SBO you can do this, but I don't think using the SDK. The reason why it's giving you the message "Base Document Card and Target Document Card do not match" is because one is a vendor and one is a customer.
    Hope it helps,
    Adele

  • Add additional authorization object to create purchase order t-code me21n

    Hi,
    we are running 4.7 Enterprise.
    I would like to add an additional auth. object to transaction code ME21N in order to restrict purchase order entry by material type.
    Ideally I would like that the M_MATE_MAR (Material Master: Material Types) auth. object is checked since I want to restrict certain users by material type = HAWA.
    Would that be possible?
    If yes, how?
    Thanks!

    Hi Armin
    Authorizationscheck are implementd directly in the source code - this means that often, it is not possible, using standard, to add an extra authorization check.
    If the M_MATE_MAR is already implemented, you can inset it manually, but if isn't you need to look for an alternative, or perhaps an user exit in which you implement it your self.
    You can find a list here http://arthur_ong.tripod.com/xab018.htm.
    Regards
    Morten Nielsen

  • Creating Purchase Order from Sales Order via DI

    Hi
    I get the dreaded -5002 Error when trying to create a Purchase Order referencing a Sales Order.
    The variables BaseEntry,BaseLibne contain valid values i've doublechecked that.
    is it not possible to generate a referenced Purchase Order this way? If not is it planned?
    I use the approach:
    oPRDR.CardCode=CardCode
    oPRDR.Lines.BaseType = 17
    oPRDR.Lines.BaseEntry = BaseEntry
    oPRDR.Lines.BaseLine = BaseLine
    retval = oPRDR.Add()
    btw. I'v tried it without:
    oPRDR.CardCode=CardCode
    but didn't work either.
    tia

    Hi Philipp,
    This is a bug. Please log it on Service Marketplace.
    Sorry,
    Frank
    PS:
    I have just been asked that question by another partner as well.
    He could even create a PO based on a SO that with demo databases (PL18 + PL21), but not in a real customer database (not 100% sure about the PL)
    He is going to inform Support about that issue...

  • How to create Purchase order from Requisitions!

    Hi there,
    Please help me in this case:
    I was created a outline agreements for item MN.001 (4600000014), and then created and released success for Requisition  10000180. After that I want to create PO from above Requisition (use T-code  ME25 -Vendor Unknown). These steps as follow:
    1. Navigator to T-Code : ME25
    2. Refer to Req : 10000180
    3. Assign Source to Agreement : 4600000014
    4. click button Generate to create PO from REQ --> system message that "Item blocked for order processing (function not possible)"
    Please help me!
    thanks for your advise!
    Viettq.

    hi,
    When you are using the outline agreement for the PR and then shd use for the PO...from where this RFQ comes in the scene??
    Also PR is already asigned to the source as outline agreement...
    Regards
    Priyanka.P
    Edited by: Priyanka Paltanwale on Nov 7, 2008 6:03 AM

  • Create purchase order from purchse requisition number

    Hi guru's,
    I have a requirement that when ever i m creating the sales order through va01 and when i will click on save button it has to create an automatic PO from the PR number which will be there in the order. Functional consultant saying that he creates an output type and configured it in nace by assiging one driver program and he is giving the transmissionmedia as 8(Which is nothing but special function) for the output.....he is saying when ever i click on save button that driver program has to be triggered and need to generate PO.
    how i can implement this one....
    replay asap.....
    Thanks&Regards,
    R.P.Sastry

    Hi chenna kesava reddy,
    i dont hav any form....its not a printing output type...
    i vonfigured all d details.but my print program is not triggering when i m pressing the save button in va01.
    but it is triggering when i run the program rsnast00 by giving the output type..
    please help me any one.....how the transmission media number 8(means special function) will work....
    regards.

  • Creating purchase order through coding

    I am trying to create purchase order through Code, for a table field i can insert as :
    odocs = GOD_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders)
    odocs.CardCode = "200173"
    But if the field is not a table field then , how can i insert it in PO?????

    Hi Ashish Patil 
    Not sure what you mean, not sure what table you are talking about. But here is some sample code on how to add a purchase order.
    Dim PO As SAPbobsCOM.Documents
            PO = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders)
            PO.CardCode = "VUL001"
            PO.Lines.ItemCode = "02SILVTS"
            PO.Lines.Quantity = 1
            PO.Lines.Price = 120
            If PO.Add() <> 0 Then
                Dim str As String
                str = oCompany.GetLastErrorDescription()
                MsgBox(str)
            End If
    hope it helps

  • Purchase order from Purchase requisition

    Hi all,
    How can we create purchase order from Purchase requisition number?
    Any BAPI or Function Module for changing purchase requisition  to purchase order .........
    Thanks in advance for all your help.
    Regards,
    Anukool

    Hi,
    Have you had a look through transaction BAPI to see if there is anything suitable?
    I've just had a quick look and found BAPI_REQUISITION_RELEASE_GEN which should release the PR and then maybe you could use BAPI_PO_CREATE1 and see if there is a way to reference the PR?
    Or what about looking at the transaction ME59N to see how that works?
    I'm just guessing here sorry.

  • Create Sales order from Internal Purchase Order using IDOC

    Hello Friends,
    I have requirement to create Sales Order from Internal Purchase Order Using IDOC.
    Backgorund, we have already configured IDOC orders05 to create Sales Order from external Purchase order from Inbound IDOC, and it is working fine.
    Now we have new requirement to create Sales Order from our own Purchase order, i.e. When PO is created in one plant corresponidng sales order automatically must needs to create in another Plant with respect PO.
    I m trying to design a solution for above problem as follows,
    1.create an Inbound Idoc from PO, by creatiing one new message type on PO save.
    2.Process that Inbound  IDOC same as it is from external PO.
    3.Once processed Sales order will create.
    Please help me in step 1. to create Inbound IDOC from PO.
    If you want any further clarification please write me.
    Thanks,
    Mahesh

    I had done a similar scenario before and we achieved it through SAP XI. The problem is with the control record. When we create a ORDERS IDOC from a PO the control record will be for outbound transmission. We sent the file to XI and XI resent it back with some data parsing and a new inbound control record. This way it went neat outbound and inbound.
    I'm not sure what kind of architecture you have. If you have to do it within your ECC/R/3, then you could create the outbound IDOC to a new port and write a fresh RFC to pick it up from the same folder and create a new control record for inbound processing.
    I haven't tried this; but there is a "processing w. trigger (inbound)" option on the outbound process code. May be you can explore into that a bit more.
    I'm sure there could be better approaches to handle this within ECC so if you stumble on any, do write back. I would like to know to update my knowledge .

  • How to hide some buttons like CREATE PURCHASE ORDER, COPY, EDIT from POWL?

    In SRM 7 ECS we need to hide some buttons like CREATE PURCHASE ORDER, COPY, EDIT from POWL"s. We can do some manipulation via security but we need to make a few buttons invisible without security. Appreciate any advice. Thanks.

    Hi Ashwanin
    To make read only
    Below are the steps to Hide the buttons in POWL table
    1. if you want to Gray out the Buttons
        IMG > SRM SERVER> Cross Application Basic Settings --> Extensions and Field Control. There you will find a node to control   Actions. based on the object type choose your option and make it as read only
    To Make invisible
    1.If you want to  make invisible  the button .
    IMG > SRM SERVER> Cross Application Basic Settings --> Powl and Advance Search - > Adjust powl layout ,search criteria and push button (OR) t-code :   /SAPSRM/POWL_CUST
    2.choose the POWL type for the POWl table
    3.click on Action node , you will find all the acction assigned for the POWL table ,delete the entry which you want to make invsible and save it
    4 .Now run the report POWL_D01 and provide powl type in the selection criteria and deleate the catche quries
    Regards
    chinnaiya P
    Edited by: chinnaiya pandiyan on Jun 27, 2011 3:12 PM

  • Inputs requried to create purchase order report from flat file

    inputs requried to create purchase order report from flat file

    At a guess, I'd say purchase order data.
    If you don't give us a clue what you are actually trying to do we can't really help you too much.
    Do you want to call a BAPI?  Do a BDC?  Use an IDOC?  Or just generally muck up the system by doing inserts into the purchasing tables?
    No doubt if you tell us, you'll get lots and lots of suggestions.
    Gareth.

  • How to create a Purchase order from XI Using ORDERS05

    Hello Experts,
    I need to create a purchase order using OREDRS05 from XI. I was not able to create and I am having these quires.
    1. What are all the mandatory fields that I need to fill in to create a purchase order?
    2. Which part of the SAP will take care of the control record? Is this done by SAP or Integration Tool?
    3. When I have tryed with an existing Inbound Idoc(On R/3 Side) its showing Satus 51 what should I do?(Error: There is no article description for item 000010)
    If Possible give me the step by step procedure to reslove..
    Thanks in Advance,
    Sai Suma

    Hi Suma,
    Check this link
    Creating Purchase Order IDOC through XI
    /people/ravikumar.allampallam/blog/2005/03/03/creating-purchase-order-idoc-through-xi
    Sachin

Maybe you are looking for

  • Payment order

    Hi, Which is the tx. to modify Payments orders in SAP 5.0? Thaks i n advance. Message was edited by:         Victor Devoto Message was edited by:         Victor Devoto

  • I am using apple iphone 3g .not support facebook apps,how can supprt facebook apps in my mobile

    i am using apple iphone 3g .not support facebook apps,how can supprt facebook apps in my mobile

  • Pulse Audio jack detection problem.

    Hi, In my work I use headphones for listening musing and if I shutdown the laptop and then remove the headphones and when I start it in home there is no sound. I found the solution: plug headphones and unplug them. For me Pulse audio does not make ch

  • Deleting parallel currency not base currency in company code

    Hi Guys, I want to delete parallel currency not base currency in company code. We defined the new currency ZWP and our base currency is ZWD. I am able to delete through SPRO but in CO its saying we cannot change currency code again. Is there a way to

  • Extended Attribute properties

    Hello, I have a problem with the property of an Extended Attribute for the Document class. If I create a New Extended Attribute and set its properties (Indexed, Settable and ReadOnly), after the Apply the Read Only property is setted, also if I unche