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

User Exit Called by OKC7 Controlling Validation

Former Member
0 Likes
1,613

We currently have a requirement to prevent users issuing materials to orders of a certain type via transaction MB1A, unless they have the correct authorisation in one of their assigned roles.

So far I've managed to achieve this using a CO validation (defined in transaction OKC7) which calls exit U100, part of form pool ZGGBR000. The code I have in this exit currently looks like this:

 
FORM u100 USING b_result. 

AUTHORITY-CHECK OBJECT 'I_AUART' 
ID 'IWERK' FIELD '1000' 
ID 'AUFART' FIELD 'ZHI1'. 

IF SY-SUBRC = 0. 
  B_RESULT = B_TRUE. 
ELSE. 
  B_RESULT = B_FALSE. 
ENDIF. 

ENDFORM. 

This code currently works for order type ZHI1, but is obviously very rudimentary as I'm a functional consultant rather than an ABAPer. What I'd like to achieve is to avoid hard-coding the order type, by passing the type of the current order into the exit from the validation. How would I go about achieving this?

Alternatively, is there a way for the exit to retrieve the current order type itself? This can be achieved in the validation transaction by just referencing the field CAUFV-AUART, but I'm not sure how to achieve this in ABAP.

Any help or guidance would be greatly appreciated.

Thanks,

Richard

We currently have a requirement to prevent users issuing materials to orders of a certain type via transaction MB1A, unless they have the correct authorisation in one of their assigned roles.

So far I've managed to achieve this using a CO validation (defined in transaction OKC7) which calls exit U100, part of form pool ZGGBR000. The code I have in this exit currently looks like this:

 
FORM u100 USING b_result. 

AUTHORITY-CHECK OBJECT 'I_AUART' 
ID 'IWERK' FIELD '1000' 
ID 'AUFART' FIELD 'ZHI1'. 

IF SY-SUBRC = 0. 
  B_RESULT = B_TRUE. 
ELSE. 
  B_RESULT = B_FALSE. 
ENDIF. 

ENDFORM. 

This code currently works for order type ZHI1, but is obviously very rudimentary as I'm a functional consultant rather than an ABAPer. What I'd like to achieve is to avoid hard-coding the order type, by passing the type of the current order into the exit from the validation. How would I go about achieving this?

Alternatively, is there a way for the exit to retrieve the current order type itself? This can be achieved in the validation transaction by just referencing the field CAUFV-AUART, but I'm not sure how to achieve this in ABAP.

Any help or guidance would be greatly appreciated.

Thanks,

Richard

4 REPLIES 4
Read only

Former Member
0 Likes
1,088

Hi Richard,

Sample code:


DATA : v_aufart TYPE aufart VALUE 'ZHI1',
       v_iwerk TYPE iwerk  VALUE '1000'.


authority-check object 'I_AUART'
id 'IWERK' field  v_iwerk
id 'AUFART' field v_aufart.

or


DATA : v_aufart TYPE aufart

select single  aufart into v_aufart  from CAUFV where AUFNR = import parameter  of Aufnr.

I hope this may helpfull.

Thank you,

Thanks,

AMS

Read only

0 Likes
1,088

Thanks AMS, that is helpful.

Your second example seems like what I'm trying to achieve. How would I import the parameter for AUFNR? In the validation the exit is called by simply referencing U100, what I'd like to be able to do is call something like 'U100(parameter)' to pass the import parameter to the exit, but am not sure of the syntax for this.

Thanks,

Richard

Read only

0 Likes
1,088

Hi Richard,

In the exit you need to get the import parameter related to you tables then only we can use this.

Or

We can get the values while the Tcode is execting in any exit using Assign statement.

But the enhancement has to trigger in the TCode to do validation on it.

I hope this may helpfull.

Thank you,

Thanks,

AMS

Read only

0 Likes
1,088

Could you give some example code for any of that? Essentially all I want to do is pass a value into an exit, how would you normally do that?

Thanks for your help.