Using BAPI_PO_CREATE1

I would like use bapi to create po, once call the function, some warning occur,
"No instance of object type PurchaseOrder has been created. External reference:
Purchase order still contains faulty items
Can delivery date be met?"
Can i bypass the warning and generate a po document. Thanks!

** Program ID              :
** Program Desc            :              PO Creation Using BAPI
** Process Overview        :
** Created By              :              P.KARTHIKEYAN
** Created Date            :              25/10/2006
** Company Name            :              Infoview Technologies Limited
*& Report  ZBAPI_CREATE_PO                                             *
REPORT  ZBAPI_CREATE_PO                         .
*DATA DECLARATION
CONSTANTS : C_X VALUE 'X'.
*Structures to hold PO header data
DATA : HEADER LIKE  BAPIMEPOHEADER   ,
       HEADERX LIKE  BAPIMEPOHEADERX .
*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.
data : w_header(40) value 'PO Header'.
data : ws_langu like sy-langu.
data:  V_EXPPURCHASEORDER  like BAPIMEPOHEADER-PO_NUMBER.
*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 '1000'      ,
             doctyp  like HEADER-DOC_TYPE   default 'NB'        ,
             cdate   like HEADER-CREAT_DATE default sy-datum    ,
             vendor  like HEADER-VENDOR     default 'RAJ',
             pur_org like HEADER-PURCH_ORG  default '0001'      ,
             pur_grp like HEADER-PUR_GROUP  default '001'       .
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 '00020',
             material like ITEM-MATERIAL default 'M-127'   ,
             plant    like ITEM-PLANT    default '0001' ,
             quantity like ITEM-QUANTITY default 200.
selection-screen end of block b2.
**START-OF-SELECTION.
**DATA POPULATION
ws_langu = sy-langu.   "Language variable
*POPULATE HEADER DATA FOR PO
HEADER-COMP_CODE  = company    .
HEADER-DOC_TYPE   = doctyp     .
HEADER-CREAT_DATE = cdate      .
HEADER-VENDOR     = vendor     .
HEADER-LANGU      = ws_langu   .
HEADER-PURCH_ORG  = pur_org    .
HEADER-PUR_GROUP  = pur_grp    .
*POPULATE HEADER FLAG.
HEADERX-comp_code  = c_x.
HEADERX-doc_type   = c_x.
HEADERX-creat_date = c_x.
HEADERX-vendor     = c_x.
HEADERX-langu      = c_x.
HEADERX-purch_org  = c_x.
HEADERX-pur_group  = c_x.
*HEADERX-doc_date   = c_x.
*POPULATE ITEM DATA.
ITEM-PO_ITEM  = item_num.
ITEM-MATERIAL = material.
ITEM-PLANT    = plant.
ITEM-QUANTITY = quantity.
APPEND ITEM.
*POPULATE ITEM FLAG TABLE
ITEMX-PO_ITEM    = item_num.
ITEMX-MATERIAL   = C_X.
ITEMX-PLANT      = C_X .
*ITEMX-STGE_LOC   = C_X .
ITEMX-QUANTITY   = C_X .
*ITEMX-TAX_CODE   = C_X .
*ITEMX-ITEM_CAT   = C_X .
*ITEMX-ACCTASSCAT = C_X .
APPEND ITEMX.
*BAPI CALL
CALL FUNCTION 'BAPI_PO_CREATE1'
  EXPORTING
    POHEADER                     = HEADER
    POHEADERX                    = HEADERX
  POADDRVENDOR                 =
  TESTRUN                      =
IMPORTING
   EXPPURCHASEORDER             =   V_EXPPURCHASEORDER
  EXPHEADER                    =
  EXPPOEXPIMPHEADER            =
TABLES
   RETURN                       = RETURN
   POITEM                       = ITEM
   POITEMX                      = ITEMX.
*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 /  v_EXPPURCHASEORDER.
*ENDLOOP.

Similar Messages

  • Error  while creating a Service PO using BAPI_PO_CREATE1

    Hi,
    Im facing Error as "In case of account assignment, please enter acc. assignment data for item" while creating Service PO using BAPI_PO_CREATE1.
    Header Data
          w_poheader-comp_code = w_src-bukrs.  "Company Code
          w_poheader-doc_type = w_src-bsart.   "Document type
         w_poheader-delete_ind = w_src-vrtkz. "Deletion Indicator
          CLEAR: lv_date.
          CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
            EXPORTING
              date_external            = w_src-aedat
            IMPORTING
              date_internal            = lv_date
            EXCEPTIONS
              date_external_is_invalid = 1
              OTHERS                   = 2.
          w_poheader-creat_date = lv_date.    "Creation Date
          w_poheader-created_by = sy-uname.    "Creator Name
          w_poheader-vendor = w_src-lifnr.     "Vendor
          w_poheader-pmnttrms = w_src-zterm.   "Payment Terms
          w_poheader-purch_org = w_src-ekorg.  "Purchase Organization
          w_poheader-pur_group = w_src-ekgrp.  "Purchase Group
          w_poheader-ref_1    = w_src-ihrez.   "OLD PO
          w_poheaderx-comp_code = 'X'.  "Company Code
          w_poheaderx-doc_type = 'X'.   "Document type
         w_poheaderx-delete_ind = 'X'.      "Deletion Indicator
          w_poheaderx-creat_date = 'X'.    "Creation Date
          w_poheaderx-created_by = 'X'.
          w_poheaderx-vendor = 'X'.
          w_poheaderx-pmnttrms = 'X'.   "Payment Terms
          w_poheaderx-purch_org = 'X'.  "Purchase Organization
          w_poheaderx-pur_group = 'X'.  "Purchase Group
          w_poheaderx-ref_1 = 'X'.
    Item Data
          w_poitem-po_item = w_src-ebelp.
          IF NOT w_src-elikz IS INITIAL.
            w_poitem-delete_ind = w_src-elikz.
          ENDIF.
          IF NOT w_src-txz01 IS INITIAL.
            w_poitem-short_text = w_src-txz01.
          ENDIF.
          IF NOT w_src-werks IS INITIAL.
            w_poitem-plant = w_src-werks.
          ENDIF.
    Material group
          IF NOT w_src-matkl IS INITIAL.
            w_poitem-matl_group = w_src-matkl.
          ENDIF.
    Open or Partial Qty
          IF w_src-opqty IS  NOT INITIAL.
            w_poitem-quantity = w_src-opqty.
          ELSEIF NOT w_src-paqty IS INITIAL.
            w_poitem-quantity = w_src-paqty.
          ENDIF.
          IF NOT w_src-meins IS INITIAL.
            w_poitem-po_unit = w_src-meins. "Base Unit of Measure
          ENDIF.
          IF NOT w_src-netpr IS INITIAL.
            w_poitem-net_price = w_src-netpr.  "Net Price
          ENDIF.
          IF NOT w_src-mwskz IS INITIAL.
            w_poitem-tax_code = w_src-mwskz.
          ENDIF.
          IF NOT w_src-pstyp IS INITIAL.
            w_poitem-item_cat = w_src-pstyp.
          ENDIF.
          IF NOT w_src-knttp IS INITIAL.
            w_poitem-acctasscat = w_src-knttp.
          ENDIF.
          IF NOT w_src-vrtkz IS INITIAL.
            w_poitem-distrib = w_src-vrtkz.
          ENDIF.
    Package No
          IF NOT w_src-packno IS INITIAL.
            w_poitem-pckg_no = w_src-packno.  "Package no
          ENDIF.
          IF w_poitem-delete_ind IS INITIAL AND
             w_poitem-short_text IS INITIAL AND
             w_poitem-plant IS INITIAL AND
             w_poitem-matl_group IS INITIAL AND
             w_poitem-quantity IS INITIAL AND
             w_poitem-po_unit IS INITIAL AND
             w_poitem-net_price IS INITIAL AND
             w_poitem-tax_code IS INITIAL.
            CLEAR lv_item.
          ELSE.
            APPEND w_poitem TO i_poitem.
            CLEAR: w_poitem.
            lv_item = 'X'.
          ENDIF.
          w_poitemx-po_item = w_src-ebelp.
          w_poitemx-delete_ind = 'X'.
          w_poitemx-short_text = 'X'.
          w_poitemx-plant = 'X'.
          w_poitemx-matl_group = 'X'.
          w_poitemx-quantity = 'X'.
          w_poitemx-po_unit = 'X'.
          w_poitemx-net_price = 'X'.
          w_poitemx-tax_code = 'X'.
          w_poitemx-item_cat = 'X'.
          w_poitemx-acctasscat = 'X'.
          w_poitemx-distrib = 'X'.
          IF NOT w_src-packno IS INITIAL.
            w_poitemx-pckg_no = 'X'.
          ENDIF.
          IF lv_item = 'X'.
            APPEND w_poitemx TO i_poitemx.
            CLEAR: w_poitemx,
                   lv_item.
          ENDIF.
    PO Deliery Address
          w_poaddrdelivery-po_item = w_src-ebelp.
          IF NOT w_src-adrn2 IS INITIAL.
            w_poaddrdelivery-addr_no = w_src-adrn2.
            APPEND w_poaddrdelivery TO i_poaddrdelivery.
            CLEAR w_poaddrdelivery.
          ENDIF.
    POschedule
          w_poschedule-po_item = w_src-ebelp.
          CLEAR: lv_date.
          CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
            EXPORTING
              date_external            = w_src-eindt
            IMPORTING
              date_internal            = lv_date
            EXCEPTIONS
              date_external_is_invalid = 1
              OTHERS                   = 2.
          IF NOT lv_date IS INITIAL.
            w_poschedule-del_datcat_ext = 'D'. "Delivery Date in Day Format
            w_poschedule-delivery_date = lv_date.
            w_poschedule-quantity = w_src-menge.
            APPEND w_poschedule TO i_poschedule.
            CLEAR w_poschedule.
            lv_schd = 'X'.
          ENDIF.
          w_poschedulex-po_item = w_src-ebelp.
          w_poschedulex-del_datcat_ext = 'X'.
          w_poschedulex-delivery_date = 'X'.
          w_poschedulex-quantity = 'X'.
          IF lv_schd = 'X'.
            APPEND w_poschedulex TO i_poschedulex.
            CLEAR : w_poschedulex,
                    lv_schd.
          ENDIF.
    PO Account Assignment
          w_poaccount-po_item = w_src-ebelp.
          w_poaccount-serial_no = w_src-zekkn.
    Distribution Indicator is 1
          IF w_src-vrtkz EQ '1'.
            w_poaccount-distr_perc = w_src-vproz.
            IF NOT w_src-menge IS INITIAL.
              CLEAR lv_menge.
              lv_menge = w_src-menge.
            ENDIF.
            lv_acct_qty = lv_menge * w_src-vproz / 100.
    Get Round value of Quanity
            frac = FRAC( lv_acct_qty ).
            IF frac EQ 0.
              lv_acct_qty = FLOOR( lv_acct_qty ).
            ELSE.
              lv_acct_qty = CEIL( lv_acct_qty ).
            ENDIF.
            w_poaccount-quantity = lv_acct_qty.
          ELSEIF w_src-vrtkz IS INITIAL.
            w_poaccount-quantity = w_src-menge.
          ENDIF.
          w_poaccount-gl_account = w_src-saknr.
          w_poaccount-costcenter = w_src-kostl.
          w_poaccount-asset_no = w_src-anln1.
          w_poaccount-wbs_element = w_src-wbs.
          w_poaccount-network = w_src-nplnr.
          w_poaccount-tax_code = w_src-mwskz.
          w_poaccount-activity = w_src-vornr.
          APPEND w_poaccount TO i_poaccount.
          CLEAR w_poaccount.
          w_poaccountx-po_item = w_src-ebelp.
          w_poaccountx-serial_no = w_src-zekkn.
          IF w_src-vrtkz EQ '1'.
            w_poaccountx-distr_perc =  'X'.
          ENDIF.
          w_poaccountx-quantity = 'X'.
          w_poaccountx-gl_account = 'X'.
          w_poaccountx-costcenter = 'X'.
          w_poaccountx-wbs_element = 'X'.
          w_poaccountx-network = 'X'.
          w_poaccountx-tax_code = 'X'.
          w_poaccountx-activity = 'X'.
          APPEND w_poaccountx TO i_poaccountx.
          CLEAR w_poaccountx.
    PO Services
          w_poservices-pckg_no = w_src-packno.  "Package no
          w_poservices-line_no = w_src-srv_line_no.    "Line item
          w_poservices-ext_line = w_src-extrow.    "External line
         w_poservices-outl_level = 0.
         w_poservices-outl_ind = 'X'.
          w_poservices-subpckg_no = w_src-sub_packno.  "Sub package no
          w_poservices-quantity = w_src-srqty.  "Service Quantity
          w_poservices-base_uom = w_src-srmeins.  "Service Basic unit of Measure
          w_poservices-price_unit = '1'.
         w_poservices-from_line = '1'.
          w_poservices-gr_price  = w_src-brtwr.  "GR Price
          w_poservices-short_text = w_src-sh_text1.    "Service Short Text
         w_poservices-matl_group = w_src-matkl.  "Material Group
          APPEND w_poservices TO i_poservices.
          CLEAR w_poservices.
    PO Service Access values
          w_posrvacc-pckg_no = w_src-packno.  "Package no
          w_posrvacc-line_no = w_src-srv_line_no. "Line item
          w_posrvacc-serno_line = w_src-zekkn.                  "'01'..
          IF w_src-vproz IS INITIAL.
            w_posrvacc-percentage = '100.0'.
          ENDIF.
          w_posrvacc-serial_no = w_src-zekkn.                   "'01'.
          w_posrvacc-quantity = w_src-srqty.  "Service Quantity
          w_posrvacc-net_value = w_src-srqty.  "Net value
          APPEND w_posrvacc TO i_posrvacc.
          CLEAR w_posrvacc.
        ENDIF.
    ***Create a NEW PO
        AT END OF ihrez.
    Call BAPI
          CALL FUNCTION 'BAPI_PO_CREATE1'
            EXPORTING
              poheader          = w_poheader
              poheaderx         = w_poheaderx
            IMPORTING
              exppurchaseorder  = gv_ebeln
            TABLES
              return            = i_return
              poitem            = i_poitem[]
              poitemx           = i_poitemx[]
              poaddrdelivery    = i_poaddrdelivery[]
              poschedule        = i_poschedule[]
              poschedulex       = i_poschedulex[]
              poaccount         = i_poaccount[]
              poaccountx        = i_poaccountx[]
              poservices        = i_poservices[]
              posrvaccessvalues = i_posrvacc[]
              extensionin       = i_extensionin[].
    Commit the Transaction
          CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
           EXPORTING
             WAIT          = 'X'.
    Regards,
    Deepthi.

    1. If we get error as  "In case of account assignment, please enter acc. assignment data for item" than First cehck whetaher u have authorization to Tcode ME23n or not. In my case, I din't had authorization to Me23n tcode.
    2. If we get Error as "Please Mainatain Services or Limits". Please create a Service PO in the following Order.
    *& Internal Table Declaration
    DATA : i_intern         TYPE STANDARD TABLE OF alsmex_tabline WITH HEADER LINE,
           i_poitem         TYPE STANDARD TABLE OF bapimepoitem,
           i_poitemx        TYPE STANDARD TABLE OF bapimepoitemx,
           i_poaddrdelivery TYPE STANDARD TABLE OF bapimepoaddrdelivery,
           i_poschedule     TYPE STANDARD TABLE OF bapimeposchedule,
           i_poschedulex    TYPE STANDARD TABLE OF bapimeposchedulx,
           i_poaccount      TYPE STANDARD TABLE OF bapimepoaccount,
           i_poaccountx     TYPE STANDARD TABLE OF bapimepoaccountx,
           i_poservices     TYPE STANDARD TABLE OF bapiesllc,
           i_posrvacc       TYPE STANDARD TABLE OF bapiesklc,
           i_extensionin    TYPE STANDARD TABLE OF bapiparex,
           i_return         TYPE STANDARD TABLE OF bapiret2.
    *& Work Area Declaration
    DATA:
          w_poheader       TYPE bapimepoheader,
          w_poheaderx      TYPE bapimepoheaderx,
          w_poitem         TYPE bapimepoitem,
          w_poitemx        TYPE bapimepoitemx,
          w_poaddrdelivery TYPE bapimepoaddrdelivery,
          w_poschedule     TYPE bapimeposchedule,
          w_poschedulex    TYPE bapimeposchedulx,
          w_poaccount      TYPE bapimepoaccount,
          w_poaccountx     TYPE bapimepoaccountx,
          w_poservices     TYPE bapiesllc,
          w_posrvacc       TYPE bapiesklc,
          w_extensionin    TYPE bapiparex,
          w_return         TYPE bapiret2.
    START-OF-SELECTION.
    Header Data
      w_poheader-comp_code = '5791'.  "Company Code
      w_poheader-doc_type = 'Z0CM'.   "Document type
      w_poheader-creat_date = sy-datum.  "lv_date.    "Creation Date
      w_poheader-created_by = sy-uname.    "Creator Name
      w_poheader-vendor = '0005012343'.     "Vendor
      w_poheader-pmnttrms = 'Z004'.   "Payment Terms
      w_poheader-purch_org = 'P000'.  "Purchase Organization
      w_poheader-pur_group = '001'.  "Purchase Group
      w_poheader-ref_1    = '004500007671'.   "OLD PO
      w_poheaderx-comp_code = 'X'.  "Company Code
      w_poheaderx-doc_type = 'X'.   "Document type
      w_poheaderx-creat_date = 'X'.    "Creation Date
      w_poheaderx-created_by = 'X'.
      w_poheaderx-vendor = 'X'.
      w_poheaderx-pmnttrms = 'X'.   "Payment Terms
      w_poheaderx-purch_org = 'X'.  "Purchase Organization
      w_poheaderx-pur_group = 'X'.  "Purchase Group
      w_poheaderx-ref_1 = 'X'.
    Item Data
      w_poitem-po_item = '000010'.
      w_poitem-short_text = 'Z0CM - Default Appr. Test  '.
      w_poitem-plant = '5368'.
      Trackign no
      w_poitem-trackingno = ''.
    Material group
      w_poitem-matl_group = '119'.
      w_poitem-po_unit = 'EA'. "Base Unit of Measure
      w_poitem-net_price = '17500.00'.  "Net Price
      w_poitem-tax_code = 'I0'.
      w_poitem-item_cat = '9'.
      w_poitem-acctasscat = 'K'.
      w_poitem-distrib = space.
    Package must be given in item to create Service PO
      w_poitem-pckg_no = 0000000001.
      APPEND w_poitem TO i_poitem.
      CLEAR: w_poitem.
      w_poitemx-po_item = '000010'.
      w_poitemx-delete_ind = 'X'.
      w_poitemx-short_text = 'X'.
      w_poitemx-plant = 'X'.
      w_poitemx-trackingno = 'X'.
      w_poitemx-matl_group = 'X'.
      w_poitemx-quantity = 'X'.
      w_poitemx-po_unit = 'X'.
      w_poitemx-net_price = 'X'.
      w_poitemx-tax_code = 'X'.
      w_poitemx-item_cat = 'X'.
      w_poitemx-acctasscat = 'X'.
      w_poitemx-distrib = 'X'.
      w_poitemx-pckg_no = 'X'.
      APPEND w_poitemx TO i_poitemx.
      CLEAR: w_poitemx.
    PO Deliery Address
          w_poaddrdelivery-po_item = '000010'.
            w_poaddrdelivery-addr_no = '0000061208'.
            APPEND w_poaddrdelivery TO i_poaddrdelivery.
            CLEAR w_poaddrdelivery.
    POschedule
          w_poschedule-po_item = '000010'..
    DATA : LV_DATE TYPE SY-DATUM,
           lv_schd.
          CLEAR: lv_date.
          CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
            EXPORTING
              date_external            = '12/2/2009'
            IMPORTING
              date_internal            = lv_date
            EXCEPTIONS
              date_external_is_invalid = 1
              OTHERS                   = 2.
          IF NOT lv_date IS INITIAL.
            w_poschedule-del_datcat_ext = 'D'. "Delivery Date in Day Format
            w_poschedule-delivery_date = lv_date.
            w_poschedule-quantity = '1.000'.
            APPEND w_poschedule TO i_poschedule.
            CLEAR w_poschedule.
            lv_schd = 'X'.
          ENDIF.
          w_poschedulex-po_item = '000010'.
          w_poschedulex-del_datcat_ext = 'X'.
          w_poschedulex-delivery_date = 'X'.
          w_poschedulex-quantity = 'X'.
          IF lv_schd = 'X'.
            APPEND w_poschedulex TO i_poschedulex.
            CLEAR : w_poschedulex,
                    lv_schd.
          ENDIF.
    PO Account Assignment
      w_poaccount-po_item = '000010'.
      w_poaccount-serial_no = '01'.
      w_poaccount-distr_perc = ''.
      w_poaccount-quantity = '1.000'.
      w_poaccount-gl_account = '0000603064'.
      w_poaccount-costcenter = '0053680100'.
      w_poaccount-asset_no = ''.
      w_poaccount-wbs_element = ''.
      w_poaccount-network = ''.
      w_poaccount-tax_code = 'I0'.
      w_poaccount-activity = ''.
      APPEND w_poaccount TO i_poaccount.
      CLEAR w_poaccount.
      w_poaccountx-po_item = '000010'.
      w_poaccountx-serial_no = '01'.
      w_poaccountx-distr_perc =  'X'.
      w_poaccountx-quantity = 'X'.
      w_poaccountx-gl_account = 'X'.
      w_poaccountx-costcenter = 'X'.
      w_poaccountx-wbs_element = 'X'.
      w_poaccountx-network = 'X'.
      w_poaccountx-tax_code = 'X'.
      w_poaccountx-activity = 'X'.
      w_poaccountx-cmmt_item = 'X'.
      APPEND w_poaccountx TO i_poaccountx.
      CLEAR w_poaccountx.
    Extension for ZZSub
      w_extensionin-structure = 'BAPI_TE_MEPOACCOUNTING'.
      w_extensionin-valuepart1+0(5) = '00010'..
      w_extensionin-valuepart1+5(2) = '01'.
      w_extensionin-valuepart1+28(5) = ''.
      APPEND w_extensionin TO i_extensionin.
      CLEAR w_extensionin.
      w_extensionin-structure = 'BAPI_TE_MEPOACCOUNTINGX'.
      w_extensionin-valuepart1+0(5) = '00010'.
      w_extensionin-valuepart1+5(2) = '01'.
      w_extensionin-valuepart1+11(1) = 'X'.
      APPEND w_extensionin TO i_extensionin.
      CLEAR w_extensionin.
    Extension to add Expense Type only
      w_extensionin-structure = 'BAPI_TE_MEPOHEADER'.
      w_extensionin-valuepart1+10(4) = '0131'.
      APPEND w_extensionin TO i_extensionin.
      CLEAR w_extensionin.
      w_extensionin-structure = 'BAPI_TE_MEPOHEADERX'.
      w_extensionin-valuepart1+10(4) = 'X'.
      APPEND w_extensionin TO i_extensionin.
      CLEAR w_extensionin.
      EXPORT i_extensionin[] TO MEMORY ID 'SUB'.
    PO Services
    PO Services( One Line Iem)
    Assign the dummy no as Pacakage no
      w_poservices-pckg_no = 0000000001.  "(assign package no as a dummy number)
      w_poservices-line_no = 0000000001.      "Line item
      w_poservices-outl_ind = 'X'.
    Assign Dummy no as sub package no
      w_poservices-subpckg_no = 0000000003.   "(Dummy No.) "Sub package no
      w_poservices-from_line = '1'.
      APPEND w_poservices TO i_poservices.
      CLEAR w_poservices.
    PO Services(Second Line Item )
    Assign the same sub package dummy no which is mentioned above
      w_poservices-pckg_no = 0000000003.   "(Dummy No.) "Sub package no
      w_poservices-line_no = 0000000002.
      w_poservices-ext_line = '0000000010'.     "External line
      w_poservices-quantity = '17500.0'.    "Service Quantity
      w_poservices-base_uom = 'EA'.    "Service Basic unit of Measure
      w_poservices-price_unit = '1'.
      w_poservices-gr_price  = '1'.    "GR Price
      w_poservices-short_text = 'Z0CM - Default Appr. T'.      "Service Short Text
    w_poservices-matl_group = '119'.  "w_src-matkl.  "Material Group
      APPEND w_poservices TO i_poservices.
      CLEAR w_poservices.
    PO Service Access values
      w_posrvacc-pckg_no = 0000000003.  "w_src-sub_packno.  "Sub package no
      w_posrvacc-line_no = 0000000002.  "w_src-srv_line_no. "Line item
      w_posrvacc-serno_line = '01'.
      w_posrvacc-percentage = '100.0'.
      w_posrvacc-serial_no = '01'.
      w_posrvacc-quantity = '17500.0'.  "w_src-srqty.  "Service Quantity
      APPEND w_posrvacc TO i_posrvacc.
      CLEAR w_posrvacc.
      DATA : gv_ebeln TYPE ebeln.
    Call BAPI
      CALL FUNCTION 'BAPI_PO_CREATE1'
        EXPORTING
          poheader          = w_poheader
          poheaderx         = w_poheaderx
        IMPORTING
          exppurchaseorder  = gv_ebeln
        TABLES
          return            = i_return
          poitem            = i_poitem[]
          poitemx           = i_poitemx[]
          poaddrdelivery    = i_poaddrdelivery[]
          poschedule        = i_poschedule[]
          poschedulex       = i_poschedulex[]
          poaccount         = i_poaccount[]
          poaccountx        = i_poaccountx[]
          poservices        = i_poservices[]
          posrvaccessvalues = i_posrvacc[]
          extensionin       = i_extensionin[].
    Commit the Transaction
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait = 'X'.
      WRITE:/5 gv_ebeln COLOR 5.
      SKIP 2.
      DATA : lv_msg TYPE string.
      LOOP AT i_return INTO w_return WHERE type = 'E'.
        CALL FUNCTION 'FORMAT_MESSAGE'
          EXPORTING
            id        = w_return-id
            lang      = 'EN'
            no        = w_return-number
            v1        = w_return-message_v1
            v2        = w_return-message_v2
            v3        = w_return-message_v3
            v4        = w_return-message_v4
          IMPORTING
            msg       = lv_msg
          EXCEPTIONS
            not_found = 1
            OTHERS    = 2.
        WRITE:/10 lv_msg.
      ENDLOOP.

  • 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.

  • Service PO for Multiple Acct Assig is not created using BAPI_PO_CREATE1

    Hi,
    Im unable to create the Service po with multiple acct assiignment using BAPI_PO_CREATE1
    Header Data
          w_poheader-comp_code = w_src-bukrs.  "Company Code
          w_poheader-doc_type = w_src-bsart.   "Document type
         w_poheader-delete_ind = w_src-vrtkz. "Deletion Indicator
          CLEAR: lv_date.
          CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
            EXPORTING
              date_external            = w_src-aedat
            IMPORTING
              date_internal            = lv_date
            EXCEPTIONS
              date_external_is_invalid = 1
              OTHERS                   = 2.
          w_poheader-creat_date = lv_date.    "Creation Date
          w_poheader-created_by = sy-uname.    "Creator Name
          w_poheader-vendor = w_src-lifnr.     "Vendor
          w_poheader-pmnttrms = w_src-zterm.   "Payment Terms
          w_poheader-purch_org = w_src-ekorg.  "Purchase Organization
          w_poheader-pur_group = w_src-ekgrp.  "Purchase Group
          w_poheader-ref_1    = w_src-ihrez.   "OLD PO
          w_poheaderx-comp_code = 'X'.  "Company Code
          w_poheaderx-doc_type = 'X'.   "Document type
         w_poheaderx-delete_ind = 'X'.      "Deletion Indicator
          w_poheaderx-creat_date = 'X'.    "Creation Date
          w_poheaderx-created_by = 'X'.
          w_poheaderx-vendor = 'X'.
          w_poheaderx-pmnttrms = 'X'.   "Payment Terms
          w_poheaderx-purch_org = 'X'.  "Purchase Organization
          w_poheaderx-pur_group = 'X'.  "Purchase Group
          w_poheaderx-ref_1 = 'X'.
    Item Data
          w_poitem-po_item = w_src-ebelp.
          IF NOT w_src-elikz IS INITIAL.
            w_poitem-delete_ind = w_src-elikz.
          ENDIF.
          IF NOT w_src-txz01 IS INITIAL.
            w_poitem-short_text = w_src-txz01.
          ENDIF.
          IF NOT w_src-werks IS INITIAL.
            w_poitem-plant = w_src-werks.
          ENDIF.
    Material group
          IF NOT w_src-matkl IS INITIAL.
            w_poitem-matl_group = w_src-matkl.
          ENDIF.
    Open or Partial Qty
          IF w_src-opqty IS  NOT INITIAL.
            w_poitem-quantity = w_src-opqty.
          ELSEIF NOT w_src-paqty IS INITIAL.
            w_poitem-quantity = w_src-paqty.
          ENDIF.
          IF NOT w_src-meins IS INITIAL.
            w_poitem-po_unit = w_src-meins. "Base Unit of Measure
          ENDIF.
          IF NOT w_src-netpr IS INITIAL.
            w_poitem-net_price = w_src-netpr.  "Net Price
          ENDIF.
          IF NOT w_src-mwskz IS INITIAL.
            w_poitem-tax_code = w_src-mwskz.
          ENDIF.
          IF NOT w_src-pstyp IS INITIAL.
            w_poitem-item_cat = w_src-pstyp.
          ENDIF.
          IF NOT w_src-knttp IS INITIAL.
            w_poitem-acctasscat = w_src-knttp.
          ENDIF.
          w_src-vrtkz = '2'.    "Added
          IF NOT w_src-vrtkz IS INITIAL.
            w_poitem-distrib = w_src-vrtkz.
          ENDIF.
    Package No
          IF w_src-srv_line_no EQ '2'.
            w_poitem-pckg_no = 0000000001. "Assign dummy package no "w_src-packno.  "Package no
          ELSEIF w_src-srv_line_no EQ '3'.
            w_poitem-pckg_no = 0000000004. "Assign dummy package no "w_src-packno.  "Package no
          ENDIF.
          IF w_poitem-delete_ind IS INITIAL AND
             w_poitem-short_text IS INITIAL AND
             w_poitem-plant IS INITIAL AND
             w_poitem-matl_group IS INITIAL AND
             w_poitem-quantity IS INITIAL AND
             w_poitem-po_unit IS INITIAL AND
             w_poitem-net_price IS INITIAL AND
             w_poitem-tax_code IS INITIAL.
            CLEAR lv_item.
          ELSE.
            APPEND w_poitem TO i_poitem.
            CLEAR: w_poitem.
            lv_item = 'X'.
          ENDIF.
          w_poitemx-po_item = w_src-ebelp.
          w_poitemx-delete_ind = 'X'.
          w_poitemx-short_text = 'X'.
          w_poitemx-plant = 'X'.
          w_poitemx-matl_group = 'X'.
          w_poitemx-quantity = 'X'.
          w_poitemx-po_unit = 'X'.
          w_poitemx-net_price = 'X'.
          w_poitemx-tax_code = 'X'.
          w_poitemx-item_cat = 'X'.
          w_poitemx-acctasscat = 'X'.
          w_poitemx-distrib = 'X'.
          w_poitemx-pckg_no = 'X'.
          IF lv_item = 'X'.
            APPEND w_poitemx TO i_poitemx.
            CLEAR: w_poitemx,
                   lv_item.
          ENDIF.
    PO Deliery Address
          w_poaddrdelivery-po_item = w_src-ebelp.
          IF NOT w_src-adrn2 IS INITIAL.
            w_poaddrdelivery-addr_no = w_src-adrn2.
            APPEND w_poaddrdelivery TO i_poaddrdelivery.
            CLEAR w_poaddrdelivery.
          ENDIF.
    POschedule
          w_poschedule-po_item = w_src-ebelp.
       w_poschedule-SCHED_LINE = w_src-
          CLEAR: lv_date.
          CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
            EXPORTING
              date_external            = w_src-eindt
            IMPORTING
              date_internal            = lv_date
            EXCEPTIONS
              date_external_is_invalid = 1
              OTHERS                   = 2.
          IF NOT lv_date IS INITIAL.
            w_poschedule-del_datcat_ext = 'D'. "Delivery Date in Day Format
            w_poschedule-delivery_date = lv_date.
            w_poschedule-quantity = w_src-menge.
            APPEND w_poschedule TO i_poschedule.
            CLEAR w_poschedule.
            lv_schd = 'X'.
          ENDIF.
          w_poschedulex-po_item = w_src-ebelp.
       w_poschedule-SCHED_LINE = 'X'.
          w_poschedulex-del_datcat_ext = 'X'.
          w_poschedulex-delivery_date = 'X'.
          w_poschedulex-quantity = 'X'.
          IF lv_schd = 'X'.
            APPEND w_poschedulex TO i_poschedulex.
            CLEAR : w_poschedulex,
                    lv_schd.
          ENDIF.
    PO Account Assignment
          w_poaccount-po_item = w_src-ebelp.
          w_poaccount-serial_no = w_src-zekkn.
    Distribution Indicator is 1
          IF w_src-vrtkz EQ '1'.
            w_poaccount-distr_perc = w_src-vproz.
            IF NOT w_src-menge IS INITIAL.
              CLEAR lv_menge.
              lv_menge = w_src-menge.
            ENDIF.
            lv_acct_qty = lv_menge * w_src-vproz / 100.
    Get Round value of Quanity
            frac = FRAC( lv_acct_qty ).
            IF frac EQ 0.
              lv_acct_qty = FLOOR( lv_acct_qty ).
            ELSE.
              lv_acct_qty = CEIL( lv_acct_qty ).
            ENDIF.
            w_poaccount-quantity = lv_acct_qty.
          ELSEIF w_src-vrtkz IS INITIAL.
            w_poaccount-quantity = w_src-menge.
          ENDIF.
      w_poaccount-quantity = w_src-menge.    "added
          w_poaccount-gl_account = w_src-saknr.
          w_poaccount-costcenter = w_src-kostl.
          w_poaccount-asset_no = w_src-anln1.
          w_poaccount-wbs_element = w_src-wbs.
          w_poaccount-network = w_src-nplnr.
          w_poaccount-tax_code = w_src-mwskz.
          w_poaccount-activity = w_src-vornr.
          APPEND w_poaccount TO i_poaccount.
          CLEAR w_poaccount.
          w_poaccountx-po_item = w_src-ebelp.
          w_poaccountx-serial_no = w_src-zekkn.
          IF w_src-vrtkz EQ '1'.
            w_poaccountx-distr_perc =  'X'.
          ENDIF.
          w_poaccountx-quantity = 'X'.
          w_poaccountx-gl_account = 'X'.
          w_poaccountx-costcenter = 'X'.
          w_poaccountx-wbs_element = 'X'.
          w_poaccountx-network = 'X'.
          w_poaccountx-tax_code = 'X'.
          w_poaccountx-activity = 'X'.
          w_poaccountx-cmmt_item = 'X'.
          APPEND w_poaccountx TO i_poaccountx.
          CLEAR w_poaccountx.
    Extension for ZZSub
          IF NOT w_src-zzsub IS INITIAL.
            w_extensionin-structure = 'BAPI_TE_MEPOACCOUNTING'.
            w_extensionin-valuepart1+0(5) = w_src-ebelp.
            w_extensionin-valuepart1+5(2) = '01'.
            w_extensionin-valuepart1+28(5) = w_src-zzsub.
            APPEND w_extensionin TO i_extensionin.
            CLEAR w_extensionin.
            w_extensionin-structure = 'BAPI_TE_MEPOACCOUNTINGX'.
            w_extensionin-valuepart1+0(5) = w_src-ebelp.
            w_extensionin-valuepart1+5(2) = '01'.
            w_extensionin-valuepart1+11(1) = 'X'.
            APPEND w_extensionin TO i_extensionin.
            CLEAR w_extensionin.
          ENDIF.
    Extension to add Expense Type only
          IF NOT  w_src-zzexptype IS INITIAL.
            w_extensionin-structure = 'BAPI_TE_MEPOHEADER'.
            w_extensionin-valuepart1+10(4) = w_src-zzexptype.
            APPEND w_extensionin TO i_extensionin.
            CLEAR w_extensionin.
            w_extensionin-structure = 'BAPI_TE_MEPOHEADERX'.
            w_extensionin-valuepart1+10(4) = 'X'.
            APPEND w_extensionin TO i_extensionin.
            CLEAR w_extensionin.
          ENDIF.
          EXPORT i_extensionin[] TO MEMORY ID 'SUB'.
    PO Services( One Line Iem)
          IF w_src-srv_line_no EQ '2'.
            w_poservices-pckg_no = 0000000001.  "w_src-packno. "(assign package no as a dummy number)
            w_poservices-line_no = 0000000001.  "w_src-srv_line_no.    "Line item
            w_poservices-outl_ind = 'X'.
            w_poservices-subpckg_no = 0000000003.  "w_src-sub_packno. "(Dummy No.) "Sub package no
         w_poservices-quantity = w_src-srqty.  "Service Quantity
         w_poservices-base_uom = w_src-srmeins.  "Service Basic unit of Measure
         w_poservices-price_unit = '1'.
            w_poservices-from_line = '1'.
         w_poservices-gr_price  = w_src-brtwr.  "GR Price
         w_poservices-short_text = w_src-sh_text1.    "Service Short Text
            APPEND w_poservices TO i_poservices.
            CLEAR w_poservices.
    PO Services(Second Line Item )
            w_poservices-pckg_no = 0000000003.  "w_src-sub_packno. "(Dummy No.) "Sub package no
            w_poservices-line_no = 0000000002.
            w_poservices-ext_line = w_src-extrow.    "External line
            w_poservices-quantity = w_src-srqty.  "Service Quantity
            w_poservices-base_uom = w_src-srmeins.  "Service Basic unit of Measure
            w_poservices-price_unit = '1'.
            w_poservices-gr_price  = w_src-brtwr.  "GR Price
            w_poservices-short_text = w_src-sh_text1.    "Service Short Text
            APPEND w_poservices TO i_poservices.
            CLEAR w_poservices.
    PO Service Access values
            w_posrvacc-pckg_no = 0000000003.  "w_src-sub_packno.  "Sub package no
            w_posrvacc-line_no = 0000000002.  "w_src-srv_line_no. "Line item
            w_posrvacc-serno_line = w_src-zekkn.                "'01'.
            IF w_src-vproz IS INITIAL.
              w_posrvacc-percentage = '100.0'.
            ENDIF.
            w_posrvacc-serial_no = '01'.
            w_posrvacc-quantity = w_src-srqty.  "Service Quantity
            APPEND w_posrvacc TO i_posrvacc.
            CLEAR w_posrvacc.
          ELSEIF w_src-srv_line_no EQ '3'.
    PO Services
            if w_src-srv_line_no EQ '2'.
            w_poservices-pckg_no = 0000000004.  "(assign package no as a dummy number)
            w_poservices-line_no = 0000000001.  "Line item
            w_poservices-outl_ind = 'X'.
            w_poservices-subpckg_no = 0000000005.  "(Dummy No.) "Sub package no
            w_poservices-from_line = '1'.
            APPEND w_poservices TO i_poservices.
            CLEAR w_poservices.
            w_poservices-pckg_no = 0000000005.  "w_src-sub_packno. "(Dummy No.) "Sub package no
            w_poservices-line_no = 0000000002.
            w_poservices-ext_line = w_src-extrow.    "External line
            w_poservices-quantity = w_src-srqty.  "Service Quantity
            w_poservices-base_uom = w_src-srmeins.  "Service Basic unit of Measure
            w_poservices-price_unit = '1'.
            w_poservices-gr_price  = w_src-brtwr.  "GR Price
            w_poservices-short_text = w_src-sh_text1.    "Service Short Text
            APPEND w_poservices TO i_poservices.
            CLEAR w_poservices.
            endif.
            if  w_src-srv_line_no EQ '3'.
            w_poservices-pckg_no = 0000000005.  "w_src-sub_packno. "(Dummy No.) "Sub package no
            w_poservices-line_no = 0000000003.
            w_poservices-ext_line = w_src-extrow.    "External line
            w_poservices-quantity = w_src-srqty.  "Service Quantity
            w_poservices-base_uom = w_src-srmeins.  "Service Basic unit of Measure
            w_poservices-price_unit = '1'.
            w_poservices-gr_price  = w_src-brtwr.  "GR Price
            w_poservices-short_text = w_src-sh_text1.    "Service Short Text
            APPEND w_poservices TO i_poservices.
            CLEAR w_poservices.
            endif.
    PO Service Access values
           if  w_src-srv_line_no EQ '2'.
            w_posrvacc-pckg_no = 0000000005.  "w_src-sub_packno.  "Sub package no
            w_posrvacc-line_no = 0000000002.  "w_src-srv_line_no. "Line item
            w_posrvacc-serno_line = '01'.
            w_posrvacc-percentage = '100.0'.
            w_posrvacc-serial_no = '01'.    "w_src-zekkn.
            w_posrvacc-quantity = w_src-srqty.  "Service Quantity
            APPEND w_posrvacc TO i_posrvacc.
            CLEAR w_posrvacc.
            endif.
            if  w_src-srv_line_no EQ '3'.
            w_posrvacc-pckg_no = 0000000005.  "w_src-sub_packno.  "Sub package no
            w_posrvacc-line_no = 0000000003.  "w_src-srv_line_no. "Line item
            w_posrvacc-serno_line = '01'.
            w_posrvacc-percentage = '100.0'.
            w_posrvacc-serial_no = '02'.  "w_src-zekkn.  "'01'.
            w_posrvacc-quantity = w_src-srqty.  "Service Quantity
            APPEND w_posrvacc TO i_posrvacc.
            CLEAR w_posrvacc.
            endif.
          ENDIF.
        ENDIF.
    ***Create a NEW PO
    Call BAPI
          CALL FUNCTION 'BAPI_PO_CREATE1'
            EXPORTING
              poheader          = w_poheader
              poheaderx         = w_poheaderx
              TESTRUN           = ' '
            IMPORTING
              exppurchaseorder  = gv_ebeln
            TABLES
              return            = i_return
              poitem            = i_poitem[]
              poitemx           = i_poitemx[]
              poaddrdelivery    = i_poaddrdelivery[]
              poschedule        = i_poschedule[]
              poschedulex       = i_poschedulex[]
              poaccount         = i_poaccount[]
              poaccountx        = i_poaccountx[]
              poservices        = i_poservices[]
              posrvaccessvalues = i_posrvacc[]
              extensionin       = i_extensionin[].
    Commit the Transaction
          CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
            EXPORTING
              wait = 'X'.
    Regards,
    Deepthi.

    it is solved

  • Short dump while using BAPI_PO_CREATE1

    Hi all,
    I am facing this short dump while executing my program that uses BAPI_PO_CREATE1.
    The error is 'Exception condition "failure" raised'.
    The trigger location of runtime error is
    Program : CL_HANDLE_MANAGER_MM====================CP
    Include:   CL_HANDLE_MANAGER_MM=====================CM005
    Module name:   GET
    Source code:
    Method GET.
    If my_manager is initial.
        Call method get_manager.
    endif.
    call method my_manager-> search EXporting im_id  = im_id
                                                            Importing ex_handle = ex_handle
                                                            Exceptions failure = 01.
    If sy-subrc <>0.
      raise failure.
    endif.
    I am a beginner in ABAP. Plz help.

    Hi ,
    I faced the similar situation once , in my case when i passed the Delivery indicator value in the Item Table as well as Itemx Table , i was facing this error .
    what  i suggest you is to pass it at the Item table only , not at the itemx Table.
    it worked  for me .
    try this and reply for the same.

  • Creating Service PO using BAPI_PO_CREATE1

    Hi gurus,
    I am trying to create a PO with service lines using BAPI_PO_CREATE1 but am getting the following errror even though i have passed values to the structures POSERVICES POSRVACCESSVALUES and POACCOUNT along with item and header details:
    Please maintain services or limits
    Please suggest what are the basic details that need to be passed to the structures for creating a PO with service lines.

    Hi,
    You need to use Package Number to link the services with the item. Check the tables like ESKN to know how the linking works with your existing data.
    There are lot of posts related to this. Please do a search to get detailed answers. Thanks for your patience!!
    Regards,
    Yogesh

  • Creation of invoicing plan while creating the PO using BAPI_PO_CREATE1

    Hi, basically I'm creating a PO using BAPI_PO_CREATE1 and then creating Invoicing plan thru ME22 using BDC.
    Could anyone please help me if there is any possibility of creation of invoicing plan while creating the PO itself using BAPI_PO_CREATE1.
    thanks in advance.

    Hi,
    Have you tried filling up the invoicing plan related tables of the bapi ?
    *"      INVPLANHEADER STRUCTURE  BAPI_INVOICE_PLAN_HEADER OPTIONAL
    *"      INVPLANHEADERX STRUCTURE  BAPI_INVOICE_PLAN_HEADERX OPTIONAL
    *"      INVPLANITEM STRUCTURE  BAPI_INVOICE_PLAN_ITEM OPTIONAL
    *"      INVPLANITEMX STRUCTURE  BAPI_INVOICE_PLAN_ITEMX OPTIONAL
    Regards.

  • Creation of PO using BAPI_PO_CREATE1 without info record

    Hi,
    I am making a  progrma to create the PO using BAPI_PO_CREATE1 but for the materials for which info record is create din the system it is creating the PO properly but for the materials for which info record is no there even I am giving the Price and tax cod ein th eBAPI item table system is not creating th PO,  so is info record mandatory for this.
    regards,
    zafar

    Hi,
    I have use the BAPI as per given note ref.  I am taking the PO price from Info record for this I am not giving the item price in the BAPI items,  but I want that  the header discount should from the user input,  but when I ma giving the header discount codnition  system is giving error   PO header fault,   but along with this  If i given the items value to in the net price then it is creating the PO,  so is it possible to get the items value from the info record and header codnition discount value from user input, we dont want to maintain discount at info record.
    regards,
    zafar

  • PO item characteristic using BAPI_PO_CREATE1

    Dear All,
    I am uploading open purchase order using BAPI_PO_CREATE1. everything is working fine. but for Semi-finished products i have to upload Individual length. i.e. in characterstics of purchase order item.
    kindly help

    Hi
    Please go through the documentation in SE37 for the FM.. It is very clear on how you need to work on this BAPI. It is given with examples.
    Regards,
    Vishwa.

  • PO Upload using BAPI_PO_CREATE1

    Hello All,
    I m developing PO upload program using BAPI_PO_CREATE1.
    It gives me massages like this:
    Error transferring ExtensionIn data for enhancement CI_EKPODB.
    PO held under the number 4800000109.
    But no PO exists. Include CI_EKPODB contains one Quan and four Char fields.
    Please tell me how to resolve this issue.
    Regards
    Nadeem

    Hi
    check this code
    Program : ZGMIMM_ME21.
    Transaction Code :
    Description : BDC for Purchase order
    report zgmimm_me21 no standard page heading line-size 255.
    tables: t100.
    type-pools: truxs.
    types: begin of i_upload,
            lifnr    like ekko-lifnr,         "Vendor Number
            bukrs    like ekko-bukrs,         "Order type
            bedat    like ekko-bedat,         "Purchase Order Date
            ekorg    like ekko-ekorg,         "Purchasing organization
            ausnr    like ekko-ausnr,         "Purchase order
            ekgrp    like ekko-ekgrp,         "Purchasing group
            eddat    like ekko-bedat,         "Delivery date
            werks    like ekpo-werks,         "Plant
            lgort    like ekpo-lgort,         "Storage location
            zterm    like ekko-zterm,         "Payment terms
            ematn    like ekpo-ematn,         "Material
            menge    like ekpo-menge,         "PO Quantity
            lewed    like ekpo-lewed,          "Latest GR Date
          end of i_upload.
    data: begin of i_input occurs 0,
          pbg(10) type c,
          bldat(07) type c,         "001
         BLDAT like BKPF-BUDAT,
          hkont(10) type c,
          kostl(10) type c,
          wrbtr(11) type c,
          dbcrflag(01) type c,
           sgtxt(32) type c,
       end of i_input.
    data: v_counter(2) type n.
    data: v_mod        type i.
    data: v_ebelp      like ekpo-ebelp.
    data: v_fname(132) type c.
    data: v_fname1(132) type c.
    data: v_tabix      like sy-tabix.
    data : ws_text(200) type c.
    data : wa_mag(1).
    data: begin of int_msg occurs 0,
           cnt type i,
           massage(1) type c,
           text(200) type c,
          end of int_msg.
    data : begin of i_final occurs 0,
            lifnr    like ekko-lifnr,         "Vendor Number
            bukrs    like ekko-bukrs,         "Order type
            bedat(10),
            ekorg    like ekko-ekorg,         "Purchasing organization
            ausnr    like ekko-ausnr,         "Purchase order
            ekgrp    like ekko-ekgrp,         "Purchasing group
            eddat(10),
            werks    like ekpo-werks,         "Plant
            lgort    like ekpo-lgort,         "Storage location
            zterm    like ekko-zterm,         "Payment terms
            ematn    like ekpo-ematn,         "Material
            menge    type char15,             "PO Quantity
            lewed(10),
    ***+EDS
            TAX_CODE type mwskz,
            GR_BASEDIV,
          end of i_final.
    data: it_datatab type standard table of i_upload,
          wa_datatab type i_upload.
    data: it_raw type truxs_t_text_data.
    data: begin of bdcdata occurs 0.
            include structure bdcdata.
    data: end of bdcdata.
    data: begin of messtab occurs 0.
            include structure bdcmsgcoll.
    data: end of messtab.
    data: begin of t_input occurs 0.
            include structure i_input.
    data:  end of t_input.
    data: begin of i_local_output occurs 0,
             text(2800) type c,
          end of i_local_output.
    data: begin of i_error occurs 0.
            include structure i_input.
    data:    text(50) type c.
    data: end of i_error.
    data : _datum1(10).
    data :  t_datum1(10).
    data:  msgno like sy-msgno,
           msgid like sy-msgid,
           msgty like sy-msgty,
           message like message.
    *Data : TEXT(50) Type c value 'File Shoud be in Excel Format'.
    data: wa_head     type bapimepoheader,
          wa_headx    type bapimepoheaderx,
          i_return    type bapiret2            occurs 0 with header line,
          i_item      type bapimepoitem        occurs 0 with header line,
          i_itemx     type bapimepoitemx       occurs 0 with header line,
          i_sch       type bapimeposchedule    occurs 0 with header line,
          i_schx      type bapimeposchedulx    occurs 0 with header line.
                  SELECTION SCREEN
    parameters: p_file type  rlgrap-filename obligatory modif id app.
               Write : /3 Text.
             START OF SELECTION
    at selection-screen on value-request for p_file.
      call function 'F4_FILENAME'
           exporting
                field_name = 'P_FILE'
           importing
                file_name  = p_file.
    start-of-selection.
      perform data_from_excel_to_sap.
      perform pass_data_to_final_int_tab.
    perform fill_bdc_data.
      perform fill_bapi_parameters.
      perform call_po_create_bapi.
    *&      Form  DATA_FROM_EXCEL_TO
          text
    -->  p1        text
    <--  p2        text
    form data_from_excel_to_sap.
      call function 'TEXT_CONVERT_XLS_TO_SAP'
          exporting
        I_FIELD_SEPERATOR        =
            i_line_header            =  'X'
            i_tab_raw_data           =  it_raw       " WORK TABLE
            i_filename               =  p_file
          tables
            i_tab_converted_data     = it_datatab[]    "ACTUAL DATA
         exceptions
            conversion_failed        = 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.                    " DATA_FROM_EXCEL_TO
    *&      Form  PASS_DATA_TO_FINAL_INTERNAL_TA
          text
    -->  p1        text
    <--  p2        text
    form pass_data_to_final_int_tab.
      loop at it_datatab into wa_datatab.
        move wa_datatab-lifnr to i_final-lifnr.  "Vendor Number
        move wa_datatab-bukrs to i_final-bukrs.  "Order type
        move wa_datatab-bedat to i_final-bedat.  "Purchase Order Date
        concatenate i_final-bedat6(2) '.' i_final-bedat4(2) '.20'
                         i_final-bedat+2(2) into _datum1.
        i_final-bedat = _datum1.
        move wa_datatab-ekorg to i_final-ekorg.  "Purchasing organization
        move wa_datatab-ausnr to i_final-ausnr.  "Purchase order
        move wa_datatab-ekgrp to i_final-ekgrp.  "Purchasing group
        move wa_datatab-eddat to i_final-eddat.  "Delivery date
        concatenate i_final-eddat6(2) '.' i_final-eddat4(2) '.20'
                         i_final-eddat+2(2) into _datum1.
        i_final-eddat = _datum1.
        move wa_datatab-werks to i_final-werks.  "Plant
        move wa_datatab-lgort to i_final-lgort.  "Storage location
        move wa_datatab-zterm to i_final-zterm.  "Payment terms
        move wa_datatab-ematn to i_final-ematn.  "Material
        move wa_datatab-menge to i_final-menge.  "PO Quantity
        move wa_datatab-lewed to i_final-lewed.  "Latest GR Date
    ***Value Hard coaded considering this Program is only for Import.
        I_FINAL-TAX_CODE   = 'V0'.
        I_FINAL-GR_BASEDIV = ' '.
        concatenate i_final-lewed6(2) '.' i_final-lewed4(2) '.20'
                         i_final-lewed+2(2) into _datum1.
        i_final-lewed = _datum1.
        append i_final.
      endloop.
    endform.                    " PASS_DATA_TO_FINAL_INTERNAL_TA
    *&      Form  FILL_BDC_DATA
          text
    -->  p1        text
    <--  p2        text
    form fill_bdc_data.
      read table i_final index 1.
      perform f0510_bdcdata using :
                 'X'          'SAPMM06E'   '0100',
                 ' '          'BDC_CURSOR' 'RM06E-MATKL',
                 ' '          'BDC_OKCODE' '=KOPF',
                 ' '          'EKKO-LIFNR'  i_final-lifnr,
                 ' '          'RM06E-BSART' i_final-bukrs,
                 ' '          'RM06E-BEDAT' i_final-bedat,
                 ' '          'RM06E-BSTNR' i_final-ausnr,
                 ' '          'EKKO-EKORG'  i_final-ekorg,
                 ' '          'EKKO-EKGRP'  i_final-ekgrp,
                 ' '          'RM06E-EEIND' i_final-eddat,
                 ' '          'RM06E-LPEIN' 'T',
                 ' '          'RM06E-WERKS' i_final-werks,
                 ' '          'RM06E-LGORT' i_final-lgort.
      perform f0510_bdcdata using :
                 'X'          'SAPMM06E'   '0101',
                 ' '          'BDC_OKCODE' '=AB',
                 ' '          'EKKO-ZTERM' i_final-zterm.
      move: '01' to v_counter.
      loop at i_final.
        move: sy-tabix to v_tabix.
        concatenate 'EKPO-EMATN(' v_counter ')' into v_fname.
        concatenate 'EKPO-MENGE(' v_counter ')' into v_fname1.
        perform f0510_bdcdata using :
                   'X'           'SAPMM06E'    '0120',
                   ' '           'BDC_OKCODE'  '=DETZ',
                ' '           'RM06E-EBELP' '5',
                   ' '           v_fname       i_final-ematn,
                   ' '           v_fname1      i_final-menge.
        perform f0510_bdcdata using :
                        'X'            'SAPMM06E'   '0112',
                        ' '            'BDC_CURSOR' 'EKPO-LEWED',
                        ' '            'BDC_OKCODE' '/00',
                        ' '            'EKPO-LEWED' i_final-lewed,
                        ' '            'EKPO-PRDAT' i_final-bedat.
                      ' '            'EKPO-IPRKZ' 'D'.
        v_mod = v_counter mod 5.
        if v_mod eq 0.
          clear v_ebelp.
          move: v_tabix to v_ebelp.
          perform f0510_bdcdata using :
                     'X'           'SAPMM06E'    '0120',
                     ' '           'BDC_OKCODE'  '/00',
                     ' '           'RM06E-EBELP'  v_ebelp.
          v_counter = '02'.
        else.
          v_counter = v_counter + 1.
        endif.
      endloop.
    loop at i_final.
       clear: v_fname.
       v_counter = sy-tabix.
       v_ebelp = sy-tabix.
       concatenate 'RM06E-TCSELFLAG(' '01' ')' into v_fname.
       perform f0510_bdcdata using :
                       'X'             'SAPMM06E'    '0120',
                       ' '             'RM06E-EBELP' v_ebelp,
                       ' '             'BDC_OKCODE'  '/00'.
       perform f0510_bdcdata using :
                       'X'             'SAPMM06E'    '0120',
                       ' '             'BDC_CURSOR'  'RM06E-BSTPO(01)',
                       ' '             'BDC_OKCODE'  '=DETZ',
                        ' '             'RM06E-EBELP' v_ebelp,
                       ' '             v_fname       'X'.
       perform f0510_bdcdata using :
                       'X'            'SAPMM06E' '0112',
                       ' '            'BDC_CURSOR'  'EKPO-LEWED',
                       ' '            'BDC_OKCODE' '/00',
                       ' '            'EKPO-PLIFZ' '91',
                       ' '            'EKPO-GEWEI' 'KG',
                       ' '            'EKPO-PRDAT' i_final-bedat,
                       ' '            'EKPO-IPRKZ' 'D',
                       ' '            'EKPO-LEWED' i_final-lewed.
    endloop.
      perform f0510_bdcdata using :
                  'X'          'SAPMM06E' '0120',
                  ' '          'BDC_CURSOR' 'RM06E-BSTPO(10)',
                  ' '          'BDC_OKCODE' '=BU',
                  ' '          'RM06E-EBELP' '1'.
      perform f0510_bdcdata using :
               'X'        'SAPLSPO1'   '0300',
               ' '        'BDC_OKCODE' '=YES'.
      call transaction 'ME21' using bdcdata messages into messtab
                          mode 'A' update 'S'.
      perform f000_process_errors.
      clear: bdcdata, messtab.
      refresh: bdcdata, messtab.
      loop at int_msg.
        write:/ int_msg-text.
      endloop.
    endform.                    " FILL_BDC_DATA
    *&      Form  F0510_BDCDATA
          text
         -->dynbegin   text
         -->name       text
         -->value      text
    form f0510_bdcdata using    value(dynbegin)
                          value(name)
                          value(value).
      if dynbegin = 'X'.
        clear bdcdata.
        move: name to bdcdata-program,
             value to bdcdata-dynpro,
               'X' to bdcdata-dynbegin.
        append bdcdata.
      else.
        clear bdcdata.
        move: name to bdcdata-fnam,
              value to bdcdata-fval.
        append bdcdata.
      endif.
    endform.                    " F0510_BDCDATA
    *&      Form  F000_PROCESS_ERRORS
          text
    -->  p1        text
    <--  p2        text
    form f000_process_errors.
      loop at messtab.
        clear t100.
        select single * from t100 where sprsl = messtab-msgspra
                                  and   arbgb = messtab-msgid
                                  and   msgnr = messtab-msgnr.
        ws_text = t100-text.
        wa_mag  = messtab-msgtyp.
        if ws_text cs '&1'.
          replace '&1' with messtab-msgv1 into ws_text.
          replace '&2' with messtab-msgv2 into ws_text.
          replace '&3' with messtab-msgv3 into ws_text.
          replace '&4' with messtab-msgv4 into ws_text.
        else.
          replace '&' with messtab-msgv1 into ws_text.
          replace '&' with messtab-msgv2 into ws_text.
          replace '&' with messtab-msgv3 into ws_text.
          replace '&' with messtab-msgv4 into ws_text.
        endif.
        condense ws_text.
        move ws_text to int_msg-text.
        move wa_mag to int_msg-massage.
        append int_msg.
      endloop.
      delete int_msg where massage = 'W'.
    endform.                    " F000_PROCESS_ERRORS
    *&      Form  fill_bapi_parameters
          Subroutine to fill BAPI Parameters
    form fill_bapi_parameters.
      clear: wa_head, wa_headx, i_return, i_item, i_itemx, i_sch, i_schx.
      perform fill_bapi_header.
      perform fill_bapi_items.
    endform.                    " fill_bapi_parameters
    *&      Form  fill_bapi_header
          Subroutine to fill the bapi header
    form fill_bapi_header.
      read table i_final index 1.
      check sy-subrc eq 0.
      move: i_final-ausnr          to wa_head-po_number,
            i_final-bukrs          to wa_head-doc_type,
            i_final-zterm          to wa_head-pmnttrms,
            i_final-ekorg          to wa_head-purch_org,
            i_final-ekgrp          to wa_head-pur_group,
            'FOB'                  to wa_head-incoterms1,
            'Free On Board'        to wa_head-incoterms2.
      call function 'CONVERSION_EXIT_ALPHA_INPUT'
           exporting
                input  = i_final-lifnr
           importing
                output = i_final-lifnr.
      move:         i_final-lifnr  to wa_head-vendor.
      concatenate i_final-bedat+6(4)
                  i_final-bedat+3(2)
                  i_final-bedat(2) into wa_head-doc_date.
      move: 'X'                    to wa_headx-po_number,
            'X'                    to wa_headx-doc_type,
            'X'                    to wa_headx-vendor,
            'X'                    to wa_headx-pmnttrms,
            'X'                    to wa_headx-purch_org,
            'X'                    to wa_headx-pur_group,
            'X'                    to wa_headx-doc_date,
            'X'                    to wa_headx-incoterms1,
            'X'                    to wa_headx-incoterms2.
    endform.                    " fill_bapi_header
    *&      Form  fill_bapi_items
          Subroutine to fill the bapi items
    form fill_bapi_items.
      loop at i_final.
        call function 'CONVERSION_EXIT_ALPHA_INPUT'
             exporting
                  input  = i_final-ematn
             importing
                  output = i_final-ematn.
        move: sy-tabix          to i_item-po_item,
              i_final-ematn     to i_item-material,
              i_final-werks     to i_item-plant,
              i_final-lgort     to i_item-stge_loc,
              i_final-menge     to i_item-quantity.
                I_ITEM-TAX_CODE   = I_FINAL-TAX_CODE.
                I_ITEM-GR_BASEDIV = I_FINAL-GR_BASEDIV.
        concatenate i_final-lewed+6(4)
                    i_final-lewed+3(2)
                    i_final-lewed(2) into i_item-gr_to_date.
        move: sy-tabix          to i_itemx-po_item,
              'X'               to i_itemx-po_itemx,
              'X'               to i_itemx-material,
              'X'               to i_itemx-plant,
              'X'               to i_itemx-stge_loc,
              'X'               to i_itemx-quantity,
              'X'               to i_itemx-gr_to_date.
    **EDS
        move: 'X'     TO        i_itemx-TAX_CODE ,
              'X'     TO        i_itemx-GR_BASEDIV.
        append: i_item, i_itemx.
        move: sy-tabix          to i_sch-po_item,
              '0001'            to i_sch-sched_line,
              'D'               to i_sch-del_datcat_ext.
            i_final-menge     to i_sch-quantity.
        concatenate i_final-eddat(2)
                    i_final-eddat+3(2)
                    i_final-eddat+6(4) into i_sch-delivery_date.
        move: sy-tabix          to i_schx-po_item,
              '0001'            to i_schx-sched_line,
              'X'               to i_schx-po_itemx,
              'X'               to i_schx-sched_linex,
            'X'               to i_schx-quantity,
              'X'               to i_schx-delivery_date,
              'X'               to i_schx-del_datcat_ext.
        append: i_sch, i_schx.
      endloop.
    endform.                    " fill_bapi_items
    *&      Form  call_po_create_bapi
          Subroutine to call PO CREATE BAPI
    form call_po_create_bapi.
      call function 'BAPI_PO_CREATE1'
           exporting
                poheader    = wa_head
                poheaderx   = wa_headx
           tables
                return      = i_return
                poitem      = i_item
                poitemx     = i_itemx
                poschedule  = i_sch
                poschedulex = i_schx.
      read table i_return with key type = 'S'
                                   id   = '06'
                                   number = '017'.
      if sy-subrc eq 0.
        call function 'BAPI_TRANSACTION_COMMIT'
             exporting
                  wait = 'X'.
        write:/ i_return-message.
      else.
        delete i_return where type = 'S'.
        delete i_return where type = 'I'.
        delete i_return where type = 'W'.
        write:/ 'Following Errors occured in PO Creation:'.
        skip.
        loop at i_return.
          write:/ i_return-message.
        endloop.
      endif.
    endform.                    " call_po_create_bapi
    thanks
    sitaram

  • Using BAPI_PO_CREATE1 : Linking service, and account assignment

    Hello,
    I have trouble when using BAPI_PO_CREATE1. When creating PO using BAPI_PO_CREATE1, I need to input service for each po item and the service itself need to have account assignment. I simplify the code below.
    **PO item
    t_poitem-po_item        = '10'. "for item 10
    t_poitem-PCKG_NO        = '20'. "link with service
    t_poitemx-po_item        = 'X'.
    t_poitemx-PCKG_NO       = 'X'.
    **Account Assignment
    t_poaccount-po_item    = '10'. "link with PO Item
    t_poaccount-SERIAL_NO  = '01'.
    t_poaccount-DISTR_PERC = 1.
    t_poaccountx-po_item    = '10'.
    t_poaccountx-SERIAL_NO  =  '01'.
    t_poaccountx-po_itemx    = 'X'.
    t_poaccountx-SERIAL_NOx  = 'X'.
    t_poaccountx-DISTR_PERC = 'X'.
    **PO Services
    **1st row
    t_poservices-PCKG_NO = '20'.
    t_poservices-LINE_NO = '0000000001'.
    t_poservices-SUBPCKG_NO  = '21'.
    APPEND t_poservices.
    clear t_poservices.
    **2nd row
    t_poservices-PCKG_NO = '21'.
    t_poservices-LINE_NO = '0000000002'.
    t_poservices-EXT_LINE = '0000000010'.
    **fill account assignment for services
    t_POSRVACCESSVALUES-pckg_no = '21'.
    t_POSRVACCESSVALUES-LINE_NO = '0000000002'.
    T_POSRVACCESSVALUES-SERNO_LINE = '01'.
    t_POSRVACCESSVALUES-SERIAL_NO = '01'. "acct. assign. link
    t_POSRVACCESSVALUES-PERCENTAGE = '100'.
    Every time i execute BAPI_PO_CREATE1 using entry similar like above, i always found error message in t_return like this:
    No account assignment exists for service line 0000000010
    I feel sure that i have fill every field needed to link services and account assignment which is using serial_no, but somehow it does not link correctly. Can anyone advise me if there is some thing missing or incorrect with my ABAP code above? Thank you in advance for your help. For sure, first helpful answer will receive my rewards point.
    Regards,
    Abraham

    Thank you for the code. Actually i have fill the required field as you told but i did not put it in my code here to focus the problem on service and account assignment. After checking out your code, i found that the different between your code and mine is in services table.
    <u><b>your code :</b></u>
    <b>POSERVICES:structure</b>
    PCKG_NO : 0000000001
    LINE_NO :0000000001
    SUBPCKG_NO : 0000000002
    SERVICE :3000000000017
    QUANTITY :5
    BASE_UOM :AU
    GR_PRICE :20000
    <b>POSRVACCESSVALUES: structure name</b>
    PCKG_NO :0000000002
    LINE_NO :0000000002
    <u><b>my code are:</b></u>
    <b>POSERVICES:structure</b>
    PCKG_NO : 0000000001
    LINE_NO :0000000001
    SUBPCKG_NO : 0000000002
    PCKG_NO : 0000000002
    LINE_NO :0000000002
    SERVICE :3000000000017
    QUANTITY :5
    BASE_UOM :AU
    GR_PRICE :20000
    <b>POSRVACCESSVALUES: structure name</b>
    PCKG_NO :0000000002
    LINE_NO :0000000002
    SERIAL_NO :0000000001
    The other difference are in account assignment table, you didn't fill SERIAL_NO field.
    my code will be like below:
    <b>POACCOUNT: structure name</b>
    PO_ITEM :10
    SERIAL_NO : 0000000001
    If using your version, the error message will be:
    <i>In case of account assignment, please enter acc. assignment data for item</i>
    If using my version, the error message will be:
    <i>No account assignment exists for service line 0000000010</i>
    Please advise what was wrong with my code. Thank you.
    Regards,
    Abraham

  • 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

  • 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

  • Error using BAPI_PO_CREATE1 for creating PO with services

    Hi,
    I'm getting an error saying 'EnTER account assignment data for item' when I use BAPI_PO_CREATE1 and try to create POs with Service Items. I have filled all the required details, even then the system throws up this error message. Thanks for any help.
    Regards,
    Vijay

    what have you passed to the table POACCOUNT? and POACCOUNTX?
    Regards,
    Ravi

  • Error: Internal Prising Error while using BAPI_PO_CREATE1

    Hi Experts,
    I am creating PO from Contract (VA41/VA42) using BAPI_PO_CREATE1 in user exit MV45AFZZ - USEREXIT_SAVE_DOCUMENT_PREPARE.
    BAPI is returning the PO number and after coming out from BAPI. I am getting an popup message STOP - Internal Prising Error.
    Even though bapi returned the PO number there is no PO exists with that number.
    Please provide you valuable inputs.
    Thanks & Regards

    Hi Experts,
    I am creating PO from Contract (VA41/VA42) using BAPI_PO_CREATE1 in user exit MV45AFZZ - USEREXIT_SAVE_DOCUMENT_PREPARE.
    BAPI is returning the PO number and after coming out from BAPI. I am getting an popup message STOP - Internal Prising Error.
    Even though bapi returned the PO number there is no PO exists with that number.
    Please provide you valuable inputs.
    Thanks & Regards

  • Service PO creation Using BAPI_PO_CREATE1

    Hi Friends,
    Can any body tell me how to create a service PO based on the existing service Agreement by using BAPI_PO_CREATE1 with sample code.
    Thanks,
    Kamlesh

    Hi Friends,
    Can any body tell me how to create a service PO based on the existing service Agreement by using BAPI_PO_CREATE1 with sample code.
    Thanks,
    Kamlesh

Maybe you are looking for

  • How to set up Print Specs and Profiles in CS5 Suite

    I am no color management expert but I do want to get my printer to print the same colors as my monitor displays in PSD, AI and InD applications. My Intel iMac and Cinema Display running OS10.5.8 are both color calibrated with Spyder 3 Elite to achiev

  • Global Temp Table vs. PL/SQL Table

    Hi, I'm trying to find out which better (efficient) to use in coding, a Global Temporary Table or PL/SQL table. The process requires evaluation to what data stored in the tbale. Thanks in advance.

  • Why does my ipod touch show up as a camera?

    Hello. I upgraded to windows 7 about three weeks ago and I didn't have a single problem with my ipod touch. Yesterday a friend of mine signed into his account on my itunes to download some music. Today, I plugged my ipod touch into my laptop and it s

  • Most of the music in my itunes library has a "i" before it.

    My computer crashed recently and the hard drive had to be cleared. I downloaded the new itunes and now most of my music has an "i" in front of it. (music I have purchased recently does not have the i). When I try to play this music I get the error me

  • The Customer has requested complete delivery

    Hello all, I am unable to create a delivery, and I am getting the following message log  in the delivery creation Log. The Customer has requested complete delivery But my problem is, I dont know which item this is related to? How can i find out which