Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
jogeswararao_kavala
Active Contributor

Hello Friends,

As the title tells, we are going to discuss here the two queries involved:

  1. Whether we can default values in the Notification and Order header fields?
  2. If we can, how to do it ?

First we see the case of Notifications:

The answer to the first question is 'YES'. SAP has provided exclusive user-exit for defaulting values while creating a Notification. The user-exit is QQMA0025. Every user-exit comes with a Z-include where we can write our code which the standard program i.e, Notification create program here, obeys.

Now the second question, How to do it?

It is very simple. Example: suppose you want to default planner-group value as 'XYZ' and Notification short text as 'HVAC Repairs' for Notification type 'HV' then the code you need to put here is:

------------------------------------------------------------

   IF i_viqmel-qmart = 'HV'.
     e_viqmel-ingrp = 'XYZ'
     e_viqmel-qmtxt = 'HVAC Repairs'.
   ENDIF
.

------------------------------------------------------------

After this whenever you create 'HV' Notification, you will find these two values are defaulted. You might wonder what is the need of defaulting the Notification short text? Though that was an example, there can be a case of Prefixing a certain string to the Notification Short text for a particular Notification type. Here the value we defaulted is the fixed part of the short text. User will add the variable part. Thus we are saving the punching effort to the end user. Similar are several other useful applications.

Please note that this is applicable to Create Notification only.

Note:

Things discussed above are relevant for QM Notifications also, but the exit is different. It is QQMA0007. The include here is ZXQQMU01. Codes are identical.

Let's see another way of doing it:

Suppose there is no need of editing a defaulted field value and our default value requirement is very clear, then we can use another user exit namely QQMA0014. The include here is ZXQQMU20. (It is the same for QM also).  We'll try to understand through the same code discussed above. This code in this exit AT THE TIME OF SAVING THE NOTIFICATION erases whatever present in the these fields (Planner Group and Short text) and Creates the Notification with these specified values. You can think of such applications for you.


The difference between these two exits is that the first one (QQMA0025) works only at Create (IW21) event, whereas this exit (QQMA0014) works at Create(IW21) and Change(IW22) both. Means whenever the Notification is subjected to SAVE. So if you want to confine the code to a particular tcode say IW21, then the above code changes like this.

------------------------------------------------------------

IF sy-tcode 'IW21'.
   IF i_viqmel-qmart = 'HV'.
     e_viqmel-ingrp = 'XYZ'
     e_viqmel-qmtxt = 'HVAC Repairs'.
   ENDIF.
ENDIF.

------------------------------------------------------------

An example for this case is: I have one custom Notification type which is used as a Repair request to a central repair facility. What happens here is the Planner group, Work Center values are defaulted from the Reference Object Equipment on which the Notification is being created. Customer is supposed to change these values to specific values related to the Central Repair facility to which this notification is directed. They often forget doing so. So I used this exit, for replacing the correct values automatically when the Notification is saved.

Thus we have areached to the end of the Notification segment of this blog.

Now let's see the case of Order:

The answer to the first question here (Whether we can default Order header values?) is 'No'.  To my knowledge so far, SAP has not provided any user-exit like QQMA0025 discussed above (or a BAdi) in Order area for this purpose. But....Updating Order header fields while at the Save event of Order can be managed like that happens in the case of QQMA0014 discussed above.

Then,  how can we do this:

Our objective here is to update few Order field values whileSave event. The user-exit that makes this possible is IWO10009.  Here the Z-include where we put  our code is ZXWOCU07. Now what is the code.....

Let's consider an example of our requirement, where we need the Planner group, Work center and the Maintenance Planning Plant for an Order type are to be updated with specific values while Saving .

------------------------------------------------------------

IF caufvd_imp-auart = 'PM08'.
   caufvd_imp-ingpr = 'HV1'.
   caufvd_imp-vaplz = 'MOTREP'.
   caufvd_imp-iwerk = '1000'.

   CALL FUNCTION 'CO_IH_SET_HEADER'
     EXPORTING
       caufvd_imp = caufvd_imp.

   PERFORM header_update(saplcoih).

ENDIF.

------------------------------------------------------------

If we want to confine the code to IW31 only, then it can be done in a similar way as explained previously for IW21.

For quite sometime I felt the deficiency of not having the value defaulting user-exit for the maintenance order. But after I found this method using fm 'co_ih_set_header' , things became simpler for me for addressing special checks.

I want to give another example for this updating requirement. We wanted to update the Order short text field with a formatted Work Order number like DeptName/NNNN/YYYY while saving. The code here first determines the values of DeptName from the Planner Group, Running serial number NNNN on the basis of the serial number for the previously Order and the YYYY is the current year. Code then combines (concatenate) these three values all these values into a variable say v_text with / in between.


Then we use same code as above to update Order short text:

------------------------------------------------------------

IF caufvd_imp-auart = 'PM07'.
   caufvd_imp-ktext = v_ktext.

   CALL FUNCTION 'CO_IH_SET_HEADER'
     EXPORTING
       caufvd_imp = caufvd_imp.

   PERFORM header_update(saplcoih).

ENDIF.

------------------------------------------------------------

I feel we have adequately discussed on the titled subject.


Now, let me remind some general points on using user-exit.

  • Use of user-exits is very simple. (tcode SMOD).
  • If you sit with an ABAPer, you'd learn it within few minutes
  • User-exit functions only if it is assigned to a project created through tcode CMOD.
  • I feel every functional man should have the knowledge of enhancements especially user-exits.

Thank you & Regards

KJogeswaraRao

30/12/2015

Recently there was a requirement of defaulting values to Order custom fields. A solution was worked-out using the PBO module of the screen-exit IWO10018, through which these custom fields are created. The solution is in this thread: Make default Date to Custom Field

4 Comments
Labels in this area