Sample Bapi code for creating orders

HI all,
ive been working on creating an order using idoc_input_orders and couldnt do it because of 2 fields. now changed my decission and thinking of writing a bapi to do the same. has anybody got the sample code for mapping and filling in the bapis before calling bapi for creating an order. Could somebody help me with a sample code and i could use it as a reference before starting coding.
thanks,
Kiran

See if this helps.
        one order with total sum of effort
          clear:   l_order_header,
                   l_salesdocument,
                   l_order_partners,
                   l_order_items,
                   l_order_schdl.
          refresh: it_order_items,
                   it_order_partners,
                   it_order_schdl,
                   it_return.
???????? get from material ...
        Order header
          l_order_header-doc_type          = 'ZQBV'.
          l_order_header-distr_chan        = '10'.
          l_order_header-division          = '00'.
          if g_qals-werk eq '1100'.
            l_order_header-sales_org         = '1000'.
          else.
            if g_qals-werk eq '3100'.
              l_order_header-sales_org         = '3000'.
            else.
              message i001(00) with text-005.
            endif.
          endif.
          l_order_header-purch_no_c        = g_qals-prueflos.  " <= lot
        Partner data
          l_order_partners-partn_role      = 'AG'.
          l_order_partners-partn_numb      = g_qals-kunnr.
          append l_order_partners to it_order_partners.
        Order items => only one
          l_order_items-itm_number         = 10.
          l_order_items-material           = g_qals-matnr.
          l_order_items-target_qty         = 1.
          append l_order_items to it_order_items.
        Schedules for quantity
          l_order_schdl-itm_number         = 10.
          l_order_schdl-req_qty            = 1.        " <=  only 1 !
          append l_order_schdl to it_order_schdl.
        Conditions for value
          l_order_conditions-itm_number    = 10.
          l_order_conditions-cond_type     = 'PR00'.
          l_order_conditions-cond_value    = g_effort_sum.
          l_order_conditions-currency      = g_effort_unit.
          append l_order_conditions to it_order_conditions.
        BAPI to create sales order
          CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
            EXPORTING
           SALESDOCUMENTIN               =
              ORDER_HEADER_IN               = l_order_header
           ORDER_HEADER_INX              =
           SENDER                        =
           BINARY_RELATIONSHIPTYPE       =
           INT_NUMBER_ASSIGNMENT         =
           BEHAVE_WHEN_ERROR             =
           LOGIC_SWITCH                  =
           TESTRUN                       =
           CONVERT                       = ' '
            IMPORTING
              SALESDOCUMENT                 = l_salesdocument
            TABLES
              RETURN                        = it_return
              ORDER_ITEMS_IN                = it_order_items
           ORDER_ITEMS_INX               =
              ORDER_PARTNERS                = it_order_partners
              ORDER_SCHEDULES_IN            = it_order_schdl
           ORDER_SCHEDULES_INX           =
              ORDER_CONDITIONS_IN           = it_order_conditions
           ORDER_CONDITIONS_INX          =
           ORDER_CFGS_REF                =
           ORDER_CFGS_INST               =
           ORDER_CFGS_PART_OF            =
           ORDER_CFGS_VALUE              =
           ORDER_CFGS_BLOB               =
           ORDER_CFGS_VK                 =
           ORDER_CFGS_REFINST            =
           ORDER_CCARD                   =
           ORDER_TEXT                    =
           ORDER_KEYS                    =
           EXTENSIONIN                   =
           PARTNERADDRESSES              =
          if not l_salesdocument is initial.
          order successfully created
            message i001(00) with text-001 l_salesdocument.
          endif.
        endif.

Similar Messages

  • Need code for sales order create report using bapi's

    need code for sales order create report using bapi's

    Hi,
    Go through below link
    http://www.saptechies.com/bapi_salesorder_createfromdat2/
    <b>Reward points if it helps,</b>
    Satish

  • Function module which uses both BAPI's for sales order create and change

    Please name the function module which uses both BAPI's for sales order create and change.
    BAPI_SALESORDER_CREATEFORMDAT2
    BAPI_SALESORDERCHANGE

    Yup.
    you must write a piece of code for this.
    with if else condition.first check if SO is exsist than use second FM to change it else create new SO from first FM.
    logic somethig like this.
    Amit.

  • Bapi's for creating Maintenance order in IW31 with notification

    Hi All,
       Is there any bapi's for creating Maintenance order with Notification number in the transaction iw31.
      Also is there any bapi's for creating measurement document.
    Points will be awarded.
    Regards,
    vinoth

    RFC MeasDocument: Individual Processing, Create
    MEASUREM_DOCUM_RFC_SINGLE_001
    RFC MeasDocument: Individual Processing, Change/Display or Read
    MEASUREM_DOCUM_RFC_SINGLE_002

  • BAPI/RFC for Sales Order or Warehouse Order that retrives VBAK,VBAP,VBEP

    Hi,
       Is there any BAPI/RFC for Sales Order or Warehouse Order that retrives VBAK,VBAP,VBEP and VBPA tables for specified inputs.
       The BAPI or RFC should return the Sales Order details with tables VBAK,VBAP,VBEP and VBPA.
       Rewards if useful.
    Thanks,
    Mich

    Try creating an RFC calling FM: SD_SALES_DOCUMENT_PREFETCH with required details for Header, Item, Schedule and Partners.
    Below code can give you idea in handling the FM.
    PARAMETERS: p_vbeln TYPE vbeln_vl OBLIGATORY.
    CONSTANTS: c_x TYPE char01 VALUE 'X'.
    DATA: st_view TYPE order_view,
          i_vbak_key TYPE TABLE OF sales_key,
          i_vbak TYPE TABLE OF vbak,
          i_vbap TYPE TABLE OF vbapvb,
          i_vbep TYPE TABLE OF vbepvb,
          i_vbpa TYPE TABLE OF vbpavb.
    START-OF-SELECTION.
      MOVE c_x TO : st_view-header,
                    st_view-item,
                    st_view-sdschedule,
                    st_view-partner.
      APPEND p_vbeln TO i_vbak_key.
      CALL FUNCTION 'SD_SALES_DOCUMENT_PREFETCH'
        EXPORTING
          i_sales_view  = st_view
          i_memory_read = 'A'
        TABLES
          i_vbak_keytab = i_vbak_key " List of Sales Orders to extract
          fxvbak        = i_vbak     " Header
          fxvbap        = i_vbap     " Item
          fxvbep        = i_vbep     " Schedule Lines
          fxvbpa        = i_vbpa.    " Partners

  • Need sample source code for calling stored procedure in Oracle

    Hi.
    I try to call stored procedure in oracle using JCA JDBC.
    Anybody have sample source code for that ?
    Regards, Arnold.

    Thank you very much for a very quick reply. It worked, but I have an extended problem for which I would like to have a solution. Thank you very much in advance for your help. The problem is described below.
    I have the Procedure defined as below in the SFCS1 package body
    Procedure Company_Selection(O_Cursor IN OUT T_Cursor)
    BEGIN
    Open O_Cursor FOR
    SELECT CompanyId, CompanyName
    FROM Company
    WHERE CompanyProvince IN ('AL','AK');
    END Company_Selection;
    In the Oracle Forms, I have a datablock based on the above stored procedure. When I execute the form and from the menu if I click on Execute Query the data block gets filled up with data (The datablock is configured to display 10 items as a tabular form).
    At this point in time, I want to automate the process of displaying the data, hence I created a button and from there I want to call this stored procedure. So, in the button trigger I have the following statements
    DECLARE
    A SFCS1.T_Cursor;
    BEGIN
    SFCS1.Company_Selection(A);
    go_Block ('Block36');
    The cursor goes to the corresponding block, but does not display any data. Can you tell me how to get the data displayed. In the future versions, I'm planning to put variables in the WHERE clause.

  • PROCESS CODE  FOR  PURCHASE ORDER

    Hi Friends,
        what is the process code for Purchase order...  because  i need to   creating a  partner profile in WE20 in the inbound side.. if iselect  message type   ORDERS menas.. that related.. process code( for purchase order is not  displaying)..
      can  any of you give me the <b>Message type </b> and that related <b>Process code</b> for <b> purchase order</b>..
    thanks
    Babu

    Hi Babu,
        You will find out the all Process Code from WE41 for Outbound & WE42 for Inbound.
    The Process code for ORDERS: Purchase order is ME10 for Outbound and you can find it out the message type for Inbound from WE42.
    If need more info let me know..
    Cheers
    Veera

  • T-code for sales order

    Hi friends,
    Can any body tell me the t-code for creating sales order in CRM.
    Thanks in Advance

    Use CRMD_ORDER.
    Then select the transaction type that you need to create.
    Regards
    Kaushal

  • FM/BAPI/Method for Sales Order Costing

    Hi,
    I need the FM/BAPI/Method for Sales Order Costing.
    Which is calculating at run time while process of Sales Order Costing
    Can any one please help me out.
    Thanks
    Chinni
    Edited by: Tirumula Rao Chinni on Mar 10, 2010 3:04 PM
    Edited by: Tirumula Rao Chinni on Mar 10, 2010 3:35 PM

    Vinraaj, thank you very much for your advice and the time you've spent for the ask.
    I am searching for whether there is any SAP offered FM. Therefore, I did not think to check the background (code side) of the process by debugging.
    There is not any documentation about the FM that you have offered, in the system.
    So , I can not be sure about the usage of it, too.
    Thank you very much.

  • Needs sample ABAP code for field routine

    Dear Expert,
    There is a field "Pay Scale Group" in my DSO which stores the data in the format
    AA1/B1/CCC2/DD2/EEE1, A1/BB2/CC2/DDD3/EE2 etc. These data has to be transferred to
    InfoCube where "pay Scale Group" in the InfoCube will store the data like EEE1,EE2 etc.
    I need to write a field routine on the transformation between DSO and Cube.
    Can any one please help me with the sample ABAP code for this scenario.
    Some more examples for better understanding of the requirement:-
    Data in DSO(Source)            Data in Cube(Target)
    ===================            ===================
    AA1/B1/CCC2/DD2/EEE1            EEE1
    AAA1/BB2/CC1/DDD3/EE2           EE2
    A2/BBB2/CC2/DDD3/EEE5           EEE5
    AA2/BB1/C1/DDD3/EE3             EE3
    A3/B1/CC2/DDD1/EE4              EE4
    Many thanks in advance.
    Regards,
    Prakash
    Please do not dump your code requirements in SDN
    Edited by: Pravender on May 18, 2011 11:37 AM

    Hi,
    You can use the following code :
    Suppose the technical name of the field coming from DSO is ZPAY_SGRP.
    And also for example let me take one record, that is ZPAY_SGRP = AA1/B1/CCC2/DD2/EEE1 .
    My assumption is that there will always be 4 '/'.
    In the field routine write the below code
    data: V1(5) type c,
              V2(5) type c,
             V3(5) type c,
              V4(5) type c,
             V5(5) type c.
    data : VAR1 TYPE /BIC/OIZPAY_SGRP.
    split VAR 1  at '/' into V1 V2 V3 V4 V5.
    result = V5.
    V5 will be having the characters after the last '/' .That is V5 = EEE1.
    Hope the above reply was helpful.
    Kind Regards,
    Ashutosh Singh
    Edited by: Ashutosh Singh on May 17, 2011 3:53 PM
    Edited by: Ashutosh Singh on May 17, 2011 4:17 PM

  • Need Sample source code for Forum in jsp

    Hi..
    Please tell me the website which is having the sample source code for simple forum... I have to implement it into my project... kindly help me out...
    thanx in advance
    kumar

    Hi..
    Please tell me the website which is having the sample source code for simple forum... I have to implement it into my project... kindly help me out...
    thanx in advance
    kumar

  • I need the code for creating popup windows and code for open and close

    I can write the code for creating popup window , i am getting problem while trying to open and closing that popup windows.
    Can anybody help me in that pls ?
    Regards
    Sreeni.

    Hi
    For pop up window
    IWDWindowInfo windowInfo = (IWDWindowInfo)wdComponentAPI.getComponentInfo().findInWindows("PopWin");
    IWDWindow window = wdComponentAPI.getWindowManager().createModalWindow(windowInfo);
    window.setWindowPosition (300, 150);
    window.show();
    wdContext.currentYourNodeElement().setPopupAttribute(window);
    For closing window code
    IWDWindow window = wdContext.currentYourNodeElement().getPopupAttribute();
    window.hide();
    window.destroyInstance();
    For more infornation refer this link
    http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/20d2def3-f0ec-2a10-6b80-877a71eccb68&overridelayout=true
    This link is very useful for you.
    Regards
    Ruturaj
    Edited by: Ruturaj Inamdar on Aug 13, 2009 9:10 AM

  • Need code for Sales order creation in oops using xi as integration server

    Need code for Sales order creation in oops using xi as integration server.

    hi rocky,
              could you pls give a bit explanation on what you are expecting.
    regards,
    Pavan

  • T-code for creating new payment term

    Dear All,
    What is the T-code for creating new payment term in PO.
    Pleaze reply it soon.
    Thanks
    Prasant Sekhar

    use /NOME2.here u can create or copy as u wish.
    regards,
    indranil

  • What is the T-Code for creating Cost center - profit center standard hierar

    Hi,
    What is the T-Code for creating Cost center - profit center standard hierarchy.Please provide me the T-codes.
    Thanks

    Hi Supriya,
    Create / Change Cost Center Standard Hierarchy - OKEON
    Display Cost Center Standard Hierarchy - OKENN
    Create Profit Center Standard Hierarchy - KCH1
    Change Profit Center Standard Hierarchy - KCH5N
    Display Profit Center Standard Hierarchy - KCH6N
    Srikanth Munnaluri

Maybe you are looking for

  • Can't open photos or they aren't available?

    Whenever a contact sends a photo, I'll only see the thumbnail, like the first attached photo. They don't open when I click on them, and I can't find them in my Skype received files OR the media messaging folder that also contains photos received/sent

  • Error during program syntax check

    Hi, I have written the following code INCLUDE zfirf_rfd_final_top. * INCLUDE ZFIRF_RFD_FINAL1_O01                    .  " PBO-Modules * INCLUDE ZFIRF_RFD_FINAL1_I01                    .  " PAI-Modules INCLUDE ZFIRF_RFD_FINAL_F01                    . 

  • Phone will not reset

    Phone will not reset

  • Firefox crashes when applet + XSLTProcessor are running

    a 66K .xsl file run through firefox when a dummy java applet is loaded (libnpjp2.so 1.6.0_29) crashes my firefox (8.0.1) on Ubuntu 10.0.4 You need to run it with my .xsl and .xml files. ('''sorry''' about cut and paste but have no access to file shar

  • Showing a Final Cut Pro project to an audience - from Final Cut or Quicktime?

    I've created a 13 min Final Cut Pro project to show at an Awards Ceremony of our college.  Is it better to show the video directly from Final Cut or to export it and show it from Quicktime?  What's the best quality output?