Friday 22 April 2022

Mass Deletion of MRP controller in APO

I recently just first touched on the APO system and surprisingly find out that APO even doesn’t have the MARA/MARC table and Transaction code MM01 not to mention the function module like ‘BAPI_MATERIAL_SAVEDATA’!

Here list of the basic approach to mass deletes MRP controllers in APO. It’s for the beginning level of APO development only :

1. Get the structure of the planning objects by ‘/SAPAPO/TS_PLOB_LIST_GET’

◉ Input parameter IV_BAS_PLOBID is mandatory, which will define&provide by functions

◉ Input parameter table it_group_by will be lists of object names that will contain fields like material/plant/MRP controller etc. In my case, it’s totally customized fields like Z_MATNR.

◉ Output table et_plobs_in_view will be the result of the above Z fields at specified PLOBID.

  CALL FUNCTION '/SAPAPO/TS_PLOB_LIST_GET'

    EXPORTING

      iv_bas_plobid            = plobname

      it_selection             = lt_selection

      it_group_by              = lt_group_by

*     is_read_options          = ls_read_options

    IMPORTING

      et_plobs_in_view         = gt_plobs_in_view

*     et_plob_values           = lt_plob_values

    EXCEPTIONS

      invalid_selection        = 1

      no_bas_plobid            = 2

      inherited_error          = 3

      coding_generation_failed = 4

      OTHERS                   = 5.

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

2. Get material related fields for report purposes


Use the value from step1 to fetch fields from below APO tables. Material fields could be MATID~

◉ Material table: /SAPAPO/MATKEY
◉ Location table: /SAPAPO/LOC
◉ Location Product table: /SAPAPO/MATLOC

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

3. Delete MRP controller using FM ‘/SAPAPO/TS_PLOB_DELETE’


◉ Input parameter IV_BAS_PLOBID will be the same as step 1;
◉ Input parameter IT_SELECTION will be working as filters like a combination of select-options

" Material
  CLEAR ls_selection.
  ls_selection-iobjnm = 'Z_MATNR'.
  ls_selection-sign  = 'I'.
  ls_selection-option = 'EQ'.
  ls_selection-low = wa_data-matnr.
  APPEND ls_selection TO lt_selection.
..."add other fields accordingly to specify the filter

◉ Finally using the FM to do the deletion, no extra commit work is required.

CALL FUNCTION '/SAPAPO/TS_PLOB_DELETE'
  EXPORTING
    IV_BAS_PLOBID         = lv_plobid
    IT_SELECTION          = lt_selection
    IV_NOTE_DELETE        = 'X'
 EXCEPTIONS
   NO_BAS_PLOBID         = 1
   INHERITED_ERROR       = 2
   INTERFACE_ERROR       = 3
   OTHERS                = 4 .

Source: sap.com

No comments:

Post a Comment