cancel
Showing results for 
Search instead for 
Did you mean: 

How to read maintenance plan history MHIS on save of notification?

gopalkrishna_baliga
Participant
0 Kudos

Dear Experts,

I want to read maintenance plan call date and due package from MHIS table when plan is scheduled in IP10. Actually IP10 internally creates notification.

So in the user exit for create notification EXIT_SAPLMCI1_001 I written my custom code. Here I need to fetch call date and due package for the current schedule call. I tried to query table MHIS but I don't find my entry in MHIS. I think MHIS is updated later.

Then how to get call date and package in this user exit?

Is there any FM to read MHIS from buffer?

thanks & Regards

Gopal

Accepted Solutions (1)

Accepted Solutions (1)

former_member208149
Participant
0 Kudos

Hi Gopal,

Yes, you are correct when you say that MHIS is not yet updated when this exit EXIT_SAPLMCI1_001 is called because update task hasn't been called yet. Therefore, current call will not be available in MHIS table until this point.

Therefore, to get the values of MHIS corresponding to current call (which will be updated in MHIS after COMMIT), you have to make use of stack variable. These are the variables which are the part of main program and present in memory stack but not visible in current FM but they can be accessed from memory using field symbols.

You can retrieve MHIS table in your exit as below (copy-paste below code in your exit as is):

CONSTANTS : lc_fnam TYPE bdcdata-fnam VALUE '(SAPLIWP3)AMHIS[]',

FIELD-SYMBOLS : <l_tab> TYPE ANY TABLE,
<l_rec> TYPE ANY.

DATA: lt_mhis TYPE TABLE OF MHIS,

lw_mhis TYPE mhis.

ASSIGN (lc_fnam) TO <l_tab>.
IF sy-subrc EQ 0.
LOOP AT <l_tab> ASSIGNING <l_rec>.
MOVE <l_rec> TO lw_mhis.
APPEND lw_mhis TO lt_mhis.
ENDLOOP.

Your MHIS is ready to be used as you need. This will have all the calls (old and new) for the Maintenance Plan. 🙂

Hope this helps. Please let me know if it worked and solved your query.

Regards,

Sapeksh

Answers (3)

Answers (3)

peter_atkin
Active Contributor
0 Kudos

Gopal

User-exit MCI10001 (EXIT_SAPLMCI1_001) is for PMIS updates and therefore not really designed for IP10/MHIS data.

Have a look at user-exit IPRM0004 (SMOD) or BADI MPLAN_BADI_HEADER_SAVE (SE18) instead.

PeteA

gopalkrishna_baliga
Participant
0 Kudos

Hi Gopalkrishna Bhat

I appreciate your response in answering my question. Let me explain with steps what I am facing.

I have followed below steps in IP10.

In IP10 I entered my plan number

I have put breakpoint in my user exit. At this stage when I check MHIS table i can't find my call number ending with 019 entry there. MHIS has the previous/old call number ending with 018.

This is the problem. I hope now its clear.

Now how to get my current/latest call details like call date and due package when its still not updated in MHIS?

Your help will be really appreciated.

Thanks

Gopal

bhat_gk
Explorer
0 Kudos

Your requirement is not much clear. I assume, you are triggering Notification as call object from maintenance plan and want to derive the Plan date, call date (there is no field called plan call date as you mentioned) and due package for this notification. You should get the required data from MHIS table as explained below.

When the Notification is created, QMIH table will have Maintenance Plan, Maintenance Plan Call Number and Maintenance item (WARPL, ABNUM, WAPOS)

If you pass the above values to MHIS-WARPL and MHIS-ABNUM you will get the package (MHIS- ZAEHL) and "plan date" from (MHIS-NPLDA). If there are more than once entry for this means there are multiple packages due.

(ZAEHL is internal number, does not matter for single cycle, but for strategy plan, To get the text for package get strategy from MPLA-STRAT and from T351P table get the package text)

Note that "Call date" is notification created date (QMEL-ERDAT). You may not find the "call date" in (MHIS-HORDA) once the call object is called/created.

Hope this clarifies your doubt.

gopalkrishna_baliga
Participant
0 Kudos

Please see my response below.