Skip to Content
Author's profile photo ShanmugaSundaram Rajamanickam

Creation of Service-PO using BAPI_PO_CREATE1

About the post:

Hi everyone,

This post provides a detailed explanation of Service PO creation. Also, can able to understand the below bulletin points:

  • The tables that refer to the service line logic.
  • Passing the fields (needed for service-PO creation) to the BAPI_PO_CREATE1.


Check the entries in ESLL, and ESKL (see attached images with the boxes indicated). Observe how the values are stored.

  • ESLL – Lines of Service Package table

In the above table, we can see that:

  1. There are two service lines. A service line belongs to two rows in the ESLL table.
  2. For each service line, there are two rows created. The first row is a dummy but we need to pass values to few fields such as packno, introw, package and sub_packno.
  3. The second row is the real service line which we are able to see it PO screen. In other words, we need to map the fields according to our requirement in the second row of each line item.
  • ESKL – Account Assignment Service Line table

In the above table, we can see that:

  1. There are two service lines. Each row belongs to a service line in the ESKL table.
  2. The service lines (refer to field Introw- 2, 4) are stored in this table.

Coding that I implemented for Service-PO creation:

DATA: lv_dummy TYPE packno,
      lv_pkgno TYPE packno,
      lv_item_pno TYPE packno,
      lv_pckg_no TYPE char10,
      lv_pckg_no1 TYPE char10,
      lv_subpckg_no TYPE char10,
      lv_line_no TYPE char2,
      lv_line_no1 TYPE char2.

Internal Tables
DATA: lt_poitem            TYPE TABLE OF bapimepoitem,
      lt_poitemx           TYPE TABLE OF bapimepoitemx,
      lt_poaccount         TYPE TABLE OF bapimepoaccount,
      lt_poaccountx        TYPE TABLE OF bapimepoaccountx,
      lt_poservices        TYPE TABLE OF bapiesllc,
      lt_poservices        TYPE TABLE OF bapiesllc,
      lt_posrvaccessvalues TYPE TABLE OF bapiesklc,
      gt_po                TYPE TABLE OF {structure we maintain}.

Work Area
DATA: ls_poitem            TYPE bapimepoitem,
      ls_poitemx           TYPE bapimepoitemx,
      ls_poaccount         TYPE bapimepoaccount,
      ls_poaccountx        TYPE bapimepoaccountx,
      ls_poservices        TYPE bapiesllc,
      ls_poservices        TYPE bapiesllc,
      ls_posrvaccessvalues TYPE bapiesklc.

CLEAR: lv_pkgno.
 lv_dummy = lc_1. " maintaining Line number at service level

*_ Item level details starts
 LOOP AT gt_po INTO DATA(ls_po)
                    WHERE ebeln = <ls_po_temp>-ebeln. "#EC CI_NESTED

ls_poitem-item_cat = ls_po-pstyp. " Item category in purchasing document
 IF ls_po-pstyp IS NOT INITIAL.
  lv_pkgno = lv_dummy.
  ls_poitem-pckg_no = lv_pkgno.
 " for mapping in poservice table, moving 'pckg no'(@item level) to lv_item_pno
  lv_item_pno = ls_poitem-pckg_no.
  lv_dummy = lv_item_pno + 2.

 " additional fields to be passed
  ls_poitem-period_ind_expiration_date = lc_d. " Period Ind Exp Date
  ls_poitemx-item_cat = lc_x. " Item category in purchasing document
  ls_poitemx-pckg_no = lc_x.

  IF ls_po-knttp = 'K'
  AND ls_po-pstyp EQ 'D'.
                                      WHERE po_item = ls_po-ebelp
                                        AND pckg_no = lv_item_pno.
      ls_poservices-pckg_no = ls_poservices-line_no = lv_item_pno.
      lv_pckg_no = ls_poservices-pckg_no.
      lv_line_no = lv_item_pno+8(2).
      ls_poservices-outl_ind = lc_x.
      ls_poservices-subpckg_no = lv_item_pno + 1.
      lv_subpckg_no = ls_poservices-subpckg_no.
      APPEND ls_poservices TO lt_poservices.
      ls_poservices-pckg_no = ls_poservices-pckg_no + 1.
      lv_pckg_no1 = ls_poservices-pckg_no.
      ls_poservices-line_no = lv_pckg_no1.
      lv_line_no1 = ls_poservices-line_no+8(2).
      ls_poservices-ext_line = lc_1000(2).
      ls_poservices-outl_ind = space.
      ls_poservices-subpckg_no = space. " ls_poservices-pckg_no.
      ls_poservices-service = ls_po-matnr.
      ls_poservices-short_text = ls_po-txz01.
      ls_poservices-quantity = ls_po-menge.
      ls_poservices-base_uom = ls_po-lmein.
      ls_poservices-gr_price = ls_po-netpr.
      ls_poservices-net_value = ls_po-netpr.
      ls_poservices-matl_group = ls_po-wgbez.
      APPEND ls_poservices TO lt_poservices.
      CLEAR: ls_poservices.

      ls_posrvaccessvalues-pckg_no = lv_pckg_no1.
      ls_posrvaccessvalues-line_no = lv_pckg_no1.
      ls_posrvaccessvalues-serno_line = lv_item_pno+8(2).
      ls_posrvaccessvalues-percentage = '100'.
      ls_posrvaccessvalues-serial_no = lv_item_pno+8(2).
      ls_posrvaccessvalues-quantity = ls_po-menge.
      ls_posrvaccessvalues-net_value = ls_po-netpr.
      APPEND ls_posrvaccessvalues TO lt_posrvaccessvalues.
      CLEAR: ls_posrvaccessvalues.
     " Mapping the account assignment fields at service level.
          LOOP AT lt_poservices TRANSPORTING NO FIELDS
                                                 WHERE pckg_no = lv_pckg_no1
                                                   AND line_no = lv_line_no1.
          " Account Assignment at service level
             ls_poaccount-po_item = ls_po-ebelp. " Item number
             ls_poaccountx-po_item = ls_po-ebelp. " Item number
             ls_poaccountx-po_itemx = lc_x. " Item number
             ls_poaccount-serial_no = lv_line_no.
             ls_poaccountx-serial_no = lv_line_no.
             ls_poaccountx-serial_nox = lc_x.
             PERFORM f_conv_poaccount USING    ls_po
                                      CHANGING ls_poaccount.
             IF ls_poaccount-gl_account IS NOT INITIAL. " G/L Account Number
                   ls_poaccountx-gl_account = lc_x.
             IF ls_poaccount-costcenter IS NOT INITIAL. " Cost Center
                   ls_poaccountx-costcenter = lc_x.
             IF ls_poaccount-orderid IS NOT INITIAL. " Order Number
                   ls_poaccountx-orderid = lc_x.
             IF ls_poaccount-profit_ctr IS NOT INITIAL. " Profit Center
                   ls_poaccountx-profit_ctr = lc_x.
             IF ls_poaccount-wbs_element IS NOT INITIAL. " wbs element
                   ls_poaccountx-wbs_element = lc_x.
             ls_poaccount-co_area = lc_1000. " Control Area
             ls_poaccountx-co_area = lc_x.
             IF ls_poaccount-net_value IS NOT INITIAL. " Net Price
                   ls_poaccount-net_value = ls_po-netpr.
                   ls_poaccountx-net_value = lc_x.
             IF ls_poaccount-quantity IS NOT INITIAL. " Qty
                   ls_poaccount-quantity = ls_po-menge.
                   ls_poaccountx-quantity = lc_x.
             *_ Distribution percentage has to be passed value like below
                   ls_poaccount-distr_perc = '1.0'.
                   ls_poaccountx-distr_perc = lc_x.
             APPEND ls_poaccount TO lt_poaccount.
             APPEND ls_poaccountx TO lt_poaccountx.
             CLEAR: ls_poaccount, ls_poaccountx.
*_ Item level details ends

CLEAR: lv_ponum.
    testrun   = lv_testrun
    exppurchaseorder = lv_ponum
    poitem            = lt_poitem
    poitemx           = lt_poitemx
    poaccount         = lt_poaccount
    poaccountx        = lt_poaccountx
    poservices        = lt_poservices
    posrvaccessvalues = lt_posrvaccessvalues.


I appreciate your comments for the betterment of this post. Please notify me if any of the lines need to be updated or requires additional explanatory.

Thank you, everyone in advance, for your support and co-operation.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member


      Service Purchase Order in SAP : ME23N  – guru99

      Author's profile photo ShanmugaSundaram Rajamanickam
      ShanmugaSundaram Rajamanickam
      Blog Post Author

      Thank you for the providing the supportive link Bhanu Prasad.

      Author's profile photo Former Member
      Former Member

      I believe SAP provided a full FAQ for each case on Note 2114353 - How to create service PO with BAPI_PO_CREATE1

      Author's profile photo ShanmugaSundaram Rajamanickam
      ShanmugaSundaram Rajamanickam
      Blog Post Author

      I believe that SAP has provided the SAP Note. But not everyone has access to enter into that link. Please let me know if non-users can also make use of it. Thank you for providing the link.

      For your reference, I have the problem in accessing the SAP Notes (see attached).

      Kindly suggest your solution if I am not correct. Thank you once again.