Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Bapi_po_create1 for service

Former Member
0 Likes
1,442

I am trying to create a PO with reference to PR for service.

Getting error saying “In case of account assignment, please enter acc. assignment data for item” at POITEM level

Normal PO and PO with ref to PR are working fine.

Any clue what might be wrong?


CALL FUNCTION 'BAPI_PO_CREATE1'

    EXPORTING

     poheader                     = wa_header

   poheaderx                    = wa_headerx

   poaddrvendor                 = tb_address

     testrun                      = co_space

*   MEMORY_UNCOMPLETE            =

*   MEMORY_COMPLETE              =

*   NO_MESSAGING                 =

*   NO_MESSAGE_REQ               =

*   NO_AUTHORITY                 =

   no_price_from_po             = 'X'

* IMPORTING

*   EXPPURCHASEORDER             =

*   EXPHEADER                    =

 TABLES

   return                       = tb_return

   poitem                       = tb_item

   poitemx                      = tb_itemx

*   POADDRDELIVERY               =

   poschedule                   = tb_sch

   poschedulex                  = tb_schx

   poaccount                    = tb_acc

*   POACCOUNTPROFITSEGMENT       =

   poaccountx                   = tb_accx

*   pocondheader                 = tb_condheader

*   pocondheaderx                = tb_condheaderx

   pocond                       = tb_cond

   pocondx                      = tb_condx

   polimits                     = tb_e1bpesuhc

   pocontractlimits             = tb_e1bpesucc

   poservices                   = tb_service

   posrvaccessvalues            = tb_e1bpesklc

   poservicestext               = tb_e1bpeslltx

*   EXTENSIONIN                  =

*   EXTENSIONOUT                 =

   potextheader                 = tb_htext

   potextitem                   = tb_itext

   popartner                    = tb_e1bpekkop

 

 

 

 

 

* Following line added for testing purpose

  READ TABLE tb_ze1bpekkotx INDEX 1.

  IF sy-subrc EQ 0.

    st_e1bpekkoc-po_number = tb_ze1bpekkotx-po_number.

  ENDIF.

 

* End of Insertion.

 

* Fill the PO Header

  wa_header-doc_date   = st_e1bpekkoc-doc_date.

  wa_header-doc_type   = st_e1bpekkoc-doc_type.

  wa_header-comp_code  = st_e1bpekkoc-co_code.

  wa_header-purch_org  = st_e1bpekkoc-purch_org.

  wa_header-pur_group  = st_e1bpekkoc-pur_group.

  wa_header-vendor     = st_e1bpekkoc-vendor.

  wa_header-po_number  = st_e1bpekkoc-po_number.

  wa_header-pmnttrms   = st_e1bpekkoa-pmnttrms.

  wa_header-dscnt1_to  = st_e1bpekkoa-dscnt1_to.

  wa_header-dscnt2_to  = st_e1bpekkoa-dscnt2_to.

  wa_header-dscnt3_to  = st_e1bpekkoa-dscnt3_to.

  wa_header-dsct_pct1  = st_e1bpekkoa-cash_disc1.

  wa_header-dsct_pct2  = st_e1bpekkoa-cash_disc2.

  wa_header-created_by = st_e1bpekkoa-created_by.

  wa_header-currency   = st_e1bpekkoa-currency.

  wa_header-exch_rate  = st_e1bpekkoa-exch_rate.

  wa_header-ex_rate_fx = st_e1bpekkoa-ex_rate_fx.

  wa_header-incoterms1 = st_e1bpekkoa-incoterms1.

  wa_header-incoterms2 = st_e1bpekkoa-incoterms2.

  wa_header-ref_1      = st_e1bpekkoa-ref_1.

  wa_header-sales_pers = st_e1bpekkoa-sales_pers.

  wa_header-telephone  = st_e1bpekkoa-telephone.

 

 

 

* Fill the PO Header Change Toolbar

  wa_headerx-doc_date   = co_x.

  wa_headerx-doc_type   = co_x.

  wa_headerx-comp_code  = co_x.

  wa_headerx-purch_org  = co_x.

  wa_headerx-pur_group  = co_x.

  wa_headerx-vendor     = co_x.

  wa_headerx-po_number  = co_x.

  wa_headerx-pmnttrms   = co_x.

  wa_headerx-dscnt1_to  = co_x.

  wa_headerx-dscnt2_to  = co_x.

  wa_headerx-dscnt3_to  = co_x.

  wa_headerx-dsct_pct1  = co_x.

  wa_headerx-dsct_pct2  = co_x.

  wa_headerx-created_by = co_x.

  wa_headerx-currency   = co_x.

  wa_headerx-exch_rate  = co_x.

  wa_headerx-ex_rate_fx = co_x.

  wa_headerx-incoterms1 = co_x.

  wa_headerx-incoterms2 = co_x.

  wa_headerx-ref_1      = co_x.

  wa_headerx-sales_pers = co_x.

  wa_headerx-telephone  = co_x.

 

* Fill the Address Table

  tb_address-po_number  = st_e1bpekkoc-po_number.

  tb_address-addr_no    = st_e1bpaddress-addrnumber.

  tb_address-name       = st_e1bpaddress-name1.

  tb_address-name_2     = st_e1bpaddress-name2.

  tb_address-name_3     = st_e1bpaddress-name3.

  tb_address-name_4     = st_e1bpaddress-name4.

  tb_address-city       = st_e1bpaddress-city1.

  tb_address-district   = st_e1bpaddress-city2.

  tb_address-city_no    = st_e1bpaddress-city_code.

  tb_address-postl_cod1 = st_e1bpaddress-post_code1.

  tb_address-postl_cod2 = st_e1bpaddress-post_code2.

  tb_address-postl_cod3 = st_e1bpaddress-post_code3.

  tb_address-po_box     = st_e1bpaddress-po_box.

  tb_address-po_box_cit = st_e1bpaddress-po_box_loc.

  tb_address-street     = st_e1bpaddress-street.

  APPEND tb_address.

 

 

* Fill the POItem Table

  LOOP AT tb_e1bpekpoc.

    tb_item-po_item            = tb_e1bpekpoc-po_item.

 

* Process the material based on the value.

    IF tb_e1bpekpoc-material+0(2) EQ co_b9.

      tb_item-material         = co_space.

    ELSE.

      tb_item-material         =  tb_e1bpekpoc-material.

    ENDIF.

    tb_item-item_cat           =  tb_e1bpekpoc-item_cat.

    tb_item-acctasscat         =  tb_e1bpekpoc-acctasscat.

    tb_item-agreement          =  tb_e1bpekpoc-agreement.

    tb_item-agmt_item          =  tb_e1bpekpoc-agmt_item.

    tb_item-matl_group         =  tb_e1bpekpoc-mat_grp.

    tb_item-short_text         =  tb_e1bpekpoc-short_text.

    tb_item-distrib            =  tb_e1bpekpoc-distrib.

    tb_item-part_inv           =  tb_e1bpekpoc-part_inv.

    tb_item-kanban_ind         =  tb_e1bpekpoc-kanban_ind.

    tb_item-plant              =  tb_e1bpekpoc-plant.

    tb_item-po_unit            =  tb_e1bpekpoc-unit.

    tb_item-po_unit_iso        =  tb_e1bpekpoc-po_unit_iso.

    tb_item-net_price          =  tb_e1bpekpoc-net_price.

    tb_item-conv_num1          =  tb_e1bpekpoc-conv_num1.

    tb_item-conv_den1          =  tb_e1bpekpoc-conv_den1.

    tb_item-orderpr_un         =  tb_e1bpekpoc-orderpr_un.

    tb_item-pckg_no            =  tb_e1bpekpoc-pckg_no.

    tb_item-trackingno         =  tb_e1bpekpoc-trackingno.

    tb_item-at_relev           =  tb_e1bpekpoc-at_relev.

    tb_item-po_price           =  tb_e1bpekpoc-po_price.

    tb_item-tax_code           =  tb_e1bpekpoc-tax_code.

    tb_item-preq_name          =  tb_e1bpekpoc-preq_name.

    tb_item-delete_ind         =  tb_e1bpekpoc-delete_ind.

    tb_item-free_item          =  co_space.

    tb_item-material_external  = tb_e1bpekpoc-material_external.

*Populate the table from the other segments.

    READ TABLE tb_e1bpekpoa WITH KEY po_item = tb_e1bpekpoc-po_item.

    IF sy-subrc EQ 0.

      tb_item-info_upd         =  tb_e1bpekpoa-info_upd.

      tb_item-gr_ind           =  tb_e1bpekpoa-gr_ind.

      tb_item-ir_ind           =  tb_e1bpekpoa-ir_ind.

      wf_ind_check = co_x.

    ENDIF.

 

    READ TABLE tb_e1bpeket WITH KEY po_item = tb_e1bpeket.

    IF sy-subrc EQ 0.

      tb_item-preq_no          =  tb_e1bpeket-preq_no.

      tb_item-preq_item        =  tb_e1bpeket-preq_item.

*      tb_item-ref_doc          =  tb_e1bpeket-preq_no.

      tb_item-quantity         =  tb_e1bpeket-quantity.

      wf_qty_check = co_x.

    ENDIF.

    APPEND tb_item.

 

 

 

* Fill the POItemx Table

 

    tb_itemx-po_item           = tb_e1bpekpoc-po_item.

    tb_itemx-material          = co_x.

    tb_itemx-item_cat          = co_x.

    tb_itemx-acctasscat        = co_x.

    tb_itemx-agreement         = co_x.

    tb_itemx-agmt_item         = co_x.

    tb_itemx-matl_group        = co_x.

    tb_itemx-short_text        = co_x.

    tb_itemx-distrib           = co_x.

    tb_itemx-part_inv          = co_x.

    tb_itemx-kanban_ind        = co_x.

    tb_itemx-plant             = co_x.

    tb_itemx-po_unit           = co_x.

    tb_itemx-po_unit_iso       = co_x.

    tb_itemx-net_price         = co_x.

    tb_itemx-conv_num1         = co_x.

    tb_itemx-conv_den1         = co_x.

    tb_itemx-orderpr_un        = co_x.

    tb_itemx-pckg_no           = co_x.

    tb_itemx-trackingno        = co_x.

    tb_itemx-at_relev          = co_x.

    tb_itemx-po_price          = co_x.

    tb_itemx-tax_code          = co_x.

    tb_itemx-preq_name         = co_x.

    tb_itemx-delete_ind        = co_x.

    tb_itemx-free_item         = co_x.

    tb_itemx-material_external = co_x.

    IF NOT wf_ind_check IS INITIAL.

      tb_itemx-info_upd        = co_x.

      tb_itemx-gr_ind          = co_x.

      tb_itemx-ir_ind          = co_x.

    ENDIF.

    IF NOT wf_qty_check IS INITIAL.

      tb_itemx-preq_no         = co_x.

      tb_itemx-preq_item       = co_x.

*      tb_itemx-ref_doc          = co_x.

      tb_itemx-quantity        = co_x.

    ENDIF.

    APPEND tb_itemx.

 

  ENDLOOP.

 

 

 

* Fill the POSCHEDULE Table.

  LOOP AT tb_e1bpeket.

    tb_sch-po_item        = tb_e1bpeket-po_item.

    tb_sch-delivery_date  = tb_e1bpeket-deliv_date.

    tb_sch-quantity       = tb_e1bpeket-quantity.

    tb_sch-preq_no        = tb_e1bpeket-preq_no.

    tb_sch-preq_item      = tb_e1bpeket-preq_item.

    tb_sch-del_datcat_ext = tb_e1bpeket-del_datcat_ext.

 

    APPEND tb_sch.

 

 

* Fill the POSCHEDULEX Table

    tb_schx-po_item       = tb_e1bpeket-po_item.

    tb_schx-delivery_date = co_x.

    tb_schx-quantity      = co_x.

    tb_schx-preq_no       = co_x.

    tb_schx-preq_item     = co_x.

    tb_sch-del_datcat_ext = co_x.

    APPEND tb_schx.

  ENDLOOP.

 

 

 

* Fill the POTEXTITEM Table.

  LOOP AT tb_e1bpekpotx.

    tb_itext-po_number = tb_e1bpekpotx-po_number.

    tb_itext-po_item   = tb_e1bpekpotx-po_item.

    tb_itext-text_id   = tb_e1bpekpotx-text_id.

    tb_itext-text_form = tb_e1bpekpotx-text_form.

    tb_itext-text_line = tb_e1bpekpotx-text_line.

    APPEND tb_itext.

  ENDLOOP.

 

* Fill the POTEXTHEADER Table.

  LOOP AT tb_ze1bpekkotx.

    tb_htext-po_number = tb_ze1bpekkotx-po_number.

    tb_htext-text_id   = tb_ze1bpekkotx-text_id.

    tb_htext-text_form = tb_ze1bpekkotx-text_form.

    tb_htext-text_line = tb_ze1bpekkotx-text_line.

    APPEND tb_htext.

  ENDLOOP.

 

  LOOP AT tb_item.

* Fill the Condition Table.

    tb_cond-cond_value = tb_item-net_price.

    tb_cond-itm_number = 10. "tb_item-po_item.

    tb_cond-currency = st_e1bpekkoa-currency.

    tb_cond-change_id = 'I'.      "co_i.

    tb_cond-condchaman = co_x.

    APPEND tb_cond.

 

    tb_condheader-cond_value = tb_item-net_price.

    tb_condheader-cond_type = 'PB00'.

    tb_condheader-currency = st_e1bpekkoa-currency.

    tb_condheader-change_id = 'I'.

    tb_condheader-condchaman = co_x.

 

    APPEND tb_condheader.

 

* Fill the Condition header Table

    tb_condx-itm_number = tb_item-po_item.

    tb_condx-cond_value = co_x.

    tb_condx-cond_type  = co_x.

    tb_condx-currency = co_x.

    tb_condx-change_id = co_x.

    tb_condx-condchaman = co_x.

    APPEND tb_condx.

    tb_condheaderx-cond_type = co_x.

    tb_condheaderx-cond_value = co_x.

    tb_condheaderx-currency = co_x.

    tb_condheaderx-change_id = co_x.

    tb_condheaderx-condchaman = co_x.

 

    APPEND tb_condheaderx.

  ENDLOOP.

 

 

* Testing for PR and Services

  IF NOT wf_qty_check IS INITIAL.

    SELECT *

      FROM eban

    INTO TABLE tb_eban_po

    FOR ALL ENTRIES IN tb_item

    WHERE banfn = tb_item-preq_no

     AND  bnfpo = tb_item-preq_item.

 

 

    IF NOT tb_eban_po[] IS INITIAL.

      CLEAR lv_tabix.

      LOOP AT tb_item.

        lv_tabix = sy-tabix.

        READ TABLE tb_eban_po WITH KEY banfn = tb_item-preq_no

                                       bnfpo = tb_item-preq_item.

        IF sy-subrc EQ 0.

          tb_item-item_cat = tb_eban_po-pstyp.

          tb_item-acctasscat = tb_eban_po-knttp.

          tb_item-gr_basediv = co_x.

* Populate the Service Table

          tb_service-pckg_no = tb_eban_po-packno.

          tb_service-matl_group = tb_eban_po-matkl.

          tb_service-quantity = tb_eban_po-menge.

          tb_service-base_uom = tb_eban_po-meins.

          tb_service-short_text = tb_eban_po-txz01.

          tb_service-base_uom   = tb_eban_po-meins.

          tb_service-ext_line   = '10'.

          tb_service-gr_price   = tb_eban_po-preis.

          APPEND tb_service.

 

          tb_srv_acc-pckg_no = tb_eban_po-packno.

          APPEND tb_srv_acc.

 

          READ TABLE tb_itemx INDEX lv_tabix.

          IF sy-subrc EQ 0.

            tb_itemx-item_cat = co_x.

            tb_itemx-acctasscat = co_x.

            tb_itemx-gr_basediv = co_x.

            MODIFY tb_item INDEX lv_tabix.

            MODIFY tb_itemx INDEX lv_tabix.

          ENDIF.

 

          tb_item-item_cat = tb_eban_po-pstyp.

          tb_item-acctasscat = tb_eban_po-knttp.

        ENDIF.

      ENDLOOP.

    ENDIF.

  ENDIF.

* Fill the POACCOUNT Table.

  SELECT *

      FROM ebkn

  INTO TABLE tb_ebkn_po

  FOR ALL ENTRIES IN tb_sch

  WHERE banfn = tb_sch-preq_no.

 

  IF NOT tb_ebkn_po[] IS INITIAL.

 

    LOOP AT tb_ebkn_po.

      tb_acc-po_item     = tb_ebkn_po-bnfpo.

      tb_acc-serial_no   = tb_ebkn_po-zebkn.

      tb_acc-quantity    = tb_ebkn_po-menge.

      tb_acc-gl_account  = tb_ebkn_po-sakto.

      tb_acc-costcenter  = tb_ebkn_po-kostl.

      tb_acc-profit_ctr  = tb_ebkn_po-prctr.

      tb_acc-co_area     = tb_ebkn_po-kokrs.

      tb_acc-net_value   = tb_ebkn_po-netwr.

      APPEND tb_acc.

* Fill the POACCOUNTX Table

      tb_accx-po_item    = tb_ebkn_po-bnfpo.

      tb_accx-po_itemx   = co_x.

      tb_accx-serial_no  = tb_ebkn_po-zebkn.

      tb_accx-serial_nox = co_x.

      tb_accx-quantity   = co_x.

      tb_accx-gl_account = co_x.

      tb_accx-costcenter = co_x.

      tb_accx-profit_ctr = co_x.

      tb_accx-co_area    = co_x.

      tb_accx-net_value  = co_x.

      APPEND tb_accx.

    ENDLOOP.

  ENDIF.

 

ENDFORM.

Edited by: Archish RS on Feb 7, 2008 9:34 AM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,237

Hello,

The same problem is discussed before two days.

Please have a look at this thread:

https://www.sdn.sap.com/irj/sdn/profile?userid=3461421

solved the issue by debugging.

Don't get too worried, there is an easy way to solve this if you get issues like this. See I was able to create a service PO from ME21N transaction. As you know service PO needs Service lines to be created it's mandatory. Here were my error is.

SAP from front end is using a hierarchical method of creating service lines. Not sure this is always like this!!!

The way you can figure out is ..go and create a PO from front end. use that PO number in BAPI_PO_GETDETAIL.

See the values it returns in the associated tables. Compare these values with your mapping in data load program. Then make the necessary changes. Of course there are things needs to be changed in Both Service line structure and Account structure. good luck

Hope this will solve ur problem

Cheers,

Vasanth

I am trying to create a PO with reference to PR for service.

Getting error saying “In case of account assignment, please enter acc. assignment data for item” at POITEM level

Normal PO and PO with ref to PR are working fine.

Any clue what might be wrong?


CALL FUNCTION 'BAPI_PO_CREATE1'

    EXPORTING

     poheader                     = wa_header

   poheaderx                    = wa_headerx

   poaddrvendor                 = tb_address

     testrun                      = co_space

*   MEMORY_UNCOMPLETE            =

*   MEMORY_COMPLETE              =

*   NO_MESSAGING                 =

*   NO_MESSAGE_REQ               =

*   NO_AUTHORITY                 =

   no_price_from_po             = 'X'

* IMPORTING

*   EXPPURCHASEORDER             =

*   EXPHEADER                    =

 TABLES

   return                       = tb_return

   poitem                       = tb_item

   poitemx                      = tb_itemx

*   POADDRDELIVERY               =

   poschedule                   = tb_sch

   poschedulex                  = tb_schx

   poaccount                    = tb_acc

*   POACCOUNTPROFITSEGMENT       =

   poaccountx                   = tb_accx

*   pocondheader                 = tb_condheader

*   pocondheaderx                = tb_condheaderx

   pocond                       = tb_cond

   pocondx                      = tb_condx

   polimits                     = tb_e1bpesuhc

   pocontractlimits             = tb_e1bpesucc

   poservices                   = tb_service

   posrvaccessvalues            = tb_e1bpesklc

   poservicestext               = tb_e1bpeslltx

*   EXTENSIONIN                  =

*   EXTENSIONOUT                 =

   potextheader                 = tb_htext

   potextitem                   = tb_itext

   popartner                    = tb_e1bpekkop

 

 

 

 

 

* Following line added for testing purpose

  READ TABLE tb_ze1bpekkotx INDEX 1.

  IF sy-subrc EQ 0.

    st_e1bpekkoc-po_number = tb_ze1bpekkotx-po_number.

  ENDIF.

 

* End of Insertion.

 

* Fill the PO Header

  wa_header-doc_date   = st_e1bpekkoc-doc_date.

  wa_header-doc_type   = st_e1bpekkoc-doc_type.

  wa_header-comp_code  = st_e1bpekkoc-co_code.

  wa_header-purch_org  = st_e1bpekkoc-purch_org.

  wa_header-pur_group  = st_e1bpekkoc-pur_group.

  wa_header-vendor     = st_e1bpekkoc-vendor.

  wa_header-po_number  = st_e1bpekkoc-po_number.

  wa_header-pmnttrms   = st_e1bpekkoa-pmnttrms.

  wa_header-dscnt1_to  = st_e1bpekkoa-dscnt1_to.

  wa_header-dscnt2_to  = st_e1bpekkoa-dscnt2_to.

  wa_header-dscnt3_to  = st_e1bpekkoa-dscnt3_to.

  wa_header-dsct_pct1  = st_e1bpekkoa-cash_disc1.

  wa_header-dsct_pct2  = st_e1bpekkoa-cash_disc2.

  wa_header-created_by = st_e1bpekkoa-created_by.

  wa_header-currency   = st_e1bpekkoa-currency.

  wa_header-exch_rate  = st_e1bpekkoa-exch_rate.

  wa_header-ex_rate_fx = st_e1bpekkoa-ex_rate_fx.

  wa_header-incoterms1 = st_e1bpekkoa-incoterms1.

  wa_header-incoterms2 = st_e1bpekkoa-incoterms2.

  wa_header-ref_1      = st_e1bpekkoa-ref_1.

  wa_header-sales_pers = st_e1bpekkoa-sales_pers.

  wa_header-telephone  = st_e1bpekkoa-telephone.

 

 

 

* Fill the PO Header Change Toolbar

  wa_headerx-doc_date   = co_x.

  wa_headerx-doc_type   = co_x.

  wa_headerx-comp_code  = co_x.

  wa_headerx-purch_org  = co_x.

  wa_headerx-pur_group  = co_x.

  wa_headerx-vendor     = co_x.

  wa_headerx-po_number  = co_x.

  wa_headerx-pmnttrms   = co_x.

  wa_headerx-dscnt1_to  = co_x.

  wa_headerx-dscnt2_to  = co_x.

  wa_headerx-dscnt3_to  = co_x.

  wa_headerx-dsct_pct1  = co_x.

  wa_headerx-dsct_pct2  = co_x.

  wa_headerx-created_by = co_x.

  wa_headerx-currency   = co_x.

  wa_headerx-exch_rate  = co_x.

  wa_headerx-ex_rate_fx = co_x.

  wa_headerx-incoterms1 = co_x.

  wa_headerx-incoterms2 = co_x.

  wa_headerx-ref_1      = co_x.

  wa_headerx-sales_pers = co_x.

  wa_headerx-telephone  = co_x.

 

* Fill the Address Table

  tb_address-po_number  = st_e1bpekkoc-po_number.

  tb_address-addr_no    = st_e1bpaddress-addrnumber.

  tb_address-name       = st_e1bpaddress-name1.

  tb_address-name_2     = st_e1bpaddress-name2.

  tb_address-name_3     = st_e1bpaddress-name3.

  tb_address-name_4     = st_e1bpaddress-name4.

  tb_address-city       = st_e1bpaddress-city1.

  tb_address-district   = st_e1bpaddress-city2.

  tb_address-city_no    = st_e1bpaddress-city_code.

  tb_address-postl_cod1 = st_e1bpaddress-post_code1.

  tb_address-postl_cod2 = st_e1bpaddress-post_code2.

  tb_address-postl_cod3 = st_e1bpaddress-post_code3.

  tb_address-po_box     = st_e1bpaddress-po_box.

  tb_address-po_box_cit = st_e1bpaddress-po_box_loc.

  tb_address-street     = st_e1bpaddress-street.

  APPEND tb_address.

 

 

* Fill the POItem Table

  LOOP AT tb_e1bpekpoc.

    tb_item-po_item            = tb_e1bpekpoc-po_item.

 

* Process the material based on the value.

    IF tb_e1bpekpoc-material+0(2) EQ co_b9.

      tb_item-material         = co_space.

    ELSE.

      tb_item-material         =  tb_e1bpekpoc-material.

    ENDIF.

    tb_item-item_cat           =  tb_e1bpekpoc-item_cat.

    tb_item-acctasscat         =  tb_e1bpekpoc-acctasscat.

    tb_item-agreement          =  tb_e1bpekpoc-agreement.

    tb_item-agmt_item          =  tb_e1bpekpoc-agmt_item.

    tb_item-matl_group         =  tb_e1bpekpoc-mat_grp.

    tb_item-short_text         =  tb_e1bpekpoc-short_text.

    tb_item-distrib            =  tb_e1bpekpoc-distrib.

    tb_item-part_inv           =  tb_e1bpekpoc-part_inv.

    tb_item-kanban_ind         =  tb_e1bpekpoc-kanban_ind.

    tb_item-plant              =  tb_e1bpekpoc-plant.

    tb_item-po_unit            =  tb_e1bpekpoc-unit.

    tb_item-po_unit_iso        =  tb_e1bpekpoc-po_unit_iso.

    tb_item-net_price          =  tb_e1bpekpoc-net_price.

    tb_item-conv_num1          =  tb_e1bpekpoc-conv_num1.

    tb_item-conv_den1          =  tb_e1bpekpoc-conv_den1.

    tb_item-orderpr_un         =  tb_e1bpekpoc-orderpr_un.

    tb_item-pckg_no            =  tb_e1bpekpoc-pckg_no.

    tb_item-trackingno         =  tb_e1bpekpoc-trackingno.

    tb_item-at_relev           =  tb_e1bpekpoc-at_relev.

    tb_item-po_price           =  tb_e1bpekpoc-po_price.

    tb_item-tax_code           =  tb_e1bpekpoc-tax_code.

    tb_item-preq_name          =  tb_e1bpekpoc-preq_name.

    tb_item-delete_ind         =  tb_e1bpekpoc-delete_ind.

    tb_item-free_item          =  co_space.

    tb_item-material_external  = tb_e1bpekpoc-material_external.

*Populate the table from the other segments.

    READ TABLE tb_e1bpekpoa WITH KEY po_item = tb_e1bpekpoc-po_item.

    IF sy-subrc EQ 0.

      tb_item-info_upd         =  tb_e1bpekpoa-info_upd.

      tb_item-gr_ind           =  tb_e1bpekpoa-gr_ind.

      tb_item-ir_ind           =  tb_e1bpekpoa-ir_ind.

      wf_ind_check = co_x.

    ENDIF.

 

    READ TABLE tb_e1bpeket WITH KEY po_item = tb_e1bpeket.

    IF sy-subrc EQ 0.

      tb_item-preq_no          =  tb_e1bpeket-preq_no.

      tb_item-preq_item        =  tb_e1bpeket-preq_item.

*      tb_item-ref_doc          =  tb_e1bpeket-preq_no.

      tb_item-quantity         =  tb_e1bpeket-quantity.

      wf_qty_check = co_x.

    ENDIF.

    APPEND tb_item.

 

 

 

* Fill the POItemx Table

 

    tb_itemx-po_item           = tb_e1bpekpoc-po_item.

    tb_itemx-material          = co_x.

    tb_itemx-item_cat          = co_x.

    tb_itemx-acctasscat        = co_x.

    tb_itemx-agreement         = co_x.

    tb_itemx-agmt_item         = co_x.

    tb_itemx-matl_group        = co_x.

    tb_itemx-short_text        = co_x.

    tb_itemx-distrib           = co_x.

    tb_itemx-part_inv          = co_x.

    tb_itemx-kanban_ind        = co_x.

    tb_itemx-plant             = co_x.

    tb_itemx-po_unit           = co_x.

    tb_itemx-po_unit_iso       = co_x.

    tb_itemx-net_price         = co_x.

    tb_itemx-conv_num1         = co_x.

    tb_itemx-conv_den1         = co_x.

    tb_itemx-orderpr_un        = co_x.

    tb_itemx-pckg_no           = co_x.

    tb_itemx-trackingno        = co_x.

    tb_itemx-at_relev          = co_x.

    tb_itemx-po_price          = co_x.

    tb_itemx-tax_code          = co_x.

    tb_itemx-preq_name         = co_x.

    tb_itemx-delete_ind        = co_x.

    tb_itemx-free_item         = co_x.

    tb_itemx-material_external = co_x.

    IF NOT wf_ind_check IS INITIAL.

      tb_itemx-info_upd        = co_x.

      tb_itemx-gr_ind          = co_x.

      tb_itemx-ir_ind          = co_x.

    ENDIF.

    IF NOT wf_qty_check IS INITIAL.

      tb_itemx-preq_no         = co_x.

      tb_itemx-preq_item       = co_x.

*      tb_itemx-ref_doc          = co_x.

      tb_itemx-quantity        = co_x.

    ENDIF.

    APPEND tb_itemx.

 

  ENDLOOP.

 

 

 

* Fill the POSCHEDULE Table.

  LOOP AT tb_e1bpeket.

    tb_sch-po_item        = tb_e1bpeket-po_item.

    tb_sch-delivery_date  = tb_e1bpeket-deliv_date.

    tb_sch-quantity       = tb_e1bpeket-quantity.

    tb_sch-preq_no        = tb_e1bpeket-preq_no.

    tb_sch-preq_item      = tb_e1bpeket-preq_item.

    tb_sch-del_datcat_ext = tb_e1bpeket-del_datcat_ext.

 

    APPEND tb_sch.

 

 

* Fill the POSCHEDULEX Table

    tb_schx-po_item       = tb_e1bpeket-po_item.

    tb_schx-delivery_date = co_x.

    tb_schx-quantity      = co_x.

    tb_schx-preq_no       = co_x.

    tb_schx-preq_item     = co_x.

    tb_sch-del_datcat_ext = co_x.

    APPEND tb_schx.

  ENDLOOP.

 

 

 

* Fill the POTEXTITEM Table.

  LOOP AT tb_e1bpekpotx.

    tb_itext-po_number = tb_e1bpekpotx-po_number.

    tb_itext-po_item   = tb_e1bpekpotx-po_item.

    tb_itext-text_id   = tb_e1bpekpotx-text_id.

    tb_itext-text_form = tb_e1bpekpotx-text_form.

    tb_itext-text_line = tb_e1bpekpotx-text_line.

    APPEND tb_itext.

  ENDLOOP.

 

* Fill the POTEXTHEADER Table.

  LOOP AT tb_ze1bpekkotx.

    tb_htext-po_number = tb_ze1bpekkotx-po_number.

    tb_htext-text_id   = tb_ze1bpekkotx-text_id.

    tb_htext-text_form = tb_ze1bpekkotx-text_form.

    tb_htext-text_line = tb_ze1bpekkotx-text_line.

    APPEND tb_htext.

  ENDLOOP.

 

  LOOP AT tb_item.

* Fill the Condition Table.

    tb_cond-cond_value = tb_item-net_price.

    tb_cond-itm_number = 10. "tb_item-po_item.

    tb_cond-currency = st_e1bpekkoa-currency.

    tb_cond-change_id = 'I'.      "co_i.

    tb_cond-condchaman = co_x.

    APPEND tb_cond.

 

    tb_condheader-cond_value = tb_item-net_price.

    tb_condheader-cond_type = 'PB00'.

    tb_condheader-currency = st_e1bpekkoa-currency.

    tb_condheader-change_id = 'I'.

    tb_condheader-condchaman = co_x.

 

    APPEND tb_condheader.

 

* Fill the Condition header Table

    tb_condx-itm_number = tb_item-po_item.

    tb_condx-cond_value = co_x.

    tb_condx-cond_type  = co_x.

    tb_condx-currency = co_x.

    tb_condx-change_id = co_x.

    tb_condx-condchaman = co_x.

    APPEND tb_condx.

    tb_condheaderx-cond_type = co_x.

    tb_condheaderx-cond_value = co_x.

    tb_condheaderx-currency = co_x.

    tb_condheaderx-change_id = co_x.

    tb_condheaderx-condchaman = co_x.

 

    APPEND tb_condheaderx.

  ENDLOOP.

 

 

* Testing for PR and Services

  IF NOT wf_qty_check IS INITIAL.

    SELECT *

      FROM eban

    INTO TABLE tb_eban_po

    FOR ALL ENTRIES IN tb_item

    WHERE banfn = tb_item-preq_no

     AND  bnfpo = tb_item-preq_item.

 

 

    IF NOT tb_eban_po[] IS INITIAL.

      CLEAR lv_tabix.

      LOOP AT tb_item.

        lv_tabix = sy-tabix.

        READ TABLE tb_eban_po WITH KEY banfn = tb_item-preq_no

                                       bnfpo = tb_item-preq_item.

        IF sy-subrc EQ 0.

          tb_item-item_cat = tb_eban_po-pstyp.

          tb_item-acctasscat = tb_eban_po-knttp.

          tb_item-gr_basediv = co_x.

* Populate the Service Table

          tb_service-pckg_no = tb_eban_po-packno.

          tb_service-matl_group = tb_eban_po-matkl.

          tb_service-quantity = tb_eban_po-menge.

          tb_service-base_uom = tb_eban_po-meins.

          tb_service-short_text = tb_eban_po-txz01.

          tb_service-base_uom   = tb_eban_po-meins.

          tb_service-ext_line   = '10'.

          tb_service-gr_price   = tb_eban_po-preis.

          APPEND tb_service.

 

          tb_srv_acc-pckg_no = tb_eban_po-packno.

          APPEND tb_srv_acc.

 

          READ TABLE tb_itemx INDEX lv_tabix.

          IF sy-subrc EQ 0.

            tb_itemx-item_cat = co_x.

            tb_itemx-acctasscat = co_x.

            tb_itemx-gr_basediv = co_x.

            MODIFY tb_item INDEX lv_tabix.

            MODIFY tb_itemx INDEX lv_tabix.

          ENDIF.

 

          tb_item-item_cat = tb_eban_po-pstyp.

          tb_item-acctasscat = tb_eban_po-knttp.

        ENDIF.

      ENDLOOP.

    ENDIF.

  ENDIF.

* Fill the POACCOUNT Table.

  SELECT *

      FROM ebkn

  INTO TABLE tb_ebkn_po

  FOR ALL ENTRIES IN tb_sch

  WHERE banfn = tb_sch-preq_no.

 

  IF NOT tb_ebkn_po[] IS INITIAL.

 

    LOOP AT tb_ebkn_po.

      tb_acc-po_item     = tb_ebkn_po-bnfpo.

      tb_acc-serial_no   = tb_ebkn_po-zebkn.

      tb_acc-quantity    = tb_ebkn_po-menge.

      tb_acc-gl_account  = tb_ebkn_po-sakto.

      tb_acc-costcenter  = tb_ebkn_po-kostl.

      tb_acc-profit_ctr  = tb_ebkn_po-prctr.

      tb_acc-co_area     = tb_ebkn_po-kokrs.

      tb_acc-net_value   = tb_ebkn_po-netwr.

      APPEND tb_acc.

* Fill the POACCOUNTX Table

      tb_accx-po_item    = tb_ebkn_po-bnfpo.

      tb_accx-po_itemx   = co_x.

      tb_accx-serial_no  = tb_ebkn_po-zebkn.

      tb_accx-serial_nox = co_x.

      tb_accx-quantity   = co_x.

      tb_accx-gl_account = co_x.

      tb_accx-costcenter = co_x.

      tb_accx-profit_ctr = co_x.

      tb_accx-co_area    = co_x.

      tb_accx-net_value  = co_x.

      APPEND tb_accx.

    ENDLOOP.

  ENDIF.

 

ENDFORM.

Edited by: Archish RS on Feb 7, 2008 9:34 AM

6 REPLIES 6
Read only

Former Member
0 Likes
1,237

helo i also tried that bapi that has blog in that bapi for service po.

dont use it

Read only

0 Likes
1,237

Hi hari,

Didnt get you, what do you mean by blog?? did you mean bug?

"that has blog in that bapi for service po"

Read only

Former Member
0 Likes
1,237

In the item table there is field pass the blwo value for account item caltegory .

s_bapipoitem-acctasscat = rs_upload-acctasscat.

also in the Item X table the following parameter .

s_bapipoitemx-acctasscat = c_x.

This works ,it works for me .

Please reward if useful .

Read only

Former Member
0 Likes
1,237

ya there is some bug .

i searched fr sap notes.but was failure so i wrote bdc.

Read only

Former Member
0 Likes
1,238

Hello,

The same problem is discussed before two days.

Please have a look at this thread:

https://www.sdn.sap.com/irj/sdn/profile?userid=3461421

solved the issue by debugging.

Don't get too worried, there is an easy way to solve this if you get issues like this. See I was able to create a service PO from ME21N transaction. As you know service PO needs Service lines to be created it's mandatory. Here were my error is.

SAP from front end is using a hierarchical method of creating service lines. Not sure this is always like this!!!

The way you can figure out is ..go and create a PO from front end. use that PO number in BAPI_PO_GETDETAIL.

See the values it returns in the associated tables. Compare these values with your mapping in data load program. Then make the necessary changes. Of course there are things needs to be changed in Both Service line structure and Account structure. good luck

Hope this will solve ur problem

Cheers,

Vasanth

Read only

0 Likes
1,237

HI Vasanth,

Thanks for the information. I tried the method suggested but sadly i am still stuck with the same error. Any more info will be of great help