Quantcast
Channel: Enterprise Asset Management (SAP EAM)
Viewing all articles
Browse latest Browse all 209

Specify conditions for Components in PM Order (User Exit IWO10009)

$
0
0

Hello Friends,

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 of Header and Operation Tabs directly to define his conditions for ‘Saveevent.


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

Capture.JPG

 

 

Similarly the code below forces the user to fill the Plan 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.
*--------------------------------------------------
* Get Status line of the PM Order
*--------------------------------------------------
 CALL FUNCTION 'STATUS_TEXT_EDIT'
 EXPORTING
 FLG_USER_STAT = 'X'
 OBJNR         = CAUFVD_IMP-OBJNR
 ONLY_ACTIVE   = 'X'
 SPRAS         = SY-LANGU
 IMPORTING
 LINE          = V_STAT.
 *------------------------------------------------
 IF V_STAT+0(3) = 'REL'.
 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

 

Thank you

Jogeswara Rao K


Viewing all articles
Browse latest Browse all 209

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>