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

Enhancement

Former Member
0 Likes
3,867

hello everyone

I have a Question based on my own requirement. It is based on Travel management.

whenever i create a record in travel profile IT 0470 using PA30 for an employee then user exit should be triggered to create default record in flight preference IT0471 using BDC.

So the problem here is when i create a record in travel profile IT0470 for an employee and at last if i hit ENTER, then the user exit is triggered, IT 0471 screen is shown up, default values are created and comes back to intial screen IT 0470.

Now, if i hit SAVE to save the record for IT 0470 then again the user exit is triggered.

I dont want this to happen, all that i want is only if the user hits SAVE for saving the record IT 0470 then only user exit must be triggered and default values for IT 0471 must be created.

Any suggestion will be appreciated and awarded with points.

Thanking you.

Regards

vijay

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,813

Through SM30 Transacton you have to create entries in table t588z.

Please find the sample customization below. Please read help on each field of these table entries. Those are self explanatory.

9918 04 0 ***CREATE INFOTYPE 9919 ***

9918 04 200 I INS,9919,,,(P9918-BEGDA),(P9918-ENDDA)

9918 04 201 W P9919-NAME='TEST DYNAMIC ACTIONS'

In the above example: When ever you are creating Infotype 9918 record, an infotype 9919 record will be created. The values for 9919-begda and 9919-endda are passed from infotype 9918.

Please close the issue with appropriate points if it is helpful. Let me know if you have any questions while customizing.

Good luck.

Venu

37 REPLIES 37
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
3,813

Yes, in the user exit you must check the ok_code of the screen before doing the process of the user exit. The user exit will get triggered either way, so you must wrap your logic inside the user exit to only be executed when the "SAVE" function is being clicked. You must first find out what the FCODE or ok_code is behind the save button in that particular screen, then in your user exit, you must try doing something like this.

IF ok_code = 'SAVE'.

* Then do the logic.

ENDIF.

I probably won't be as easy as this, because you probably won't have access to the OK_CODE field in the user exit, but you never know. If you can't get access to it, you can use a trick with field symbols.




  data: field(50).

  field-symbols: <ok_code>.

* Assign an individual variable 
* Here you need the main program name and the 
* ok_code field of the screen.
  field = '(MainProgramName)ok_code'.
  assign (field) to <ok_code>.


if <ok_code> = 'SAVE'.

ENDIF.

Does this make sense?

Regards,

Rich Heilman

Read only

0 Likes
3,813

Maybe you could even get away with checking SY-UCOMM.

if sy-UCOMM = 'SAVE'.


Endif.

Again you need to find out what the FCODE is for "Save" in that transaction. Turn on debugger just befor hitting save, then type sy-ucomm into the debugger field at the bottom and hit enter, see if there is value there.

Regards,

Rich Heilman

Read only

0 Likes
3,813

yep Rich

You are right, i have to see the or i have to capture the ok_code for SAVE and include it in myh user exit code.

But you i know what i have tried for all possible vaules like SAVE , =UPD,.......(combinations) and result FAILED.

And at last as you mentioned using feild-symbols, i did`nt get it. Can you explain more.

Thanking you.

Regards

vj

Read only

0 Likes
3,813

Try to run the transaction manually. Put a break point in the user exit, run the transaction, when it program stops at your break point, check the value of sy-ucomm by typeing sy-ucomm in the box at the bottom of the debugger, is there any value here? if so, then check for this value in your IF statement.

Let me know.

Regards,

Rich Heilman

Read only

0 Likes
3,813

Hello Rich

I have checked the value of sy-ucomm in the debug mode

and it is UPD. Then i tried to use this condition in IF statement "IF innnn-infty = '0470' and sy-ucomm = 'UPD'" and i am facing the same problem.

Previously i was using the following IF statement :

IF innnn-infty = '0470' and ipsyst-IOPER = 'UPD'

and i was facing the same problem.

Thanking you

Regards

vijay

Read only

0 Likes
3,813

hi Vijay,

Why don't you set a flag the first time it enters the User exit and check its value when it gets triggered again... BTW are you using the ZXPADU02 exit?

Suresh

Read only

0 Likes
3,813

Are you saying that sy-ucomm = UPD when user presses ENTER and when he clicks SAVE? I'm a little confused.

When you click save, sy-ucomm is UPD, in the user exit you only want to do certain logic when the user presses save(UPD).

So in user exit, you should be able to wrap all that logic in a single IF statement.

If sy-ucomm = 'UPD'.

* do this logic.

Endif.

Check this in debug, it is not bypassing when user hits ENTER?

REgards,

Rich Heilman

Read only

0 Likes
3,813

Hello suresh

Yes i am using exit ZXPADU02.

As per your logic goes, if i set a flag value to 'X' when it enters the first time and when it gets triggered again i can check the value of the flag in the condition.

It should work fine, alright.

This will work when the user is creating record (IT 0470 and IT 0471) only for one employee.

What if the user is dealing with more than one employee.

As for the first employee the FLAG will be changed to 'X' (lets say) and will remain 'X' for the next time too and finally condition will not be TRUE for second employee and so on.

Let me know if i am wrong suresh.

Thanking you.

Regards

vijay

Read only

0 Likes
3,813

hello rich

What i have observed is when the user presses ENTER then sy-ucomm value is nothing and when the user hits SAVE then sy-ucomm is UPD.

I am not able to uderstand if sy-ucomm is nothing when user presses ENTER then how is the condition

"IF innnn-infty = '0470' and sy-ucomm = 'UPD'"

being statisfied.

Hello Venu

That was a valuable info about dynamic action (setting it up).

Thanking you

Regards

vijay

Read only

0 Likes
3,813

Vijay,

you can check the pernr each time too as this is triggered for each record...

Suresh

Read only

0 Likes
3,813

That's what I'd like to know, if sy-ucomm is space when user is hitting enter, how is the program going inside the IF statement. Have you stepped thru this in debug?

Regards,

Rich Heilman

Read only

0 Likes
3,813

Hello suresh

Can you explain more about the logic using pernr.

Thanking you

Regards

vijay

Read only

0 Likes
3,813

Hello Rich

I have checked in the debug mode when user presses ENTER, then the value sy-ucomm is space. And also seen when it reaches the condition IF statement it is not getting into it.

But ...................seems to be weird even though if it is not getting into If statement, then how come it is showing me the IT 0471 screen. This problem is heating up my brain :(.

Thanking you

Regards

vj

Read only

0 Likes
3,813

Oh, not sure there. I was just trying to keep you from executing the user exit logic, that part seems to be working. When and how is this other screen called?

Regards,

Rich Heilman

Read only

0 Likes
3,813

Vijay,

IN your logic that creates the 0471 record, export a variable to memory and check for its value in the User exit by importing from memory and decide whether or not to go further in the User exit. Do an F1 and the SAP documentation is very clear on how to use the EXPORT/IMPORT statements.

hope it helps,

Suresh Datti

Read only

0 Likes
3,813

Hello Rich

I did`nt get what you said " was just trying to keep you from executing the user exit logic, that part seems to be working". can you be more clear please.

Before coming to the screens, let me correct my statement "i am using CALL TRANSACTION not BDC" and following code is written in the user exit.

*IF innnn-infty = '0470' and ipsyst-ioper = 'UPD'.

IF innnn-infty = '0470' and sy-ucomm = 'UPD'.

DATA : tbl_data type bdcdata occurs 0 with header line.

DATA : tbl_msg type bdcmsgcoll occurs 0 with header line.

tbl_data-program = 'SAPMP50A'.

tbl_data-dynpro = '1000'.

tbl_data-dynbegin = 'X'.

append tbl_data.

clear tbl_data.

tbl_data-fnam = 'RP50G-PERNR'.

tbl_data-fval = innnn-pernr.

append tbl_data.

clear tbl_data.

tbl_data-fnam = 'RP50G-CHOIC'.

tbl_data-fval = '471'.

append tbl_data.

clear tbl_data.

tbl_data-fnam = 'BDC_OKCODE'.

tbl_data-fval = '/00'.

append tbl_data.

clear tbl_data.

tbl_data-program = 'SAPMP50A'.

tbl_data-dynpro = '1000'.

tbl_data-dynbegin = 'X'.

append tbl_data.

clear tbl_data.

tbl_data-fnam = 'BDC_OKCODE'.

tbl_data-fval = '=INS'.

append tbl_data.

clear tbl_data.

tbl_data-program = 'MP047100'.

tbl_data-dynpro = '2000'.

tbl_data-dynbegin = 'X'.

append tbl_data.

clear tbl_data.

DATA : a like p0471-begda,

b type p0471-begda.

a = innnn-begda.

b4(4) = a0(4).

b2(2) = a6(2).

b0(2) = a4(2).

tbl_data-fnam = 'P0471-BEGDA'.

tbl_data-fval = b.

append tbl_data.

clear tbl_data.

tbl_data-fnam = 'P0471-MEALS'.

tbl_data-fval = 'AVML'.

append tbl_data.

clear tbl_data.

tbl_data-fnam = 'P0471-SMOKE'.

tbl_data-fval = 'N'.

append tbl_data.

clear tbl_data.

tbl_data-fnam = 'P0471-SEATP'.

tbl_data-fval = 'A'.

append tbl_data.

clear tbl_data.

tbl_data-fnam = 'P0471-BHEAD'.

tbl_data-fval = 'X'.

append tbl_data.

clear tbl_data.

tbl_data-fnam = 'BDC_OKCODE'.

tbl_data-fval = '=UPD'.

append tbl_data.

clear tbl_data.

CALL TRANSACTION 'PA30'

USING TBL_DATA MODE 'A' MESSAGES INTO TBL_MSG.

IF SYST-SUBRC NE 0.

LOOP AT TBL_MSG.

WRITE 😕 TBL_MSG.

ENDLOOP.

ENDIF.

endif.

Thank you guys for your patience.

Regards

vijay

Read only

0 Likes
3,813

So are you saying that the code inside the IF statement is getting executed when the user presses ENTER? Or only when he clicks SAVE? What is happening exactly?

Regards,

Rich Heilman

Read only

0 Likes
3,813

Also, please be sure to clear out your tbl_data table after calling the transaction, or before it, or both.



CLEAR tbl_data.  REFRESH tbl_data.

Regards,

Rich Heilman

Read only

0 Likes
3,813

Hello Rich

When user presses ENTER, the code inside IF statement is not getting executed and when user hits SAVE then the code inside the IF statement is getting executed.

Thanking you.

Regards

vijay

Read only

0 Likes
3,813

Ok, isn't that your problem? Now what is happening that shouldn't be?

Regards,

Rich Heilman

Read only

0 Likes
3,813

Hello Rich

Yes thats the problem and not able to figure out why its happening.

Thanking you

Regards

vijay

Read only

0 Likes
3,813

I'm totally confused now.

I thought that you wanted to bypass the CALL TRANSACTION PA30 in your user exit. You put the IF statement around the code checking for sy-ucomm = UPD. You said that you only wanted the PA30 transaction(in the user exit) to be done when the user clicks SAVE. Is the IF statement working in the user exit or not. I thought that you said that its only going inside if sy-ucomm = 'UPD'(user clicked save) which is what you wanted, right?

What is happening that you don't want happening?

Also, in the call transaction in the user exit, I noticed that the mode = 'A'. Is this the way that you want it? Having it this way, will show all screens of the CALL TRANSACTION PA30. Do you not want to see the screens? If so, change mode = 'N'.

REgards,

Rich Heilman

Read only

0 Likes
3,813

hello Rich

I think there is some misunderstanding here. In the previous(recent) post of mine i explained what's happening in the debug mode.

Now if user presses ENTER, the code inside the IF statement is not executed but i am been directed to IT 0471 screen (as if the code is being executed)? This is my problem. Logically this should`nt happen, right.

Coming to mode A, i have used it normally as there was no restriction on it. I could even use Mode N.

Thanking you

Regards

vijay

Read only

0 Likes
3,813

Try this once, just a test. Comment out......





*CALL TRANSACTION 'PA30'
*USING TBL_DATA MODE 'A' MESSAGES INTO TBL_MSG.

Now run the transaction again, is that screen still coming?

Regards,

Rich Heilman

Read only

0 Likes
3,813

Hi Vijay,

Can you pl verify if a Dynamic Action already exists for 0470? Sm 31> V_T588Z>Infotype '0470'--> Display

may be that is what taking the user to the 0471 screen..

Suresh

Read only

0 Likes
3,813

Hello Rich

After i have commented and ran the transaction again.

The screen is still coming rich.

Thanking you

Regards

vijay

Read only

0 Likes
3,813

hello suresh

I have checked sm31 -> V_T588Z -> infotype '0470' -> Display : No enteries are found here.

Thanking you.

Regards

vijay

Read only

Former Member
0 Likes
3,813

I don't think you need to worry about all this, You can use dynamic actions, by which you can create another infotype record while creating or changing an infotype.

If dynamic actoins is ok for you. Pleae let me know, I can guide you through.

Venu

Read only

0 Likes
3,813

Hi Vijay,

You say it is a BDC right? then why do you need the User exit? If your objective is to create a 0471 for every 0470, put the code in the BDC.. or instead of BDC, you can use the "HR_INFOTYPE_OPERATION' function call twice.. ie once each for 0470 & 0471.. If it is not an initial load, you can also opt for Dynamic Actions ( V_T588*) as suggested by Venugopal..

Regards,

Suresh Datti

Read only

0 Likes
3,813

Hello venu and suresh

As you have mentioned Dynamic action, i dont know how to set it up. But if you could explain in more detail that would be great.

Suresh, I know i can use HR_INFOTYPE_OPERATION FM to create a record in IT 0471 for every record in IT 0471, but i want to do using BDC. And my main problem is with triggering the user exit only when the user hits SAVE and not when user hits ENTER.

Thank you for your replies guys.

Regards

vijay

Read only

Former Member
0 Likes
3,814

Through SM30 Transacton you have to create entries in table t588z.

Please find the sample customization below. Please read help on each field of these table entries. Those are self explanatory.

9918 04 0 ***CREATE INFOTYPE 9919 ***

9918 04 200 I INS,9919,,,(P9918-BEGDA),(P9918-ENDDA)

9918 04 201 W P9919-NAME='TEST DYNAMIC ACTIONS'

In the above example: When ever you are creating Infotype 9918 record, an infotype 9919 record will be created. The values for 9919-begda and 9919-endda are passed from infotype 9918.

Please close the issue with appropriate points if it is helpful. Let me know if you have any questions while customizing.

Good luck.

Venu

Read only

Former Member
0 Likes
3,813

Hi,

You can create entries in t588z table. You can try doing similarly as I explained in my previous answer. Let me know if you need any help in customizing.

Venu

Read only

0 Likes
3,813

Hello venu

Yes i shall try and will let you know if there is any problem.

Thanking you

Regards

vijay

Read only

0 Likes
3,813

Well then that screen coming has nothing to do with the logic in the user exit. You must find why it is coming. Once you find why it is coming, then your user exit should work good with the IF statement checking sy-ucomm, that I suggested earlier. Good Luck.

Regards,

Rich Heilman

Read only

0 Likes
3,813

Hello rich

Thanks for the time and for the replies.

I shall try my way out.

Thanking you

regards

vijay

Read only

Former Member
0 Likes
3,813

Hello guys

I am not able to find out what exactly the problem is ?

please try to help me in this issue.

Thanking you

Regards

vijay

Read only

0 Likes
3,813

Hi Vijay,

I will repeat my questions..

1. If it is a BDC, why do you need the User exit?

2. Why are you not willing to use the function module

HR_INFOTYPE_OPERATION?

Also, can you paste your complete code?

Regards,

Suresh Datti