Field Our_ref in BAPI_PO_CREATE

Hello,
I would like to fill the field our reference in the purchase order at the same time I create it. The fuba Bapi_po_create work well in creating, but the field is not filled.
Maybe I need to fill some more fields, but I don´t know which one. Anyone who knows, how I can fill this field.
In table it is EKKO-UNSEZ.
Coding
DATA: x_po_header TYPE bapiekkoc,
      x_po_header_add type BAPIEKKOA.
   x_po_header_add-OUR_REF     = 'TEST'.
    CALL FUNCTION 'BAPI_PO_CREATE'
         EXPORTING
              po_header         = x_po_header
             PO_HEADER_ADD_DATA = x_po_header_add
         IMPORTING
              purchaseorder     = x_po_number
         TABLES
              po_items          = x_po_items
              po_item_schedules = x_po_items_schedules
              return            = x_bapireturn.
Thanks Nicole
Edited by: Nicole Lorenz on Feb 1, 2010 9:50 AM

You cannot fill the "Our reference" field (EKKO-UNSEZ) using BAPI ,  BAPI_PO_CREATE
chk this link
/people/arminda.jack/blog/2009/08/03/do-you-know-what-you-can-or-canacutet-do-with-the-bapiacutes-for-purchase-orders

Similar Messages

  • A custom field added in BAPI_PO_CREATE and BAPI_PO_CREATE1

    Hi,
      I am trying to create a Service Purchase Order Single Account Assignment.
    A Custom field ZZEXPTYPE(Expense Type) is added in BAPI_PO_CREATE and passed the value '9015', The PO Is created Successfully but when I add same Custom Field ZZEXPTYPE(Expense Type) in BAPI_PO_CREATE1 whose value is '9015' ,It throws an Error Message as " Please enter a valid (SBU Specific) expense type!" . 
      The functional consultant says that Expense Type '9015' is correct. please Let me know what must be done.
    Regards,
    Deepthi.

    Extension to add Expense Type only
          IF NOT  w_src-zzexptype IS INITIAL.
            w_extensionin-structure = 'BAPI_TE_MEPOHEADER'.
            w_extensionin-valuepart1+10(4) = w_src-zzexptype.
            APPEND w_extensionin TO i_extensionin.
            CLEAR w_extensionin.
            w_extensionin-structure = 'BAPI_TE_MEPOHEADERX'.
            w_extensionin-valuepart1+10(4) = 'X'.
            APPEND w_extensionin TO i_extensionin.
            CLEAR w_extensionin.
          ENDIF.
    Call BAPI
          CALL FUNCTION 'BAPI_PO_CREATE1'
            EXPORTING
              poheader          = w_poheader
              poheaderx         = w_poheaderx
            IMPORTING
              exppurchaseorder  = gv_ebeln
            TABLES
             return            = i_return
             poitem            = i_poitem[]
             poitemx           = i_poitemx[]
             extensionin       = i_extensionin[].
    Commit the Transaction
          CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
           EXPORTING
             WAIT          = 'X'.

  • Quantity field in bapi  BAPI_PO_CREATE

    Hi ,
    What is the filed name to pass the QUANTITY in the lineitems table*(PO_ITEMS) for the Bapi BAPI_PO_CREATE
    FIleld name DISP_QUAN is not accepting the Quantity and showing the error as  ENTER QUANTITY
    when BAPI is executed.
    Regards
    Ajay

    Hai.
    check this.
    REPORT zpo_bapi_purchord_tej.
    DATA DECLARATIONS *
    TYPE-POOLS slis.
    TYPES: BEGIN OF ty_table,
    v_legacy(8),
    vendor TYPE bapimepoheader-vendor,
    purch_org TYPE bapimepoheader-purch_org,
    pur_group TYPE bapimepoheader-pur_group,
    material TYPE bapimepoitem-material,
    quantity(13),
    delivery_date TYPE bapimeposchedule-delivery_date,
    net_price(23),
    plant TYPE bapimepoitem-plant,
    END OF ty_table.
    TYPES: BEGIN OF ty_alv,
    v_legs(8),
    success(10),
    v_legf(8),
    END OF ty_alv.
    TYPES: BEGIN OF ty_alv1,
    v_legf1(8),
    v_msg(500),
    END OF ty_alv1.
    *-----Work area declarations.
    DATA: x_table TYPE ty_table,
    x_header TYPE bapimepoheader,
    x_headerx TYPE bapimepoheaderx,
    x_item TYPE bapimepoitem,
    x_itemx TYPE bapimepoitemx,
    x_sched TYPE bapimeposchedule,
    x_schedx TYPE bapimeposchedulx,
    x_commatable(255),
    x_alv TYPE ty_alv,
    x_alv1 TYPE ty_alv1,
    x_alv2 TYPE ty_alv1.
    *-----Internal table declarations.
    DATA: it_table TYPE TABLE OF ty_table,
    it_commatable LIKE TABLE OF x_commatable,
    it_item TYPE TABLE OF bapimepoitem,
    it_itemx TYPE TABLE OF bapimepoitemx,
    it_sched TYPE TABLE OF bapimeposchedule,
    it_schedx TYPE TABLE OF bapimeposchedulx,
    it_alv TYPE TABLE OF ty_alv,
    it_alv1 TYPE TABLE OF ty_alv1,
    it_alv2 TYPE TABLE OF ty_alv1.
    DATA: po_number TYPE bapimepoheader-po_number,
    x_return TYPE bapiret2,
    it_return TYPE TABLE OF bapiret2,
    v_file TYPE string,
    v_temp(8),
    v_succsount TYPE i VALUE 0,
    v_failcount TYPE i VALUE 0,
    v_total TYPE i.
    DATA: v_temp1(5) TYPE n VALUE 0.
    DATA: x_event TYPE slis_t_event,
    x_fieldcat TYPE slis_t_fieldcat_alv,
    x_list_header TYPE slis_t_listheader,
    x_event1 LIKE LINE OF x_event,
    x_layout1 TYPE slis_layout_alv,
    x_variant1 TYPE disvariant,
    x_repid2 LIKE sy-repid.
    DATA : it_fieldcat TYPE TABLE OF slis_t_fieldcat_alv.
    SELECTION-SCREEN *
    SELECTION-SCREEN BEGIN OF BLOCK v_b1 WITH FRAME.
    *-----To fetch the flat file.
    PARAMETERS: p_file TYPE rlgrap-filename.
    SELECTION-SCREEN END OF BLOCK v_b1.
    AT SELECTION-SCREEN *
    AT SELECTION-SCREEN.
    IF p_file IS INITIAL.
    MESSAGE text-001 TYPE 'E'.
    ENDIF.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    *-----To use F4 help to find file path.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
    program_name = syst-cprog
    dynpro_number = syst-dynnr
    IMPORTING
    file_name = p_file.
    v_file = p_file.
    START-OF-SELECTION *
    START-OF-SELECTION.
    PERFORM gui_upload.
    LOOP AT it_table INTO x_table.
    PERFORM header_details.
    v_temp = x_table-v_legacy.
    LOOP AT it_table INTO x_table WHERE v_legacy = v_temp.
    PERFORM lineitem.
    PERFORM schedule.
    ENDLOOP.
    DELETE it_table WHERE v_legacy = v_temp.
    PERFORM bapicall.
    MOVE po_number TO x_alv-success.
    APPEND x_alv TO it_alv.
    CLEAR x_alv.
    *-----To clear the item details in internal table after the operation for a header.
    REFRESH: it_item,
    it_itemx,
    it_sched,
    it_schedx.
    CLEAR: v_temp1.
    ENDLOOP.
    v_total = v_succsount + v_failcount.
    PERFORM display_alv.
    FORM GUI_UPLOAD *
    FORM gui_upload .
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = v_file
    filetype = 'ASC'
    TABLES
    data_tab = it_commatable
    EXCEPTIONS
    file_open_error = 1
    file_read_error = 2
    no_batch = 3
    gui_refuse_filetransfer = 4
    invalid_type = 5
    no_authority = 6
    unknown_error = 7
    bad_data_format = 8
    header_not_allowed = 9
    separator_not_allowed = 10
    header_too_long = 11
    unknown_dp_error = 12
    access_denied = 13
    dp_out_of_memory = 14
    disk_full = 15
    dp_timeout = 16
    OTHERS = 17
    IF sy-subrc = 0.
    *-----To fetch the comma seperated flat file into an internal table.
    LOOP AT it_commatable INTO x_commatable.
    IF x_commatable IS NOT INITIAL.
    SPLIT x_commatable AT ',' INTO
    x_table-v_legacy
    x_table-vendor
    x_table-purch_org
    x_table-pur_group
    x_table-material
    x_table-quantity
    x_table-delivery_date
    x_table-net_price
    x_table-plant.
    APPEND x_table TO it_table.
    ENDIF.
    CLEAR x_table.
    ENDLOOP.
    ENDIF.
    ENDFORM. " gui_upload
    FORM HEADER_DETAILS *
    FORM header_details .
    MOVE 'NB' TO x_header-doc_type.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    input = x_table-vendor
    IMPORTING
    output = x_table-vendor
    MOVE x_table-vendor TO x_header-vendor.
    MOVE x_table-purch_org TO x_header-purch_org.
    MOVE x_table-pur_group TO x_header-pur_group.
    x_headerx-doc_type = 'X'.
    x_headerx-vendor = 'X'.
    x_headerx-purch_org = 'X'.
    x_headerx-pur_group = 'X'.
    ENDFORM. " header_details
    FORM LINEITEM *
    FORM lineitem .
    v_temp1 = v_temp1 + 10.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    input = v_temp1
    IMPORTING
    output = v_temp1.
    MOVE v_temp1 TO x_item-po_item.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    input = x_table-material
    IMPORTING
    output = x_table-material.
    MOVE x_table-material TO x_item-material.
    MOVE x_table-quantity TO x_item-quantity.
    MOVE x_table-net_price TO x_item-net_price.
    MOVE x_table-plant TO x_item-plant.
    x_itemx-po_item = v_temp1.
    x_itemx-material = 'X'.
    x_itemx-quantity = 'X'.
    x_itemx-net_price = 'X'.
    x_itemx-plant = 'X'.
    APPEND x_item TO it_item.
    APPEND x_itemx TO it_itemx.
    CLEAR: x_item, x_itemx.
    ENDFORM. " lineitem1
    FORM SCHEDULE *
    FORM schedule .
    MOVE x_table-delivery_date TO x_sched-delivery_date.
    MOVE v_temp1 TO x_sched-po_item.
    x_schedx-delivery_date = 'X'.
    x_schedx-po_item = v_temp1.
    APPEND x_sched TO it_sched.
    APPEND x_schedx TO it_schedx.
    CLEAR: x_sched, x_schedx.
    ENDFORM. " schedule
    FORM BAPICALL *
    FORM bapicall .
    CALL FUNCTION 'BAPI_PO_CREATE1'
    EXPORTING
    poheader = x_header
    poheaderx = x_headerx
    IMPORTING
    exppurchaseorder = po_number
    TABLES
    return = it_return
    poitem = it_item
    poitemx = it_itemx
    poschedule = it_sched
    poschedulex = it_schedx.
    IF po_number IS NOT INITIAL.
    v_succsount = v_succsount + 1.
    MOVE x_table-v_legacy TO x_alv-v_legs.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    ELSE.
    v_failcount = v_failcount + 1.
    MOVE x_table-v_legacy TO x_alv-v_legf.
    MOVE x_table-v_legacy TO x_alv1-v_legf1.
    LOOP AT it_return INTO x_return.
    IF x_alv1-v_msg IS INITIAL.
    MOVE x_return-message TO x_alv1-v_msg.
    ELSE.
    CONCATENATE x_alv1-v_msg x_return-message INTO x_alv1-v_msg SEPARATED BY space.
    ENDIF.
    ENDLOOP.
    APPEND x_alv1 TO it_alv1.
    CLEAR x_alv1.
    ENDIF.
    ENDFORM. " bapicall
    FORM DISPLAY_ALV *
    FORM display_alv .
    PERFORM x_list_header.
    PERFORM build_fieldcat CHANGING x_fieldcat.
    x_repid2 = sy-repid.
    x_event1-name = 'TOP_OF_PAGE'.
    x_event1-form = 'TOP_OF_PAGE'.
    APPEND x_event1 TO x_event.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = x_repid2
    is_layout = x_layout1
    it_fieldcat = x_fieldcat
    i_callback_user_command = 'USER_COMMAND'
    i_callback_top_of_page = 'TOP_OF_PAGE'
    i_save = 'A'
    is_variant = x_variant1
    it_events = x_event
    TABLES
    t_outtab = it_alv
    EXCEPTIONS
    program_error = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ENDFORM. " display_master_data
    FORM USER_COMMAND *
    FORM user_command USING ucomm LIKE sy-ucomm selfield
    TYPE slis_selfield.
    READ TABLE it_alv INTO x_alv INDEX selfield-tabindex.
    CLEAR : x_alv2,it_alv2[].
    LOOP AT it_alv1 INTO x_alv1 WHERE v_legf1 = x_alv-v_legf.
    x_alv2 = x_alv1.
    APPEND x_alv2 TO it_alv2 .
    ENDLOOP.
    DATA : it_fieldcat TYPE slis_t_fieldcat_alv.
    DATA : x3_fieldcat LIKE LINE OF it_fieldcat.
    CLEAR : x3_fieldcat,it_fieldcat[].
    CLEAR x3_fieldcat.
    x3_fieldcat-col_pos = '1'.
    x3_fieldcat-fieldname = 'V_LEGF1'.
    x3_fieldcat-reptext_ddic = text-111.
    x3_fieldcat-ref_tabname = 'IT_ALV2'.
    APPEND x3_fieldcat TO it_fieldcat.
    CLEAR x3_fieldcat.
    CLEAR x3_fieldcat.
    x3_fieldcat-col_pos = '1'.
    x3_fieldcat-fieldname = 'V_MSG'.
    x3_fieldcat-reptext_ddic = text-112.
    x3_fieldcat-ref_tabname = 'IT_ALV2'.
    APPEND x3_fieldcat TO it_fieldcat.
    CLEAR x3_fieldcat.
    x_layout1-colwidth_optimize = 'X'.
    x_layout1-zebra = 'X'.
    IF it_alv2[] IS NOT INITIAL.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = x_repid2
    is_layout = x_layout1
    it_fieldcat = it_fieldcat
    i_save = 'A'
    i_callback_top_of_page = 'TOP'
    is_variant = x_variant1
    it_events = x_event
    TABLES
    t_outtab = it_alv2
    EXCEPTIONS
    program_error = 1
    OTHERS = 2.
    ENDIF.
    ENDFORM.
    FORM USER_COMMAND *
    FORM top.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    it_list_commentary = 'Commentry'.
    ENDFORM.
    FORM BUILD_FIELDCAT *
    FORM build_fieldcat CHANGING et_fieldcat TYPE slis_t_fieldcat_alv.
    DATA: x1_fieldcat TYPE slis_fieldcat_alv.
    CLEAR x1_fieldcat.
    x1_fieldcat-col_pos = '1'.
    x1_fieldcat-fieldname = 'V_LEGS'.
    x1_fieldcat-reptext_ddic = text-108.
    x1_fieldcat-ref_tabname = 'IT_ALV'.
    APPEND x1_fieldcat TO et_fieldcat.
    CLEAR x1_fieldcat.
    x1_fieldcat-col_pos = '2'.
    x1_fieldcat-fieldname = 'SUCCESS'.
    x1_fieldcat-key = 'X'.
    x1_fieldcat-reptext_ddic = text-109.
    x1_fieldcat-ref_tabname = 'IT_ALV'.
    APPEND x1_fieldcat TO et_fieldcat.
    CLEAR x1_fieldcat.
    x1_fieldcat-col_pos = '3'.
    x1_fieldcat-fieldname = 'V_LEGF'.
    x1_fieldcat-key = 'X'.
    x1_fieldcat-reptext_ddic = text-110.
    x1_fieldcat-ref_tabname = 'IT_ALV'.
    APPEND x1_fieldcat TO et_fieldcat.
    CLEAR x1_fieldcat.
    ENDFORM. " build_fieldcat
    FORM BUILD_LIST_HEADER *
    FORM x_list_header.
    DATA: x_list_header1 TYPE slis_listheader.
    *-----List Header: type H
    CLEAR x_list_header1 .
    x_list_header1-typ = 'H'.
    x_list_header1-info = text-105.
    APPEND x_list_header1 TO x_list_header.
    *-----List Key: type S
    x_list_header1-typ = 'S'.
    x_list_header1-key = text-106.
    x_list_header1-info = v_total.
    APPEND x_list_header1 TO x_list_header.
    *-----List Key: Type S
    CLEAR x_list_header1 .
    x_list_header1-typ = 'S'.
    x_list_header1-key = text-107.
    x_list_header1-info = v_succsount.
    APPEND x_list_header1 TO x_list_header.
    ENDFORM. " build_list_header
    FORM TOP_OF_PAGE *
    FORM top_of_page.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    it_list_commentary = x_list_header.
    ENDFORM. " TOP_OF_PAGE
    regards.
    sowjanya.b

  • How to pass enhanced fields in BAPI_PO_CREATE

    Dear Memebers,
    I have a requirement to pass the Enhanced fileds in Module Function BAPI_PI_CREATE using VB.NET can anyone send me sample.
    Thanks,
    Nasir

    Dear Nasir,
    In order to pass enhanced fields to the BAPI_PO_CREATE function module, populate a table of type BAPIPAREX and pass it to the EXTENSIONIN tables parameter of the FM.
    (Sample Code): Suppose you enhanced Purchasing Document Item Table EKPO with Append structure ZEKPO with the fields ZNAME1 and ZDATA1.
    DATA: GT_EXTENSION TYPE TABLE OF BAPIPAREX,
               WA_EXTENSION TYPE BAPIPAREX.
    CLEAR WA_EXTENSION.
    WA_EXTENSION-STRUCTURE = 'ZEKPO'. " 'Name of the Append Structure for Standard PO header/item table'
    CONCATENATE WA_EKPO-ZNAME1 WA_EKPO-ZDATA1 INTO WA_EXTENSION-VALUEPART1. (Ensure that the total character length of these fields is less than 240)
    APPEND WA_EXTENSION TO GT_EXTENSION.
    Similarly, you need to pass the ZEKPOX structure with the relevant check boxes. For this, you need to refer to the documentation for Function Module but generally, Passing Enhanced Fields work this way.
    Regards,
    Amit Sharma

  • Issuing Storage location in BAPI_PO_CREATE

    Hi.
    I am trying to find out field in BAPI_PO_CREATE in which i can send issuing storage location but can't find.
    here is my code which i am using
    MOVE: 'Z218' TO int_pohead-doc_type,
         '2200' TO int_pohead-purch_org,
         'DH1' TO int_pohead-pur_group,
         'GM01' TO int_pohead-suppl_plnt,
         '1500' TO int_pohead-co_code,
         '00010' TO int_poitem-po_item,
         '000000001050000020' TO int_poitem-material,
         '000000001050000020' TO int_poitem-pur_mat,
    *     '1040000023' TO int_poitem-material,
    *     '1040000023' TO int_poitem-pur_mat,
    *     '51' TO int_poitem-net_price,
         'MK01' TO int_poitem-plant,
         '7' TO int_poitem-item_cat,
         'S101' TO int_poitem-store_loc,
         '00010' TO int_posched-po_item,
         '20101231' TO int_posched-deliv_date,
         '7'        TO int_posched-quantity.
    APPEND int_poitem.
    CLEAR int_poitem.
    APPEND int_posched.
    CLEAR int_posched.
    This code gives error of 'Not Possible To determine Shipping Data for material'. While using standard ME21N t-code to creating STO, same error comes if i do not enter issuing storage location. But removed when i enter Issuing storage location. Now i have to send this field value in BAPI_PO_CREATE. but unable to find field. Please Help out.
    Edited by: tahir naqqash on Dec 1, 2010 2:55 PM

    I have solved this issue by using BAPI_PO_CREATE1. In this bapi , my required field is coming.

  • PORDCR04 -  IDOC Extention

    Hi All,
    Is there any field available in Idoc type PORDCR04 for 'Unit of measure' mapped to EKPO-GEWEI (Unit of weight) and 'Total Net Weight' (EKPO-NTGEW * EKPO-MENGE). There is a requirement to add these two field to IDOC.
    Seems to me the case of Extension. In the background there is a BAPI 'BAPI_PO_CREATE' creating the PO's. Is there any field already available in the IDoc which can be used for this purpose or it has to be the extension. ?
    /Manik

    Hi sanjeev,
    Thanks for the response.
    BAPI (BAPI_PO_CREATE) is already in use with few partners for which this functionality is required and also it have some conditions defined in the user-exit for the same Message Type. It's not a feasible idea to implement a new BAPI all together cause then all the changes need to replicated which will make the whole process complex in practical.
    Can you suggest me how to get the value into tables once I am done with the IDOC extension ?. I found out that in FM BAPI_PO_CREATE there is a CALL CUSTOMER-FUNCTION 002 , but as per my findings till now there is no field defined in BAPI_PO_CREATE Function Module for these fields and get them populated at the desired location.
    any suggestion / Sample code on this.
    /Manik

  • Using BAPI_PO_CREATE to create a PO with reference to another PO.

    Hi, I am using BAPI_PO_CREATE to create a PO with reference to another PO, in the po_header_add_data, I have done this: po_head_add-our_ref = p_ebeln.
                 CALL FUNCTION 'BAPI_PO_CREATE'
                       EXPORTING
                            po_header             = po_head
                            po_header_add_data    = po_head_add
                            skip_items_with_error = ''
                       IMPORTING
                            purchaseorder         = po_nbr
                       TABLES
                            po_item_schedules     = po_item_schedules
                            po_item_text          = po_item_text
                            po_items              = poitem1
                            return                = return.
    But when I have created the PO, in the our reference field, it is space? Why? If I want to fill the the our reference  with the another PO, how should I do?

    NULL

  • What are the Mandatory Fields in Transaction ME51

    Hello Seniors,
    I have a requirement about purchase order creation. In this process, I am using the BAPI named   " BAPI_PO_CREATE1 ". I have passed all the fields but when I debug and look into the internal tables, I couldn't find certain records. I even debugged " bapiret2"  and I see an error which reads "" All mandatory fields are missing"". I have even created a PO  in ME51 and found out the mandatory fields but in vain. BAPIRET2 still says, there are some more mandatory fields missing. I need to know what are all the mandatory fields to create a Purchase order using TCODE - ME51.
    Your reply is most awaited and rewarded.
    Thanks and Regards,
    MARKIV

    hi ,
    Functionality
    Function module BAPI_PO_CREATE1 enables you to create purchase orders. The BAPI uses the technology behind the Enjoy purchase order transaction ( ME21N).
    Alternatively, the IDoc type PORDCR1 is available. The data from this IDoc automatically populates the interface parameters of the function module BAPI_PO_CREATE1.
    Functionality in Detail
    Authorization
    The following authorization objects are checked when an Enjoy purchase order is created (activity 01):
    M_BEST_BSA (document type in PO)
    M_BEST_EKG (purchasing group in PO)
    M_BEST_EKO (purchasing organization in PO)
    M_BEST_WRK (plant in PO)
    Controlling adoption of field values via X bar
    For most tables, you can determine via your own parameters in the associated X bar in each case (e.g. PoItemX) whether fields are to be set initial, values inserted via the interface, or default values adopted (e.g. from Customizing or master records) (for example, it is not mandatory to adopt the material group from an underlying purchase requisition - you can change it with the BAPI).
    Transfer
    Header data
    The header data of the Enjoy purchase order is transferred in the table PoHeader.
    Item data
    The item data of the Enjoy purchase order is stored in the table PoItem (general item data). The delivery schedule lines are stored in the table PoSchedule.
    Use the table PoAccount to specify the account assignment information. If account assignments have been specified for services and limits, you show the relevant account assignment line in PoAccount in the table PoSrvAccessValues via the package number of the service or the limit.
    Services and limits
    Services, free limits and limits with contract reference can be specified in the tables PoServices, PoLimits, and PoContractLimits.
    Conditions
    Conditions are transferred in the table PoCond; header conditions in the table PoCondHeader. Price determination is reinitiated via the parameter CALCTYPE in the table PoItem.
    Vendor and delivery address
    The vendor's address can be specified individually in the table PoAddrVendor; the delivery address in the table PoAddrDelivery. If you do not make any individual specification, the fields will be populated via the central address managementfacility.
    Note
    In this method, the following restrictions apply with regard to addresses:
    Addresses can only be created with this method - they cannot be changed. You can only change address data with the method BAPI_ADDRESSORG_CHANGE.
    When you create addresses, they are not checked by the method. An Enjoy purchase order may therefore contain faulty address data.
    Partner roles
    The partners can be maintained individually via the table PoPartner (with the exception of the partner role "vendor").
    Import/export data
    Import/Export data can be specified per item in the table PoExpImpItem. Foreign trade data can only be transferred as default data for new items.
    Texts
    Header and item texts can be transferred in the tables PoTextHeader and PoTextItem. Texts for services are imported in the table PoServicesText.
    Version Management
    You can make use of the Version Management facility via the table AllVersions.
    Return
    The PO number is returned in the parameter ExpPurchaseOrder. In addition, all information except the service and export/import tables is placed in the output structures.
    Return messages
    Messages are returned in the parameter Return. This also contains information as to whether interface data has been wrongly or probably wrongly (heuristical interface check) populated. If a PO has been successfully created, the PO number is also placed in the return table with the appropriate message.
    Example
    Example of population of BAPI interface in the Function Builder
    Parameter: POHEADER
    COMP_CODE = 1000
    DOC_TYPE = NB
    ITEM_INTVL = 00001
    VENDOR = 0000001000
    PMNTTRMS = 0001
    PURCH_ORG = 1000
    PUR_GROUP = 001
    CURRENCY = EUR
    Parameter: POHEADERX
    COMP_CODE = X
    DOC_TYPE = X
    ITEM_INTVL = X
    VENDOR = X
    PMNTTRMS = X
    PURCH_ORG = X
    PUR_GROUP = X
    Parameter: POITEM
    PO_ITEM = 00001
    MATERIAL = 100-100
    PLANT = 1000
    STGE_LOC = 0001
    QUANTITY = 15.000
    TAX_CODE = V0
    ITEM_CAT = 0
    ACCTASSCAT = K
    Parameter: POITEMX
    PO_ITEM = 00001
    MATERIAL = X
    PLANT = X
    STGE_LOC = X
    QUANTITY = X
    TAX_CODE = X
    ITEM_CAT = X
    ACCTASSCAT = X
    Parameter: POSCHEDULE
    PO_ITEM = 00001
    SCHED_LINE = 0001
    DELIVERY_DATE = 02.12.2002
    QUANTITY = 6.000
    PO_ITEM = 00001
    SCHED_LINE = 0002
    DELIVERY_DATE = 03.12.2002
    QUANTITY = 5.000
    PO_ITEM = 00001
    SCHED_LINE = 0003
    DELIVERY_DATE = 04.12.2002
    QUANTITY = 4.000
    Parameter: POSCHEDULEX
    PO_ITEM = 00001
    SCHED_LINE = 0001
    PO_ITEMX = X
    SCHED_LINEX = X
    DELIVERY_DATE = X
    QUANTITY = X
    PO_ITEM = 00001
    SCHED_LINE = 0002
    PO_ITEMX = X
    SCHED_LINEX = X
    DELIVERY_DATE = X
    QUANTITY = X
    PO_ITEM = 00001
    SCHED_LINE = 0003
    PO_ITEMX = X
    SCHED_LINEX = X
    DELIVERY_DATE = X
    QUANTITY = X
    Parameter: POACCOUNT
    PO_ITEM = 00001
    SERIAL_NO = 01
    QUANTITY = 15.000
    GL_ACCOUNT = 0000400000
    COSTCENTER = 0000001000
    CO_AREA = 1000
    Parameter: POACCOUNTX
    PO_ITEM = 00001
    SERIAL_NO = 01
    QUANTITY = X
    GL_ACCOUNT = X
    COSTCENTER = X
    CO_AREA = X
    Parameter: POCOND
    ITM_NUMBER = 000001
    COND_ST_NO = 001
    COND_TYPE = PB00
    COND_VALUE = 79.900000000
    CURRENCY = EUR
    CURRENCY_ISO = EUR
    COND_UNIT = KG
    COND_P_UNT = 1
    CHANGE_ID = U
    Parameter: POCONDX
    ITM_NUMBER =  000001
    COND_ST_NO =  000
    ITM_NUMBERX =  X
    COND_TYPE =  X
    COND_VALUE =  X
    CURRENCY =  X
    CHANGE_ID =  X
    Parameter: POPARTNER
    PARTNERDESC =  OA
    LANGU =  EN
    BUSPARTNO =  0000001100
    PARTNERDESC =  GS
    LANGU =  EN
    BUSPARTNO =  0000001200
    PARTNERDESC =  PI
    LANGU =  EN
    BUSPARTNO =  0000001000
    Help in the Case of Problems
    1. Note 197958 lists answers to frequently asked questions (FAQs). (Note 499626 contains answers to FAQs relating to External Services Management.)
    2. If you have detected an error in the function of a BAPI, kindly create a reproducible example in the test data directory in the Function Builder (transaction code SE37). Note 375886 tells you how to do this.
    3. If the problem persists, please create a Customer Problem Message for the componente MM-PUR-PO-BAPI, and document the reproducible example where necessary.
    Customer Enhancements
    The following user exits (function modules) are available for the BAPI BAPI_PO_CREATE1:
    EXIT_SAPL2012_001 (at start of BAPI)
    EXIT_SAPL2012_003 (at end of BAPI)
    The following user exits (function modules) are available for the BAPI BAPI BAPI_PO_CHANGE:
    EXIT_SAPL2012_002 (at start of BAPI)
    EXIT_SAPL2012_004 (at end of BAPI)
    These exits belong to the enhancement SAPL2012 (see also transaction codes SMOD and CMOD).
    There is also the option of populating customer-specific fields for header, item, or account assignment data via the parameter EXTENSIONIN.
    Further information
    1. Note 197958 contains up-to-date information on the purchase order BAPIs.
    2. If you test the BAPIs BAPI_PO_CREATE1 or BAPI_PO_CHANGE in the Function Builder (transaction code SE37), no database updates will be carried out. If you need this function, please take a look at Note 420646.
    3. The BAPI BAPI_PO_GETDETAIL serves to read the details of a purchase order. The BAPI cannot read all details (e.g. conditions). However, you can use the BAPI BAPI_PO_CHANGE for this purpose if only the document number is populated and the initiator has change authorizations for purchase orders.
    4. Frequently used BAPIs for purchase orders are BAPI_PO_CREATE, BAPI_PO_CREATE1, BAPI_PO_CHANGE, BAPI_PO_GETDETAIL, BAPI_PO_GETITEMS, BAPI_PO_GETITEMSREL, and BAPI_PO_GETRELINFO.
    5. For more information on purchase orders, refer to the SAP library (under MM Purchasing -> Purchase Orders) or the Help for the Enjoy Purchase Order, or choose the path Tools -> ABAP Workbench -> Overview -> BAPI Explorer from the SAP menu.
    regards
    reena

  • How to populate a custom field of a Std. SAP Tx with BAPI usage 2 Load data

    Hi Experts,
    For instance, I created a custom field (say, custom_field_1) on a screen of standard SAP tx(say, ME21N) by using screen exit. And in order to populate the data into it (custom_field_1), will use the Function user exits of this Tx(ME23N).
    1) In next step, Where Where I have to add this field, apart from appending the same custom field in EKKO/EKPO table or any other related table; Extending the corresponding IDOC or creating a new Custom ÍDOC type? like What about BAPI?
    2) If I got a text file with the data (including the data for this custom_field_1 too) and I have been asked to load it into SAP, then, I decided to use BAPI (say, BAPI_PO_CREATE or CREATE1) to create the data, So, How to handle this custom field, I mean, In which BAPI structure I have to pass this custom_field_1 data? ( Iguess, for some BAPIs EXTENSIONIN structures are provided, sorry if am wrong!)
    Thank you.
    Edited by: SAP ABAPer on Feb 21, 2009 7:40 PM

    for example if you added field in the  VBAP table  then you can pass the custome field values like below
         move 'BAPE_VBAP' to lwa_extension-structure.
          lwa_bape_vbap-vbeln = lwa_final-vbeln.
          lwa_bape_vbap-posnr = lv_posnr.
          move lwa_final-yyslotid to  lwa_bape_vbap-new custome field.
          move lwa_bape_vbap to lwa_extension-valuepart1.
          append  lwa_extension to  lt_extension.
          clear  lwa_extension.
          move 'BAPE_VBAPX' to lwa_extension-structure.
          lwa_bape_vbapx-vbeln = lwa_final-vbeln.
          lwa_bape_vbapx-posnr = lv_posnr.
          move 'X' to lwa_bape_vbapx--new custome field.
          move lwa_bape_vbapx to lwa_extension-valuepart1.
          append  lwa_extension to  lt_extension.
          clear  lwa_extension.
    call function 'BAPI_SALESORDER_CHANGE'
            exporting
              salesdocument    = strcture
              order_header_inx = strcture
            tables
              order_item_in    =strcture
              order_item_inx   = strcture
              schedule_lines   = strcture
              schedule_linesx  = strcture
              extensionin      = lt_extension.

  • BAPI_PO_CREATE

    Actually I don't have much time left so I though of posting this thread again, I am working on an interface where I need to create PO's using BAPI_PO_CREATE but to my bad luck the code that I have written is not working properly and I have just about an hour left to subit the program to my manager so can you please help me to get out of this very critical situation. I have written the following code,
    internal table to store the data
    data:  poheader LIKE bapimepoheader,
           poheaderx LIKE  bapimepoheaderx,
           poitem LIKE bapimepoitem OCCURS 0 WITH HEADER LINE,
           poitemx LIKE  bapimepoitemx  OCCURS 0 WITH HEADER LINE,
           return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
           return2 LIKE  bapiret2 OCCURS 0 WITH HEADER LINE,
           exppurchaseorder  LIKE  bapimepoheader-po_number,
           poschedule LIKE bapimeposchedule OCCURS 0 WITH HEADER LINE,
           poschedulex LIKE bapimeposchedulx OCCURS 0 WITH HEADER LINE.
    data: begin of it_input_file OCCURS 0,
            ref_no(2),
            c_code(4),
            doc_typ(4),
            doc_date(10),
            vend_no(10),
            purch_org(4),
            purch_grp(3),
            currency(3),
            item_no(3),
            material(18),
            Plant(4),
            Strg_loc(4),
            Quantity(13),
            Price(10),
            ord_unit(7),
            del_date(10),
            seq_num(5) type n,
          end of it_input_file.
    data: it_ref_no_old(2)  type c.
    data: it_record like it_input_file occurs 0 with header line.
    data: it_record_x like it_input_file occurs 0 with header line.
    data: ld_file LIKE rlgrap-filename.
    data: it_ser_data like it_input_file occurs 0 with header line.
    data: begin of it_pipe_data occurs 0,
            line(1000),
          end of it_pipe_data.
    data:  file1(70) type c value '/tmp/test_file_',
           len type i.
    data: begin of it_lfa1 occurs 0,
            lifnr like lfa1-lifnr,
          end of it_lfa1.
    data: begin of it_t001 occurs 0,
            bukrs like t001-bukrs,
          end of it_t001.
    data: begin of it_mara occurs 0,
            matnr like mara-matnr,
          end of it_mara.
    data: begin of it_mard occurs 0,
            lgort like mard-lgort,
          end of it_mard.
    data: begin of it_marc occurs 0,
            werks like marc-werks,
          end of it_marc.
    data: begin of it_t024 occurs 0,
            ekgrp like t024-ekgrp,
          end of it_t024.
    data: begin of it_t024e occurs 0,
            ekorg like t024e-ekorg,
          end of it_t024e.
    data: begin of it_read_file occurs 0,
            line(1000),
          end of it_read_file.
    data: it_file like it_input_file occurs 0 with header line.
    data: begin of it_err_log occurs 0,
            seq_num(10),
            bukrs(4),
            bukrs_err_desc(50),
            lifnr(10),
            lifnr_err_desc(50),
            ekorg(4),
            ekorg_err_desc(50),
            ekgrp(3),
            ekgrp_err_desc(50),
            matnr(18),
            matnr_err_desc(50),
            werks(4),
            werks_err_desc(50),
            lgort(4),
            lgort_err_desc(50),
          end of it_err_log.
    data: v_fullpath type string,
          v_length type i.
    Definition of Variables                                             *
    data: v_semfile like RLGRAP-FILENAME.
    Definition of Constants                                             *
    data: c_bukrs_err_desc(50)           value 'Invalid company code',
          c_currency_err_desc(50)        value 'Invalid valid currency',
          c_lifnr_err_desc(50)           value 'Invalid valid Vendor',
          c_ekorg_err_desc(50)           value 'Invalid valid purchasing Organization',
          c_ekgrp_err_desc(50)           value 'Invalid valid Purchasing group',
          c_matnr_err_desc(50)           value 'Invalid valid Material',
          c_werks_err_desc(50)           value 'Invalid valid Plant',
          c_lgort_err_desc(50)           value 'Invalid valid Storage Location'.
    Selection Screen                                                    *
    selection-screen  begin of block b1 with frame title text-001.
    parameters: p_ifname LIKE rlgrap-filename OBLIGATORY
                    DEFAULT 'C:\'.
    parameter : p_lfile TYPE c RADIOBUTTON GROUP g1,   " local file
                p_ufile TYPE c RADIOBUTTON GROUP g1 DEFAULT 'X'. " Unix file
    selection-screen  end of block b1 .
    selection-screen  begin of block b2 with frame.             " text-002.
    parameters: p_user like sy-uname MODIF ID md1 default syst-uname.
    selection-screen  end of block b2.
    selection-screen  begin of block b3 with frame title text-003.
    parameters: p_upld radiobutton group upld default 'X' ,
                p_upldex radiobutton group upld.
    selection-screen  end of block b3.
    at selection screen
    at selection-screen on value-request for p_ifname.
      call function 'F4_FILENAME'   "allows user to select path/file
         EXPORTING
            program_name  = 'Z_PO_Creation'
            dynpro_number = syst-dynnr
            field_name    =  'p_ifname'
         IMPORTING
            file_name     = p_ifname.
    START-OF-SELECTION *
    start-of-selection.
      if p_upld = 'X'.
        perform build_table.
        perform validate_data.
        perform disp_error_report.
      else.
        if p_ufile = 'X'.
          perform open_unix_dataset.
        else.
          perform open_files.
        endif.
        perform data_process.
      endif.
    perform put_data.
    end-of-selection.
    *&      Form  call_bapi
          text
    -->  p1        text
    <--  p2        text
    FORM call_bapi .
      LOOP AT it_input_file.
    moving header data.
        MOVE: it_input_file-vend_no    TO  poheader-vendor,
              it_input_file-doc_typ    TO  poheader-doc_type,
              it_input_file-purch_org  TO  poheader-purch_org,
              it_input_file-purch_grp  TO  poheader-pur_group,
              it_input_file-c_code     TO  poheader-comp_code,
              it_input_file-doc_date   TO  poheader-doc_date.
    updating header data.
        if poheader-vendor       <> ' '.
          poheaderx-vendor       =  'X'.
        endif.
        if poheader-doc_type     <> ' '.
          poheaderx-doc_type     =  'X'.
        endif.
        if poheader-doc_date     <> ' '.
          poheaderx-doc_date     =  'X'.
        endif.
        if poheader-purch_org    <> ' '.
          poheaderx-purch_org    =  'X'.
        endif.
        if poheader-pur_group    <> ' '.
          poheaderx-pur_group    =  'X'.
        endif.
        if poheader-comp_code    <> ' '.
          poheaderx-comp_code    =  'X'.
        endif.
    moving item data.
        MOVE: it_input_file-item_no    TO  poitem-po_item,
              it_input_file-plant      TO  poitem-plant,
              it_input_file-Strg_loc   TO  poitem-stge_loc,
              it_input_file-material   TO  poitem-material,
              it_input_file-quantity   TO  poitem-quantity,
              it_input_file-price      TO  poitem-price_unit,
              it_input_file-ref_no     TO  poitem-ref_doc,
              it_input_file-ord_unit   TO  poitem-po_unit.
    updating Item data.
        if poitem-plant <> ' '.
          poitemx-plant     =  'X'.
        endif.
        if poitem-material <> ' '.
          poitemx-material     =  'X'.
        endif.
        if poitem-stge_loc <> ' '.
          poitemx-stge_loc     =  'X'.
        endif.
        if poitem-quantity <> ' '.
          poitemx-quantity     =  'X'.
        endif.
      if poitem-price_unit <> ' '.
            poitemx-price_unit    =  'X'.
      endif.
      if poitem-ref_doc <> ' '.
            poitemx-ref_doc     =  'X'.
      endif.
      if poitem-po_unit <> ' '.
            poitemx-po_unit     =  'X'.
      endif.
        poitemx-po_item      =  it_input_file-item_no.
        move: it_input_file-del_date      TO poschedule-delivery_date.
        move: 'X'                         TO poschedulex-delivery_date.
        APPEND:  poitem, poitemx.
        CALL FUNCTION 'BAPI_PO_CREATE1'
          EXPORTING
            poheader         = poheader
            poheaderx        = poheaderx
          IMPORTING
            exppurchaseorder = exppurchaseorder
          TABLES
            poitem           = poitem
            poitemx          = poitemx
            poschedule       = poschedule
            poschedulex      = poschedulex
            return           = return.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          IMPORTING
            return = return2.
        WRITE:/ 'PO created with PO number:' ,
              exppurchaseorder.
      ENDLOOP.
    ENDFORM.                    " call_bapi
    *&      Form  data_process
          text
    -->  p1        text
    <--  p2        text
    FORM data_process .
      if it_input_file[] is initial.
        message E319 with 'There is no data to process!!'.
      else.
        sort it_input_file by ref_no.
        clear: it_ref_no_old.
        loop at it_input_file into it_record.
          if  it_record-ref_no ne it_ref_no_old .
            loop at it_input_file into it_record_x
                 where  ref_no = it_record-ref_no .
            endloop.
            if  syst-subrc = 0 .
              PERFORM call_bapi.
            endif.
          endif.
          it_ref_no_old = it_record-ref_no.
        endloop.
      endif.
    ENDFORM.                    " data_process
    *&      Form  put_data
          text
    -->  p1        text
    <--  p2        text
    FORM put_data .
      it_ser_data-ref_no = '1'.
      it_ser_data-c_code = 'AEM'.
      it_ser_data-doc_typ = 'AB'.
      it_ser_data-vend_no = '100004'.
      it_ser_data-purch_org = 'A001'.
      it_ser_data-purch_grp = '522'.
      it_ser_data-currency  = 'USD'.
      it_ser_data-item_no   = '10'.
      it_ser_data-material  = '1000003'.
      it_ser_data-Plant     = '1005'.
           it_ser_data-Strg_loc
      it_ser_data-Quantity  = '100'.
      it_ser_data-Price     = '2000'.
      it_ser_data-ord_unit  = 'EA'.
           it_ser_data-del_date  =
      append it_ser_data.
      clear it_ser_data.
      loop at it_ser_data.
        concatenate it_ser_data-ref_no it_ser_data-c_code it_ser_data-doc_typ it_ser_data-vend_no it_ser_data-purch_org it_ser_data-purch_grp
                    it_ser_data-currency it_ser_data-item_no it_ser_data-material it_ser_data-Plant it_ser_data-Quantity it_ser_data-Price
                    it_ser_data-ord_unit into it_pipe_data separated by '|'.
        append it_pipe_data.
      endloop.
      clear it_pipe_data.
      open dataset file1 in text mode for output encoding default.
      if syst-subrc eq 0.
        loop at it_pipe_data.
          transfer it_pipe_data to file1.
        endloop.
        close dataset file1.
      endif.
    ENDFORM.                    " put_data
    *&      Form  validate_data
          text
    -->  p1        text
    <--  p2        text
    FORM validate_data .
      loop at it_input_file.
        read table it_t001 with key bukrs = it_input_file-c_code.
        if syst-subrc <> 0.
          move: it_input_file-c_code  to it_err_log-bukrs,
                it_input_file-seq_num to it_err_log-seq_num,
                c_bukrs_err_desc      to it_err_log-bukrs_err_desc.
        endif.
        read table it_t024 with key ekgrp = it_input_file-purch_grp.
        if syst-subrc <> 0.
          move: it_input_file-purch_grp  to it_err_log-ekgrp,
                it_input_file-seq_num to it_err_log-seq_num,
                c_ekgrp_err_desc         to it_err_log-ekgrp_err_desc.
        endif.
        read table it_t024e with key ekorg = it_input_file-purch_org.
        if syst-subrc <> 0.
          move: it_input_file-purch_org  to it_err_log-ekorg,
                it_input_file-seq_num to it_err_log-seq_num,
                c_ekorg_err_desc         to it_err_log-ekorg_err_desc.
        endif.
        read table it_lfa1 with key lifnr = it_input_file-vend_no.
        if syst-subrc <> 0.
          move: it_input_file-vend_no    to it_err_log-lifnr,
                it_input_file-seq_num to it_err_log-seq_num,
                c_lifnr_err_desc         to it_err_log-lifnr_err_desc.
        endif.
        read table it_mara with key matnr = it_input_file-material.
        if syst-subrc <> 0.
          move: it_input_file-material   to it_err_log-matnr,
                it_input_file-seq_num to it_err_log-seq_num,
                c_matnr_err_desc         to it_err_log-matnr_err_desc.
        endif.
        read table it_marc with key werks = it_input_file-plant.
        if syst-subrc <> 0.
          move: it_input_file-plant      to it_err_log-werks,
                it_input_file-seq_num to it_err_log-seq_num,
                c_werks_err_desc         to it_err_log-werks_err_desc.
        endif.
        read table it_mard with key lgort = it_input_file-Strg_loc.
        if syst-subrc <> 0.
          move: it_input_file-strg_loc   to it_err_log-lgort,
                it_input_file-seq_num to it_err_log-seq_num,
                c_lgort_err_desc         to it_err_log-lgort_err_desc.
        endif.
      endloop.
    ENDFORM.                    " validate_data
    *&      Form  open_unix_dataset
          text
    -->  p1        text
    <--  p2        text
    FORM open_unix_dataset .
      open dataset ld_file for input in text mode encoding default.
      do.
        read dataset ld_file into it_read_file.
        if sy-subrc NE 0.
          exit.
        endif.
        append it_read_file.
        clear it_read_file.
      enddo.
      close dataset ld_file.
      if NOT it_read_file[] is initial.
        loop at it_read_file.
          split it_read_file at '|' into it_file-item_no
                                          it_file-ref_no
                                          it_file-vend_no
                                          it_file-material
                                          it_file-quantity
                                          it_file-price
                                          it_file-ord_unit
                                          it_file-plant
                                          it_file-strg_loc
                                          it_file-purch_org
                                          it_file-purch_grp
                                          it_file-c_code
                                          it_file-doc_typ.
          append it_file.
          clear it_file.
        endloop.
      endif.
    ENDFORM.                    " open_unix_dataset
    *&      Form  open_files
          text
    -->  p1        text
    <--  p2        text
    FORM open_files .
      v_semfile = p_ifname.
      CALL FUNCTION 'WS_UPLOAD'
        EXPORTING
          filename                = v_semfile
          filetype                = 'DAT'
        TABLES
          data_tab                = it_input_file
        EXCEPTIONS
          conversion_error        = 1
          file_open_error         = 2
          file_read_error         = 3
          invalid_table_width     = 4
          invalid_type            = 5
          no_batch                = 6
          unknown_error           = 7
          gui_refuse_filetransfer = 8
          OTHERS                  = 9.
    ENDFORM.                    " open_files
    *&      Form  build_table
          text
    -->  p1        text
    <--  p2        text
    FORM build_table .
      select bukrs into table it_t001
        from t001
        for all entries in it_input_file
        where bukrs = it_input_file-c_code.
      select ekgrp into table it_t024
       from t024
       for all entries in it_input_file
       where ekgrp = it_input_file-purch_grp.
      select ekorg into table it_t024e
        from t024e
        for all entries in it_input_file
        where ekorg = it_input_file-purch_org.
      select lifnr into table it_lfa1
         from lfa1
         for all entries in it_input_file
         where lifnr = it_input_file-vend_no.
      select matnr into table it_mara
         from mara
         for all entries in it_input_file
         where matnr = it_input_file-material.
      select werks into table it_marc
         from marc
         for all entries in it_input_file
         where werks = it_input_file-plant.
      select lgort into table it_mard
         from mard
         for all entries in it_input_file
         where lgort = it_input_file-Strg_loc.
    ENDFORM.                    " build_table
    *&      Form  disp_error_report
          text
    -->  p1        text
    <--  p2        text
    FORM disp_error_report .
      if NOT it_err_log[] is initial.
        move: '0'                     to it_err_log-seq_num,
              'Vendor'                to it_err_log-lifnr,
              'Vendor Error'          to it_err_log-lifnr_err_desc,
              'Company Code'          to it_err_log-bukrs,
              'Company Code Error'    to it_err_log-bukrs_err_desc,
              'Purchase Org'          to it_err_log-ekorg,
              'Purchase Org Error'    to it_err_log-ekorg_err_desc,
              'Purchase Group'        to it_err_log-ekgrp,
              'Purchase Group Error'  to it_err_log-ekgrp_err_desc,
              'Plant'                 to it_err_log-werks,
              'Plant Error'           to it_err_log-werks_err_desc,
              'Storage Loc'           to it_err_log-lgort,
              'Storage Loc Error'     to it_err_log-lgort_err_desc,
              'Material'              to it_err_log-matnr,
              'Material Error'        to it_err_log-matnr_err_desc.
        append it_err_log.
        sort it_err_log by seq_num.
        loop at it_err_log where seq_num eq '0'.
          move 'Seq Num' to it_err_log-seq_num.
          modify it_err_log.
        endloop.
        concatenate 'c:\inventory_error_log' syst-datum syst-uzeit '.xls'
          into v_fullpath.
        CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
      BIN_FILESIZE                    =
            FILENAME                        =  v_fullpath
            FILETYPE                        = 'DAT'
      APPEND                          = ' '
      WRITE_FIELD_SEPARATOR           = ' '
      HEADER                          = '00'
      TRUNC_TRAILING_BLANKS           = ' '
      WRITE_LF                        = 'X'
      COL_SELECT                      = ' '
      COL_SELECT_MASK                 = ' '
      DAT_MODE                        = ' '
      CONFIRM_OVERWRITE               = ' '
      NO_AUTH_CHECK                   = ' '
      CODEPAGE                        = ' '
      IGNORE_CERR                     = ABAP_TRUE
      REPLACEMENT                     = '#'
      WRITE_BOM                       = ' '
      TRUNC_TRAILING_BLANKS_EOL       = 'X'
      WK1_N_FORMAT                    = ' '
      WK1_N_SIZE                      = ' '
      WK1_T_FORMAT                    = ' '
      WK1_T_SIZE                      = ' '
         IMPORTING
           FILELENGTH                      = v_length
          TABLES
            DATA_TAB                        = it_err_log
      FIELDNAMES                      =
         EXCEPTIONS
           FILE_WRITE_ERROR                = 1
           NO_BATCH                        = 2
           GUI_REFUSE_FILETRANSFER         = 3
           INVALID_TYPE                    = 4
           NO_AUTHORITY                    = 5
           UNKNOWN_ERROR                   = 6
           HEADER_NOT_ALLOWED              = 7
           SEPARATOR_NOT_ALLOWED           = 8
           FILESIZE_NOT_ALLOWED            = 9
           HEADER_TOO_LONG                 = 10
           DP_ERROR_CREATE                 = 11
           DP_ERROR_SEND                   = 12
           DP_ERROR_WRITE                  = 13
           UNKNOWN_DP_ERROR                = 14
           ACCESS_DENIED                   = 15
           DP_OUT_OF_MEMORY                = 16
           DISK_FULL                       = 17
           DP_TIMEOUT                      = 18
           FILE_NOT_FOUND                  = 19
           DATAPROVIDER_EXCEPTION          = 20
           CONTROL_FLUSH_ERROR             = 21
           OTHERS                          = 22
        IF SY-SUBRC <> 0.
          write:/30 'Error in generating purchase order error log'.
          write:/30 syst-uline(44).
        else.
          write:/30 'Purchase Order error log'.
          write:/30 syst-uline(24).
          skip 2.
          write:/10 'Please check the error loag file at:', v_fullpath.
        ENDIF.
      else.
        write:/30 'Purchase Order data l log'.
        write:/30 syst-uline(24).
        skip 2.
        write:/10 'There is no error in the input file data, so please proceed to execute the load!!'.
      endif.
    ENDFORM.                    " disp_error_report
    and my input file looks like this:
    1 1000 NB 20071210 V1 AE01 501 USD 10 M5 1003 100 1000 EA 20071110
    1 1000 NB 20071210 V1 AE01 507 USD 10 P10 1003 100 2000 EA 20071110
    2 1000 NB 20071210 V1 AE01 501 USD 10 M5 1003 50 1000 EA 20071110
    the name of the fields in order are : refno., compnaycode,doc-typ,doc_date,vendor,purch_org,purch_grp,currency
    tem no, material, plant, quantity, price, order unit, del_date.
    The ref No. field in the text file acts as a unique identifier So basically my Program should create 2 PO's but to my surprise it created 5 or 6 po's with only first record.
    Can you please help me out....
    Thanks
    Rajeev Gupta
    Message was edited by:
            Rajeev Gupta
    Title and Message were edited by:
            Alvaro Tejada Galindo

    and have you set a breakpoint at loop at input file and at bapi_po_create ??
    perhaps there is something wrong with the amount of items passed ?
    kind regards
    arthur

  • What are the mandatory fields of BAPI for creating a new purchase order?

    Hi friends,
    I am very new to XI.My Boss has given me task to create a purchase order using BAPI. I want step by step guide to create it.How will i know which fields are mandatory for BAPI_PO_CREATE?

    Hi Shweta,
    However It depends upon the configuration that which fields to be passed.
    But you can check this by running the BAPI in the SAP system by using transaction Se37.
    The most commanly used fields are:
    HEADER :
    DOC_TYPE                       NB
    CO_CODE                        9001
    PURCH_ORG                    9001
    PUR_GROUP                    900
    VENDOR                         100000
    ITEM
    PO_ITEM                        00001
    MATERIAL                      MM10
    STORE_LOC                   01
    MAT_GRP                       01
    SHORT_TEXT                  SERVICE (optional )
    PLANT                            9001
    NET_PRICE                    500
    ITEM_SCHEDULE
    PO_ITEM                        00001
    SERIAL_NO                      0001
    DELIV_DATE                     05.04.2008
    QUANTITY                                  1.000
    You can run the BAPI with some test data... if something is missing the BAPI will ask for it... the Results are displayed in Return Table.
    Regrads,
    Sachin

  • Map a custom SRM field to a standard field in R/3

    Hello All,
    We have created a custom field in SRM and it needs to be transferred to one of R/3's
    standard field. it has to be done in both the classic and extended classic scenario.
    For the extended classic scenario I tried using the BADI BBP_ECS_PO_OUT_BADI
    but this is not getting called in the creation of local purchase order neither
    does it transfer the changes made to r/3
    As for classic scenario I tried using the BADI BBP_CREATE_BE_PO_NEW ~ FILL_PO_INTERFACE1
    but the structure cs_po1_document-IT_POITEM does not get filled up with the item_guid
    which needs to act as a reference field to read the table.
    At the backend i tried using the bbp_po_inbound_badi and tried to change the value in the
    debuggung mode. But it didn't carry the value to the field either.
    Thanks in advance,
    Prasanna

    1. The BADI BBP_CREATE_BE_PO_NEW will only be called in the classic
    scenario wherein the purchase order is directly created in the backend
    R/3 system.
    For extended classic scenario, kindly use the BADI BBP_ECS_PO_OUT_BADI
    instead.
    Please be sure that you have filled  BBP_CREATE_BE_PO_NEW  with these lines:
    CS_CTRL_ATT-BE_DOC_TYPE = 'SRM'.
    CS_CTRL_ATT-BE_STORAGE_CAT = 'DMS_C1_ST'
    Please also check the settings in the customing of the backend (DC10, DC20, DC30).
    2.  Please create test data in BAPI_PO_CREATE1 in backend system according to note 539978 As in the note described, please 
      - set the Parameter FBGENDAT 'X' in the backend system for the
        RFC user of the SRM system
      - execute the report FBGENDAT in the mode 'A'.
        after activating this report, test data will be created by every
        BAPI_PO_CREATE(1) call.
      - once you have a new entry in the SM13 of the backend system,
        please deactivate the generation of test data in report FBGENDAT.
    Please check the Data transfered from SRM.
    3, There are some field with will be cleared during MM processing when
    you run the BAPI_PO_CREATE1 with the data transfered from SRM.
    Examples : 
    Classic scenario.
    In this case you create service purchase order.
    For service purchase orders fields WEMPF and ABLAD(GR_RCPT and UNLOAD_PT in BAPI) are not filled when creating the document. It is absolutely not possible to have this unloading point/ Recepient on item level service documents. The account assignment is entered on service level and it is then used to determine the account assignment on item level.  So even if you were able to pass from SRM the unloading point/Recepient on item level in service documents it would be overwritten from the account assignment of services. This functionality won't be available in standard R/3.
    Please see note 118008 for more information.
    Extended classic scenario.
    As soon as you pass delivery address The system clears field EMLIF (supp_vendor in the BAPI interface). Do not pass delivery address and you will be able to have Vendor in the purchase order. Due to the fact that delivery address exist, a lot of fields in lt_item are cleared, including supp_vendor.
    Call stack:
    8 SAPL2012 FORM PROCESS_ADDR_TABLE
    7 SAPL2012 FORM CREATE_ITEM_ADDR
    6 SAPL2012 FORM PROCESS_NON_INTEGRATED_COMP
    5 SAPL2012 FUNCTION BAPI_PO_CREATE1
    Please see code in subroutine PROCESS_ADDR_TABLE:
                    CLEAR imt_item-kunnr.
                    imt_itemx-kunnr = bapi_yes.
                    CLEAR imt_item-emlif.            !!!!!!!!!!!!!!!!!!!!
                    imt_itemx-emlif = bapi_yes.
                    CLEAR imt_item-lblkz.
    If you have the fields cleared in MM process , it is not a SRM-EBP-POR issue , but a MM-PUR-PO-BAPI  The BADI BBP_CREATE_BE_PO_NEW will only be called in the classic scenario wherein the purchase order is directly created in the backend R/3 system. For extended classic scenario, kindly use the BADI BBP_ECS_PO_OUT_BADI instead.
    I hope this information will help you .
    Summer Wang
    Edited by: Summer Wang on Nov 24, 2009 2:50 AM

  • Free item and BAPI_PO_CREATE

    Hi experts,
    When creating a PO with BAPI_PO_CREATE I need to set the indicator "Free" (MEPO1211-UMSON) of the item.
    The question is, can I do it with this bapi? I can't find the field in the bapi.
    Thanks a lot

    Hi,
    I get it. What it's needed to do is:
    wa_po_items_add_data-ir_ind = ' '.
    append wa_po_items_add_data to t_po_items_add_data.
    and mark ITEM_ADD_DATA_RELEVANT     = 'X' when calling the bapi
    Thanx for your help

  • PO service is not created using BAPI_PO_CREATE FM

    Hi,
          CALL FUNCTION 'BAPI_PO_CREATE'
            EXPORTING
              po_header                  = wa_header
              po_header_add_data         = wa_hdr_add
              header_add_data_relevant   = wa_hdr_flg
            IMPORTING
              purchaseorder              = v_po
            TABLES
              po_items                   = i_line
              po_item_schedules          = i_sch
              po_item_account_assignment = i_po_acc
              po_services                = i_po_ser
              po_srv_accass_values       = i_po_srv
              po_services_text           = i_po_sertxt
              return                     = i_return
              poaddrdelivery             = i_del_addr.
    TheIT_RETURN returned me the below 2 lines.
    1. Sum of percentages >200.0< exceeds 100 %
    2. Document contains no items
    Regards
    Deepthi.

    Hi,
    wa_header-DOC_DATE = 20080901
    wa_header-DOC_TYPE = 'Z0RD'.
    wa_header-CO_CODE = '3082'.
    wa_header-PURCH_ORG = 'P000'.
    wa_header-PUR_GROUP = '052'..
    wa_header-VENDOR = '0005021295'.
    wa_header-CREATED_BY = sy-uname.
    wa_header-ZZEXPTYPE = '9015'.
    wa_hdr_add-PMNTTRMS = 'Z004'.
    wa_hdr_add-CURRENCY = 'USD'.
    wa_hdr_add-REF_1 = 'CONVERSION'.
    wa_hdr_add-OUR_REF = '5172APN'.
    wa_hdr_flg = 'X'.
    w_line-PO_ITEM = '00010'.
    w_line-ITEM_CAT = '9'.
    w_line-ACCTASSCAT = 'N'.
    w_line-MAT_GRP = '088'.
    w_line-SHORT_TEXT = 'Alarm System Installation'.
    w_line-DISTRIB = space.
    w_line-PLANT = '3082'.
    w_line-UNIT = 'AU'.
    w_line-NET_PRICE = '2000.0000'.
    w_line-PCKG_NO = '0000000010'.
    w_line-TRACKINGNO = '10'.
    w_line-TAX_CODE = 'I0'.
    append w_line to i_line.
    w_sch-PO_ITEM = '00010'.
    w_sch-SERIAL_NO = '01'.
    w_sch-DELIV_DATE = '20100901'.
    w_sch-QUANTITY = '2000.000'.
    w_sch-CREATE_IND = 'X'.
    append w_sch to i_sch.
    w_po_acc-PO_ITEM = '00010'.
    w_po_acc-SERIAL_NO = '01'.
    w_po_acc-w_po_acc-w_po_acc-QUANTITY = ' 2000.000'.
    w_po_acc-DISTR_PERC = '0.0'.
    w_po_acc-G_L_ACCT = '0000622025'.
    w_po_acc-CO_AREA = 'FC01'.
    w_po_acc-NETWORK = '000004003658'.
    w_po_acc-ACTIVITY = '0210'.
    append w_po_acc to i_po_acc.
    w_po_ser-PCKG_NO = '0000000010'.
    w_po_ser-LINE_NO = '0000000001'.
    w_po_ser-w_po_ser-SUBPCKG_NO = '0000000010'.
    w_po_ser-QUANTITY = '2000.00'.
    w_po_ser-BASE_UOM = 'LE'.
    w_po_ser-GR_PRICE = '1.00'.
    w_po_ser-SHORT_TEXT = 'Alarm System Installation'.
    w_po_ser-distrib = space.
    w_po_ser-TAX_CODE = 'I0'.
    w_po_ser-MATL_GROUP = '001'.
    append w_po_ser to i_po_ser.
    w_po_srv-PCKG_NO = '0000000010'.
    w_po_srv-LINE_NO = '0000000001'.
    w_po_srv-PERCENTAGE = '100.0'.
    w_po_srv-SERIAL_NO = '01'.
    w_po_srv-QUANTITY = '1.00'.
    append w_po_src to i_po_srv
    w_po_sertxt-PCKG_NO = '0000000010'.
    w_po_sertxt-LINE_NO = '0000000001'.
    w_po_sertxt-TEXT_LINE = 'CONVERSION'.
    append w_po_sertxt to i_po_sertxt.
    w_del_addr-po_item = '00010'.
    w_del_addr-addr_no = '0000068279'.
    append w_del_addr to i_del_addr.
    data:  v_po         TYPE ebeln,
              i_return    TYPE STANDARD TABLE OF bapireturn.
          CALL FUNCTION 'BAPI_PO_CREATE'
            EXPORTING
              po_header                  = wa_header
              po_header_add_data         = wa_hdr_add
              header_add_data_relevant   = wa_hdr_flg
            IMPORTING
              purchaseorder              = v_po
            TABLES
              po_items                   = i_line
              po_item_schedules          = i_sch
              po_item_account_assignment = i_po_acc
              po_services                = i_po_ser
              po_srv_accass_values       = i_po_srv
              po_services_text           = i_po_sertxt
              return                     = i_return
              poaddrdelivery             = i_del_addr.
    Regards,
    Deepthi.

  • Transfer customer fields from EBP to R/3

    Hey,
    we have a SRM-system with a R/3 backend and added some customer fields to the accounting or purchase orders. The question now is how to transfer the cuf-data from SRM to R/3.
    There are the function-modules like B470_PO_CREATE of package BBP_BD which are dealing with the data and include the cuf-data. For my understanding i should write my own driver by copying such a function-module and call the remote BAPI (also a copy of the SAP-functionmodule BAPI_PO_CREATE) that has the cuf-data as import (original SAP doesnt have that) and save them according to that.
    The question now is how can i make SRM using the new functionmodule and what is the best practice for that problem.
    thanks for your help.
    best regards,
    oliver

    Hi,
    In classic scenario, use BADI BBP_CREATE_PO_BACK.
    In extended classic scenario or direct procurement, use BADI BBP_ECS_PO_OUT_BADI.
    Depending on your SRM version, Use either of the BADIs in SRM
    BBP_CREATE_BE_PO_NEW
    BBP_CREATE_PO_BACK
    BBP_ECS_PO_OUT_BADI
    Related links ->
    Update Custom Fields in PO - BBP_ECS_PO_OUT_BADI
    Re: How to replicate SRM PO customer fields to ERP PO in ECS
    Sample code for BADI implementation
    Re: Backend PO creation - What is the fist BADI
    BBP_ECS_PO_OUT_BADI
    Update Custom Fields on PO Header - BBP_ECS_PO_OUT_BADI
    See these related links for sample code/hints:
    Re: How to replicate SRM PO customer fields to ERP PO in ECS
    Update Custom Fields in PO - BBP_ECS_PO_OUT_BADI
    BBP_ECS_PO_OUT_BADI
    implementation of BADI BBP_ECS_PO_OUT_BADI in SRM. and BBP_PO_INBOUND_BADI
    Update Header Text in R/3 using BBP_ECS_PO_OUT_BADI
    BR,
    Disha.
    Pls reward points for useful answers.

Maybe you are looking for

  • How do I make my MAC Lion OS compatible with my new hp eprinter series 6510?

    I want to use my new hp eprinter as a backup for my Mac Laptop.  It works well wirelessly over the WIFI with my ipad.  However, when I inserted the installation disk into my Mac (with lion os), I was prompted to get an updated installation software f

  • X fails to start, causes computer to shutdown

    Hi everyone, I'm trying to install Arch on my Lenovo Y500, following the Beginner's Guide. When I try to start X, however, my screen first goes black, then my fans start freaking out for a couple of seconds, after which the computer simply shuts down

  • Message Driven Beans

    Hi, I am building a simple dispatcher around Message Driven Beans. I have a simple test program - MDB : onMessage sleeps for 10 seconds. Client: sends 100 messages I notected the following: 1. Only 13 messages are processed concurrently 2. Client is

  • Error with flash player on my worpress blog

    i can't use flash player on my blog, i used many flash player wordpress plugin but can't used flash player for watching video. can anybody help me? my blog: http:musicbold.com

  • 2 Step Verification not possible?

    Someone has my Birthday and Email address and is downloading on my account from China. They are able to change my password in the middle of the night while I'm asleep and get what they will (so far it's free childrens apps but what's next?)  I have c