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

VA42 User Exit Help Please

Former Member
0 Likes
1,854

I need to modify the behaviour of VA42 (Contract Change) as follows:

If field VBAK-MAHDT is not initial and doc types are Z020-Z022, do not allow any changes to any fields except to field VBAK-MAHDT.

If that field is initial, VA42 should work as normal.

I've tried making this coding change in form userexit_field_modification in MV45AFZZ. However it does not perform as desired.

if sy-tcode = 'VA42'.

if ( ( vbak-auart = 'Z020' )

or ( vbak-auart = 'Z021' )

or ( vbak-auart = 'Z022' ) ).

if vbak-mahdt is initial.

else.

message W899 with 'Change not allowed'.

endif.

endif.

endif.

Any suggestions are welcome.

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,658

To change screen attributes you will have to loop in screen table in PAI user exit,

Try program MV45AFZZ_USEREXIT_FIELD_MODIFI

I need to modify the behaviour of VA42 (Contract Change) as follows:

If field VBAK-MAHDT is not initial and doc types are Z020-Z022, do not allow any changes to any fields except to field VBAK-MAHDT.

If that field is initial, VA42 should work as normal.

I've tried making this coding change in form userexit_field_modification in MV45AFZZ. However it does not perform as desired.

if sy-tcode = 'VA42'.

if ( ( vbak-auart = 'Z020' )

or ( vbak-auart = 'Z021' )

or ( vbak-auart = 'Z022' ) ).

if vbak-mahdt is initial.

else.

message W899 with 'Change not allowed'.

endif.

endif.

endif.

Any suggestions are welcome.

Thanks.

10 REPLIES 10
Read only

Former Member
0 Likes
1,658

Hi ,

This subroutine userexit_field_modification is called in PBO. Please try subroutine USEREXIT_SAVE_DOCUMENT_PREPARE.

Cheers

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,658

If you are doing validation checking, you will want to put this code in the PAI include MV45AIZZ.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,658

Whenever I've become confused by to many nested 'if' statements, I try to rewrite it as a 'case' structure.

case vbak-auart .

when 'Z020'.

....

when 'Z021'.

...

when space .

...

when others .

endcase.

That makes each inspection point isolated.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,658

If you are doing validation checking, you will want to put this code in the PAI include MV45AIZZ.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,658

Have you tried to use USEREXIT_CHECK_VBAK and

USEREXIT_CHECK_VBAP in MV45AFZB.

Max

Read only

Former Member
0 Likes
1,658

Thanks everyone for their reply. I am still checking out some of the suggestions.

However I've modified the code as such and am very close to a solution. The problem with the below code is that not all fields are being protected from input, e.g. Contract Dates, and I can also add a line item. I guess what I am aiming for is for it to look and behave like VA43 where ALL fields are protected EXCEPT the one the user is allowed to change.

if sy-tcode = 'VA42'.

if ( ( vbak-auart = 'Z020' )

or ( vbak-auart = 'Z021' )

or ( vbak-auart = 'Z022' ) ).

if vbak-mahdt is initial.

else.

if screen-name = 'VBAK-MAHDT'.

else.

screen-input = 0.

endif.

endif.

endif.

endif.

Read only

Former Member
0 Likes
1,659

To change screen attributes you will have to loop in screen table in PAI user exit,

Try program MV45AFZZ_USEREXIT_FIELD_MODIFI

Read only

Former Member
0 Likes
1,658

Sanjay,

Your response seems to be working better for me than the others at the moment.

The problem with this section is that it's not called on any screen VEDA screen fields. Therefore they are all staying unprotected. Furthermore, the text field on the Text tabs are unprotected as well as any fields where there are multiple lines of input.

I tried to make a modification to the form USEREXIT_FIELD_MODIFICATION in include LV45WFZZ. I have access to the VEDA fields here. However I have no access to the contents of VBAK which are critical to my logic.

Do you or anyone else have other suggestions?

Bottom line under certain conditions of VBAK, I want VA42 to operate just like VA43 except ONE field is unprotected and modifiable.

Read only

Former Member
0 Likes
1,658

I've resolved the screen protect problem on any VEDA related fields.

Now my only problem is that repeatable fields, such as line item, etc are still updateable.

Any other recommendations are welcome.

Wardell

Read only

Former Member
0 Likes
1,658

If you want only certain few fields to be open for editing then put your if condition accordingly ( screen-input = 1 ) and for all other screen elements make screen-input = 0.