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

regarding user command

Former Member
0 Likes
999

DATA: NUMBER1 TYPE I VALUE 20,

NUMBER2 TYPE I VALUE 5,

RESULT TYPE I.

START-OF-SELECTION.

WRITE: / NUMBER1, '?', NUMBER2.

AT USER-COMMAND.

CASE SY-UCOMM.

WHEN 'ADD'.

RESULT = NUMBER1 + NUMBER2.

WHEN 'SUBR'.

RESULT = NUMBER1 - NUMBER2.

WHEN 'MUL'.

RESULT = NUMBER1 * NUMBER2.

WHEN 'DIV'.

RESULT = NUMBER1 / NUMBER2.

WHEN OTHERS.

WRITE 'Unknown function code'.

EXIT.

ENDCASE.

WRITE: / 'Result:', RESULT.

can any one explain about this code ...

how the function code is assigned...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
921

Hi

You have to design PF-STATUS

using SET PF-STATUS 'AAA'

and add the buttons whose functions codes are ADD, DIV,SUBR etc

then when you press on the respective button the respective output will be displayed

<b>Reward points for useful Answers</b>

Regards

Anji

8 REPLIES 8
Read only

Former Member
0 Likes
921

when u create your button u need to give an fctcode for that button nothing but function code, which u are going to use in the program

Message was edited by:

vamsi reddy

Read only

Former Member
0 Likes
922

Hi

You have to design PF-STATUS

using SET PF-STATUS 'AAA'

and add the buttons whose functions codes are ADD, DIV,SUBR etc

then when you press on the respective button the respective output will be displayed

<b>Reward points for useful Answers</b>

Regards

Anji

Read only

former_member189059
Active Contributor
0 Likes
921

The function is not assigned here but somewhere else such as a toolbar

look out for any toolbars used and see if they have function codes attached to their custom buttons

Read only

Former Member
0 Likes
921

Hi srinivasa

create the buttons add subr mul and div and give the functioncode for that buttons as ADD SUBR MUL DIV and then when u run ur program and click that buttons that appropriate function will happen

Please reward point if useful

Regards,

Azhar

Read only

varma_narayana
Active Contributor
0 Likes
921

Hi

Basically the Event AT USER-COMMAND is triggered when u select a button or menuitem on the GUI Status(Menubar + Application Toolbar + Function keys)

But You have to Create the GUI status in SE41.

Each button / menu item in the GUI status has to assigned to a Function code.

Like ADD, MULT etc.

The system field SY-UCOMM holds the function code when u click on a button.

Then The GUI status has to called in the List using SET PF-STATUS.

DATA: NUMBER1 TYPE I VALUE 20,

NUMBER2 TYPE I VALUE 5,

RESULT TYPE I.

START-OF-SELECTION.

<b> SET PF-STATUS 'GUISTATUS'.</b>WRITE: / NUMBER1, '?', NUMBER2.

AT USER-COMMAND.

CASE SY-UCOMM.

WHEN 'ADD'.

RESULT = NUMBER1 + NUMBER2.

WHEN 'SUBR'.

RESULT = NUMBER1 - NUMBER2.

WHEN 'MUL'.

RESULT = NUMBER1 * NUMBER2.

WHEN 'DIV'.

RESULT = NUMBER1 / NUMBER2.

WHEN OTHERS.

WRITE 'Unknown function code'.

EXIT.

ENDCASE.

WRITE: / 'Result:', RESULT.

<b>Reward if Helpful.</b>

Read only

former_member196299
Active Contributor
0 Likes
921

hi Srinivasa ,

In the code what you have given , definately there will be 4 buttons for ADD, SUBR , MUL and DIV . and those buttomn can wither be created using ME41 ( menu painter ) or by declaring them in your program as pushbuttons .

In Either case you have to assign function codes( ADD,SUBR,MUL and DIV for 4 buttons ) and those function codes are being captured here and the process takes place .

To assign function codes go to menu painter( SE41 ), create a statuc there and then create 4 options for these for these and assign them with these function codes .

Regards,

Ranjita

Read only

Former Member
0 Likes
921

when u r using user-command , SET PF-STATUS 'XXX' if you double click on 'XXX' it takes you to se41 .in that in application toolbar you can your own function code and your own buttons.

In your example ADD,SUBR,MUL,DIV are function codes for the buttons in the user-command screen.

Read only

Former Member
0 Likes
921

Probably this is a programm to do arithmetic fuctions as per the user inputs.

*// Initially the above lines the the result and two numbers, number1 and number2 is declared as integers with initial value as 20 and 5.

DATA: NUMBER1 TYPE I VALUE 20,

NUMBER2 TYPE I VALUE 5,

RESULT TYPE I.

*// This is the first event for the list..

START-OF-SELECTION.

WRITE: / NUMBER1, '?', NUMBER2.

*// A case statement is used to check fot the user input and execute corresponding statements within that case..

AT USER-COMMAND.

CASE SY-UCOMM.

WHEN 'ADD'.

RESULT = NUMBER1 + NUMBER2.

WHEN 'SUBR'.

RESULT = NUMBER1 - NUMBER2.

WHEN 'MUL'.

RESULT = NUMBER1 * NUMBER2.

WHEN 'DIV'.

RESULT = NUMBER1 / NUMBER2.

**// when others is used in the end to handle exceptions

WHEN OTHERS.

WRITE 'Unknown function code'.

EXIT.

ENDCASE.

WRITE: / 'Result:', RESULT.