We know that user-exit IWO10009 (PM Order: Customer Check for ‘Save’ Event) has been provided to specify our conditions to be fulfilled for a PM Order to get through ‘Save’ event. The Function-exit here namely EXIT_SAPLCOIH_009 is based on a structure CAUFVD wherein user gets many fields beyond Order Header fields to define his conditions for ‘Save’ event.
In this blog let’s see the codes for simple applications first and then reach the subject matter. All the codes discussed in this post are needed to be put in the include ZXWOCU07 provided in this Exit.)
Let’s look at a simple code given below .
IF CAUFVD_IMP-AUART = 'PM03' OR CAUFVD_IMP-AUART = 'PM02'. IF CAUFVD_IMP-TPLNR IS INITIAL AND CAUFVD_IMP-EQUNR IS INITIAL. MESSAGE: 'Please fill either F/Location or Equipment' TYPE 'E' DISPLAY LIKE 'I'. ENDIF. ENDIF.
The code above, checks (for Order types PM03, PM02) whether both the Functional Location and Equipment fields in the Reference Object screen are left blank and in such case stops the Order to be Saved / Created giving rise to the error message below
Similarly the code below forces the user to fill the Plant Section in the Location field of PM04 Order.
IF CAUFVD_IMP-AUART = 'PM04'. IF CAUFVD_IMP-BEBER IS INITIAL. MESSAGE 'Please fill Plant Section in Location Tab’ TYPE 'E' DISPLAY LIKE 'I'. ENDIF. ENDIF.
So what I want to say is, such are varied needs of users and these can be met with the simple syntaxes as shown above.
Now, let’s see a requirement for checks in the Components tab. The structure in the user exit (CAUFVD) does not have the fields of Components tab (RESB structure) such as MATNR (Material code), BDMNG (Quantity) etc. So we can not readily incorporate checks on Material related information in a PM Order to prevent ‘Save’ event.
This requirement has been addressed in the following syntax, as a result the code is a bit lengthier.
Case1: User wants check on the MRP Types of the components used- Means Order should accept Components of certain MRP types only.
The Code for this:
TYPES: BEGIN OF TY_RESB, MATNR TYPE RESB-MATNR, RSPOS TYPE RESB-RSPOS, END OF TY_RESB. DATA: IT_RESB TYPE TABLE OF TY_RESB, WA_RESB LIKE LINE OF IT_RESB, LV_DISMM TYPE MARC-DISMM. FIELD-SYMBOLS: <FS_RESB> TYPE ANY. DATA: BEGIN OF I_RESB OCCURS 100. INCLUDE STRUCTURE RESB. DATA:END OF I_RESB. ASSIGN ('(SAPLCOBC)resb_bt') TO <FS_RESB>. I_RESB = <FS_RESB>. SELECT MATNR RSPOS FROM RESB INTO TABLE IT_RESB WHERE AUFNR = CAUFVD_IMP-AUFNR. CLEAR LV_DISMM. LOOP AT I_RESB. READ TABLE IT_RESB INTO WA_RESB WITH KEY RSPOS = I_RESB-RSPOS. IF SY-SUBRC = 0. SELECT SINGLE DISMM FROM MARC INTO LV_DISMM WHERE MATNR = WA_RESB-MATNR. IF LV_DISMM = 'P1' OR LV_DISMM = 'P2' OR LV_DISMM = 'P3'. MESSAGE: 'Please check the MRP type of the component materials used' TYPE 'E'. ENDIF. ENDIF. ENDLOOP.
The above code refuse the Order to be saved in case the MRP types of components used belong to ‘P1’, ‘P2’ or ‘P3’.
Take this as a code-key to unconventional requirements. Study what extra has been used here. Yourself and/or your ABAPer will be able to solve several such requirements using this technique, where user-exit structures do not directly support the requirements.
Case2: Similar was another requirement where, changes in Material Quantities are not acceptable once the PM Order has been set to REL status
This is the code for this purpose:
TYPES: BEGIN OF ty_resb, rspos TYPE resb-rspos, bdmng TYPE resb-bdmng, END OF ty_resb. DATA: it_resb TYPE TABLE OF ty_resb, wa_resb LIKE LINE OF it_resb. DATA: v_stat TYPE j_stext. FIELD-SYMBOLS: <fs_resb> TYPE ANY. DATA: BEGIN OF i_resb OCCURS 100. INCLUDE STRUCTURE resb. DATA:END OF i_resb. ASSIGN ('(SAPLCOBC)resb_bt') TO <fs_resb>. i_resb = <fs_resb>. SELECT rspos bdmng FROM resb INTO TABLE it_resb WHERE aufnr = caufvd_imp-aufnr. IF caufvd_imp-iphas = '2'. LOOP AT i_resb. READ TABLE it_resb INTO wa_resb WITH KEY rspos = i_resb-rspos. IF sy-subrc = 0. IF wa_resb-bdmng <> i_resb-bdmng. MESSAGE: 'Component changes not accepted after release of Order' TYPE 'E'. ENDIF. ENDIF. ENDLOOP. ENDIF.
The things usually in author’s mind while posting such information
- Create repository of ready solutions to frequently asked questions
- Let functional man become self-reliant in working with User-Exits through simple coding logics like these.
Hope this post too helps members
Recently I have explored another user-exit related to checks in Order Components. i.e. PPCO0023 . Today I replied to one such requirement in the thread given here.Regarding Bill of Material in maintenance order
- I felt this user-exit looks better for the checks in components tab due to these advantages:
- Heavy coding using field symbols etc can be avoided.
- Instant Check happens when some change takes place in components tab. (IWO10009 checks at the time of Save)