Friday 29 April 2022

Enhancement at Purchase Requisition: Status Grid

There’re some articles already explaining how to add customized fields at the customized sub-screen of ME53N:

Add Custom Field to Purchase Requisition – MEREQ001 by M.Ozgur Unal

Add a Custom Screen on Purchase Requisition Header by Gangrong Chen

What if only a few more standard fields at Purchase Requisition: Status Grid without using custom TAB/sub-screen?

SAP ABAP, SAP ABAP Exam, SAP ABAP Exam Prep, SAP ABAP Preparation, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Learning

Find the corresponding sub-screen number which is 3317 for Purchas Requisition: Status – ALV Grid at function group: MEGUI. Screen 3316 is a sub-area for purchase requisition: status.

SAP ABAP, SAP ABAP Exam, SAP ABAP Exam Prep, SAP ABAP Preparation, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Learning

Related objects for Purchase Requisition: Status Grid:

◉ Structure name: MEREQ_HISTORY
◉ Refered class: cl_grid_view_mm
◉ Populate method: transport_from_model
◉ Populate FM: MM_PURREQ_HISTORY_GET

SAP ABAP, SAP ABAP Exam, SAP ABAP Exam Prep, SAP ABAP Preparation, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Learning

Besides, the key function module ‘MEPOBADI_CHANGE_OUTTAB’ will provide method ‘fill_outtab’ against the BADI ‘me_change_outtab_cus ‘ to populate customized or newly added fields inside ‘MM_PURREQ_HISTORY_GET’.

SAP ABAP, SAP ABAP Exam, SAP ABAP Exam Prep, SAP ABAP Preparation, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Learning

So now it’ll be clear that we can simply enhance this standard ALV grid with the following steps:

1. Create append structure for ‘MMREQ_HISTORY’

SAP ABAP, SAP ABAP Exam, SAP ABAP Exam Prep, SAP ABAP Preparation, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Learning

2. Create BADI Implementation for ‘ME_CHANGE_OUTTAB_CUS’

SAP ABAP, SAP ABAP Exam, SAP ABAP Exam Prep, SAP ABAP Preparation, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Learning

METHOD if_ex_me_change_outtab_cus~fill_outtab.
* When processing this source code, you activate the following functionality:
* The reporting transactions for purchasing documents provide three main views
* for display: basic list, delivery schedule, and account assignment. All
* three views contain a column "Material". If the material of a purchasing
* document item is a manufacturer part number (MPN) then this MPN is shown
* as "Material". The internal inventory managed material is not visible.
* The following source code replaces the MPN by the inventory managed material.

  DATA: ls_ekpo TYPE ekpo,
        lv_werks type EWERK,
        lv_bstYP type EBSTYP.

  FIELD-SYMBOLS: <fs_outtab>   TYPE any,
                 <fs_ebeln>    TYPE ebeln,
                 <fs_ebelp>    TYPE ebelp,
                 <fs_ertwr>    TYPE bbwert,
                 <fs_abskz>    TYPE abskz,
                 <fs_werks>    TYPE EWERK,
                 <fs_agmem>    TYPE agmem,
                 <fs_material> TYPE matnr.

* check that a purchasing document view is displayed
  CHECK im_struct_name EQ 'MMREQ_HISTORY'. "PO HISTORY for ITEM

* loop at the output table and assign a field symbol
  LOOP AT ch_outtab ASSIGNING <fs_outtab>.

*-- assign the purchasing document number to a field symbol
    ASSIGN COMPONENT 'EBELN' OF STRUCTURE <fs_outtab> TO <fs_ebeln>.
    CHECK sy-subrc = 0.
*-- assign the purchasing document item number to a field symbol
    ASSIGN COMPONENT 'EBELP' OF STRUCTURE <fs_outtab> TO <fs_ebelp>.
    CHECK sy-subrc = 0.
    ASSIGN COMPONENT 'WERKS' OF STRUCTURE <fs_outtab> TO <fs_werks>.
    CHECK sy-subrc = 0.
*   NEW 3 fields at PO history item level!
    ASSIGN COMPONENT 'BRTWR' OF STRUCTURE <fs_outtab> TO <fs_ertwr>.
    ASSIGN COMPONENT 'ABSKZ' OF STRUCTURE <fs_outtab> TO <fs_abskz>.
    ASSIGN COMPONENT 'AGMEM' OF STRUCTURE <fs_outtab> TO <fs_agmem>.

"   get Purchasing Document Category
   clear lv_bstyp.
   select single bstyp
     into lv_bstyp
     from ekko
     where ebeln eq <fs_ebeln>.

* Restriction for IN* plant and 'RFQ' only!
   if lv_bstyp eq 'A' and <fs_werks>+0(2) EQ 'IN'.
     "populate those 3 added fields for ME53N at PO item history~!
    SELECT SINGLE brtwr abskz agmem FROM ekpo
      INTO ( <fs_ertwr>, <fs_abskz>, <fs_agmem> )
      WHERE ebeln EQ <fs_ebeln>
      AND   ebelp EQ <fs_ebelp>.
   endif.

  ENDLOOP.

ENDMETHOD.

3. Change the layout at ME53n

SAP ABAP, SAP ABAP Exam, SAP ABAP Exam Prep, SAP ABAP Preparation, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Learning

So BADI ‘ME_CHANGE_OUTTAB_CUS’ will be very helpful for all those kinds of enhancing for ME* transactions. Check this first before using any other approaches.

Source: sap.com

No comments:

Post a Comment