Problem creating Purchase Order with Bapi_po_create  Return Message is ""

Hello everybody
When I get to create PO with bapi_po_create . I get this message in the return parameter :"Enter the PURCH_ORG".
I think that I have implemented it very well but I don´t get the results that I was expected : No PO was created.
Please see the following codes and let me know if something is wrong. Thanks .
=====================================
*& Report  Z_PED_TRAS                                                  *
REPORT  z_ped_tras  .
Definición de la tabla asociada la tabla interna bdcdata
*DATA :in_data LIKE bdcdata OCCURS 0 WITH HEADER LINE.
Definición de la estructura que contendrá los pedidos
DATA : s_cabeceras_pedidos LIKE bapiekkoc,
       s_pos_pedidos LIKE bapiekpoc.
DATA : t_cabeceras_pedidos LIKE  bapiekkoc OCCURS 0 WITH HEADER LINE,
       t_pos_pedidos LIKE  bapiekpoc OCCURS 0 WITH HEADER LINE,
       t_final_cabeceras_pedidos LIKE  bapiekkoc OCCURS 0 WITH HEADER
LINE,
       t_final_pos_pedidos LIKE  bapiekpoc OCCURS 0 WITH HEADER LINE.
Data : item_schedule like BAPIEKET occurs 0 with header line.
*DATA : BEGIN OF pedidos,
      ematn TYPE mepo1211-ematn, "Número de material
      menge TYPE mepo1211-menge, "Cantidad de pedido
      name1 TYPE mepo1211-name1," Centro destino
      lgobe TYPE mepo1211-lgobe, "Almacén
     END OF pedidos.
*DATA: s_pedidos  LIKE pedidos,
     wa_pedidos LIKE pedidos,
     t_pedidos LIKE pedidos OCCURS 0 .
Variables  auxiliaires
Variables para la ejecución del explorador de archivos
DATA: l_temp_dir TYPE string.
DATA: l_filter TYPE string.
DATA: l_files TYPE filetable.
DATA: l_rc TYPE i.
DATA: l_file TYPE filename.
DATA: l_filename TYPE string.
DATA: excel TYPE alsmex_tabline OCCURS 0 WITH HEADER LINE.
DATA: s_excel TYPE alsmex_tabline.
DATA: qid LIKE apqi-qid.
Declaración de parametros de selección
PARAMETERS :
   p_center LIKE bapiekkoc-suppl_plnt OBLIGATORY,"" Proveedor/Centro
   p_ekorg LIKE bapiekkoc-purch_org OBLIGATORY , " Organización compras
   p_ekgrp LIKE bapiekkoc-pur_group OBLIGATORY, " Grupo de compras
   p_bukrs LIKE bapiekkoc-co_code OBLIGATORY,"Sociedad"
   p_date LIKE sy-datum DEFAULT sy-datum OBLIGATORY,  "fecha
   test AS CHECKBOX DEFAULT 'X'.
  p_center LIKE mepo_topline-superfield, " Proveedor/Centro
  p_ekorg LIKE mepo1222-ekorg, " Organización de compras
  p_ekgrp LIKE mepo1222-ekgrp, " Grupo de compras
  p_bukrs LIKE mepo1222-bukrs,"Sociedad"
  p_date LIKE sy-datum," Fecha
  test AS CHECKBOX DEFAULT 'X'.
PARAMETERS: p_file LIKE rlgrap-filename DEFAULT 'C:PEDIDOS.XLS'. " Ruta
Carga del explorador de ficheros **
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  l_temp_dir = 'C:A'.
  l_filter = '.'.
  CALL METHOD cl_gui_frontend_services=>file_open_dialog
    EXPORTING
      default_extension       = '*.xls'
      file_filter             = l_filter
      initial_directory       = l_temp_dir
    CHANGING
      file_table              = l_files
      rc                      = l_rc
    EXCEPTIONS
      file_open_dialog_failed = 1
      cntl_error              = 2
      error_no_gui            = 3
      not_supported_by_gui    = 4
      OTHERS                  = 5.
  IF NOT l_files[] IS INITIAL.
    READ TABLE l_files INTO l_file INDEX 1.
    p_file = l_file.
    TRANSLATE p_file TO UPPER CASE.
  ENDIF.
START-OF-SELECTION.
  IF p_file NE space.
    PERFORM upload_data.
    PERFORM fill_data.
    PERFORM llamar_bapi.
  ENDIF.
END-OF-SELECTION.
*&      Form  Upload_data
      text
-->  p1        text
<--  p2        text
FORM upload_data .
  IF excel IS INITIAL .
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        filename                = p_file
        i_begin_col             = 1
        i_begin_row             = 2
        i_end_col               = 4
        i_end_row               = 50000
      TABLES
        intern                  = excel
      EXCEPTIONS
        inconsistent_parameters = 1
        upload_ole              = 2
        OTHERS                  = 3.
    IF sy-subrc <> 0.
      WRITE :/'Hay un problema al cargar los datos delfichero excell'.
    ENDIF.
    SORT excel DESCENDING BY row col.
  ENDIF.
ENDFORM.                    " Upload_data
*&      Form  fill_excell
      text
-->  p1        text
<--  p2        text
FORM fill_data .
  DATA :  cant TYPE i ,
          value_row TYPE i VALUE 1,
          data_aux TYPE alsmex_tabline OCCURS 0 WITH HEADER LINE.
Leer las filas del fichero excell.
  IF test NE 'X'.
    s_cabeceras_pedidos-suppl_plnt = p_center.
    s_cabeceras_pedidos-purch_org = p_ekorg.
    s_cabeceras_pedidos-pur_group = p_ekgrp .
    s_cabeceras_pedidos-co_code = p_bukrs .
    s_cabeceras_pedidos-doc_date = p_date.
    APPEND  s_cabeceras_pedidos TO t_cabeceras_pedidos.
    cant = excel-row.
    DO cant TIMES.
      LOOP AT excel WHERE row EQ value_row.
        APPEND excel TO data_aux.
      ENDLOOP.
      SORT data_aux BY col.
      LOOP AT data_aux.
        CASE data_aux-col.
          WHEN '1'.
            s_pos_pedidos-pur_mat = data_aux-value.
          WHEN '2'.
            s_pos_pedidos-DISP_QUAN = data_aux-value.
          WHEN '3'.
            s_pos_pedidos-plant = data_aux-value.
          WHEN '4'.
            s_pos_pedidos-store_loc = data_aux-value.
        ENDCASE.
      ENDLOOP.
      APPEND s_pos_pedidos TO t_pos_pedidos.
    ENDDO.
  ENDIF.
ENDFORM.                    " fill_data
*&      Form  llamar_Bapi
      text
-->  p1        text
<--  p2        text
FORM llamar_bapi .
data : T_RETURN LIKE BAPIRETURN OCCURS 0 WITH HEADER LINE,
       PORDER LIKE BAPIEKKOC-PO_NUMBER.
t_final_cabeceras_pedidos[] = t_cabeceras_pedidos[].
t_final_pos_pedidos[] = t_pos_pedidos[].
  CALL FUNCTION 'BAPI_PO_CREATE'
    EXPORTING
      po_header                        = t_final_cabeceras_pedidos
IMPORTING
   PURCHASEORDER                     = PORDER
    TABLES
      po_items                       = t_final_pos_pedidos
      po_item_schedules                = item_schedule
      RETURN                           = T_RETURN
  IF sy-subrc EQ 0 .
    WRITE :/ 'P O created well'.
  ELSE .
    WRITE :/ 'P .O was not created  well'.
    endif.
  ENDFORM.                    " llamar_Bapi

Hi,
When we use BAPI_PO_CREATE1 to create service PO, following tables are populated at item level:
a) POITEM
b) POITEMX
c) POACCOUNT
d) POACCOUNTX
e) POSERVICES
f) POSRVACCESSVALUES
For service items: POITEM-PCKG_NO = u20180000000001u2019. (assign package no as a dummy number)
Set PCKG_NO flag in POITEMX table as u2018Xu2019.
Package No is the link that connect POITEM table to POACCOUNT table through tables POSERVICES and POSRVACCESSVALUES.
Set POACCOUNT-SERIAL_NO to u201801u2019.
Set same PCKG_NO to u20180000000001u2019 in POSERVICES table. Maintain two entries in POSERVICES table like this:
WA_POSERVICES-PCKG_NO = u20180000000001u2019.
WA_POSERVICES-LINE_NO = u20180000000001u2019.
WA_POSERVICES-OUTL_IND = u2018Xu2019.
WA_POSERVICES-SUBPCKG_NO = u20180000000003u2019. (Dummy No.)
WA_POSERVICES-QUANTITY = u2018100.000u2019.
WA_POSERVICES-BASE_UOM = u2018EAu2019.
WA_POSERVICES-PRICE_UNIT = u20181u2019.
WA_POSERVICES-GR_PRICE = u2018100.000u2019.
WA_POSERVICES-SHORT_TEXT = u2018SERVICE TESTu2019.
APPEND WA_POSERVICES TO IT_POSERVICES.
WA_POSERVICES- PCKG_NO = u20180000000003u2019.
WA_POSERVICES- LINE_NO = u20180000000002u2019.
WA_POSERVICES-QUANTITY = u201810.000u2019.
WA_POSERVICES- BASE_UOM = u2018EAu2019.
WA_POSERVICES--PRICE_UNIT = u20181u2019.
WA_POSERVICES-GR_PRICE = u2018100.000u2019.
WA_POSERVICES-SHORT_TEXT = u2018SERVICE 1u2019.
WA_POSERVICES-MATL_GROUP = u20180012u2019.
APPEND WA_POSERVICES TO IT_POSERVICES.
Set PCKG_NO as SUB_PCKG_NO in table POSRVACCESSVALUES this:
WA_POSRVACCESSVALUES-PCKG_NO = u20180000000003u2019.
WA_POSRVACCESSVALUES-LINE_NO = u20180000000002u2019.
WA_POSRVACCESSVALUES-SERNO_LINE = u201801u2019.
WA_POSRVACCESSVALUES-SERIAL_NO = u201801u2019.
WA_POSRVACCESSVALUES-QUANTITY = u201910.000u2019.
APPEND WA_POSRVACCESSVALUES TO IT_ POSRVACCESSVALUES.
This logic will work definitely and PO Service Items will be created.
Thanks & Regards.
Dhina..

Similar Messages

  • Creating an SRM Purchase Order with a Return Line

    Is it possible within standard SRM to create a purchase order with a 'Returns Item' line?
    I know it's possible in R/3 but really need to create it via SRM.
    Regards
    Keith

    Ganesh
    We are using the Extended Classic Scenario of SRM (and the Sourcing Cockpit) which therefore means that we won't be creating requisitions within R/3.
    In the R/3 PO you can create a line item as a 'Returns Line' (MEPO1211-RETPO)
    The standard help text is as follows:
    Logistics - General (LO)
    The returned goods from a customer to an internal or external vendor.
    Returns can be divided into the following types, according to vendor and recipient:
    Customer returns
    Returns to vendor
    Returns for stock transfers
    I know we can use a BADI to mark this flag in R/3 but for completeness really want to show this as a returns line in SRM too.
    Keith

  • Error while creating purchase order with account assignment category "A"

    Dear All,
                      At the time of creating purchase order with account assignment category A - Asset its throwing error as " GL Account 123400 can not be used"
    how to resolve this  issue"
    Edited by: Matt on Sep 16, 2010 10:09 AM - removed bold tags

    HI,
    Assign all assets GL to Asset Class
    spro --> financial accounting new -->assets accounting --> assets accounting (lean Implementation) --> organization structures --> Assign GL
    Hope Help U !
    Regards,
    Pardeep Malik

  • 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

  • Is it possible to create purchase order with zero value ?

    Is it possible to create purchase order with zero value ?

    Hi,
    There are two scenarios where the purchase order is created with zero value.
    1. Standard Purchase order with Free tick indicator.
    Whenever we expect a material with free of cost from vendor, we use to put the free indicator in item overview.  This means the material is valuated at zero price irrespective of price control in material master. Quanitiy is updated while receipts.
    Conditions tab in item detail doesnt appear.
    2. Consignment PO.
    While creating a purchase order for consignment, the system doesnt ask us the price and the condition tab doesnt appear in item detail.
    An info record for consignment must be maintained before making the GR.
    Hope i have clarified.  If you want any further clarification. please do reply.

  • How to Create Purchase Order with Co Product greater than Consumption

    Hi All,
    I'm new to SAP. Can any one please help with the steps to create PO with Co Product greater than Consumption.
    Thanks in Advance.    

    Hi Srinivasu,
    If you are talking about handling by-products during subcontracting follow the following steps.
    Create Purchase order with item category "L". In the components tab maintain by-product in negative quantity. If you are not sure about the actual quantity, enter theoretical quantity ( Actual quantity can be adjusted in Subsequent adjustment in Goods receipt).
    Hope this helps you.
    If this has not helped you, please elaborate your requirement.
    Thanks
    Vasuki B S

  • Create Purchase Order with reference to Purchase Requisition using BAPI's

    Hello Experts,
    I need to create a Purchase order with reference to a Purchase Requisition.
    All the above has to be done by using BAPI's.
    For creating PR, I am using BAPI_REQUISITION_CREATE.
    and for PO, I am using BAPI_PO_CREATE.
    I am not able to use the requistion number in the PO. BAPI throws the following exception
    "Requisition 1014396 00010 not selectable"
    "Document contains no items"
    Query's:
    1. Do I need to release the PR for using it in PO?
    2. If so how can I work with the "BAPI_REQUISITION_RELEASE_GEN" to release PR?
    I have tried using the BAPI getting the following error "Release outside filed of responsibility".
    Please help I am in critical Postion...
    Thanks,
    Suma

    Hi Meenakshi,
    When, I try to release error I am getting the following the error " Purchase Requisition can not be released".
    Is this problem because of authorization or data issue?
    Thanks
    Suma

  • Create purchase order with reference to Sales order Line item

    Hi All,
    i had a requirement that i need to create the Purchase order with reference to sales order line item...
    In T.code me27 client requied a input field for sales order no and with that order reference he want the data of line item to PO creation line item screen.....
    please sujjust......how to proceed......
    regards,
    Ravi Nemani

    Hi
    Go to SPRO->Logistic general->Tax on goods movement->India->Movement types.
    Here you will find the group of movement types check which movement types is mantained for the out side movement groups or inward movement.
    also check the Material Master in MRP view if the collective requirements (02) is mantained.
    Regards
    Sri

  • ME21N Create Purchase Order with reference to previous Purchase Order

    Hello Expert,
    Previously have been using Purchase Info Records for reference when creating Purchase Orders using ME21N.  We then have deleted the Pricing Condition in the Purchase Info Record using ME12.  Now when we are trying to create a new Purchase Order with the same values (Vendor, Material, Plant and Storage Location), the transaction code ME21N automatically fetches the previous values of the Pricing Condition as if it was cached.  I remember of studying this in the MM academy but I am not sure how to disable it. 
    This error only happens when we are creating the first Purchase Order after the deletion, for the second Purchase Order, error will be prompted to the user saying that the Pricing Condition could not be found. 
    I would like to ask where in configuration can I delete this cache behaviour or is that any work around for this. 
    Thanks in advance.

    Hello Antony,
    I found the "Update Prices" function in the Conditions Tab of the Item Details helps to refresh the data and fetch the new information from the Purchase Info Record.  I would like to ask is there anyway to provoke this function automatically everytime when a user runs the transaction ME21N.
    Thanks in advance again.

  • Problem creating process order with ref of sale order

    Dear all,
    Kindly give solution for this scenerio..............................
    I am creating Process Order with ref of sale order manually in cor1. In the COR1 screen copy from field i gave my ref sale order, so that particualr order and batch is assigned to that order only.
    My problem was suppose if sale order is created for 10 tonns, but my batch size and resource capacity is 2 tonns only. so first time i change my batch quantity 2 tonns instead of 10 tonns and created my order and confirmed.
    if i go to second time the same process i am doing creating process order with ref of same sale order but it comes again 10 tonns instead of 8 tonns. why it comes like this already i confirmed 2 tonns in this sale order?
    my requirement is if any process order is created with ref of any sale order and again if i am creating any process order with ref of same sale order left quantity only system should show.
    for this what i have to do kindly help to this
    regards,
    s.sakthivel

    Dear KK,
    Pls check whether ZKIN, ZKQT, ZKOR have all the properties similar to IN, QT, OR respectively. If they are different, please ensure that you know the reason why they are different. This check has to be done at tcode VOV8
    Some fields like sales document category, Transaction group, screen seq group, Doc pricing procedure need to be similar to the parent document unless you know why you have changed them.
    Once this check is done, check the copy controls in VTAA. Before that try creating these documents separately without reference. This shoudl work fine only after which you need to check copy control. If this is not working fine, then there is some problem with the document type settings in VOV8. Testing this is possible only if Reference mandatory field is left empty. Make sure that is properly configured.
    Once this is done, check copy controls in VTAA. You can just copy the copycontrol between IN and QT and QT and OR and create for ZKIN to ZKQT and ZKQT to ZKOR.
    Once this is done, check whether your item category settings are properly done , also the schedule line settings. The tcodes are VOV7, VOV6, VOV4, VOV5 etc.
    Now check whether your material master and customer master are consistent with the item category settings(Item category group).
    Now create the transaction. It shoudl work fine.
    Reward if this helps.

  • Change/Create purchase order with customer BSART via CIF

    Hi,
    we create Purchase Orders in SCM SNP.  Those POs are passed via CIF to R/3, but the Purchase orders should be created with a customer BSART.
    In SCM the POs currently use the standard ATPCategories. I found an exit in CIF_PO_INBOUND where you can change BSART, but at this point there is no access to the data from APO.
    Has anybody already implemented such a scenario?

    Hi Michael,
    I used CIF outbound user exit from APO , for filtering purchase requisions going to SAP R/3.
    You are creating purchase oders in SCM APO and transferring the same to SAP R/3 / ECC through CIF.
    We may have two options : Change the data before publishing to SAP R/3 from APO. This happens in APO , outbound .
    Otherwise we can change the data in the PO before it is created in SAP R/3 , for this we use user exit inbound SAP R/3.
    You have option of changing or enahancing purchase order data inbound in SAP R/3, before the PO is created in SAP R/3.
    The enhancement is CIFPUR02.
    With this enhancement, you can change purchase order data from your APO system before a purchase requisition or purchase order is created in the ERP system
    The enhancement contains the following components:
    EXIT_SAPLCPUR_001
    You can use this enhancement to change purchasing data (purchase requisitions, purchase orders) in ERP inbound. To do this, you can change the existing transfer data or include additional customer-specific data in your own tables.
    Other enhancements in the same
    EXIT_SAPLMEPI_004
    With this enhancement, you can change the header data of a purchase order before it is created in the ERP system.
    The following data can be changed:
    Document type (parameter CP_BSART)
    EXIT_SAPLMEPI_007
    You can use this enhancement to specify the document type of a purchase requisition or purchase order when they are created in the ERP system (parameter CP_BSART).
    There are other ehancements which I have not listed.
    I assume you can create an enhancemnet projects for incorporating the above enhancements in CMOD / SMOD transactions.
    I hope this helps you.
    Please confirm.
    Regards
    Datta

  • Create Sales Order with type "return" using API

    Dears ,
    I tried to create a sales order with type Return using oe_order_pub.process_order but the order is not created .
    There is no error msg returned .
    Can anyone help me to solve this .?

    Hi 2800842
    Please use the following link for your issue;
    https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=539354996395765&parent=DOCUMENT&sourceId=746787.1&id=292…
    or visit metalink: How to create an RMA via Process Order API ? (Doc ID 292743.1)
    Thanks
    Mirza Tanzeel

  • Problem regarding Purchase Order with Free of Cost Material

    Dear Xperts,
    I am facing problems while doing Goods Receipt of a Purchase Order having all the materials we are going to receive Free of Cost from the Vendor.
    This case is happening with Doemstic and as well as Importer Vendors also.
    Problems to be solved:
    1. If we are using Tax Code(with excise conditions) ,excise duty calculation does not take pace automatically at Goods Receipt as the Material Value is Zero on which the duties will be calculated for a Manufactuing Plant.
    2. This case seems very problammatic if that Purchase Order is having almost thousand line items.The user has to enter all the Excise duties manually for each & every line item during Goods receipt in a manufacturing Plant.
    3. In case of Importer Purchase Order also, the CVD portion & CESS on CVD portion user has to enter manually.
    4. To solve this problem we are  not using Free Goods Indicator in PO, we are entering 0.01 paisa , but during the MIRO of Planned Delivery Costs , the system is not showing or providing POP-ups of those relevant condition types to the user to enter the actual amount.
    Please advice, how can we proceed in this case.
    Regards,
    Soumick

    First you are putting 0.01 value . So the planned delivery cost is not showing coz if say tax is 8% then 0.01 x 0.08 will be  0.0008. It will take first two digit after decimal and hence its 0.00 and hence plannded delivery cost is not showing.
    If you put 0.5 you will be able to put planned delivery cost in MIRO
    Now regarding value is zero and how will the import duty be calculated. May be make a  pricing routine where in the custom duty is not calculated on this base price 0.5 or 0.01 but on the actual value if it was not free of cost and that value you can maintain  through MEK1 transaction code.
    And while posting MIRO or MIGO you need to identify that these are free of cost material and use BADI fi_ac_document
    and may be replace the actual GL with some other GL so that 0.5 or 0.01  does not add to your inventory cost and you could knock off later.
    Regards
    Sangeeta
    Edited by: Sangeeta Khurana on Feb 6, 2012 1:37 PM

  • Creating purchase order with bapi_po_create1

    hi ,
    i am getting an error saying shippin details not maintained for the material ....which i have created by using bapi_material_savedata.
    where do i have to look for to fill the shipping data in bapi_material_savedata
    thanks and regards ,'
    mithun seshadri

    Hi,
    Dont think Shipping data will be there in Material Master. U probably need to chk the shipping details for the customer instead.
    Regards,
    Bikash

  • PURCHASE ORDER WITH OUT BAPI_PO_CREATE CAN WE CREATE?

    PURCHASE ORDER WITH OUT calling BAPI_PO_CREATE CAN WE CREATE?
    Don't Post your question with all Caps. Follow the Rules of Engagement
    Edited by: Vijay Babu Dudla on Apr 23, 2009 1:46 AM

    [Create Purchase order with program|can we create purchase order through report programming?]
    Plz be clear about your requirement instead of posting questions like these.
    Don't violate forum rules with Duplicate posts

Maybe you are looking for

  • Sample SOAP request for Data Loader API

    Hi Can anyone please help me out in giving a sample SOAP request for Data Loader API .This is to say import 1K records from my system to the CRM instance I have .

  • How to set main thread Priority?

    i have set: Thread.currentThread().setPriority(Thread.MAX_PRIORITY); // and the other thread ( ) thread_load = new Thread(); thread_load.setPriority(Thread.MIN_PRIORITY); thread_load.start();but it doesn't make any diffrent, i mean diffent the CPU us

  • Applet communication with struts servlet

    Hi I�ve seen a lot of examples where a Java applet communicates with a servlet. I�ve made a web application using Struts, and i would like to know if it is possible to use an applet (View) and send to Stuts some data, I mean, call an action like http

  • Route scheduling "calendars for route stages not checked"

    Hello My client is shipping materials from the shipping point to the end customer each Monday and Thursday. Materials are shipped first to the main office and after that are shipped to the end customer (each Tuesday and Friday form the main office).

  • At some places I can't send mail

    In most places I go to with WiFi I can send and receive mail.  When I go to a few other places it will not let me send emails but I can receive them.  Why is this