SAPPractical.com

4/23/2016 10:03:20 PM

This blog will gives you How to implement SAP ABAP field exit and what are the prerequisite to implement SAP ABAP field exit.Set the profile parameter using the transaction RZ10 with the parameter abap/fieldexit = 'YES' before system start. Below the link will give you about introduction to SAP ABAP Field Exit and FAQ.

Introduction to SAP ABAP Field Exit and FAQ on SAP ABAP Field Exit

High level requirement : Whenever MM RFQ created the line item material column should me mandatory based on Doc. Type and Purchase Organization.

Possible Solution : In SPRO customizing, define screen layout level we can set whether Reqd.entry / Opt. entry /  Display.

Analysis :

1)  In selection group basic item data we couldnt find Material field so its controlled by program level.

 "Field Label                    Reqd.entry  Opt. entry  Display

Plant

Storage location

Indicator: "Texts exist"

Short text

Material group

Material description

Manufacturer part number"

 

2) Tried to put validation on enhancement 'MM06E005' with PAI and Posting level but validation got triggered and stopping the entire process. Say like I have maintained 20 rows in table control with material column and 21st row i have maintained material text, in this case validation triggered but I couldnt delete since the error got triggered. Now there is an option to create from scratch RFQ from beginning which is redundant work.

 

3) Tried BADI but not suitable.

 

4) Tried field exit(EMATNR) based on Doc. Type and Purchase Organization. But the problem is when I maintain complete line items and validated successfully as our need but the field exit code got triggered on next row which is empty. I have tried to compare the Short Text field value but the value will be assigned to variable once field exit fired.

 

Again I have created one more field exit on the data element 'TXZ01' and made small logic which is given below.

 

Both field exit FM's(FIELD_EXIT_EMATNR and FIELD_EXIT_TXZ01) are grouped into one Function Group(ZFG_ME41)

declared global variable as data gs_flag.

 Step 1) Goto SE38 and execute the report RSMODPRF


Step 2) Create a function module FIELD_EXIT_TXZ01 with a new function group ZFG_ME41


Step 3) Create a function module FIELD_EXIT_EMATNR with the same existing function group ZFG_ME41(if we use different function group then we cant share the values between two function modules)

Step 4) Goto SE38 and execute the report RSMODPRF again execute without giving any input in Data element field


Step 5) We could see what are the fields are implemented with the status either active/inactive which is given below


Step 6) We have to assign the screen program name and screen number so in our requirement is for transaction ME41. Go to ME41 and get the program name with screen number which is given below


Step 7) We have to assign the fields which needs to be register to system


Step 8) Finally activate your field exits and perform your transaction ME41 and our code will be called.

Note: before activating this we have to ensure the parameter abap/fieldexit = 'YES' otherwise we cant activate.


Below the logic written inside FM-FIELD_EXIT_TXZ01

  IF SY-TCODE EQ 'ME41' or SY-TCODE EQ 'ME42'.

       if gs_flag is not initial and input is not initial.

         message 'Please enter material code' type 'E'.

       endif.

       clear gs_flag.

  ENDIF.

Below the logic written inside FM-FIELD_EXIT_EMATNR

  IF SY-TCODE EQ 'ME41' or SY-TCODE EQ 'ME42'.

       if input is initial.

          gs_flag = 'X'.

       else.

          clear gs_flag.

       endif.

  ENDIF.

 

Now I have tested both ME41/ME42 and its working as expected.

This blog is very simple but I spent lot of time to achieve this validation and I can say 'everything is possible'.

If you like this blog, please share (Facebook/LinkedIn/Google+) to click below links so it will reach to others.


COMMENTS

LEAVE A COMMENT