Error in : Purchase order Creation using BAPI_PO_CREATE1

Hell  guys,
I am trying to create a PO using a BAPI - BAPI_PO_CREATE1
I want the new PO to have all the characteristics of an existing PO. whose PO # is  stored in wa_order_split_create-docnr and for the new PO, i want the quantity from wa_order_split_create-qty_acptd and the delivery data to be wa_order_split_create-dly_date. But this process and code below gives a short dump in the std FM - MEPO_DOC_ITEM_GET . It raises an exception of failure. I am trying to create many new PO's in the loop below. If there is just one row, sometimes, it creates the PO even with the exception failure ( which is pretty weird).
Am i making any mistake while filling the header or item or schedule lines for the BAPI_PO_CREATE1 ? Any tips or clues why I am getting a dump ?
DATA: i_insert,
        i_create_order,
        i_cycle     TYPE cycle,
        i_qty_acpt  TYPE dzmeng,
        i_dly_date  TYPE vbak-vdatu,
        i_item      TYPE roijnomiio .
  DATA: i_order TYPE symsgv,
        i_return TYPE swd_return .
  DATA: i_vbak      TYPE vbak,
        i_vbap      TYPE vbap,
        i_ekko      TYPE ekko,
        i_ekpo      TYPE ekpo,
        i_bsoh      TYPE bapisdhd1,
        i_bsohx     TYPE bapisdhd1x,
        i_bpoh      TYPE bapimepoheader,
        i_bpohx     TYPE bapimepoheaderx,
        i_vbeln     TYPE vbeln_va,
        i_posnr     TYPE posnr_va,
        i_contr     TYPE vbeln_va,
        i_conit     TYPE posnr_va,
        i_ebeln     TYPE ebeln,
        i_ebelp     TYPE ebelp,
        i_pargr     TYPE pargr,
        i_thead     TYPE thead,
        i_line      TYPE tline,
        i_note      TYPE txw_note,
        i_new_vbeln TYPE vbeln_va,
        i_new_ebeln TYPE ebeln,
        i_wa_bsoi   TYPE bapisditm,
        i_wa_bsoix  TYPE bapisditmx,
        i_wa_bsop   TYPE bapiparnr,
        i_wa_bsos   TYPE bapischdl,
        i_wa_bsosx  TYPE bapischdlx,
        i_wa_vbpa   TYPE vbpa,
        i_wa_vbkd   TYPE vbkd,
        i_wa_bpoi   TYPE bapimepoitem,
        i_wa_bpoix  TYPE bapimepoitemx,
        i_wa_bpos   TYPE bapimeposchedule,
        i_wa_bposx  TYPE bapimeposchedulx,
        i_wa_bpop   TYPE bapiekkop,
        i_wa_ekpa   TYPE ekpa,
        i_message   TYPE char72,
        i_bapiretn  TYPE bapiret2,
        i_bapiret2  TYPE TABLE OF bapiret2 INITIAL SIZE 1,
        i_vbpa      TYPE TABLE OF vbpa INITIAL SIZE 1,
        i_vbkd      TYPE TABLE OF vbkd INITIAL SIZE 1,
        i_ekpa      TYPE TABLE OF ekpa INITIAL SIZE 1,
        i_bsoi      TYPE TABLE OF bapisditm INITIAL SIZE 1,
        i_bsoix     TYPE TABLE OF bapisditmx INITIAL SIZE 1,
        i_bsos      TYPE TABLE OF bapischdl INITIAL SIZE 1,
        i_bsosx     TYPE TABLE OF bapischdlx INITIAL SIZE 1,
        i_bsop      TYPE TABLE OF bapiparnr INITIAL SIZE 1,
        i_bpoi      TYPE TABLE OF bapimepoitem INITIAL SIZE 1,
        i_bpoix     TYPE TABLE OF bapimepoitemx INITIAL SIZE 1,
        i_bpos      TYPE TABLE OF bapimeposchedule INITIAL SIZE 1,
        i_bposx     TYPE TABLE OF bapimeposchedulx INITIAL SIZE 1,
        i_bpop      TYPE TABLE OF bapiekkop INITIAL SIZE 1,
        i_text_tab  TYPE TABLE OF tline INITIAL SIZE 1,
        i_line_tab  TYPE TABLE OF tline INITIAL SIZE 1,
        i_txw_note  TYPE TABLE OF txw_note INITIAL SIZE 1,
        i_oij_el_doc_mot TYPE oij_el_doc_mot .
  CONSTANTS: c_char_c VALUE 'C',
             c_char_e VALUE 'E',
             c_char_p VALUE 'P',
             c_char_g VALUE 'G',
             c_char_i VALUE 'I',
             c_char_s VALUE 'S',
             c_char_x VALUE 'X',
             c_zsw(3) VALUE 'ZSW',
             c_nomit_stat(4) VALUE 'ZDNY' .
  DATA : lv_nomtk_split        TYPE oij_nomtk.
  DATA : i_order_split_create  TYPE TABLE OF zsws_order_split.
  DATA : wa_order_split_create TYPE zsws_order_split.
  LOOP AT i_order_split_create INTO wa_order_split_create.
    IF NOT i_create_order IS INITIAL .
      CLEAR: i_create_order .
          MOVE: wa_order_split_create-docnr  TO i_ebeln,
                wa_order_split_create-docitm TO i_ebelp .
          CALL FUNCTION 'ME_EKKO_SINGLE_READ'
               EXPORTING
                    pi_ebeln         = i_ebeln
               IMPORTING
                    po_ekko          = i_ekko
               EXCEPTIONS
                    no_records_found = 1
                    OTHERS           = 2.
          IF sy-subrc <> 0 .
          ENDIF .
* Fill PO Header
          i_bpoh-comp_code   = i_ekko-bukrs .
          i_bpoh-doc_type    = i_ekko-bsart .
          i_bpoh-vendor      = i_ekko-lifnr .
          i_bpoh-langu       = i_ekko-spras .
          i_bpoh-pmnttrms    = i_ekko-zterm .
          i_bpoh-purch_org   = i_ekko-ekorg .
          i_bpoh-pur_group   = i_ekko-ekgrp .
          i_bpoh-currency    = i_ekko-waers .
          i_bpoh-agreement   = i_ekko-konnr .
          i_bpoh-incoterms1  = i_ekko-inco1 .
          i_bpoh-incoterms2  = i_ekko-inco2 .
* Fill PO update indicator 'X'
          i_bpohx-comp_code  = c_char_x .
          i_bpohx-doc_type   = c_char_x .
          i_bpohx-vendor     = c_char_x .
          i_bpohx-langu      = c_char_x .
          i_bpohx-pmnttrms   = c_char_x .
          i_bpohx-purch_org  = c_char_x .
          i_bpohx-pur_group  = c_char_x .
          i_bpohx-currency   = c_char_x .
          i_bpohx-agreement  = c_char_x .
          i_bpohx-incoterms1 = c_char_x .
          i_bpohx-incoterms2 = c_char_x .
          CALL FUNCTION 'ME_EKPO_SINGLE_READ'
               EXPORTING
                    pi_ebeln         = i_ebeln
                    pi_ebelp         = i_ebelp
               IMPORTING
                    po_ekpo          = i_ekpo
               EXCEPTIONS
                    no_records_found = 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 .
* Fill PO Item
          i_wa_bpoi-po_item    = i_ekpo-ebelp .
          i_wa_bpoi-material   = i_ekpo-matnr .
          i_wa_bpoi-plant      = i_ekpo-werks .
          i_wa_bpoi-stge_loc   = i_ekpo-lgort .
          i_wa_bpoi-quantity   = wa_order_split_create-qty_acptd .
          i_wa_bpoi-po_unit    = i_ekpo-meins .
          i_wa_bpoi-tax_code   = i_ekpo-mwskz .
          i_wa_bpoi-val_type   = i_ekpo-bwtar .
          i_wa_bpoi-item_cat   = i_ekpo-pstyp .
          i_wa_bpoi-acctasscat = i_ekpo-knttp .
          i_wa_bpoi-agreement  = i_ekpo-konnr .
          i_wa_bpoi-agmt_item  = i_ekpo-ktpnr .
          APPEND i_wa_bpoi TO i_bpoi .
* Fill PO Item update indicator 'X'
          i_wa_bpoix-po_item    = i_ekpo-ebelp .
          i_wa_bpoix-po_itemx   = c_char_x .
          i_wa_bpoix-material   = c_char_x .
          i_wa_bpoix-plant      = c_char_x .
          i_wa_bpoix-stge_loc   = c_char_x .
          i_wa_bpoix-quantity   = c_char_x .
          i_wa_bpoix-po_unit    = c_char_x .
          i_wa_bpoix-tax_code   = c_char_x .
          i_wa_bpoix-val_type   = c_char_x .
          i_wa_bpoix-item_cat   = c_char_x .
          i_wa_bpoix-acctasscat = c_char_x .
          i_wa_bpoix-agreement  = c_char_x .
          i_wa_bpoix-agmt_item  = c_char_x .
          APPEND i_wa_bpoix TO i_bpoix .
* Fill PO Item Schedule
          i_wa_bpos-po_item       = i_ekpo-ebelp .
          i_wa_bpos-sched_line    = '0001' .
          i_wa_bpos-delivery_date = wa_order_split_create-dly_date .
          i_wa_bpos-quantity      = wa_order_split_create-qty_acptd .
          APPEND i_wa_bpos TO i_bpos .
* Fill PO Item schedule update indicator 'X'
          i_wa_bposx-po_item       = i_ekpo-ebelp .
          i_wa_bposx-sched_line    = '0001' .
          i_wa_bposx-delivery_date = c_char_x .
          i_wa_bposx-quantity      = c_char_x .
          APPEND i_wa_bposx TO i_bposx .
          CLEAR: i_pargr .
          SELECT SINGLE pargr
            INTO i_pargr
            FROM t161
           WHERE bstyp = i_ekko-bstyp
             AND bsart = i_ekko-bsart .
          CLEAR i_ekpa[].
          CALL FUNCTION 'MM_READ_PARTNERS'
               EXPORTING
                    application = c_char_p
                    ebeln       = i_ebeln
                    bstyp       = i_ekko-bstyp
                    pargr       = i_pargr
               TABLES
                    x_ekpa      = i_ekpa[].
          LOOP AT i_ekpa INTO i_wa_ekpa .
            i_wa_bpop-partnerdesc = i_wa_ekpa-parvw .
            i_wa_bpop-langu = sy-langu .
            IF NOT i_wa_ekpa-lifn2 IS INITIAL .
              i_wa_bpop-buspartno = i_wa_ekpa-lifn2 .
            ELSE .
              i_wa_bpop-buspartno = i_wa_ekpa-parnr .
            ENDIF .
            APPEND i_wa_bpop TO i_bpop .
            CLEAR: i_wa_ekpa, i_wa_bpop .
          ENDLOOP .
          CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.
          CALL FUNCTION 'BAPI_PO_CREATE1'
               EXPORTING
                    poheader         = i_bpoh
                    poheaderx        = i_bpohx
               IMPORTING
                    exppurchaseorder = i_new_ebeln
               TABLES
                    return           = i_bapiret2
                    poitem           = i_bpoi[]
                    poitemx          = i_bpoix[]
                    poschedule       = i_bpos[]
                    poschedulex      = i_bposx[].
          i_order = i_new_ebeln .
          SHIFT i_order LEFT DELETING LEADING '0' .
          i_return-errortype = c_char_i .
          i_return-workarea  = c_zsw .
          i_return-message   = '064' .
          i_return-variable1 = i_order .
        loop at i_bapiret2 into i_bapiretn where type ca 'EAX' .
        append i_bapiretn to t_bapi_return .
      endloop .
      if t_bapi_return[] is initial .
         i_create_order = c_char_x .
           CALL FUNCTION 'SWD_POPUP_MESSAGE_SEND'
               EXPORTING
                    act_return = i_return. "Popup with new PO no.
      ENDCASE .                                     " Docind
    ENDIF .
  ENDLOOP.

Hi Shareen,
I think in the following parts of the code,
          CALL FUNCTION 'MM_READ_PARTNERS'
               EXPORTING
                    application = c_char_p
                    ebeln       = i_ebeln
                    bstyp       = i_ekko-bstyp
                    pargr       = i_pargr
               TABLES
                    x_ekpa      = i_ekpa[].
Error in : Purchase order Creation using BAPI_PO_CREATE1
Posted: Mar 20, 2006 7:39 PM      Reply      E-mail this post 
Hell guys,
I am trying to create a PO using a BAPI - BAPI_PO_CREATE1
I want the new PO to have all the characteristics of an existing PO. whose PO # is stored in wa_order_split_create-docnr and for the new PO, i want the quantity from wa_order_split_create-qty_acptd and the delivery data to be wa_order_split_create-dly_date. But this process and code below gives a short dump in the std FM - MEPO_DOC_ITEM_GET . It raises an exception of failure. I am trying to create many new PO's in the loop below. If there is just one row, sometimes, it creates the PO even with the exception failure ( which is pretty weird).
Am i making any mistake while filling the header or item or schedule lines for the BAPI_PO_CREATE1 ? Any tips or clues why I am getting a dump ?
DATA: i_insert,
        i_create_order,
        i_cycle     TYPE cycle,
        i_qty_acpt  TYPE dzmeng,
        i_dly_date  TYPE vbak-vdatu,
        i_item      TYPE roijnomiio .
  DATA: i_order TYPE symsgv,
        i_return TYPE swd_return .
  DATA: i_vbak      TYPE vbak,
        i_vbap      TYPE vbap,
        i_ekko      TYPE ekko,
        i_ekpo      TYPE ekpo,
        i_bsoh      TYPE bapisdhd1,
        i_bsohx     TYPE bapisdhd1x,
        i_bpoh      TYPE bapimepoheader,
        i_bpohx     TYPE bapimepoheaderx,
        i_vbeln     TYPE vbeln_va,
        i_posnr     TYPE posnr_va,
        i_contr     TYPE vbeln_va,
        i_conit     TYPE posnr_va,
        i_ebeln     TYPE ebeln,
        i_ebelp     TYPE ebelp,
        i_pargr     TYPE pargr,
        i_thead     TYPE thead,
        i_line      TYPE tline,
        i_note      TYPE txw_note,
        i_new_vbeln TYPE vbeln_va,
        i_new_ebeln TYPE ebeln,
        i_wa_bsoi   TYPE bapisditm,
        i_wa_bsoix  TYPE bapisditmx,
        i_wa_bsop   TYPE bapiparnr,
        i_wa_bsos   TYPE bapischdl,
        i_wa_bsosx  TYPE bapischdlx,
        i_wa_vbpa   TYPE vbpa,
        i_wa_vbkd   TYPE vbkd,
        i_wa_bpoi   TYPE bapimepoitem,
        i_wa_bpoix  TYPE bapimepoitemx,
        i_wa_bpos   TYPE bapimeposchedule,
        i_wa_bposx  TYPE bapimeposchedulx,
        i_wa_bpop   TYPE bapiekkop,
        i_wa_ekpa   TYPE ekpa,
        i_message   TYPE char72,
        i_bapiretn  TYPE bapiret2,
        i_bapiret2  TYPE TABLE OF bapiret2 INITIAL SIZE 1,
        i_vbpa      TYPE TABLE OF vbpa INITIAL SIZE 1,
        i_vbkd      TYPE TABLE OF vbkd INITIAL SIZE 1,
        i_ekpa      TYPE TABLE OF ekpa INITIAL SIZE 1,
        i_bsoi      TYPE TABLE OF bapisditm INITIAL SIZE 1,
        i_bsoix     TYPE TABLE OF bapisditmx INITIAL SIZE 1,
        i_bsos      TYPE TABLE OF bapischdl INITIAL SIZE 1,
        i_bsosx     TYPE TABLE OF bapischdlx INITIAL SIZE 1,
        i_bsop      TYPE TABLE OF bapiparnr INITIAL SIZE 1,
        i_bpoi      TYPE TABLE OF bapimepoitem INITIAL SIZE 1,
        i_bpoix     TYPE TABLE OF bapimepoitemx INITIAL SIZE 1,
        i_bpos      TYPE TABLE OF bapimeposchedule INITIAL SIZE 1,
        i_bposx     TYPE TABLE OF bapimeposchedulx INITIAL SIZE 1,
        i_bpop      TYPE TABLE OF bapiekkop INITIAL SIZE 1,
        i_text_tab  TYPE TABLE OF tline INITIAL SIZE 1,
        i_line_tab  TYPE TABLE OF tline INITIAL SIZE 1,
        i_txw_note  TYPE TABLE OF txw_note INITIAL SIZE 1,
        i_oij_el_doc_mot TYPE oij_el_doc_mot .
  CONSTANTS: c_char_c VALUE 'C',
             c_char_e VALUE 'E',
             c_char_p VALUE 'P',
             c_char_g VALUE 'G',
             c_char_i VALUE 'I',
             c_char_s VALUE 'S',
             c_char_x VALUE 'X',
             c_zsw(3) VALUE 'ZSW',
             c_nomit_stat(4) VALUE 'ZDNY' .
  DATA : lv_nomtk_split        TYPE oij_nomtk.
  DATA : i_order_split_create  TYPE TABLE OF zsws_order_split.
  DATA : wa_order_split_create TYPE zsws_order_split.
  LOOP AT i_order_split_create INTO wa_order_split_create.
    IF NOT i_create_order IS INITIAL .
      CLEAR: i_create_order .
          MOVE: wa_order_split_create-docnr  TO i_ebeln,
                wa_order_split_create-docitm TO i_ebelp .
          CALL FUNCTION 'ME_EKKO_SINGLE_READ'
               EXPORTING
                    pi_ebeln         = i_ebeln
               IMPORTING
                    po_ekko          = i_ekko
               EXCEPTIONS
                    no_records_found = 1
                    OTHERS           = 2.
          IF sy-subrc <> 0 .
          ENDIF .
Fill PO Header
          i_bpoh-comp_code   = i_ekko-bukrs .
          i_bpoh-doc_type    = i_ekko-bsart .
          i_bpoh-vendor      = i_ekko-lifnr .
          i_bpoh-langu       = i_ekko-spras .
          i_bpoh-pmnttrms    = i_ekko-zterm .
          i_bpoh-purch_org   = i_ekko-ekorg .
          i_bpoh-pur_group   = i_ekko-ekgrp .
          i_bpoh-currency    = i_ekko-waers .
          i_bpoh-agreement   = i_ekko-konnr .
          i_bpoh-incoterms1  = i_ekko-inco1 .
          i_bpoh-incoterms2  = i_ekko-inco2 .
Fill PO update indicator 'X'
          i_bpohx-comp_code  = c_char_x .
          i_bpohx-doc_type   = c_char_x .
          i_bpohx-vendor     = c_char_x .
          i_bpohx-langu      = c_char_x .
          i_bpohx-pmnttrms   = c_char_x .
          i_bpohx-purch_org  = c_char_x .
          i_bpohx-pur_group  = c_char_x .
          i_bpohx-currency   = c_char_x .
          i_bpohx-agreement  = c_char_x .
          i_bpohx-incoterms1 = c_char_x .
          i_bpohx-incoterms2 = c_char_x .
          CALL FUNCTION 'ME_EKPO_SINGLE_READ'
               EXPORTING
                    pi_ebeln         = i_ebeln
                    pi_ebelp         = i_ebelp
               IMPORTING
                    po_ekpo          = i_ekpo
               EXCEPTIONS
                    no_records_found = 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 .
Fill PO Item
          i_wa_bpoi-po_item    = i_ekpo-ebelp .
          i_wa_bpoi-material   = i_ekpo-matnr .
          i_wa_bpoi-plant      = i_ekpo-werks .
          i_wa_bpoi-stge_loc   = i_ekpo-lgort .
          i_wa_bpoi-quantity   = wa_order_split_create-qty_acptd .
          i_wa_bpoi-po_unit    = i_ekpo-meins .
          i_wa_bpoi-tax_code   = i_ekpo-mwskz .
          i_wa_bpoi-val_type   = i_ekpo-bwtar .
          i_wa_bpoi-item_cat   = i_ekpo-pstyp .
          i_wa_bpoi-acctasscat = i_ekpo-knttp .
          i_wa_bpoi-agreement  = i_ekpo-konnr .
          i_wa_bpoi-agmt_item  = i_ekpo-ktpnr .
          APPEND i_wa_bpoi TO i_bpoi .
Fill PO Item update indicator 'X'
          i_wa_bpoix-po_item    = i_ekpo-ebelp .
          i_wa_bpoix-po_itemx   = c_char_x .
          i_wa_bpoix-material   = c_char_x .
          i_wa_bpoix-plant      = c_char_x .
          i_wa_bpoix-stge_loc   = c_char_x .
          i_wa_bpoix-quantity   = c_char_x .
          i_wa_bpoix-po_unit    = c_char_x .
          i_wa_bpoix-tax_code   = c_char_x .
          i_wa_bpoix-val_type   = c_char_x .
          i_wa_bpoix-item_cat   = c_char_x .
          i_wa_bpoix-acctasscat = c_char_x .
          i_wa_bpoix-agreement  = c_char_x .
          i_wa_bpoix-agmt_item  = c_char_x .
          APPEND i_wa_bpoix TO i_bpoix .
Fill PO Item Schedule
          i_wa_bpos-po_item       = i_ekpo-ebelp .
          i_wa_bpos-sched_line    = '0001' .
          i_wa_bpos-delivery_date = wa_order_split_create-dly_date .
          i_wa_bpos-quantity      = wa_order_split_create-qty_acptd .
          APPEND i_wa_bpos TO i_bpos .
Fill PO Item schedule update indicator 'X'
          i_wa_bposx-po_item       = i_ekpo-ebelp .
          i_wa_bposx-sched_line    = '0001' .
          i_wa_bposx-delivery_date = c_char_x .
          i_wa_bposx-quantity      = c_char_x .
          APPEND i_wa_bposx TO i_bposx .
          CLEAR: i_pargr .
          SELECT SINGLE pargr
            INTO i_pargr
            FROM t161
           WHERE bstyp = i_ekko-bstyp
             AND bsart = i_ekko-bsart .
          CLEAR i_ekpa[].
          CALL FUNCTION 'MM_READ_PARTNERS'
               EXPORTING
                    application = c_char_p
                    ebeln       = i_ebeln
                    bstyp       = i_ekko-bstyp
                    pargr       = i_pargr
               TABLES
                    x_ekpa      = <b>i_ekpa[].</b>
          LOOP AT i_ekpa INTO i_wa_ekpa .
            i_wa_bpop-partnerdesc = i_wa_ekpa-parvw .
            i_wa_bpop-langu = sy-langu .
            IF NOT i_wa_ekpa-lifn2 IS INITIAL .
              i_wa_bpop-buspartno = i_wa_ekpa-lifn2 .
            ELSE .
              i_wa_bpop-buspartno = i_wa_ekpa-parnr .
            ENDIF .
            APPEND i_wa_bpop TO i_bpop .
            CLEAR: i_wa_ekpa, i_wa_bpop .
          ENDLOOP .
          CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.
          CALL FUNCTION 'BAPI_PO_CREATE1'
               EXPORTING
                    poheader         = i_bpoh
                    poheaderx        = i_bpohx
               IMPORTING
                    exppurchaseorder = i_new_ebeln
               TABLES
                    return           = i_bapiret2
                <b>    poitem           = i_bpoi[]
                    poitemx          = i_bpoix[]
                    poschedule       = i_bpos[]
                    poschedulex      = i_bposx[].</b>
it should be only i_bpoi, i_bpoix, i_bpos, i_bposx but not  i_bpoi[], i_bpoix[], i_bpos[], i_bposx[].
CHange the code as follows:
DATA: i_insert,
        i_create_order,
        i_cycle     TYPE cycle,
        i_qty_acpt  TYPE dzmeng,
        i_dly_date  TYPE vbak-vdatu,
        i_item      TYPE roijnomiio .
  DATA: i_order TYPE symsgv,
        i_return TYPE swd_return .
  DATA: i_vbak      TYPE vbak,
        i_vbap      TYPE vbap,
        i_ekko      TYPE ekko,
        i_ekpo      TYPE ekpo,
        i_bsoh      TYPE bapisdhd1,
        i_bsohx     TYPE bapisdhd1x,
        i_bpoh      TYPE bapimepoheader,
        i_bpohx     TYPE bapimepoheaderx,
        i_vbeln     TYPE vbeln_va,
        i_posnr     TYPE posnr_va,
        i_contr     TYPE vbeln_va,
        i_conit     TYPE posnr_va,
        i_ebeln     TYPE ebeln,
        i_ebelp     TYPE ebelp,
        i_pargr     TYPE pargr,
        i_thead     TYPE thead,
        i_line      TYPE tline,
        i_note      TYPE txw_note,
        i_new_vbeln TYPE vbeln_va,
        i_new_ebeln TYPE ebeln,
        i_wa_bsoi   TYPE bapisditm,
        i_wa_bsoix  TYPE bapisditmx,
        i_wa_bsop   TYPE bapiparnr,
        i_wa_bsos   TYPE bapischdl,
        i_wa_bsosx  TYPE bapischdlx,
        i_wa_vbpa   TYPE vbpa,
        i_wa_vbkd   TYPE vbkd,
        i_wa_bpoi   TYPE bapimepoitem,
        i_wa_bpoix  TYPE bapimepoitemx,
        i_wa_bpos   TYPE bapimeposchedule,
        i_wa_bposx  TYPE bapimeposchedulx,
        i_wa_bpop   TYPE bapiekkop,
        i_wa_ekpa   TYPE ekpa,
        i_message   TYPE char72,
        i_bapiretn  TYPE bapiret2,
        i_bapiret2  TYPE TABLE OF bapiret2 INITIAL SIZE 1,
        i_vbpa      TYPE TABLE OF vbpa INITIAL SIZE 1,
        i_vbkd      TYPE TABLE OF vbkd INITIAL SIZE 1,
        i_ekpa      TYPE TABLE OF ekpa INITIAL SIZE 1,
        i_bsoi      TYPE TABLE OF bapisditm INITIAL SIZE 1,
        i_bsoix     TYPE TABLE OF bapisditmx INITIAL SIZE 1,
        i_bsos      TYPE TABLE OF bapischdl INITIAL SIZE 1,
        i_bsosx     TYPE TABLE OF bapischdlx INITIAL SIZE 1,
        i_bsop      TYPE TABLE OF bapiparnr INITIAL SIZE 1,
        i_bpoi      TYPE TABLE OF bapimepoitem INITIAL SIZE 1,
        i_bpoix     TYPE TABLE OF bapimepoitemx INITIAL SIZE 1,
        i_bpos      TYPE TABLE OF bapimeposchedule INITIAL SIZE 1,
        i_bposx     TYPE TABLE OF bapimeposchedulx INITIAL SIZE 1,
        i_bpop      TYPE TABLE OF bapiekkop INITIAL SIZE 1,
        i_text_tab  TYPE TABLE OF tline INITIAL SIZE 1,
        i_line_tab  TYPE TABLE OF tline INITIAL SIZE 1,
        i_txw_note  TYPE TABLE OF txw_note INITIAL SIZE 1,
        i_oij_el_doc_mot TYPE oij_el_doc_mot .
  CONSTANTS: c_char_c VALUE 'C',
             c_char_e VALUE 'E',
             c_char_p VALUE 'P',
             c_char_g VALUE 'G',
             c_char_i VALUE 'I',
             c_char_s VALUE 'S',
             c_char_x VALUE 'X',
             c_zsw(3) VALUE 'ZSW',
             c_nomit_stat(4) VALUE 'ZDNY' .
  DATA : lv_nomtk_split        TYPE oij_nomtk.
  DATA : i_order_split_create  TYPE TABLE OF zsws_order_split.
  DATA : wa_order_split_create TYPE zsws_order_split.
  LOOP AT i_order_split_create INTO wa_order_split_create.
    IF NOT i_create_order IS INITIAL .
      CLEAR: i_create_order .
          MOVE: wa_order_split_create-docnr  TO i_ebeln,
                wa_order_split_create-docitm TO i_ebelp .
          CALL FUNCTION 'ME_EKKO_SINGLE_READ'
               EXPORTING
                    pi_ebeln         = i_ebeln
               IMPORTING
                    po_ekko          = i_ekko
               EXCEPTIONS
                    no_records_found = 1
                    OTHERS           = 2.
          IF sy-subrc <> 0 .
          ENDIF .
Fill PO Header
          i_bpoh-comp_code   = i_ekko-bukrs .
          i_bpoh-doc_type    = i_ekko-bsart .
          i_bpoh-vendor      = i_ekko-lifnr .
          i_bpoh-langu       = i_ekko-spras .
          i_bpoh-pmnttrms    = i_ekko-zterm .
          i_bpoh-purch_org   = i_ekko-ekorg .
          i_bpoh-pur_group   = i_ekko-ekgrp .
          i_bpoh-currency    = i_ekko-waers .
          i_bpoh-agreement   = i_ekko-konnr .
          i_bpoh-incoterms1  = i_ekko-inco1 .
          i_bpoh-incoterms2  = i_ekko-inco2 .
Fill PO update indicator 'X'
          i_bpohx-comp_code  = c_char_x .
          i_bpohx-doc_type   = c_char_x .
          i_bpohx-vendor     = c_char_x .
          i_bpohx-langu      = c_char_x .
          i_bpohx-pmnttrms   = c_char_x .
          i_bpohx-purch_org  = c_char_x .
          i_bpohx-pur_group  = c_char_x .
          i_bpohx-currency   = c_char_x .
          i_bpohx-agreement  = c_char_x .
          i_bpohx-incoterms1 = c_char_x .
          i_bpohx-incoterms2 = c_char_x .
          CALL FUNCTION 'ME_EKPO_SINGLE_READ'
               EXPORTING
                    pi_ebeln         = i_ebeln
                    pi_ebelp         = i_ebelp
               IMPORTING
                    po_ekpo          = i_ekpo
               EXCEPTIONS
                    no_records_found = 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 .
Fill PO Item
          i_wa_bpoi-po_item    = i_ekpo-ebelp .
          i_wa_bpoi-material   = i_ekpo-matnr .
          i_wa_bpoi-plant      = i_ekpo-werks .
          i_wa_bpoi-stge_loc   = i_ekpo-lgort .
          i_wa_bpoi-quantity   = wa_order_split_create-qty_acptd .
          i_wa_bpoi-po_unit    = i_ekpo-meins .
          i_wa_bpoi-tax_code   = i_ekpo-mwskz .
          i_wa_bpoi-val_type   = i_ekpo-bwtar .
          i_wa_bpoi-item_cat   = i_ekpo-pstyp .
          i_wa_bpoi-acctasscat = i_ekpo-knttp .
          i_wa_bpoi-agreement  = i_ekpo-konnr .
          i_wa_bpoi-agmt_item  = i_ekpo-ktpnr .
          APPEND i_wa_bpoi TO i_bpoi .
Fill PO Item update indicator 'X'
          i_wa_bpoix-po_item    = i_ekpo-ebelp .
          i_wa_bpoix-po_itemx   = c_char_x .
          i_wa_bpoix-material   = c_char_x .
          i_wa_bpoix-plant      = c_char_x .
          i_wa_bpoix-stge_loc   = c_char_x .
          i_wa_bpoix-quantity   = c_char_x .
          i_wa_bpoix-po_unit    = c_char_x .
          i_wa_bpoix-tax_code   = c_char_x .
          i_wa_bpoix-val_type   = c_char_x .
          i_wa_bpoix-item_cat   = c_char_x .
          i_wa_bpoix-acctasscat = c_char_x .
          i_wa_bpoix-agreement  = c_char_x .
          i_wa_bpoix-agmt_item  = c_char_x .
          APPEND i_wa_bpoix TO i_bpoix .
Fill PO Item Schedule
          i_wa_bpos-po_item       = i_ekpo-ebelp .
          i_wa_bpos-sched_line    = '0001' .
          i_wa_bpos-delivery_date = wa_order_split_create-dly_date .
          i_wa_bpos-quantity      = wa_order_split_create-qty_acptd .
          APPEND i_wa_bpos TO i_bpos .
Fill PO Item schedule update indicator 'X'
          i_wa_bposx-po_item       = i_ekpo-ebelp .
          i_wa_bposx-sched_line    = '0001' .
          i_wa_bposx-delivery_date = c_char_x .
          i_wa_bposx-quantity      = c_char_x .
          APPEND i_wa_bposx TO i_bposx .
          CLEAR: i_pargr .
          SELECT SINGLE pargr
            INTO i_pargr
            FROM t161
           WHERE bstyp = i_ekko-bstyp
             AND bsart = i_ekko-bsart .
          CLEAR i_ekpa[].
          CALL FUNCTION 'MM_READ_PARTNERS'
               EXPORTING
                    application = c_char_p
                    ebeln       = i_ebeln
                    bstyp       = i_ekko-bstyp
                    pargr       = i_pargr
               TABLES
                    x_ekpa      = i_ekpa.
          LOOP AT i_ekpa INTO i_wa_ekpa .
            i_wa_bpop-partnerdesc = i_wa_ekpa-parvw .
            i_wa_bpop-langu = sy-langu .
            IF NOT i_wa_ekpa-lifn2 IS INITIAL .
              i_wa_bpop-buspartno = i_wa_ekpa-lifn2 .
            ELSE .
              i_wa_bpop-buspartno = i_wa_ekpa-parnr .
            ENDIF .
            APPEND i_wa_bpop TO i_bpop .
            CLEAR: i_wa_ekpa, i_wa_bpop .
          ENDLOOP .
          CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.
          CALL FUNCTION 'BAPI_PO_CREATE1'
               EXPORTING
                    poheader         = i_bpoh
                    poheaderx        = i_bpohx
               IMPORTING
                    exppurchaseorder = i_new_ebeln
               TABLES
                    return           = i_bapiret2
                    poitem           = i_bpoi
                    poitemx          = i_bpoix
                    poschedule       = i_bpos
                    poschedulex      = i_bposx.
          i_order = i_new_ebeln .
          SHIFT i_order LEFT DELETING LEADING '0' .
          i_return-errortype = c_char_i .
          i_return-workarea  = c_zsw .
          i_return-message   = '064' .
          i_return-variable1 = i_order .
        loop at i_bapiret2 into i_bapiretn where type ca 'EAX' .
        append i_bapiretn to t_bapi_return .
      endloop .
      if t_bapi_return[] is initial .
         i_create_order = c_char_x .
           CALL FUNCTION 'SWD_POPUP_MESSAGE_SEND'
               EXPORTING
                    act_return = i_return. "Popup with new PO no.
      ENDCASE .                                     " Docind
    ENDIF .
  ENDLOOP.

Similar Messages

  • Drop ship purchase order creation using Pl/Sql code..

    Hi,
    We are creating the purchase order for drop ship orders.
    1. Created order with line source as external and then we ran the workflow backround processor which created a requisition for the order, using this requisition we are trying to create a purchase order with autocreate functionality by using PO_INTERFACE_S. Is this the way to create a drop ship po from backend.
    Can you please suggest any other way.
    Thanks in Advance.
    jagdish.

    Hi,
    You can customize the workflow such that it creates PO automatically, by selecting the attributes "Is PO Auto Creation Allowed?" to create PO after the requisition is created.
    Requisition Import will call PO Create Documents w/f to create PO.
    Plz get back to me if any clarification is needed.

  • PURCHASE ORDER CREATION USING ALE ( BAPI )...

    HI,
          I DESPERATELY NEED SOME ADVISE IN CREATING A PURCHASE ORDER USING ALE....I AM VERY NEW TO ALE SO CAN ANYONE EXPLAIN IN STEPS WHAT TO BE DONE IN DETAIL....PLS HELP ME OUT IN THIS REGARD....I WILL GET SOME DATA AS INBOUND IDOCS AND I NEED TO CREATE A PURCHASE ORDER USING ALE USING BAPI( BAPI_PO_CREATE1 ).......HOPING A QUICK REPLY ASAP.....

    Hi Gianluca,
    I need to do the same as per the original post and your answers gets me halfway there.  My remaining question is how to get the PO to output the PORDCR messgage on the outbound side (also a SAP system)?  Or do you have to output the PO as an ORDERS message and map that to the PORDCR message in something like XI or other middleware?
    Thanks for the help.
    Johan

  • Error in sales order creation using BAPI_SALESORDER_CREATEFROMDAT2

    Hi all,
    Pl look into below code :
    Here order is getting created , however  ship to party and sold to party  shows the same value.
    *& Report  ZSD_SALEORDCRE
    report  zsd_saleordcre.
    Order header:*
    - Order type: OR Important you must use the german code TA*
    - Sales org: 1000*
    - Distrb. chan.: 10*
    - Division: 00*
    - Sold to party: 1032*
    - Ship to party: 1032*
    - Purch order: DG-19970626-3*
    Order item:*
    - Material: P-100*
    - Qty: 1*
    data:
    Order partners*
    li_order_partners type standard table of bapiparnr,
    l_order_partners like bapiparnr,
    Structures for order header*
    l_order_header_in like bapisdhd1,
    l_order_header_inx like bapisdhd1x,
    Tables for order items*
    li_order_items_in type standard table of bapisditm,
    l_order_items_in like bapisditm,
    li_order_items_inx type standard table of bapisditmx,
    l_order_items_inx like bapisditmx,
    schedules*
    li_order_schedules_in type standard table of bapischdl,
    l_order_schedules_in like bapischdl,
    li_order_schedules_inx type standard table of bapischdl,
    l_order_schedules_inx like bapischdl,
    Return table from bapi call*
    li_return type standard table of bapiret2,
    l_return type bapiret2,
    Sales document number*
    l_vbeln like bapivbeln-vbeln,
    Error flag*
    l_errflag(1) type c.
    start-of-selection.
    Build partner information*
      clear l_order_partners.
      l_order_partners-partn_role = 'WE'. "Remember German codes !
      l_order_partners-partn_numb = '0000000101'.
      append l_order_partners to li_order_partners.
      l_order_partners-partn_role = 'SP'. "Remember German codes !
      l_order_partners-partn_numb = '0000000107'.
      append l_order_partners to li_order_partners.
    Build order header*
    Update flag*
      l_order_header_inx-updateflag = 'I'.
    Sales document type*
      l_order_header_in-doc_type = 'ZOD2'. "Remember German codes !
      l_order_header_inx-doc_type = 'X'.
    Sales organization*
      l_order_header_in-sales_org = '1100'.
      l_order_header_inx-sales_org = 'X'.
    Distribution channel*
      l_order_header_in-distr_chan = '20'.
      l_order_header_inx-distr_chan = 'X'.
    Division*
      l_order_header_in-division = '10'.
      l_order_header_inx-division = 'X'.
    Purchase order*
      l_order_header_in-purch_no_c  = 'DG-19970626-300'.
      l_order_header_inx-purch_no_c = 'X'.
      l_order_header_in-purch_date  = '20090817'.
      l_order_header_inx-purch_date = 'X'.
    Build order item(s) - Only 1 is used in this example*
      l_order_items_in-itm_number = '10'.
      l_order_items_inx-itm_number = 'X'.
      l_order_items_in-material = '29019501AA'.
      l_order_items_inx-material = 'X'.
      l_order_items_in-plant = 'WH03'.
      l_order_items_inx-plant = 'X'.
      append l_order_items_in to li_order_items_in.
      l_order_items_in-itm_number = '20'.
      l_order_items_inx-itm_number = 'X'.
      l_order_items_in-material = '29066641'.
      call function 'CONVERSION_EXIT_ALPHA_INPUT'
        exporting
          input  = l_order_items_in-material
        importing
          output = l_order_items_in-material.
      l_order_items_inx-material = 'X'.
      l_order_items_in-plant = 'WH03'.
      l_order_items_inx-plant = 'X'.
      append l_order_items_in to li_order_items_in.
      l_order_items_inx-updateflag = 'I'.
      append l_order_items_inx to li_order_items_inx.
      l_order_schedules_in-itm_number = '10'.
      l_order_schedules_in-req_qty = '10.00'.
      append l_order_schedules_in to li_order_schedules_in.
      l_order_schedules_in-itm_number = '20'.
      l_order_schedules_in-req_qty    = '20.00'.
      append l_order_schedules_in to li_order_schedules_in.
    CALL Bapi*
      call function 'BAPI_SALESORDER_CREATEFROMDAT2'
        exporting
          order_header_in    = l_order_header_in
          order_header_inx   = l_order_header_inx
          testrun            = ' '
        importing
          salesdocument      = l_vbeln
        tables
          return             = li_return
          order_items_in     = li_order_items_in
          order_items_inx    = li_order_items_inx
          order_partners     = li_order_partners
          order_schedules_in = li_order_schedules_in.
         order_schedules_inx = li_order_schedules_inx.*
    end-of-selection.
    Check and write Return table*
      clear l_errflag.
      write: / 'Sales dcoument: ', l_vbeln.
      loop at li_return into l_return.
        write: / l_return-type, l_return-message(50).
        if l_return-type = 'E'.
          l_errflag = 'X'.
        endif.
      endloop.
    No errors - Commit*
      if l_errflag is initial.
        call function 'BAPI_TRANSACTION_COMMIT'.
      endif.
    What could be problem ?
    Pl help
    Regards
    Nagarajan

    Hi,
    Go through this sample code
    LOOP AT t_salesorder INTO wa_salesorder.
      t_header-sales_org = wa_salesorder-vkorg.
      t_header-distr_chan = wa_salesorder-vtweg.
      t_header-division = wa_salesorder-spart.
      t_header-doc_type = wa_salesorder-auart.
      APPEND t_header.
      t_headerx-sales_org = 'X'.
      t_headerx-distr_chan = 'X'.
      t_headerx-division = 'X'.
      t_headerx-doc_type = 'X'.
      APPEND t_headerx.
      t_itemx-material = 'X'.
      t_itemx-target_qty = 'X'.
      APPEND t_itemx.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  = wa_salesorder-kunnr
        IMPORTING
          output = wa_alpha-kunnr.
      wa_partner-partn_role = 'AG'.
      wa_partner-partn_numb = wa_alpha-kunnr.
      APPEND wa_partner TO t_partner.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  = wa_salesorder-kunnr1
        IMPORTING
          output = wa_alpha-kunnr1.
      wa_partner-partn_role = 'WE'.
      wa_partner-partn_numb = wa_alpha-kunnr1.
      APPEND wa_partner TO t_partner.
      wa_item-po_itm_no = wa_salesorder-bstnk.
      wa_item-itm_number = wa_salesorder-posnr.
      wa_item-material = wa_salesorder-matnr.
    wa_item-target_qty = wa_salesorder-kwmeng.
      APPEND wa_item TO t_item.
        CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
          EXPORTING
            order_header_in  = t_header
            order_header_inx = t_headerx
          IMPORTING
            salesdocument    = gv_doc_no
          TABLES
            return           = t_return
            order_items_in   = t_item[]
            order_items_inx  = t_itemx
            order_partners   = t_partner[].
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait   = 'X'
        IMPORTING
          return = t_return.
    ENDLOOP.
    Please paste only the portion of your code that gives you trouble.

  • Error in purchase order creation

    Hi,
    While doing me21n systyem throwing error message.
    "purchase order unit  "TO" allows fewer decimal places only"
    i want to enter purchase order quantity as 100.200 Tonnes
    but system is not allow this quantity how to rectify this error.
    regards,
    mehboob

    Hi Mehboob,
    This is in configuration.
    Go to CUNI transaction code.
    Select TO unit of measure and change its decimal places.
    Please let me know if this works for you.
    Regards,
    Abhay Kapase

  • Error in sales order creation using bapi

    Hi,
    Iam trying to create sales order by using BAPI_SALESORDER_CREATEFROMDAT1 and when iam trying to execute
    the function module by passing all th eparameters and iam getting the error as
    inspite of entering sold_to_party and ship_to_party details in table ORDER_PARTNERS
    "enter the sold_to_party or ship to party details"
    please help me out in this isue its an urgent.
    Thanks.
    sayed.

    Can you share the codes ?
    Thanks.
    Ashish

  • Purchase Order creation using Contarct

    Hi,
    The refer the following scenario:
    We have created two company code 1000, 2000; both having diferenet Currency.
    We have created Plant 1000 under Company Code 1000 & Plant 2000 under Company Code 2000
    We want to create only one Purchase Organization 1000
    We want to create one contract for Purchase Organization 1000.
    Using the same Contract, we want to create Purchase Order for two different Plants 1000 & 2000.
    Is is advisable/ possibe to create Purchase Order for two different Plants 1000 & 2000 belonging to two different Company Codes having different Currency using common Purchase Organization?
    Regards,

    Hi,
    Thanks for the reply.
    I have created a Purchasing Org COMM.
    I have not assigned it to any Company Code
    When I am creating a Contract using ME31K, afer entrering Vendor, Agreement Type, Agreement Date, Purch. Organization & Purchasing Group, the System gives a pop-up with the following message:
    The purchasing org. COMM has not been assigned to a CoCode Please enter a company code
    What does it mean?
    As per my thinking, we can create the Contract for one company code, say 1000;
    Down the line, now we want to create Purchase Order for the Plant 2000, which is not assigned to Company Code 1000 --- Will the System allow us to do the same??
    Regards,

  • Purchase Order Creation using BAPI  BAPI_PO_CREATE1.

    Hi All,
    We are trying to create a pruchase order with the below line items.
    Example: 
    Line item            Material         Quantity        Price                 
    10                     MATNR1        1                    53   --> should be 59
    20                     MATNR1        1                    53  --> should be  59
    30                     MATNR1        1                    53  --> should be  59
    40                     MATNR1        1                    53 --> should be   59
    50                     MATNR1        4                    53 --> Correct price based on the quantity 4.
    In the above example as the total quantity is more than 4 ( consolidating the 5 line items ), the price for each line item is picked from the Info record  applying the scaling condition for  quantity 4. Standard SAP will consolidate the quantities based on Service material, Purchase Organization, Vendor and Plant and pick the price based on the scales from Info record.
    The expected out put is.
    Line item            Material         Quantity        Price                 
    10                     MATNR1        1                    59  
    20                     MATNR1        1                    59 
    30                     MATNR1        1                    59 
    40                     MATNR1        1                    59
    50                     MATNR1        4                    53
    Please help us in knowing on how to populate the bapi to get the Expected output.

    Hi All,
    We are trying to create a pruchase order with the below line items.
    Example: 
    Line item            Material         Quantity        Price                 
    10                     MATNR1        1                    53   --> should be 59
    20                     MATNR1        1                    53  --> should be  59
    30                     MATNR1        1                    53  --> should be  59
    40                     MATNR1        1                    53 --> should be   59
    50                     MATNR1        4                    53 --> Correct price based on the quantity 4.
    In the above example as the total quantity is more than 4 ( consolidating the 5 line items ), the price for each line item is picked from the Info record  applying the scaling condition for  quantity 4. Standard SAP will consolidate the quantities based on Service material, Purchase Organization, Vendor and Plant and pick the price based on the scales from Info record.
    The expected out put is.
    Line item            Material         Quantity        Price                 
    10                     MATNR1        1                    59  
    20                     MATNR1        1                    59 
    30                     MATNR1        1                    59 
    40                     MATNR1        1                    59
    50                     MATNR1        4                    53
    Please help us in knowing on how to populate the bapi to get the Expected output.

  • Error in sales order creation using FM IDOC_INPUT_ORDERS

    Hi experts,
    I am using  FM IDOC_INPUT_ORDERS for IDoc processing for creating sales order.
    I have added customized fields over VA03 screen and to VBAP table.
    I am using user exit EXIT_SAPLVEDA_001 for populating these additional fields.
    Here I am writing below code for customized segment:
      WHEN 'Z1EDP01'.
        x_Z1EDP01 = segment-sdata.
        xvbap-ZZNETWR   = x_Z1EDP01-ZZNETWR.
        xvbap-ZZTAX     = x_Z1EDP01-ZZTAX.
        xvbap-ZZGRSWR   = x_Z1EDP01-ZZGRSWR.
        Move-Corresponding xvbap to dxvbap.
    After this, sales order is getting created but these additional fields are not populated over the VA03 screen. Can you tell me whats wrong in code or any configuration error?
    Thanks,
    ~Sachin

    DXVBAP is an internal table for this exit, where do you modify the line of this itab. (can you post the code with the READ TABLE dxvbap and MODIFY wa/fs statements)
    ([Note 753153 - FAQ: Customer-functions in IDOC_INPUT_ORDERS|https://service.sap.com/sap/support/notes/753153])
    Regards,
    Raymond

  • Error during purchase order creation

    Hello friends;
    System gives following error when i adopt already created purchase requsition.
    "system error in routine F1_TAX_CHK_PRICING_DATA  error code 13 function builder TAX 2."
    Please  help to solve this error.
    Thanks in advance!!

    Dear,
    If you have access to OSS notes then please see:
    400766 Changes in accounting interface and 112609 How are tax codes transferred to condition
    Please check with FICO person.
    TAX Procedure for the countrry for which ur working should be properly maintained inside OBQ3,
    Regards,
    R.Brahmankar

  • Regarding purchase order creation using me21n

    Hi,
    I want to set default values for Purch. Org for a document type PO:Service-FREIGHT in me21n transsaction.
    which userexit or badi can be used for this?
    When a document type PO:Service-FREIGHT  is entered, Purch. Org should have deafualt value set automatically..
    Through 'Personal Settings' it is possible but it applies for all document type..& I need it for dot tytpe
    PO:Service-FREIGHT  .
    Thanks in advance...

    Hi
    Go to me21n transaction.
    click on personal setting icon.
    Once that is done -select default balues tab.
    And you can save the settings here.
    Check out this link:
    http://home.netlinc.org.uk/ContentStore/__Public/Documents/0022100/22147/C2-C4%20ME21N%20CREATE%20PERSONAL%20SETTINGS.pdf
    Regards
    Neha

  • Keep Original Position Numbers in Purchase Order Creation

    Hi community, i'm trying to solve the following problem in purchase order creation using BAPI_PO_CREATE1:
    I'm loading a file with several order numbers and positions to be created in R/3. This file has a structure similar to:
    OrderNumber;PositionNumber;Material;Quantity;Unit;.......
    The purchase order is created successfully, but i need to keep original position numbers in the order. i.e:
    Supposing this input file:
    1900;08;993322;10.00;KG.....
    1900;13;994455;12.00;KG.....
    the positions in purchase order are created as
    00010
    00020
    But i need positions to be created as:
    00008
    00013
    Any ideas?????
    Thanks you for your cooperation
    Leonardo

    Hi Leonardo,
       I doubt if that is possible.
    You can have the configuration set up to set the Item Number Interval to  step size like 5,10,15 etc,
    based on this value, your line item number will be
    5,10,15,20...
    10,20,30,40..
    15,30,45,60
    etc.
    to set this value, you should go to SPRO.
    Material Management->Purchase Order->Define Document Types
    Regards,
    Ravi Kanth Talagana

  • Getting errors when iam using  BAPI_PO_CREATE1 for Purchase Order creation

    Hi sap Gurus,
      I am getting Errors when iam using  BAPI_PO_CREATE1 for Purchase Order creation that Material (144) does not exist but it is alreardy maintained in MM01.
    I dont get how it is coming.and what are the mandatory fields in bapi BAPI_PO_CREATE1 in item level .that is too material only.
    pls let me know .
    thanks in advance.

    Hi,
    Check the sample code..
    report  zpo_test             .
    *DATA DECLARATION
    constants : c_x value 'X'.
    *Structures to hold PO header data
    data : header like bapimepoheader ,
    headerx like bapimepoheaderx .
    *Structures to hold PO account data
    data : account like bapimepoaccount occurs 0 with header line ,
    accountx like bapimepoaccountx occurs 0 with header line .
    *Internal Tables to hold PO ITEM DATA
    data : item like bapimepoitem occurs 0 with header line,
    itemx like bapimepoitemx occurs 0 with header line,
    *Internal table to hold messages from BAPI call
    return like bapiret2 occurs 0 with header line,
    *Internal table to hold messages from BAPI call
    pocontractlimits like bapiesucc occurs 0 with header line.
    data : w_header(40) value 'PO Header',
    purchaseorder like bapimepoheader-po_number,
    delivery_date like bapimeposchedule-delivery_date.
    data : ws_langu like sy-langu.
    *text-001 = 'PO Header' - define as text element
    selection-screen begin of block b1 with frame title text-001.
    parameters : company like header-comp_code default '122' ,
    doctyp like header-doc_type default 'NB' ,
    cdate like header-creat_date default sy-datum ,
    vendor like header-vendor default '2000000012' ,
    pur_org like header-purch_org default 'PU01' ,
    pur_grp like header-pur_group default '005' .
    *sociedad like HEADER-COMP_CODE default '122' ,
    *vendedor like HEADER-SALES_PERS default 'sale person'.
    selection-screen end of block b1.
    selection-screen begin of block b2 with frame title text-002.
    parameters : item_num like item-po_item default '00010',
    material like item-material default '12000000' ,
    tipo_imp like item-acctasscat default 'K' ,
    *pos_doc like ITEM-ITEM_CAT default 'F' ,
    shorttxt like item-short_text default 'PRUEBA BAPI' ,
    grup_art like item-matl_group default '817230000' ,
    plant like item-plant default '3001' ,
    mpe like item-trackingno default '9999' ,
    *contrato like ITEM-AGREEMENT default '4904000003' ,
    *quantity like ITEM-QUANTITY default 1 .
    po_unit like item-po_unit default 'EA'.
    selection-screen end of block b2.
    Par?mnetros de imputaci?n
    selection-screen begin of block b3 with frame title text-004.
    parameters : centro like account-costcenter default '1220813150',
    cuenta like account-gl_account default '6631400' ,
    num_pos like account-po_item default '10' ,
    serial like account-serial_no default '01' ,
    ind_imp like account-tax_code default 'I2' .
    selection-screen end of block b3.
    start-of-selection.
    *DATA POPULATION
      ws_langu = sy-langu. "Language variable
    *POPULATE HEADER DATA FOR PO
    *HEADER-COMP_CODE = sociedad .
      header-doc_type = doctyp .
      header-vendor = vendor .
      header-creat_date = cdate .
      header-created_by = 'TD17191' .
      header-purch_org = pur_org .
      header-pur_group = pur_grp .
      header-comp_code = company .
      header-langu = ws_langu .
    *HEADER-SALES_PERS = vendedor .
    *HEADER-CURRENCY = 'DOP' .
    *HEADER-ITEM_INTVL = 10 .
    *HEADER-PMNTTRMS = 'N30' .
    *HEADER-EXCH_RATE = 1 .
    *POPULATE HEADER FLAG.
      headerx-comp_code = c_x.
      headerx-doc_type = c_x.
      headerx-vendor = c_x.
      headerx-creat_date = c_x.
      headerx-created_by = c_x.
      headerx-purch_org = c_x.
      headerx-pur_group = c_x.
      headerx-langu = c_x.
    *HEADERX-sales_pers = c_x.
    *HEADERX-CURRENCY = c_x.
    *HEADER-ITEM_INTVL = c_x.
    *HEADER-PMNTTRMS = c_x.
    *HEADER-EXCH_RATE = c_x.
    *HEADER-EXCH_RATE = c_x.
    *POPULATE ITEM DATA.
      item-po_item = item_num.
      item-quantity = '1'.
    *ITEM-MATERIAL = material .
      item-short_text = 'prueba bapi_po_create1'.
    *ITEM-TAX_CODE = ''.
      item-acctasscat = 'K' .
    *ITEM-ITEM_CAT = 'D' .
      item-matl_group = '817230000' .
      item-plant = '3001' .
      item-trackingno = '99999'.
      item-preq_name = 'test'.
    *ITEM-AGREEMENT = '' .
    *ITEM-AGMT_ITEM = ''.
      item-quantity = '1' .
      item-po_unit = 'EA'.
    *ITEM-ORDERPR_UN = 'EA'.
      item-conv_num1 = '1'.
      item-conv_den1 = '1'.
      item-net_price = '1000000' .
      item-price_unit = '1'.
      item-gr_pr_time = '0'.
      item-prnt_price = 'X'.
      item-unlimited_dlv = 'X'.
      item-gr_ind = 'X' .
      item-ir_ind = 'X' .
      item-gr_basediv = 'X'.
    *ITEM-PCKG_NO = '' .
      append item. clear item.
    *POPULATE ITEM FLAG TABLE
      itemx-po_item = item_num.
      itemx-po_itemx = c_x.
    *ITEMX-MATERIAL = C_X.
      itemx-short_text = c_x.
      itemx-quantity = c_x.
    *ITEMX-TAX_CODE = C_X.
      itemx-acctasscat = c_x.
    *ITEMX-ITEM_CAT = c_x.
      itemx-matl_group = c_x.
      itemx-plant = c_x.
      itemx-trackingno = c_x.
      itemx-preq_name = c_x.
    *ITEMX-AGREEMENT = C_X.
    *ITEMX-AGMT_ITEM = c_x.
      itemx-stge_loc = c_x.
      itemx-quantity = c_x.
      itemx-po_unit = c_x.
    *ITEMX-ORDERPR_UN = C_X.
      itemx-conv_num1 = c_x.
      itemx-conv_den1 = c_x.
      itemx-net_price = c_x.
      itemx-price_unit = c_x.
      itemx-gr_pr_time = c_x.
      itemx-prnt_price = c_x.
      itemx-unlimited_dlv = c_x.
      itemx-gr_ind = c_x .
      itemx-ir_ind = c_x .
      itemx-gr_basediv = c_x .
      append itemx. clear itemx.
    *POPULATE ACCOUNT DATA.
      account-po_item = item_num.
      account-serial_no = serial .
      account-creat_date = sy-datum .
      account-costcenter = centro .
      account-gl_account = cuenta .
      account-gr_rcpt = 'tester'.
      append account. clear account.
    *POPULATE ACCOUNT FLAG TABLE.
      accountx-po_item = item_num .
      accountx-po_itemx = c_x .
      accountx-serial_no = serial .
      accountx-serial_nox = c_x .
      accountx-creat_date = c_x .
      accountx-costcenter = c_x .
      accountx-gl_account = c_x .
      account-gr_rcpt = c_x.
      append accountx. clear accountx.
    *BAPI CALL
      call function 'DIALOG_SET_NO_DIALOG'.
      call function 'BAPI_PO_CREATE1'
        exporting
          poheader         = header
          poheaderx        = headerx
        importing
          exppurchaseorder = purchaseorder
        tables
          return           = return
          poitem           = item
          poitemx          = itemx
          poaccount        = account
          poaccountx       = accountx.
    *Confirm the document creation by calling database COMMIT
      call function 'BAPI_TRANSACTION_COMMIT'
      exporting
      wait = 'X'
    IMPORTING
    RETURN =
    end-of-selection.
    *Output the messages returned from BAPI call
      loop at return.
        write / return-message.
      endloop.
    Regards
    Sudheer

  • TABLES USED IN PURCHASE ORDER CREATION

    Hi all,
    I want to know the tables used in purchase order creation header line.
    Those which are refereed by structure mepo_topline
    especially...
    mepo_topline-superfield
    MEPO_TOPLINE-ebeln etc.....
    Looking forward to hear from you all.
    regards,
    VKC

    hi,
    you can check in the include : MM06EFTO Form routine
    FORM mepo_get_topline USING ex_topline LIKE mepo_topline
    Its referring   MOVE-CORRESPONDING ekko TO ex_topline.
    so it is EKKO table.
    sometimes it refers to EKBE table also.
    Regds
    Sivaparvathi
    Please reward points if helpful..

  • Document is in transfer for purchase order.Creation not possible

    Dear All,
    We did partial confirmation in EBP and later when trying to do confiramtion for the remaining quantiy getting the message"document is in transfer for purchase order.Creation not possible"
    We are taking this problem in production as well as in quality systems also.
    What are possible reason and how to solve it.
    kindly share your views.
    Thank you.

    Hi yshu,
    use tcode bd87 in SRM to check for failed confirmation IDOC (type MBGMCR).
    The double click the status record to see the exact cause of the failure.
    Rectify the error. Then try to execute the IDOC from BD87 tcode.
    For a few errors you may not be able to execute the IDOC but to create a new confirmation in SRM. In such cases, follow the below procedure..
    There should be an entry for the confirmation in the transfer table BBP_DOCUMENT_TAB in SRM. Display the details.
    Then run FM "BBP_DELETE_FROM_DOCUMENT_TAB" to delete the entry from the doc tab table.
    Then post a new confirmation in SRM.
    There is also a FM in SRM using which you can change the status of thefailed IDOC from 51 to 68 or 31.
    Rgds,
    MJ

Maybe you are looking for