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: 

How to use Push Button in a selection screen to redirect to specific programs ?

former_member559830
Participant
0 Kudos

Hello Everyone,

I have created two programs (Program A & Program B). I want to access both using a same Selection screen.

As per the requirement provided to me, the main selection screen should have two buttons A & B.

If I press Button A I should get redirected to the selection screen of program A, the same for Button B.


Help would be appreciated & rewarded.


Thanks & Regards,

Pratik

1 ACCEPTED SOLUTION

Patrick_vN
Active Contributor
0 Kudos

To create a pushbutton on the selection screen (similar to pushbuttons on screens), you use:

SELECTION SCREEN PUSHBUTTON <pos(len)> <push>

                            USER-COMMAND <ucom> [MODIF ID <key>].

Check the contents of SY-UCOMM in the AT SELECTION SCREEN event. There depending on what button was pressed, you redirect to program A or B (Call transaction, Submit,..)

Example

SELECTION-SCREEN:

  BEGIN OF SCREEN 500,

    BEGIN OF LINE,

      PUSHBUTTON 2(10) BUT1 USER-COMMAND CLI1,

      PUSHBUTTON 12(10) TEXT-020 USER-COMMAND CLI2,

    END OF LINE,

  END OF SCREEN 500.

On the other hand, if you want the buttons to be in the application toolbar of the selection screen, check here: Adding a Button on Selection Screen Tool Bar | SCN

6 REPLIES 6

former_member197916
Active Participant
0 Kudos

Hi,

Give function code to each button.

If sy-ucomm = 'fct 1'.

call transaction '1 ' with parameters  or submit program '1'

If sy-ucomm = 'fct 2'.

call transaction '2 ' with parameters  or submit program '2'

Use either submit report or call transaction.Be sure to use that in PAI.

Hope it helps

Patrick_vN
Active Contributor
0 Kudos

To create a pushbutton on the selection screen (similar to pushbuttons on screens), you use:

SELECTION SCREEN PUSHBUTTON <pos(len)> <push>

                            USER-COMMAND <ucom> [MODIF ID <key>].

Check the contents of SY-UCOMM in the AT SELECTION SCREEN event. There depending on what button was pressed, you redirect to program A or B (Call transaction, Submit,..)

Example

SELECTION-SCREEN:

  BEGIN OF SCREEN 500,

    BEGIN OF LINE,

      PUSHBUTTON 2(10) BUT1 USER-COMMAND CLI1,

      PUSHBUTTON 12(10) TEXT-020 USER-COMMAND CLI2,

    END OF LINE,

  END OF SCREEN 500.

On the other hand, if you want the buttons to be in the application toolbar of the selection screen, check here: Adding a Button on Selection Screen Tool Bar | SCN

0 Kudos

Hello Abhishek Gupta & Patrick van Nierop,

Thanks for your replies, I am trying the below code :-

SUBMIT ZReport VIA SELECTION-SCREEN.

But it's not working. I created a module pool for the two buttons in the selection screen. And I want to link Program A & B to this. I want Program A & B to display their own Selection screens after their respected buttons are pressed.

Could you provide me a sample code for my request ?

Thanks & Regards,

Pratik

0 Kudos

Hi,

SUBMIT ZReport USING SELECTION-SCREEN '1000'.

                                   WITH .........

                                  AND RETURN

                                 WITH pchtimed = 'D'.  " Use this Option



0 Kudos

Create tcode for your reports A(TCODE :Z1) and B(TCODE:Z2).

Give function code to push buttons(let it be zcall1 and zcall2).

In PAI in a module write:

If sy-ucomm = 'ZCALL1'.

call transaction 'Z1 '

If sy-ucomm = 'ZCALL2'.

call transaction 'Z2 ' .

0 Kudos

Hello guys,

Thanks for all your replies. My program works now.

I just created an executable program and used the below code :-

REPORT Z_PUSHBUTTON.

TABLES sscrfields.

SELECTION-SCREEN:

       PUSHBUTTON /2(40) button1 USER-COMMAND but1,

       PUSHBUTTON /2(40) button2 USER-COMMAND but2.

*--------------------------------------------------------------*

*At Selection-Screen

*--------------------------------------------------------------*

AT SELECTION-SCREEN.

   CASE sscrfields.

     WHEN 'BUT1'.

      SUBMIT ZreportA VIA SELECTION-SCREEN AND RETURN.

     WHEN 'BUT2'.

       SUBMIT ZreportB VIA SELECTION-SCREEN AND RETURN.

   ENDCASE.

*--------------------------------------------------------------*

*Initialization

*--------------------------------------------------------------*

INITIALIZATION.

   button1 = 'Button 1'.

   button2 = 'Button 2'.

:- I would like to know what this does"  WITH pchtimed = 'D'.".

Could you please explain it to me ?

Thanks & Regards,

Pratik