Create Sales order with reference to purchase order - Help needed

Hi Gurus
Purchase order is being created in Oracle system. SAP system will receive the purchase order and creates the sales order for the corresponding purchase order.
Hoe to create sales order, Through BAPI or through IDOC. Please suggest and give some pointers of existing interface
Thanks
Andy.

Hi,
    If you are working on ECC6.0 check for the BAPI BAPI_SALESORDER_CREATEFROMDAT1 .You can also pass the purchase order number .
Check the sample code
REPORT z_bapi_salesorder_create.
Parameters
Sales document type
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text FOR FIELD p_auart.
PARAMETERS: p_auart TYPE auart OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Sales organization
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text1 FOR FIELD p_vkorg.
PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Distribution channel
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text2 FOR FIELD p_vtweg.
PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Division.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text3 FOR FIELD p_spart.
PARAMETERS: p_spart TYPE spart OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SKIP 1.
Sold-to
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text4 FOR FIELD p_sold.
PARAMETERS: p_sold  TYPE kunnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Ship-to
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text5 FOR FIELD p_ship.
PARAMETERS: p_ship  TYPE kunnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SKIP 1.
Material
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text6 FOR FIELD p_matnr.
PARAMETERS: p_matnr TYPE matnr   OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Quantity.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text7 FOR FIELD p_menge.
PARAMETERS: p_menge TYPE kwmeng  OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Plant
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text9 FOR FIELD p_plant.
PARAMETERS: p_plant TYPE werks_d OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Data declarations.
DATA: v_vbeln            LIKE vbak-vbeln.
DATA: header             LIKE bapisdhead1.
DATA: headerx            LIKE bapisdhead1x.
DATA: item               LIKE bapisditem  OCCURS 0 WITH HEADER LINE.
DATA: itemx              LIKE bapisditemx OCCURS 0 WITH HEADER LINE.
DATA: partner            LIKE bapipartnr  OCCURS 0 WITH HEADER LINE.
DATA: return             LIKE bapiret2    OCCURS 0 WITH HEADER LINE.
DATA: lt_schedules_inx   TYPE STANDARD TABLE OF bapischdlx
                         WITH HEADER LINE.
DATA: lt_schedules_in    TYPE STANDARD TABLE OF bapischdl
                         WITH HEADER LINE.
Initialization.
INITIALIZATION.
v_text   = 'Order type'.
v_text1  = 'Sales Org'.
v_text2  = 'Distribution channel'.
v_text3  = 'Division'.
v_text4  = 'Sold-to'.
v_text5  = 'Ship-to'.
v_text6  = 'Material'.
v_text7  = 'Quantity'.
v_text9  = 'Plant'.
Start-of-selection.
START-OF-SELECTION.
Header data
Sales document type
  header-doc_type = p_auart.
  headerx-doc_type = 'X'.
Sales organization
  header-sales_org = p_vkorg.
  headerx-sales_org = 'X'.
Distribution channel
  header-distr_chan  = p_vtweg.
  headerx-distr_chan = 'X'.
*Purchase order number
header-PURCH_NO_C =  '4000006'.
headerx-PURCH_NO_C = 'X'.
Division
  header-division = p_spart.
  headerx-division = 'X'.
  headerx-updateflag = 'I'.
Partner data
Sold to
  partner-partn_role = 'AG'.
  partner-partn_numb = p_sold.
  APPEND partner.
Ship to
  partner-partn_role = 'WE'.
  partner-partn_numb = p_ship.
  APPEND partner.
ITEM DATA
  itemx-updateflag = 'I'.
Line item number.
  item-itm_number = '000010'.
  itemx-itm_number = 'X'.
Material
  item-material = p_matnr.
  itemx-material = 'X'.
Plant
  item-plant    = p_plant.
  itemx-plant   = 'X'.
Quantity
  item-target_qty = p_menge.
  itemx-target_qty = 'X'.
  APPEND item.
  APPEND itemx.
  Fill schedule lines
  lt_schedules_in-itm_number = '000010'.
  lt_schedules_in-sched_line = '0001'.
  lt_schedules_in-req_qty    = p_menge.
  APPEND lt_schedules_in.
  Fill schedule line flags
  lt_schedules_inx-itm_number  = '000010'.
  lt_schedules_inx-sched_line  = '0001'.
  lt_schedules_inx-updateflag  = 'X'.
  lt_schedules_inx-req_qty     = 'X'.
  APPEND lt_schedules_inx.
Call the BAPI to create the sales order.
  CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
       EXPORTING
            sales_header_in     = header
            sales_header_inx    = headerx
       IMPORTING
            salesdocument_ex    = v_vbeln
       TABLES
            return              = return
            sales_items_in      = item
            sales_items_inx     = itemx
            sales_schedules_in  = lt_schedules_in
            sales_schedules_inx = lt_schedules_inx
            sales_partners      = partner.
Check the return table.
  LOOP AT return WHERE type = 'E' OR type = 'A'.
    EXIT.
  ENDLOOP.
  IF sy-subrc = 0.
    WRITE: / 'Error in creating document'.
  ELSE.
Commit the work.
    COMMIT WORK AND WAIT.
    WRITE: / 'Document ', v_vbeln, ' created'.
  ENDIF.
Reward points if it worked.
Regards,
Abhishek
Edited by: Abhishek Raj on May 14, 2008 9:57 AM

Similar Messages

  • Can we create outbound delivery with reference of purchase order

    Hi All,
    can we create outbound delivery with reference of purchase order?

    dear friend,
    as far as i know you can create it with the following references:
    -to sales order;
    -to STO;
    -to subcontract order;
    -to project;
    -without any ref
    are you talking about stock transport order ?
    regards,

  • Function module to create Inbound delivery with reference to Purchase Order

    Hi experts,
    I want to create Inbound delivery with refernce to Purchase Order. But I want to create item wise. For example If one purchase order is there with 10 line items. 10, 20, 30, 40, 50......100.
    If I am showing report for Purchase Order with select option and if I select first 5 line items 10, 20, 30, 40, 50 then my program should be create one Inbound delivery for selected line items only. I have tried BDC for Tcode VL31N, but its not worked. Is there any Function module to create Inbound delivery with reference to Purchase Order for selected line items????????

    Hi,
    Try FM RV_DELIVERY_CREATE or GN_DELIVERY_CREATE.
    For creating a delivery wrt PO u 1st need to have a sales order i guess.
    Regards,
    Amit

  • Purchase Order with reference to Purchase Order

    Dear SAP Gurus,
    Can it be possible to have a purchase order with reference to purchase order.
    Regards
    Vinod Kakade

    Hi,
    there is an option to give document date in the Purchase order selection in Document overview, what you can do here is that you can get a TVARVC variable created with date range of today - Today - 179 Days, in the attributes of the variant enter the TVARVC variable so that when the user uses this variant, he will get PO's only for that date range, if you  have any confusion on this then please speak to your ABAP Consultant.
    Regards
    Chandra Shekhar

  • Sales order with reference to purchase order

    Hi
    I have a scenario where i need to create a sales order from PO raised in another company code
    My client has 4 company codes
    1000 company code
    2000 company code
    3000 company code
    4000 company code
    Now
    2000 company will raise a PO on company code 1000
    So in company code 2000 i need to create a sales order with reference to PO from compcode 1000
    where all the data has to copied from PO with schedules
    so when i create a order in VA31 i have to create scheduling agreements with refernce to PO all the schedule line items should be copied?
    Is there any standard process or do i need to go for development?
    Regards

    Hi,
       As per my Understanding,
    I guess, you can do this same as creating Purchase Order-NB ( In ordering Company code)-ME21N,
    Vendor- Plant of Supplying Comp code ( Create this Plant as Vendor in ORdering Comp code)
    Purchase org/Group-
    Comp Code - Ordering Comp Code
    Material-
    Plant - Receiving Plant.
    Try n Revert-
    No Need to go for Userexit,
    My Query is: -
    Why you want to create Scheduling agreement wrt "PO" of Diff Comp Code.
    We can use the PO from Ordering Comp Code is a ref for any dispatches ( To Pass the PO requirements to Production in Supp.Comp code, while creating PO by maintaining Checking rule )

  • Automatic creation of Sales Order with reference to Purchase Order

    Hi
    I want to create the sales order automatically when we are creating the purchase order.
    kindly guide me how to do it,
    Pramod

    Hi
    U can create BDC for Tcode VA01 in T code SHDB with the validation and ask the ABAPer to create one Y/Z Tcode. Then you input the PO no in the Tcode to create the SO in background.
    Or
    Create BDC for PO AND SO and give logic and validation with input field and ask the ABAPer to crate one Y/Z Tcode to create PO and SO in single execute.
    Thx.

  • Create outbound delivery with reference to purchase order

    Hi,
    I've created new plant and when i make purchase order i cant see the PO in VL10B, and there for i cant create outbound delivery.
    In the PO in Item Detail there is no shipping category.
    What i need to do ?
    Thank you.

    Step1: In SPRO - Materials Management - Purchasing - Purchase Order - Set up Stock Transport Order - Define Shipping Data for Plants.
    Define the Customer number, Sales Org, Distribution channel and Division for the Plant.
    The Customer you are assigning for the Plant has to be created in the System to create the outbound delivery.
    Step2: In SPRO - Materials Management - Purchasing - Purchase Order - Set up Stock Transport Order - Assign Delivery Type and Checking Rule.
        Then Assign the PO type and the supplying plant to the Delivery Type which is NL (for inter company) and Checking Rule.

  • Create inbound delivery with reference to purchase orders

    Hi,
    I´d like to create inbound deliveries using BAPI or transactions like vl10x (for outbound deliveries) for different purchase orders, items and quantities.
    Does anyone know the way to do it?
    Thank you in advance
    Best regards

    Hi,
    Is there only that transaction to create inbound deliveries??
    We want to do a load a file and create inbound deliveries. I was looking for bapi mass transactions, but I don´t know if the only way is to create a batch input of transaction VL31n.
    Thanks

  • Program for Creating Purchase Order with reference to purchase requisition

    Hi ,
    I need to Create purchase Order with reference to  Purchase requisition,
    in my case i need to automize the Process which is happening in MD04,
    Can you please suggest me ?
    Thanks ,
    Murali

    Hi,
    Plz check this link. It will be helpful to you.
    Purchase order creation with reference to PR
    We can also create the PO Using the BAPI_PO_CREATE1 function module.
    In this function module fill up the all necessary Details.
    With details in Item Table we haveto give the Fields PREQ_NO and PREQ_ITEM for each item .
    then it will creates the PO with PREQ.
    Thanks & Regards,
    Sarita Singh Rathour
    Edited by: Sarita Rathour on Aug 3, 2009 7:01 AM

  • Payment Posting with Reference to Purchase Order

    Dear Experts,
    I've created a Purchase Order with reference to a purchase requisition. Now I want to post MIRO with reference to this Purchase Order Number to give payment to Vendor mentioned in Purchase order. But when I going to post miro amount not coming which I mentioned in Purchase Order!!
    How can I post MIRO with reference to Purchase Order Number? Is it possible?
    Best Regards.
    Ripon

    >
    riponkp wrote:
    > Dear Experts,
    >
    > I've created a Purchase Order with reference to a purchase requisition. Now I want to post MIRO with reference to this Purchase Order Number to give payment to Vendor mentioned in Purchase order. But when I going to post miro amount not coming which I mentioned in Purchase Order!!
    >
    > How can I post MIRO with reference to Purchase Order Number? Is it possible?
    >
    > Best Regards.
    > Ripon
    Seems like you are doing MIRO before GR. If GR is done, it will pick the amounts, if GR is not done, the amounts are not picked. You enter the amounts manually with reference to PO.

  • Help Bapi Purchase order with reference to purchase requisition no

    Hi,
    i used BAPI_PO_CREATE1 for creating purchase order with reference to Purchase requisition number but im getting these error
    please help me to solve this
    1 E BAPI 001 No instance of object type PurchaseOrder has been created. External reference:
    2 E MEPO 001 Purchase order item 00010 still contains faulty schedule lines
    3 E 06 054 Doc. type/item cat. NB/S (requisition) <-> NB/ (purch. order)
    4 E 8W 162 No schedule line exists for schedule line number 0010000030 00010 0000.
    Thanks & Regards,
    Azhar
    Message was edited by:
            Azhar

    Hi Azar,
    I am also getting the same messages, did you get resolve the issue.

  • MIRO posting with reference to Purchase Order

    Dear Experts,
    I've created a Purchase Order with reference to a purchase requisition. Now I want to post MIRO with reference to this Purchase Order Number to give payment to Vendor mentioned in Purchase order. But when I going to post miro amount not coming which I mentioned in Purchase Order!!
    How can I post MIRO with reference to Purchase Order Number? Is it possible?
    Best Regards.
    Ripon

    As above it sounds like a GR gasn't been posted but you can still process invoice.  Just manually enter the quantity and value as per invoice.
    Note the invoice will block for payment pending the GR.
    See transaction MRBR if you want to release the invoice for payment immediately.
    Regards,
    Nick

  • Net price on purchase order with reference to purchase requisition

    Hello!
    When I create a purchase order with reference to purchase requisition, the net price goes automatically to the purchase order.
    But It's possible change the net price on PO, and I must close this possibility.
    Do you know how can I do this?
    Thanks, Camila!

    Hello
    Try to search SCN for EVO
    You will find this: PR price in PO

  • ARE-1 form with reference to Purchase Order

    Hi All,
    We are having a scenario where we need to send the ARE-1 to our vendor along with CT1. I have tried assigning the Purchase Order as reference document for creation of ARE-1 but its not working.
    Can anybody suggest the way to create ARE-1 with refernce to Purchase Order?
    Rgds,
    Antima

    Hi Rithvika,
    Yes the scenario is for merchant export. Here we are the customer and along with our purchase order, we need to send CT1 and ARE-1 to our vendor. The ARE-1 series has to be same as for our direct export, so i need to create an ARE-1 with reference to Purchase Order.
    If anybody has any idea how to do that and whether its possible in SAP then please guide me.
    Rgds,
    Antima

  • Report for gl accounts with reference to purchase order

    hi
    experts
    Is there any report which can give the gl accounts with reference to purchase order
    thnx

    Use t code ME2N and click 'Account Assignment" from application tool bar or press Shift + F12 to view PO with GL code. If GL code is not showing select from the layout.
    Rgds,
    Vijay

Maybe you are looking for

  • How do I find a program to open iPhone photos in my "photo cashe"?

    Sometimes when I take photos, they do not appear in my photo roll.  Then when I sync my phone, thumbnails appear in my photo cashe.  But when I click on it, it says Windows cannot open, and that it is a T149.itmb file?  Any help would be appreciated.

  • Problem in connecting CRM to SAP R/3  plz help

    Hi friends,   I am ravi. I am facing problem making connection between CRM to SAP R/3. In my pc i installed ECC 5.0 version and CRM 4.0 in Windows 2003 OS. He installed CRM server in Virtual Mechine of OS, and ECC 5.0 in normal mode. I am starting tw

  • File download problem

    I am using the following code to present a file to the client to download when a report is generated. The code does what is suppose to, it presents a dialog box where the user can choose to open, save, or cancel the file download. However, when the f

  • How to fix "Licensing for this product has stopped working - Error 150:30"?

    I cannot pen PSE or Bridge. It get the message "Licensing for this product has stopped working - Error 150:30". I assume it is because I recently upgraded my Mac to Yosemite. What do I need to do to be able to open PSE again? Thank you.

  • Logic Content Download for Mac Lab

    Hi all, I am sorry I do not have all the tech specs to help. They are new iMacs, running current OS. I am a music teacher that just got a brand new lab of iMacs and our tech folks installed Logic Pro today. Students need to log-in using their distric