Application Development 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: 

Why the code in a user exit is executed twice?

Former Member
0 Kudos

Hi all,

I've got a development in a user exit EXIT_SAPMP56T_001.

This user exit allows us to control the travel expenses.

When you go to the TX: PR05 you can see a list with travels to add expenses. Here you can select one item on the list and press the edit button to add new expenses.

We want to control this and we use this user exit for that purpose.

When the user selects a row and presses the edit button, the user exit is triggered. We can check the values of the table and see which row is selected. But this exit is executed twice. The first time the table doesn't have any changes on it, the second time it has marked the selected row.

Why is this happening? Why is this exit executed twice? And how can I control that the table is properlly updated?

Thank you.

2 REPLIES 2

former_member536879
Active Contributor
0 Kudos

Hi,

I think this user exist in getting triggered both in the PAI and PBO of that screen.

For avoiding this use the flag.

If flag is initial then only your code needs to trigger.

if flag is initial.

flag = 'X'.

then your code.

endif.

So when it again comes into the PBO it will check the flag and the same code will not be triggered for the second time.

With Regards,

Sumodh.P

0 Kudos

If I set the value of the flag to 'X' in the first execution, the second time the code is executed, the value is set to the default so i cannot use a flag for that.

That is because the flag is a local variable so every time the code is executed the flag comes again to the void value.

Edited by: Iñaki Nolte Usparicha on Feb 1, 2011 1:33 PM