Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Validations on User exits

Former Member
0 Likes
3,170

I need to do some validations on financial documents with transactions like FB01,FB60,FB70,ME21n,MIGO,MIRO and do some check on the RCC codes, Company codes, Accounts and some custome fields before user saves data and dispaly some error message if something is wrong. So if you someone has done anything similar can you provide me with a sample code and also what the requirement was so that i can work on similar lines and get my task done..Any help would be greatly appreciated and would be helpful to me..

Thanks in advance,

Mohsin.

8 REPLIES 8
Read only

Former Member
0 Likes
2,319

Hi,

I have worked for some user exits in Purchasing.

Best way is first find out which user exit gets triggered just before you save data. I am attaching code of a sample program. Pls create a temporary program in your development box and add code. Execute this program. Give input as any Tcode for which u r looking for a user exit. Keep a breakpoint and run the tcode to see which gets triggered just before SAVE.

For ME22N, try EXIT_SAPMM06E_012.

REPORT ZUSEREXIT.

************************************************************************

  • Finding the user-exits of a SAP transaction code

*

  • Enter the transaction code in which you are looking for the user-exit

  • and it will list you the list of user-exits in the transaction code.

  • Also a drill down is possible which will help you to branch to SMOD.

*

************************************************************************

*----


  • TABLES DECLARATION

*----


TABLES : TSTC, "SAP Transaction Codes.

TADIR, "Directory of Repository Objects.

MODSAPT, "SAP Enhancements - Short Texts.

MODACT, "Modifications.

TRDIR, "System table TRDIR.

TFDIR, "Function Module.

ENLFDIR, "Additional Attributes for Function Modules

TSTCT. "Transaction Code Texts

*----


  • INTERNAL TABLE DECLARATIONS

*----


DATA : ITAB LIKE TADIR OCCURS 0 WITH HEADER LINE.

*----


  • DATA DECLARATIONS

*----


DATA : V_FIELD1(30).

DATA : V_DEVCLASS LIKE TADIR-DEVCLASS.

*----


  • INPUT SCREEN DECLARATIONS

*----


PARAMETERS : P_TCODE LIKE TSTC-TCODE OBLIGATORY.

*----


  • START OF SELECTION EVENT

*----


START-OF-SELECTION.

*--Read SAP Transaction Code from the given input.

SELECT SINGLE *

FROM TSTC

WHERE TCODE EQ P_TCODE.

IF SY-SUBRC EQ 0.

*--Get the Directory of Repository Objects for the

*---selected program name.

SELECT SINGLE *

FROM TADIR

WHERE PGMID = 'R3TR' AND

OBJECT = 'PROG' AND

OBJ_NAME = TSTC-PGMNA.

MOVE : TADIR-DEVCLASS TO V_DEVCLASS.

IF SY-SUBRC NE 0.

*--Read System table TRDIR for the selected program name.

SELECT SINGLE *

FROM TRDIR

WHERE NAME = TSTC-PGMNA.

*--Get the function module name for the selected program name.

IF TRDIR-SUBC EQ 'F'.

SELECT SINGLE *

FROM TFDIR

WHERE PNAME = TSTC-PGMNA.

*--Get the function group for the selected program name.

SELECT SINGLE *

FROM ENLFDIR

WHERE FUNCNAME = TFDIR-FUNCNAME.

*--Read the development class for the corresponding function group.

SELECT SINGLE *

FROM TADIR

WHERE PGMID = 'R3TR' AND

OBJECT = 'FUGR' AND

OBJ_NAME EQ ENLFDIR-AREA.

MOVE : TADIR-DEVCLASS TO V_DEVCLASS.

ENDIF.

ENDIF.

*--Read all the entries into the internal table itab.

SELECT *

FROM TADIR

INTO TABLE ITAB

WHERE PGMID = 'R3TR' AND

OBJECT = 'SMOD' AND

DEVCLASS = V_DEVCLASS.

*--Read Transaction code information from the table tstct.

SELECT SINGLE *

FROM TSTCT

WHERE SPRSL EQ SY-LANGU AND

TCODE EQ P_TCODE.

*-- Column Headings

FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.

WRITE:/(19) 'Transaction Code - ',

20(20) P_TCODE,

45(50) TSTCT-TTEXT.

SKIP.

IF NOT ITAB[] IS INITIAL.

WRITE:/(95) SY-ULINE.

FORMAT COLOR COL_HEADING INTENSIFIED ON.

WRITE:/1 SY-VLINE,

2 'Exit Name',

21 SY-VLINE ,

22 'Description',

95 SY-VLINE.

WRITE:/(95) SY-ULINE.

LOOP AT ITAB.

*--Read SAP Enhancements short texts information.

SELECT SINGLE *

FROM MODSAPT

WHERE SPRSL = SY-LANGU AND

NAME = ITAB-OBJ_NAME.

FORMAT COLOR COL_NORMAL INTENSIFIED OFF.

WRITE:/1 SY-VLINE,

2 ITAB-OBJ_NAME HOTSPOT ON,

21 SY-VLINE ,

22 MODSAPT-MODTEXT,

95 SY-VLINE.

ENDLOOP.

WRITE:/(95) SY-ULINE.

DESCRIBE TABLE ITAB.

SKIP.

FORMAT COLOR COL_TOTAL INTENSIFIED ON.

WRITE:/ 'No of Exits:' , SY-TFILL.

ELSE.

FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.

WRITE:/(95) 'No User Exit exists'.

ENDIF.

ELSE.

FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.

WRITE:/(95) 'Transaction Code Does Not Exist'.

ENDIF.

*----


  • AT LINE-SELECTION EVENT

*----


AT LINE-SELECTION.

GET CURSOR FIELD V_FIELD1.

CHECK V_FIELD1(4) EQ 'ITAB'.

SET PARAMETER ID 'MON' FIELD SY-LISEL+1(10).

*-- call transation SMOD : Sap Enhancement.

CALL TRANSACTION 'SMOD' AND SKIP FIRST SCREEN.

*---End of Program

Read only

andreas_mann3
Active Contributor
0 Likes
2,319

hi,

look in your system after an EXIT-Formpool for Uxxx-Exits - e.g. program ZGGBR000

1) define an exit in Ta ob28

2) define that exit in above program

EXITS-NAME = 'UK001'.

EXITS-PARAM = C_EXIT_PARAM_CLASS.

EXITS-TITLE = TEXT-101.

APPEND EXITS.

3) ceate form routine uk001:

FORM UK001 USING B_RESULT.

-> here define your rules

Andreas

Read only

Former Member
0 Likes
2,319

Hey Andreas,

Can you please explain in more detail what you meant there also if someone has some sample code of the validations they have done please forward it to me with the requirement on which they were working.

Thanks,

Mohsin.

Read only

Former Member
0 Likes
2,319

I need to do some validations on financial documents with transactions like FB01,FB60,FB70,ME21n,MIGO,MIRO and do some check on the RCC codes, Company codes, Accounts and some custome fields before user saves data and dispaly some error message if something is wrong. So if you someone has done anything similar can you provide me with a sample code and also what the requirement was so that i can work on similar lines and get my task done. This is urgent so plzzz help me out..

Read only

0 Likes
2,319

To define validations for FI documents:

step 1 : Identify the include name to write the subroutines using transaction GCX2.

step 2 : Define the validation in transaction OB28. Call point might be at header,item or complete document level. In this transaction u will define the steps includes pre requisite,check and message.

In the check u can give the sub routine name defined in the step 1.

In the subroutine u will get the structure BSEG with data. U can read the data and validate.

Example sub routine.

***FORM U503 changing B_RESULT.

    • here bseg is available for reading

if bseg-bukrs = '1000'.

  • ...do validation here

    • B_RESULT = B_TRUE.

  • ELSE.

      • further checks ...

    • B_RESULT = B_FALSE.

endif.

*ENDFORM. "U503

Hope this helps.

Thanks,

Vamshi

Read only

Former Member
0 Likes
2,319

Hello vamshi

how can we write subroutines using GCX2..And you mean that i have to define all the validations in OB28(Can you tell me the steps how we need to define here)..Once we define validations in OB28 all we need to do is call it in the subroutine using GCX2, am i right??..or ne other way to do it..

Thanks,

Mohsin

Read only

0 Likes
2,319

(i)In GCX2 you can see the include name configured, Like

ZGGBR000 or GGBR000( standard program ). If its GGBR000

u need to change to ZGGBR000 to include ur code in this program.Because u cannot modify the standard program.

(ii)In OB28, while creating step in the check u give the subroutine defined in the program ZGGBR000...

about the order u want to define both the way u can do,

either first gcx2 or ob28.

Please find link for help :

http://help.sap.com/saphelp_47x200/helpdata/en/34/70278406b611d3b4370060941936fa/frameset.htm

Hope this help..

Thanks,

vamshi

Read only

0 Likes
2,319

Hi All,

I have the same program ZGGBR000 to include the exits. When i am creating a new step in the Validation using transaction OB28 and saving it, the save is getting terminated by an abort message "User exit form pool ZGGBR000 contains a syntax error".

But when i save , check and activate ZGGBR000 , it doesnt give any syntax error.

I have searched in SDN but not able to get any appropriate solution.

Please advise.

Thanks & Regards,

Bhavika