Skip to Content
Author's profile photo K Jogeswara Rao

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

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 beyond Order Header fields 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 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

Thank you

KJogeswaraRao

15.05.2015:

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)


Assigned Tags

      11 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Good one.

      Regards

      Santosh

      Author's profile photo Former Member
      Former Member

      One more good piece of Informative document from you,sir.

      Very useful document for functional consultant like me 🙂 🙂

      Regards,

      Parag

      Author's profile photo K Jogeswara Rao
      K Jogeswara Rao
      Blog Post Author

      Thank you Parag

      Author's profile photo Deep D
      Deep D

      Nice work sir. Helpful. 🙂

      Author's profile photo K Jogeswara Rao
      K Jogeswara Rao
      Blog Post Author

      Thank you Deep 🙂

      Author's profile photo Amol Khaimar
      Amol Khaimar

      Hello Sir,

      Your post and documents are quite knowledgeable and always helpful. But most important is the way you explain the scenarios. For anyone its a great learning on how to represent things. Great work sir. Once again thank you for sharing knowledge piece.

      Regards,
      Amol

      Author's profile photo K Jogeswara Rao
      K Jogeswara Rao
      Blog Post Author

      Thank you Amol 🙂 ,

      Basic Objectives of my documentation:

      • To preserve our discoveries to avoid situations of re-inventing the wheel.
      • To give back to SCN from where we continuously learn.

      Regards

      KJogeswaraRao

      Author's profile photo Shaurya Jain
      Shaurya Jain

      Dear Mr. Rao,

      You article is indeed very helpful.

      Many thanks for sharing your knowledge and experience with fellow SAP consultants.

      Regards,
      Shaurya Jain

      Author's profile photo Aarti Hinge
      Aarti Hinge

      Very useful blog. Thank you.

      Author's profile photo Irfan Bakhtiar
      Irfan Bakhtiar

      Thank you for making this blog. it's very helpful.

      I just wondering, how can you know program name and table name to put in your FS ?

       

      Author's profile photo Former Member
      Former Member

      Hi Sir,

      Need your help for 2 scenarios in PM.

      It would be great if you can provide me your email id so that i can directly send you the questions.

      Sir, its kind of urgent.

      Many thanks for your help in advance.