ABAP Blog Posts
cancel
Showing results for 
Search instead for 
Did you mean: 
Studi83
Explorer
0 Likes
255

In SAP Plant Maintenance (PM), warranty periods for technical objects are designed to be inherited automatically from superior functional locations to their subordinate locations. This is part of the standard functionality. However, in practice, this inheritance sometimes fails... leading to inconsistencies and manual corrections that consume time and create frustration for PM administrators.

The Problem

Although SAP provides automatic inheritance for warranty start and end dates, there are cases where this process does not work as expected. Common reasons include:

  • Data inconsistencies in the hierarchy.
  • Missing or incorrect object numbers.
  • Technical issues during creation or update of functional locations.

When inheritance fails, subordinate locations remain without warranty data, which can impact maintenance planning and compliance.

The Solution

Instead of relying solely on the standard process, we developed a lightweight ABAP report that ensures warranty data consistency across the hierarchy. The report reads warranty start and end dates from the parent functional location and applies them to all subordinate locations, writing the data directly into the BGMKOBJ table.

Key Features

  • Input: Superior functional location.
  • Logic: Reads warranty data from the parent and applies it to all child locations.
  • Execution: Uses MODIFY on BGMKOBJ, which automatically decides whether to update existing records or insert new ones.
  • Modes: Test mode for simulation and productive mode for actual updates.

Core Logic

LOOP AT lt_child ASSIGNING FIELD-SYMBOL(<child>).
  IF p_test = abap_true.
    lv_status = |SIMULATION: Location { <child>-tplnr } would be updated or newly created.|.
  ELSE.
    CLEAR wa_bgmkobj_child.
    wa_bgmkobj_child = wa_bgmkobj_parent.
    wa_bgmkobj_child-j_objnr = <child>-objnr.
    wa_bgmkobj_child-erdat   = sy-datum.
    wa_bgmkobj_child-erzei   = sy-uzeit.
    wa_bgmkobj_child-gaerb   = 'X'.

    " MODIFY automatically decides whether to INSERT or UPDATE
    MODIFY bgmkobj FROM _bgmkobj_child.

    IF sy-subrc = 0.
      lv_status = |Location { <child>-tplnr } successfully processed.|.
    ELSE.
      lv_status = |Error processing location { <child>-tplnr }.|.
    ENDIF.
  ENDIF.

  WRITE: / lv_status.
ENDLOOP.