Purchase Orders Using BAPI_PO_CREATE1

Hi guys ,
when v want to upload PO data using BAPI FM
wat r the Strutures to be passed
Is it necessary 2 pass Xstructures
if So? why ? can any one have sample Code
Regards
Anil kumar

*& Report  ZP_TEST_POBAPI
REPORT  zp_test_pobapi.
*- BAPI related declarations
DATA : g_pohdr TYPE bapimepoheader,
g_pohdrx TYPE bapimepoheaderx,
gt_poitem TYPE TABLE OF bapimepoitem,
gt_poitemx TYPE TABLE OF bapimepoitemx,
gt_posched TYPE TABLE OF bapimeposchedule,
gt_poschedx TYPE TABLE OF bapimeposchedulx,
gt_poacct TYPE TABLE OF bapimepoaccount,
lt_poacct TYPE  bapimepoaccount,
gt_poacctx TYPE TABLE OF bapimepoaccountx,
lt_poacctx TYPE  bapimepoaccountx,
gt_poservice TYPE TABLE OF bapiesllc,
gt_posrvacc TYPE TABLE OF bapiesklc,
gt_return TYPE TABLE OF bapiret2,
centro like bapimepoaccount-costcenter VALUE '1000',
cuenta like bapimepoaccount-gl_account VALUE '112655' ,
num_pos like bapimepoaccount-po_item VALUE '10' ,
serial like bapimepoaccount-serial_no VALUE '01' ,
ind_imp like bapimepoaccount-tax_code VALUE 'I2' ..
PERFORM prepare_header.
PERFORM prepare_items.
PERFORM prepare_schedule.
  lt_poacct-po_item = '0010'.
  lt_poacct-serial_no = serial .
  lt_poacct-creat_date = sy-datum .
  lt_poacct-costcenter = centro .
  lt_poacct-gl_account = cuenta .
  lt_poacct-gr_rcpt = 'tester'.
  APPEND lt_poacct to gt_poacct.
append gt_poacct. clear gt_poacct.
*POPULATE gt_poacct FLAG TABLE.
  lt_poacctx-po_item = '0010' .
  lt_poacctx-po_itemx = 'X' .
  lt_poacctx-serial_no = serial .
  lt_poacctx-serial_nox = 'X' .
  lt_poacctx-creat_date = 'X' .
  lt_poacctx-costcenter = 'X' .
  lt_poacctx-gl_account = 'X' .
  lt_poacct-gr_rcpt = 'X'.
  append lt_poacctx to gt_poacctx.
PERFORM create_po.
*& Form prepare_header
Set up header structure
FORM prepare_header.
  g_pohdr-comp_code = '1000'.
  g_pohdrx-comp_code = 'X'.
set up doc type
  g_pohdr-doc_type = 'NB'.
  g_pohdrx-doc_type = 'X'.
  g_pohdr-vendor = '0000010123'.
  g_pohdrx-vendor = 'X'.
  g_pohdr-langu = sy-langu.
  g_pohdrx-langu = 'X'.
g_pohdr-purch_org = 'BA01'.
  g_pohdr-purch_org = '1000'.
  g_pohdrx-purch_org = 'X'.
  g_pohdr-pur_group = '001'.
  g_pohdrx-pur_group = 'X'.
  g_pohdr-currency = 'EUR'.
  g_pohdrx-currency = 'X'.
ENDFORM. " prepare_header
*& Form prepare_items
Set up item values
FORM prepare_items.
  DATA : ls_poitem  TYPE bapimepoitem,
         ls_poitemx TYPE bapimepoitemx.
  ls_poitem-po_item     = '00010'.
  ls_poitemx-po_item    = '00010'.
  ls_poitemx-po_itemx   = 'X'.
  ls_poitem-material = 'PARAG03'.
  ls_poitemx-material = 'X'.
  ls_poitem-short_text = 'PAR'.
  ls_poitemx-short_text = 'X'.
  ls_poitem-vend_mat = 'xyz'.
  ls_poitemx-vend_mat = 'X'.
  ls_poitem-quantity = '100'.
  ls_poitemx-quantity = 'X'.
  ls_poitem-po_unit = 'EA'.
  ls_poitemx-po_unit = 'X'.
  ls_poitem-po_unit_iso = 'EA'.
  ls_poitemx-po_unit_iso = 'X'.
  ls_poitem-net_price = '6'.
  ls_poitemx-net_price = 'X'.
  ls_poitem-price_unit = '1'.
  ls_poitemx-price_unit = 'X'.
ls_poitem-item_cat = 'D'.
ls_poitemx-item_cat = 'X'.
  ls_poitem-plant = '1000'.
  ls_poitemx-plant = 'X'.
ls_poitem-acctasscat = 'K'.
ls_poitemx-acctasscat = 'X'.
ls_poitem-acctasscat = <fs_req>-knttp.
ls_poitemx-acctasscat = 'X'.
ls_poitem-distrib = <fs_req>-vrtkz.
ls_poitemx-distrib = 'X'.
ls_poitem-part_inv = <fs_req>-twrkz.
ls_poitemx-part_inv = 'X'.
ls_poitem-gr_ind = <fs_req>-wepos.
ls_poitemx-gr_ind = 'X'.
ls_poitem-gr_non_val = <fs_req>-weunb.
ls_poitemx-gr_non_val = 'X'.
ls_poitem-ir_ind = <fs_req>-repos.
ls_poitemx-ir_ind = 'X'.
ls_poitem-agreement = <fs_req>-konnr.
ls_poitemx-agreement = 'X'.
ls_poitem-agmt_item = <fs_req>-ktpnr.
ls_poitemx-agmt_item = 'X'.
ls_poitem-preq_no = <fs_req>-banfn.
ls_poitemx-preq_no = 'X'.
ls_poitem-preq_item = <fs_req>-bnfpo.
ls_poitemx-preq_item = 'X'.
ls_poitem-preq_name = <fs_req>-afnam.
ls_poitemx-preq_name = 'X'.
ls_poitem-pckg_no = <fs_req>-packno.
ls_poitemx-pckg_no = 'X'.
  APPEND : ls_poitem TO gt_poitem,
  ls_poitemx TO gt_poitemx.
ENDFORM. " prepare_items
*& Form prepare_schedule
Schedule data
FORM prepare_schedule.
  DATA : ls_posched TYPE bapimeposchedule,
  ls_poschedx TYPE bapimeposchedulx.
  ls_poschedx-po_item = '00010'.
  ls_posched-po_item = '00010'.
  ls_poschedx-po_itemx = 'X'.
  ls_posched-delivery_date = '10.10.2007'.
  ls_poschedx-delivery_date = 'X'.
  ls_posched-quantity = '100'.
  ls_poschedx-quantity = 'X'.
ls_posched-preq_no = <fs_req>-banfn.
ls_poschedx-preq_no = 'X'.
ls_posched-preq_item = <fs_req>-bnfpo.
ls_poschedx-preq_item = 'X'.
  APPEND : ls_posched TO gt_posched,
  ls_poschedx TO gt_poschedx.
ENDFORM. " prepare_schedule
*& Form create_po
Create PO with ref to the req
FORM create_po.
  DATA : lt_return TYPE TABLE OF bapiret2,
  l_ponum TYPE banfn.
  CALL FUNCTION 'BAPI_PO_CREATE1'
  EXPORTING
  poheader = g_pohdr
  poheaderx = g_pohdrx
testrun = 'X'
  IMPORTING
  exppurchaseorder = l_ponum
  TABLES
  return = lt_return
  poitem = gt_poitem
  poitemx = gt_poitemx
  poschedule = gt_posched
  poschedulex = gt_poschedx
  poaccount = gt_poacct
  poaccountx = gt_poacctx
  poservices = gt_poservice
  posrvaccessvalues = gt_posrvacc.
  APPEND LINES OF lt_return TO gt_return.
  IF NOT l_ponum IS INITIAL.
    MESSAGE s398(00) WITH 'Purchase document ' l_ponum
    ' successfully created'.
  ENDIF.
ENDFORM. " create_po

Similar Messages

  • Problem in posting Custom fields in Purchase Order using BAPI_PO_CREATE1

    Hi friends,
    Did any body tried populating custom fields using BAPI_PO_CREATE1?
    I am trying to populate custom fields in Header.
    I am populating EXTENSIONIN-STRUCTURE with 'BAPI_TE_MEPOHEADER' and EXTENSIONIN-VALUEPART1 with respective values of fields using the code below.
    T_CUSTDATA_IN-PROJECT_ID_NUM = '543211'.
    T_CUSTDATA_INX-PROJECT_ID_NUM = 'X'.
    MOVE 'BAPI_TE_MEPOHEADER' TO T_EXTENSIONIN-STRUCTURE.
    *CLEAR T_BAPI_TE_PO_HEADER-PO_NUMBER.
    MOVE-CORRESPONDING T_CUSTDATA_IN TO T_BAPI_TE_MEPOHEADER.
    MOVE 'T_BAPI_TE_MEPOHEADER' TO T_EXTENSIONIN-VALUEPART1.
    APPEND T_EXTENSIONIN.
    MOVE 'BAPI_TE_MEPOHEADERX' TO T_EXTENSIONIN-STRUCTURE.
    *CLEAR T_BAPI_TE_PO_HEADER-PO_NUMBER.
    MOVE-CORRESPONDING T_CUSTDATA_INX TO T_BAPI_TE_MEPOHEADERX.
    MOVE 'T_BAPI_TE_MEPOHEADERX' TO T_EXTENSIONIN-VALUEPART1.
    APPEND T_EXTENSIONIN.
    But still it is not populating the custom fields.
    Can some body help me on this?
    Thanks & Regards,
    Ramesh Kodavati

    Hi,
    You require to implement the Badi ME_BAPI_PO_CUST
                                               Method MAP2I_EXTENSIONIN or INBOUND
    for changing the parameter CH_EXTENSIONIN in method INBOUND
                                       or  CH_STRUC in method MAP2I_EXTENSIONIN.
    in addition to passing the extensionin parameters in bapi.
    implement the above said bapi and put a break point in both of the methods (exactly i don't remember)
    and check values are populating in the CH_STRUC structure.
    Regards,
    Dwaraka.S

  • Probelm with Creating purchase order using BAPI_PO_CREATE1

    Hi Experts,
    I am trying to create a PO using the "BAPI_PO_CREATE1".
    The BAPI is returning a PO number but when I am checking for the same in ME23 its saying that the number doesnot exsists.
    In BAPI retrun I am gettig an info message as "Stock transport ord. Created number 4500016833". What does this indicate and what do I need do for the PO to get created?
    Thanks & Regards,
    Suma

    If so how can we make use of the PO create BAPI from an Integration like XI?
    I need to create a PO using BAPI from XI, and the returned PO number has to taken reference and create a Goods receipt using BAPI_GOODSMVT_CREATE. I am testing the data before using the same for XI.
    So what do i need to do for creating a PO from XI?
    Thanks,
    Suma

  • Problem in creating Purchase order Using BAPI

    Dear ABAPers,
             I am creating the Purchase order Using BAPI_PO_CREATE1. In that the Purchase order Line item i am giving the Net Price for the Material.But While creating the purchase order the system creates the puchase order with the net price which is already available in the memory.So how to solve this problem.
    Thanks & Regards,
    Ashok.

    Hi,
        Try to pass the value NO_PRICE_FROM_PO in the BAPI and see
    NO_PRICE_FROM_PO = 'X'
    Regards
    Bala Krishna

  • HOW TO CREATE PURCHASE ORDER USING BAPI

    HI FRIENDS,
    I HAVE URGENT REQUIREMNT ,TO CREATE PURCHASE ORDER USING BAPI.PLS HELP ON THIS.
    UR'S
    RAVI

    Hi
    See the sample code and do accordingly
    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
    Reward points if useful
    Anji

  • How to create purchase order using VA01 for BAPI?

    how to create purchase order using VA01 for BAPI?

    Hi Arun,
    Please check this link
    Example Program for BAPI_PO_CREATE1
    Re: BAPI_PO_CREATE1
    Questions in BAPI_PO_CREATE1
    Problem with BAPI_PO_CREATE1
    *& Report BAPI_PO_CREATE *
    REPORT bapi_po_create.
    Input File Declaration
    TYPES: BEGIN OF ty_input_file,
    column1 TYPE char50,
    column2 TYPE char50,
    column3 TYPE char50,
    column4 TYPE char50,
    column5 TYPE char50,
    column6 TYPE char50,
    column7 TYPE char50,
    column8 TYPE char50,
    column9 TYPE char50,
    column10 TYPE char50,
    column11 TYPE char50,
    column12 TYPE char50,
    column13 TYPE char50,
    column14 TYPE char50,
    column15 TYPE char50,
    column16 TYPE char50,
    column17 TYPE char50,
    column18 TYPE char50,
    END OF ty_input_file.
    DATA: i_input_file TYPE STANDARD TABLE OF ty_input_file,
    wa_input_file TYPE ty_input_file.
    CONSTANTS: c_path TYPE char20 VALUE 'C:\',
    c_mask TYPE char9 VALUE ',.,..',
    c_mode TYPE char1 VALUE 'O',
    c_filetype TYPE char10 VALUE 'ASC',
    c_x TYPE char01 VALUE 'X'.
    PARAMETERS : p_fname LIKE rlgrap-filename.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.
    Browse Presentation Server
    PERFORM f4_presentation_file.
    START-OF-SELECTION..
    Read presentation server file
    PERFORM f1003_upload_file.
    IF NOT i_input_file[] IS INITIAL.
    PERFORM split_data.
    ENDIF.
    *& Form f4_presentation_file
    *& F4 Help for presentation server
    FORM f4_presentation_file .
    CALL FUNCTION 'WS_FILENAME_GET'
    EXPORTING
    def_path = c_path
    mask = c_mask
    mode = c_mode
    title = text-001
    IMPORTING
    filename = p_fname
    EXCEPTIONS
    inv_winsys = 1
    no_batch = 2
    selection_cancel = 3
    selection_error = 4
    OTHERS = 5.
    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. " f4_presentation_file
    *& Form f1003_upload_file
    *& Upload File
    FORM f1003_upload_file .
    DATA: lcl_filename TYPE string.
    lcl_filename = p_fname.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = lcl_filename
    filetype = c_filetype
    has_field_separator = c_x
    TABLES
    data_tab = i_input_file
    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.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    EXIT.
    ENDIF.
    ENDFORM. " f1003_upload_file
    *& Form split_data
    Collect data for creating Purchase Order
    FORM split_data .
    DATA: i_poitem TYPE STANDARD TABLE OF bapimepoitem,
    i_poitemx TYPE STANDARD TABLE OF bapimepoitemx,
    i_poitem_sch TYPE STANDARD TABLE OF bapimeposchedule,
    i_poitem_schx TYPE STANDARD TABLE OF bapimeposchedulx,
    i_acct_*** TYPE STANDARD TABLE OF bapimepoaccount,
    i_acct_assx TYPE STANDARD TABLE OF bapimepoaccountx,
    i_services TYPE STANDARD TABLE OF bapiesllc ,
    i_srvacc TYPE STANDARD TABLE OF bapiesklc,
    i_return TYPE STANDARD TABLE OF bapiret2,
    wa_header TYPE bapimepoheader,
    wa_headerx TYPE bapimepoheaderx,
    wa_poitem TYPE bapimepoitem,
    wa_poitemx TYPE bapimepoitemx,
    wa_poitem_sch TYPE bapimeposchedule,
    wa_poitem_schx TYPE bapimeposchedulx,
    wa_acct_*** TYPE bapimepoaccount,
    wa_acct_assx TYPE bapimepoaccountx,
    wa_services TYPE bapiesllc,
    wa_srvacc TYPE bapiesklc,
    wa_return TYPE bapiret2,
    ws_po TYPE bapimepoheader-po_number.
    break gbpra8.
    wa_services-pckg_no = 10.
    wa_services-line_no = 1.
    wa_services-outl_no = '0'.
    wa_services-outl_ind = c_x.
    wa_services-subpckg_no = 20.
    APPEND wa_services TO i_services.
    wa_srvacc-pckg_no = 10.
    wa_srvacc-line_no = 1.
    wa_srvacc-serno_line = 01.
    wa_srvacc-serial_no = 01.
    wa_srvacc-percentage = 100.
    APPEND wa_srvacc TO i_srvacc.
    LOOP AT i_input_file INTO wa_input_file.
    IF wa_input_file-column2 EQ 'HD'.
    wa_header-doc_type = wa_input_file-column3.
    wa_header-creat_date = sy-datum.
    wa_header-created_by = sy-uname.
    wa_header-vendor = wa_input_file-column4.
    PERFORM conversion_output USING wa_header-vendor
    CHANGING wa_header-vendor.
    wa_header-comp_code = 'DE03'.
    wa_header-purch_org = 'DE03'.
    wa_header-pur_group = 'DE1'.
    wa_header-vper_start = wa_input_file-column9.
    wa_header-vper_end = wa_input_file-column10.
    wa_headerx-comp_code = c_x.
    wa_headerx-doc_type = c_x.
    wa_headerx-creat_date = c_x.
    wa_headerx-created_by = c_x.
    wa_headerx-vendor = c_x.
    wa_headerx-purch_org = c_x.
    wa_headerx-pur_group = c_x.
    wa_headerx-vper_start = c_x.
    wa_headerx-vper_end = c_x.
    ENDIF.
    IF wa_input_file-column2 EQ 'IT'.
    wa_poitem-po_item = wa_input_file-column3.
    wa_poitem-short_text = wa_input_file-column6.
    wa_poitem-plant = wa_input_file-column8.
    wa_poitem-quantity = '1'.
    wa_poitem-tax_code = 'V0'.
    wa_poitem-item_cat = 'D'.
    wa_poitem-acctasscat = 'K'.
    wa_poitem-matl_group = wa_input_file-column7.
    wa_poitem-pckg_no = '10'.
    APPEND wa_poitem TO i_poitem .
    wa_poitemx-po_item = wa_input_file-column3.
    wa_poitemx-po_itemx = c_x.
    wa_poitemx-short_text = c_x.
    wa_poitemx-plant = c_x.
    wa_poitemx-quantity = c_x.
    wa_poitemx-tax_code = c_x.
    wa_poitemx-item_cat = c_x.
    wa_poitemx-acctasscat = c_x.
    wa_poitemx-matl_group = c_x.
    wa_poitemx-pckg_no = c_x.
    APPEND wa_poitemx TO i_poitemx.
    wa_poitem_sch-po_item = wa_input_file-column3.
    wa_poitem_sch-delivery_date = sy-datum.
    APPEND wa_poitem_sch TO i_poitem_sch.
    wa_poitem_schx-po_item = wa_input_file-column3.
    wa_poitem_schx-po_itemx = c_x.
    wa_poitem_schx-delivery_date = c_x.
    APPEND wa_poitem_schx TO i_poitem_schx.
    wa_acct_***-po_item = 10.
    wa_acct_***-serial_no = 01.
    wa_acct_***-gl_account = '0006360100'.
    wa_acct_***-co_area = '1000'.
    wa_acct_***-costcenter = 'KC010000'.
    APPEND wa_acct_*** TO i_acct_***.
    wa_acct_***-po_item = 10.
    wa_acct_***-serial_no = 02.
    wa_acct_***-gl_account = '0006360100'.
    wa_acct_***-co_area = '1000'.
    wa_acct_***-costcenter = 'KC010000'.
    APPEND wa_acct_*** TO i_acct_***.
    wa_acct_assx-po_item = 10.
    wa_acct_assx-serial_no = 01.
    wa_acct_assx-po_itemx = c_x.
    wa_acct_assx-serial_nox = c_x.
    wa_acct_assx-gl_account = c_x.
    wa_acct_assx-co_area = c_x.
    wa_acct_assx-costcenter = c_x.
    APPEND wa_acct_assx TO i_acct_assx.
    wa_acct_assx-po_item = 10.
    wa_acct_assx-serial_no = 02.
    wa_acct_assx-po_itemx = c_x.
    wa_acct_assx-serial_nox = c_x.
    wa_acct_assx-gl_account = c_x.
    wa_acct_assx-co_area = c_x.
    wa_acct_assx-costcenter = c_x.
    APPEND wa_acct_assx TO i_acct_assx.
    wa_services-pckg_no = 20.
    wa_services-line_no = 2.
    wa_services-service = wa_input_file-column9.
    wa_services-quantity = '100'.
    wa_services-gr_price = '100'.
    wa_services-userf1_txt = wa_input_file-column13.
    APPEND wa_services TO i_services.
    wa_srvacc-pckg_no = 20.
    wa_srvacc-line_no = 1.
    wa_srvacc-serno_line = 02.
    wa_srvacc-serial_no = 02.
    wa_srvacc-percentage = 100.
    APPEND wa_srvacc TO i_srvacc.
    ENDIF.
    ENDLOOP.
    CALL FUNCTION 'BAPI_PO_CREATE1'
    EXPORTING
    poheader = wa_header
    poheaderx = wa_headerx
    POADDRVENDOR =
    TESTRUN =
    MEMORY_UNCOMPLETE =
    MEMORY_COMPLETE =
    POEXPIMPHEADER =
    POEXPIMPHEADERX =
    VERSIONS =
    NO_MESSAGING =
    NO_MESSAGE_REQ =
    NO_AUTHORITY =
    NO_PRICE_FROM_PO =
    IMPORTING
    exppurchaseorder = ws_po
    EXPHEADER =
    EXPPOEXPIMPHEADER =
    TABLES
    return = i_return
    poitem = i_poitem
    poitemx = i_poitemx
    POADDRDELIVERY =
    poschedule = i_poitem_sch
    poschedulex = i_poitem_schx
    poaccount = i_acct_***
    POACCOUNTPROFITSEGMENT =
    poaccountx = i_acct_assx
    POCONDHEADER =
    POCONDHEADERX =
    POCOND =
    POCONDX =
    POLIMITS =
    POCONTRACTLIMITS =
    poservices = i_services
    posrvaccessvalues = i_srvacc
    POSERVICESTEXT =
    EXTENSIONIN =
    EXTENSIONOUT =
    POEXPIMPITEM =
    POEXPIMPITEMX =
    POTEXTHEADER =
    POTEXTITEM =
    ALLVERSIONS =
    POPARTNER =
    break gbpra8.
    LOOP AT i_return INTO wa_return.
    ENDLOOP.
    ENDFORM. " split_data
    *& Form conversion_output
    Conversion exit input
    FORM conversion_output USING p_ip
    CHANGING p_op.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    input = p_ip
    IMPORTING
    output = p_op.
    ENDFORM. " conversion_output
    Best regards,
    raam

  • HEADER TEXT in purchase orders using BAPI_PO_CREATE

    How to update HEADER TEXT in purchase orders using BAPI_PO_CREATE or BAPI_PO_CREATE1?Please advice for both types.

    Hi Srini ,
    IF you are using the BAPI_PO_CREATE , we are not having the parameter to pass Header Text.
    If you want to get Header Text  directly then Use  BAPI_PO_CREATE1 wiht a parameter POTEXTHEADER (I am not sure it is  there in 4.7).
    If  BAPI_PO_CREATE1 does not exist in  4.7 then  use create_text function module to update the the Header text
    Hope it helps
    Rgds
    Sree M
    Edited by: Sree  Merugu on Jun 13, 2008 5:10 PM

  • Create a Purchase order using the BAPI using the data in the XML file.

    Hello Gurus,
    here is the scenario can anyone help me how to proceed explaining the procedure?
    Create a Purchase order using the BAPI using the data in the XML file.
    comprehensive explanations are appreciated.
    thanks in advance.

    hi,
      first use fm "bapi_po_create".
      then use fm "BAPI_ACC_GL_POSTING_POST"
    The demo environment was made with real business scenario in mind, but following subjects need to be addressed in a live implementation:
    •     No exceptions and error handling is implemented, except the order rejection (e.g. partly delivery);
    •     In Navision both XML Ports and the XML DOM has been used to integrate with SAP XI, because XML ports has some drawbacks regarding to Namespaces in XML Documents (mandatory in SAP XI);
    •     A minimum of SAP and Navision customization is required to implement this solution. (e.g. user exit in SAP, Navision XML DOM).

  • Error release purchase order using transaction code me29n

    i have warning error this purchasing document number cannot be released.
    while i enter me29n t code.why?
    then how to release purchase order using me29n t code?
    can anyone answer this two questions.

    hi
    i have warning error this purchasing document number cannot be released. while i enter me29n t code.why?
    is the release strategy is triggred for the po ?? check thisin  P order in me23n ,in header level check release strategy tab ,
    then how to release purchase order using me29n t code? can anyone answer this two questions.
    just go to me29n >release strategy tab here just click on the release button in front of the release code

  • Creating a Purchase Order using ORDERS05 Idoc

    Hi Experts,
    I need to create a purchase order using ORDERS05 Idoc, with the data I am using a sales order is gettig created but I need to create a PO insted of SO.
    Please let me know what is difference between a PO and SO while using ORDERS05. Also please let me know what are all the fields that needs to chaged in the Idoc.
    Thanks,
    Suma

    Hi,
       I'm looking at a similar problem, can we use ORDERS05 IDOC basic type to create a Purchase Order?
       What is the inbound processing FM?  I tried IDOC_INPUT_ORDRSP, but it seem to only allow changes to a PO, and not creation of a PO.
       For IDOC_INPUT_ORDERS FM this one seem to only create Sales Orders?
       Which inbound FM should i be using?
    Regards.

  • Creation of purchase order using bapi

    hi gurus,
    Can anyone give me an example of how to create purchase order using bapi

    Hi use BAPI_PO_CREATE.. I have an eg. of changing a PO using BAPI. This is almost similar to create.. Go thru and let me know if u need more info..
    Dont forget to use 'BAPI COMMIT'  after the function call...
    DATA:
    *Update Short text, qty, net price, item no.,
    *agreement no. and agreement line no.
         it_po_item                  TYPE TABLE OF bapimepoitem,
    *Select fields
         it_po_item_x                TYPE TABLE OF bapimepoitemx,
    *Delivery date
         it_po_schedule              TYPE TABLE OF bapimeposchedule,
    *Select fields
         it_po_schedule_x            TYPE TABLE OF bapimeposchedulx,
    *Return parameters
         it_return                   TYPE TABLE OF bapiret2,
    *PO Account
         it_po_account               TYPE TABLE OF bapimepoaccount,
    *Select fields
         it_po_account_x             TYPE TABLE OF bapimepoaccountx,
    Condition Types
         it_po_cond                  TYPE TABLE OF bapimepocond,
    *Select fields
         it_po_cond_x                TYPE TABLE OF bapimepocondx,
         it_po_text                  type table of BAPIMEPOTEXT.
    Structures
    DATA:
          st_po_header               TYPE         bapimepoheader,
          st_po_header_x             TYPE         bapimepoheaderx,
          st_po_item                 LIKE LINE OF it_po_item,
          st_po_item_x               LIKE LINE OF it_po_item_x,
          st_po_schedule             LIKE LINE OF it_po_schedule,
          st_po_schedule_x           LIKE LINE OF it_po_schedule_x,
          st_return                  TYPE          bapiret2,
          st_po_account              LIKE LINE OF  it_po_account,
          st_po_account_x            LIKE LINE OF  it_po_account_x,
          st_po_cond                 LIKE LINE OF  it_po_cond,
          st_po_cond_x               LIKE LINE OF  it_po_cond_x,
          st_po_text                 like line of  it_po_text.
    Variables
    DATA : po_number    TYPE bapimepoheader-po_number,
           w_item_no(10) TYPE n VALUE  '1'.
    START-OF-SELECTION.
    test values
      po_number                = '94490'.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input         = po_number
    IMPORTING
       OUTPUT        = po_number
      st_po_item-po_item       = w_item_no.
      st_po_item-quantity      = '00.000'.
      st_po_item-delete_ind    = 'X'.
    st_po_item-short_text    = 'ZMU-test1'.
    st_po_item-agreement     = '0060000128'.
    st_po_item-agmt_item     = '1'.
    st_po_item-net_price     = '1'.
      st_po_item_x-po_item      = w_item_no.
      st_po_item_x-po_itemx     = 'X'.
      st_po_item_x-delete_ind   = 'X'.
      st_po_item_x-quantity     = 'X'.
    st_po_item_x-short_text   = 'X'.
    st_po_item_x-agreement    = 'X'.
    st_po_item_x-agmt_item    = 'X'.
    st_po_item_x-net_price    = 'X'.
    st_po_schedule-po_item         = w_item_no.
    st_po_schedule-delivery_date   = '9/19/2008'.
    st_po_schedule-quantity        = '1'.
    st_po_schedule_x-po_item         = w_item_no.
    st_po_schedule_x-po_itemx        = 'X'.
    st_po_schedule_x-delivery_date   = 'X'.
    st_po_schedule_x-quantity        = 'X'.
    st_po_cond-itm_number  = w_item_no.
    st_po_cond-cond_type   = 'PB00'.
    st_po_cond-cond_value  = '1.000'.
    st_po_cond-currency    = 'USD'.
    st_po_cond-change_id   = 'U'.
    st_po_cond_x-itm_number  = w_item_no.
    st_po_cond_x-itm_numberx = 'X'.
    st_po_cond_x-cond_type   = 'X'.
    st_po_cond_x-cond_value  = 'X'.
    st_po_cond_x-currency    = 'X'.
    st_po_cond_x-change_id   = 'X'.
    st_po_text-PO_NUMBER = po_number.
    st_po_text-PO_ITEM = w_item_no.
    st_po_text-TEXT_LINE = 'MU_TEST1 MU_TEST2'.
      APPEND:
             st_po_item_x      TO it_po_item_x,
             st_po_item        TO it_po_item.
            st_po_schedule_x  TO it_po_schedule_x,
            st_po_schedule    TO it_po_schedule,
            st_po_cond        TO it_po_cond,
            st_po_cond_x      TO  it_po_cond_x,
            st_po_text        to  it_po_text.
    st_po_text-PO_NUMBER = po_number.
    st_po_text-PO_ITEM = w_item_no.
    st_po_text-TEXT_LINE = 'MU_TEST2'.
    st_po_text-TEXT_FORM = '03'.
    append st_po_text to it_po_text.
      PERFORM function_call.
      LOOP AT it_return INTO st_return.
        WRITE:/ st_return-message, 'Message type =', st_return-type,/.
      ENDLOOP.
      REFRESH:
                it_return,
                it_po_item,
                it_po_item_x,
                it_po_cond,
                it_po_cond_x.
    PERFORM update_price.
    WRITE:/ 'After update - Messages'.
    LOOP AT it_return INTO st_return.
       WRITE:/ st_return-message, 'Message type =', st_return-type,/.
    ENDLOOP.
    data: begin of test occurs 0,
            f1,
          end of test.
          FORM function_call                                            *
    FORM function_call.
      CALL FUNCTION 'BAPI_PO_CHANGE'
        EXPORTING
          purchaseorder              = po_number
         POHEADER                  =
         POHEADERX                 =
      POADDRVENDOR                 =
      TESTRUN                      =
      MEMORY_UNCOMPLETE            =
      MEMORY_COMPLETE              =
    IMPORTING
      EXPHEADER                    =
       TABLES
          return                     = it_return
          poitem                     = it_po_item
          poitemx                    = it_po_item_x
      POADDRDELIVERY               =
        poschedule                 = it_po_schedule
        poschedulex                = it_po_schedule_x
       poaccount                   =
      POACCOUNTPROFITSEGMENT       =
       poaccountx                  =
      POCONDHEADER                 =
      POCONDHEADERX                =
       pocond                      =  it_po_cond
       pocondx                     =  it_po_cond_x
      POLIMITS                     =
      POCONTRACTLIMITS             =
      POSERVICES                   =
      POSRVACCESSVALUES            =
      POSERVICESTEXT               =
      EXTENSIONIN                  =
      EXTENSIONOUT                 =
      POTEXTHEADER                 =
       POTEXTITEM                   =  it_po_text
      POPARTNER                    =
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
           EXPORTING
                wait   = 'X'
           IMPORTING
                return = st_return.
    ENDFORM.

  • Create blocked purchase order with BAPI_PO_CREATE1

    Hi,
    I´m creating stock transport orders with BAPI_PO_CREATE1. At first, I need to
    set them to the release status 'S' for blocked. After some checks, I want be able
    to relase it and create the delivery.
    I have found some fields like rel_status inside of the header structure of
    BAPI_PO_CREATE1. But when I set this to 'S', the purchase order is created
    with status 'released'.
    How can I create a purchase order with BAPI_PO_CREATE1 and set it to 'blocked'
    first?
    Thanks, Arne

    No ideas about that?

  • How to create multiple Purchase Order  using the same document number?

    HI Friends,
    I m in a product which extracts data from SAP and stored in Access database.
    For that,while i extracting Purchase Order from the Demo Database (SBODemo_US)for OEC Computers,the same DocNum is used for several Purchase Order using Index Line numbers.
    eg:
    DocNum for Purchase Order1 -->3000   0 (Index)
      DocNum for Purchase Order2 -->3000   1 (Index)
        But i can't create multiple Purchase Order using same DocNum manually in SAP B1,Could anybody please help me <b>to create a Purchase Order using same DocumentNumber?</b>
    Thanks in Advance
    SooriyaKala.P

    Hi,
    The problem statement is not quite clear to me.
    As far as I understand your statement, I think you want to club multiple orders into one purchase order using the index incrementally.
    For this I think once you have created the first purchase order, open the purchase order in edit mode the second time and append the new line items.
    If I am getting you wrong please explain the problem statement in more detail.
    Regards,
    Rara.

  • Want to create a multiple Purchase Order using one file source

    I'm want to create a multiple purchase order using one source file. I want to read the file source create LINES in a purchase order and when the Vendor code changes I want to Add the purchase order and then create a new purchase order and Add LINES and so on.
    Right now I get  Item.no is missing [POR1.ItemCode][Line 2]

    Here is a code sample
        Private Sub testcode()
            Dim strOrdplanFile As String
            Dim oLineRec As SAPbobsCOM.Recordset
            Dim strLine As String = ""
            Dim ItemName As String
            Dim Quantity As String
            Dim RequiredDate As String
            Dim SupplierType As String
            Dim ShipTo As String
            Dim Vendor As String
            Dim oPurchaseOrder As SAPbobsCOM.Documents
            Dim bAddPOrder As Boolean = True
            Dim bPurchase As Boolean = False
            Dim sSQL As String
            Dim iReads As Integer = 1
            Dim iCurrentPurchaseNumber As Integer = 0
            Dim bErrors As Boolean = False
            Dim retCode As Double
            oPurchaseOrder = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders)
            strOrdplanFile = strFolderLocation & "ORDPLAN.TXT"
            If File.Exists(strOrdplanFile) And FileLen(strOrdplanFile) > 0 Then
                Dim sr As New StreamReader(strOrdplanFile)
                strLine = sr.ReadLine()
                txtPurRec.String = "0"
                oFormStatus.Update()
                Try
                    Do
                        Vendor = strLine.Substring(0, 8).Trim()
                        ShipTo = strLine.Substring(12, 8).Trim()
                        SupplierType = strLine.Substring(26, 1)
                        ItemName = strLine.Substring(27, 20).Trim()
                        Quantity = strLine.Substring(94, 8)
                        RequiredDate = strLine.Substring(206, 9)
                        oLineRec = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
                        sSQL = "SELECT PrcrmntMtd, CardCode FROM OITM WHERE ItemCode = '" & ItemName & "'"
                        oLineRec.DoQuery(sSQL)
                        If oLineRec.RecordCount() > 0 Then ' if it exists add the record
                            If oLineRec.Fields.Item(0).Value.ToString = "B" Then
                                If (bAddPOrder) Then
                                    oPurchaseOrder.CardCode = Vendor
                                    oPurchaseOrder.DocDueDate = RequiredDate
                                    'Add first item to the purchase order
                                    oPurchaseOrder.Lines.ItemCode = ItemName
                                    oPurchaseOrder.Lines.WarehouseCode = ShipTo
                                    oPurchaseOrder.Lines.Quantity = CDbl(Quantity)
                                    oPurchaseOrder.Lines.Add()
                                    bAddPOrder = False
                                    bPurchase = True
                                    iCurrentPurchaseNumber = iCurrentPurchaseNumber + 1
                                    txtPurRec.String = "R: " & iReads & " W: " & iCurrentPurchaseNumber.ToString
                                    oFormStatus.Update()
                                Else
                                    'compare CardCode to make sure Vendor hasn't change
                                    If (oPurchaseOrder.CardCode.CompareTo(Vendor) = 0) Then
                                        'Add item to the purchase order
                                        oPurchaseOrder.Lines.ItemCode = ItemName
                                        oPurchaseOrder.Lines.WarehouseCode = ShipTo
                                        oPurchaseOrder.Lines.Quantity = CDbl(Quantity)
                                        oPurchaseOrder.Lines.Add()
                                    Else
                                        'vender code changed
                                        retCode = oPurchaseOrder.Add()
                                        If (retCode <> 0) Then
                                            SBO_Application.MessageBox(oCompany.GetLastErrorDescription(), 1, "OK", "", "")
                                        End If
                                        oPurchaseOrder.CardCode = Vendor
                                        oPurchaseOrder.DocDueDate = RequiredDate
                                        'Add first item to the purchase order
                                        oPurchaseOrder.Lines.ItemCode = ItemName
                                        oPurchaseOrder.Lines.WarehouseCode = ShipTo
                                        oPurchaseOrder.Lines.Quantity = CDbl(Quantity)
                                        oPurchaseOrder.Lines.Add()
                                        bAddPOrder = False
                                        bPurchase = True
                                        iCurrentPurchaseNumber = iCurrentPurchaseNumber + 1
                                        txtPurRec.String = "R: " & iReads & " W: " & iCurrentPurchaseNumber.ToString
                                        oFormStatus.Update()
                                    End If
                                    iReads = iReads + 1
                                End If 'new
                                strLine = sr.ReadLine()
                            End If
                        End If
                    Loop Until sr.EndOfStream
                Catch ex As Exception
                    MsgBox(ex.Message, MsgBoxStyle.Information)
                End Try
                If (bPurchase) Then
                    lRetCode = oPurchaseOrder.Add()
                End If
                sr.Close()
                swLogFile.WriteLine("Purchase orders stored : " & iCurrentPurchaseNumber)
                oPurchaseOrder = Nothing
            End If
        End Sub

  • Create Purchase Order using B1ws SAP 8.81

    Hi Experts I am creating a Purchase Order using the Web Services SAP 8.81 PL7 SQL 2008, the problem is when i create the PO in business one it comes without the deatails on the lines like Price and Line total what am i doing wrong this is the code for the lines
    Dim docLine As PurchaseOrdersService.DocumentDocumentLine = New   PurchaseOrdersService.DocumentDocumentLine With
                                        .ItemCode = gvItems.Rows(i).Cells(1).Value, .ItemDescription = gvItems.Rows(i).Cells(2).Value,  .Quantity = gvItems.Rows(i).Cells(5).Value, .UnitPrice = Double.Parse(gvItems.Rows(i).Cells(6).Value) _
    , .Price = Double.Parse(gvItems.Rows(i).Cells(6).Value), .LineTotal =  
    Double.Parse(gvItems.Rows(i).Cells(9).Value)}                                 If i = 0 Then 
                                         poDoc.DocumentLines = Array.CreateInstance(docLine.GetType(), Me.gvItems.RowCount - 1)
                                  End If 
                                  poDoc.DocumentLines.SetValue(docLine, i)
    Regards Ben

    Hi Benedict,
    Please review B1WS samples and documentation, it is stated there the following sentence:
    Per each object property with a type different of string an associated Boolean property with the same
    name but finishing with u201CSpecifiedu201D is automatically created by .NET environment. You are forced to set
    this property value to u201Ctrueu201D if you want the associated property to be correctly set in the DI Server SOAP
    message automatically formatted.
    Hope it helps,
    Trinidad.

Maybe you are looking for