How to Add and Change PO Service Line using BAPI BAPI_PO_CHANGE?

How to Add and Change PO Service Line using BAPI BAPI_PO_CHANGE?

Administrations Tab in PO screen (ME23N) is one of the feared tabs by most ABAPers. At whatever point there is a prerequisite to add, erase or change the things of the PO Administrations, I found, most ABAPers follow the most secure way of BDC? However, Why? How to Add and Change PO Service Line using BAPI BAPI_PO_CHANGE?

In one of the undertakings, I recollect that, I involved BDC for PO Administrations, since I couldn’t connect the PO Pack No to the Assistance Things.

With experience, everybody develops. The equivalent occurred with me as well. In my ongoing undertaking, when I got the prerequisite to alter the PO Administration Thing, not set in stone to finish it utilizing BAPI. To the surprise of no one, I confronted a few hiccups, however toward the finish of the passage, I saw the light. Let’s answer How to Add and Change PO Service Line using BAPI BAPI_PO_CHANGE?

I had two prerequisites.

  1. Edit existing PO Service Item.
  2. Add a new item in the PO Service.
bapi_po_change

Genuine Prerequisite: We really want to search for all Administrations Details where the Amount and Real Amount sections are NOT equivalent. In the picture above, for Administration Line 10, the Amount is 12 while the Genuine Amount is 9.293. Since the Amount and Real Amount are unique, we really want to part this line into two lines.

1. Modify Service Line 10:

Line 10 would have Amount as 9.293 and Genuine Amount as 9.293 (for example the genuine amount is replicated to the amount segment).

2. Add new Service Line say 80 (assuming already there are lines till 70)

New Help Line 80 would be added with the distinction in Amount and Real Amount for example 2.707. (12 – 9.293 = 2.707). Amount Segment will have esteem 2.707 while Real Amount would be set to 0.000.

Essentially, Line 20 would be changed to have Amount and Real Amount as 9 and a relating new Help line say, 90 would be added with Amount as 3 i.e (12 – 9 = 3) and Genuine Amount as 0.000. What’s more, same rationale must be applied to all Help lines which have a distinction in the Amount and Genuine Amount.

Ideally, the specialized prerequisite is clear. How about we get into work.

Step 1: Get the PO details using BAPI_PO_GETDETAIL1.

My necessity was exclusively to get Administrations and Record Task Class for BAPI_PO_CHANGE.

  call function 'BAPI_PO_GETDETAIL1'
      exporting
        purchaseorder      = wa_ekko-ebeln
        account_assignment = 'X'
        item_text          = 'X'
        header_text        = 'X'
        services           = 'X'
      importing
        poheader           = poheader
      tables
        return             = it_return
        poitem             = it_poitem
        poschedule         = it_poschedule
        poaccount          = it_poaccount
        poservices         = it_poservices
        posrvaccessvalues  = it_posrvaccessvalues.

Step 2: Fill the data for PO Header.

perform fill_header_data.  "ekko data passing here

Step 3: Exclude the Deleted PO Items and prepare the item[ ] table for the PO.

delete: it_poitem where delete_ind = 'L',
        it_esll1  where del = 'X'.
    loop at it_poitem into wa_poitem .
      perform fill_item.  “filling the item details.
      read table it_esll into wa_esll with key packno = wa_poitem-pckg_no.

      if sy-subrc = 0.
        loop at it_esll1 into wa_esll1 where packno = wa_esll-sub_packno.         

         if wa_esll1-act_menge ne 0.
            if wa_esll1-menge gt wa_esll1-act_menge.
              val = wa_esll1-menge - wa_esll1-act_menge.
              perform fill_po_data_new_bapi .
            endif.
        endif.
          clear: wa_esll1,val.
        endloop.
        clear: wa_esll1, lv_introw,lv_extrow,wa_poitem.
      endif.
    endloop.

Step 4: Populate insights regarding Administrations and Record Task Classification tables.

perform fill_po_data_new_bapi.

The Trickiest piece of the advancement was to find the Record Task Classification for the Help detail and planning that Record Task Classification to POACCESSVALUES[ ] table of the BAPI.

This is the Core of the advancement work. What’s more, hence, this is the center of this article. Assuming that you flounder on this planning, your BAPI could never do what you are anticipating. So don’t snooze. Keep your brain and eyes open.

4.1 Pass the Sub Pack Number and Interior Line Number of the Sub Detail to the table ESKL and pick the ZEKKN. (For connecting, this part is extremely significant). We can’t pressure more.

linking package number in po

4.2 Pass the EBELP and ESKL-ZEKKN to the table EKKN(Account Task Classification)

Account Assignment Category

You will get every one of the subtleties of replicated column with the goal that you can pass the subtleties and make another sub detail.

How to edit Service Line Item

Taking a deeper look at the HEART of the Program/Development:

PO_ITEMS[] :

ITEM    |   PACKAGE NO

10      |   10001  (Parent Package No)
PO_ACCOUNT[]:

ITEM | SERIAL | QUANTITY | GL         | COST CENTRE| PROFIT CEN……….

10   |    01  |   100    | 45245      |  1452      | ……
PO_SERVICES[]:

PCKG NO  |  LINE NO   | EXT LINE  |  OUT LINE | SUB PCKG NO

10001    |  0000001  |   0000000 |     0             |  10002   (child package no)

10002    |  0000002  |   0000010 |     0             |  00000  |

10002    |  0000006  |   0000070 |     0             |  00000  |

SAP ABAP Training Free

PO_SERVICE_ACES_VALUES[]:

Here we want to Connection the Record Task Classification (for example GL , Request id, and so forth data ) to the changing Help Details (Need to dole out the line which is altered (Administration Line 10) and the new Assistance Line 80 which is added)

Right planning is exceptionally essential. Assuming that we map right, the GL related data will be appended to the new sub details accurately.

GL related info will be attached to the new sub line items
PO_SERVICE_ACES_VALUES[]:

PCKG NO  |  LINE NO  |   SERNO_LINE  | PERCENTAGE | SERIAL  | QUAN   | ……….

00002    |  0000002  |   01          |   100      |  01 (already highlighted above)|

00002    |  0000006  |   01          |   100      |  01

In the event that you map the above Heart of the improvement accurately, your Administration Detail would be changed and added consistently.

Before executing our Conversion Program.

What is ABAP?

In the wake of executing our Transformation Program.

BAPI_PO_CHANGE

I’m sure, with the above hints, ABAPers would have the option to get the planning straight and can add, erase or change any PO Administration utilizing the BAPI. Bye BDC.

We realize you needn’t bother with to be coddled. Yet, we are joining a demo program which does precisely very thing we made sense of above. Kindly note, it is only a model program. It has not passed any quality audit. Thus, you will track down better ways of composing the code, yet in the event that you want to allude to how we have planned and connected the bundles, chronic numbers, and G/L record, the joined code underneath may be valuable.

 

YOU MAY LIKE THIS

SAP ABAP Training Institute in Pune, SAP ABAP Courses Online

Best Practices for SAP ABAP Development: A Comprehensive Guide

Top SAP ABAP Interview Questions (2024)

 

18072
X
WhatsApp WhatsApp us