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

Calling push button dynamically

pkb
Participant
0 Likes
1,291


Dear All,

Is it possible to call a push button at run time or through code?  Suppose in my module pool program in a particular screen having two push button , i.e. Button1 and Button2 . When user click on Button1 then inside program or code it should call Button2  as if user clicked on Button2.

I am asking this question because I have to jump to or call a particular Tab when some error occurred in another tab in the same screen . My screen having 5 nos of tabs.

Please help.

-Pk

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,238

Hi,

To go to a tab of the tabstrip you need to set the field activetab of the tabstrip control to the function code of the tab that you want to be displayed.

In the PAI,

tab_cntrl-activetab = 'FCT'.

That's all. This will go to the tab which has function code as FCT.

Regards,

Ashish

8 REPLIES 8
Read only

dani_mn
Active Contributor
0 Likes
1,238

Hi,

You can simply call the Form routine behind "Button 2". why you are thinking so complex.

Case sy-ucomm.

     when 'BUT1'.

          Perform   F1.

     when 'BUT2'.

         Perform F2.

endcase.

Form F1.

"your logic

Perform F2.

endform.

Form F2.

"logic

Endform.

Read only

0 Likes
1,238

Hello Wasim,

Thank you for your reply.  My actual requirement is stated in second part of my post. I have a screen with 5 nos of tabs . User can enter data in first tab screen and without going to second tab screen he can save data. But now we have inserted few checks in second tab . So Now when user entered data in first tab and try to save records with out visiting second tab , system shows error message because of our validation check . But my client wants that when user response to error message then cursor should automatically move to second tab's field where we have given the check for compulsory data.

Here the second tab in my screen is nothing but a push button which is I want to call dynamically when error occurred for validation.

So , Wasim can you help in this regards?

-PK

Read only

dani_mn
Active Contributor
0 Likes
1,238

the problem with error message is that its stop the further processing. If you show a status or information message in your logic, and then make second tab as active tab it will navigate to second tab.

Read only

Former Member
0 Likes
1,238

Hi PK,

You can directly set a SY-UCOMM Value  Where ever you want...

Ex,you are in Button 1

inside this you can use

  sy-ucomm = 'BUTTON2'. ..

Read only

0 Likes
1,238

Hello Ranjit,

Thank you for your reply.  I have tried as you have suggested . I have inserted SY-UCOMM = FctCode just after the error message  but found that Sy-UCOMM is holding value of enter key since we have responded to error message by pressing enter key.

My actual requirement is stated in  the reply to Wasim .

Ranjit can you help to solve by problem as stated in reply to Wasim ?.

-Pk

Read only

Former Member
0 Likes
1,239

Hi,

To go to a tab of the tabstrip you need to set the field activetab of the tabstrip control to the function code of the tab that you want to be displayed.

In the PAI,

tab_cntrl-activetab = 'FCT'.

That's all. This will go to the tab which has function code as FCT.

Regards,

Ashish

Read only

0 Likes
1,238

Hello Ashish ,

Your reply helps us a lot . Tabstrip Activation is the actual way to go to a particular screen's tab after responding an error message by user.

Thank you again Ashish.

-pk


Read only

Rodrigo-Giner
Active Contributor
0 Likes
1,238

I think that what you are searching for is this function.

CALL FUNCTION ‘SAPGUI_SET_FUNCTIONCODE’

  EXPORTING

    functioncode = ‘/i′

  EXCEPTIONS

    function_not_supported = 1

  OTHERS = 2.


For example this code will make that when the source code reach this fm the sessión will be closed. You can put any function code, so if you need to execute a push buton just put the function code associated to that button.


Regards