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

Calculator in Module Pool

Former Member
0 Likes
3,429

Hey i have designed a Calculator in Module pool. I have created a Screen with Buttons and other functionalities.If you Give input from Mouse by Clicking on desired button Everything is working fine .But Instead of clicking on these button i want input has to be given from keyboard itself .For example

Press 1: 1 Should be appear on Screen

Press + : It should not appear on Screen.

Press: 2 : It should Appear on Screen.

If you Press Enter Final Added Value should appear on Screen.

Is Keyboard interfacing possible with Custom developed Screen ? If possible please reply .

1 ACCEPTED SOLUTION
Read only

Kanagaraja_L
Active Contributor
0 Likes
2,358

To develop Calculator in Module Pool program Instead of you can use FM FITRV_CALCULATOR. But I dont know the Keyboard Interaction.

Report ZCalculator.
DATA: OUTPUT_VALUE(15) TYPE C.

call function 'FITRV_CALCULATOR'
  IMPORTING
    OUTPUT_VALUE               = OUTPUT_VALUE
  EXCEPTIONS
    INVALID_INPUT              = 1
    CALCULATION_CANCELED       = 2
    OTHERS                     = 3.

To develop Calculator in Module Pool program Instead of you can use FM FITRV_CALCULATOR. But I dont know the Keyboard Interaction.

Report ZCalculator.
DATA: OUTPUT_VALUE(15) TYPE C.

call function 'FITRV_CALCULATOR'
  IMPORTING
    OUTPUT_VALUE               = OUTPUT_VALUE
  EXCEPTIONS
    INVALID_INPUT              = 1
    CALCULATION_CANCELED       = 2
    OTHERS                     = 3.

10 REPLIES 10
Read only

Kanagaraja_L
Active Contributor
0 Likes
2,359

To develop Calculator in Module Pool program Instead of you can use FM FITRV_CALCULATOR. But I dont know the Keyboard Interaction.

Report ZCalculator.
DATA: OUTPUT_VALUE(15) TYPE C.

call function 'FITRV_CALCULATOR'
  IMPORTING
    OUTPUT_VALUE               = OUTPUT_VALUE
  EXCEPTIONS
    INVALID_INPUT              = 1
    CALCULATION_CANCELED       = 2
    OTHERS                     = 3.

Read only

Former Member
0 Likes
2,358

hi,

if you want to develo a custom calculator. try this.

make 1st field for first input

2nd field for operator

3rd for second no.

4th for result.

the make an enter button. in PAI

check the value of the operator field and put a case statement.

n code as per the functionality u want

eg.

case FIELD2.

when '+'

fied4 = field1 + field3.

when '-'

fied4 = field1 - field3.

etc.

hope it helps.

Read only

0 Likes
2,358

See Calculator is working Fine if you provide inputs from Mouse by clicking on push buttons . But My intention is can i provide inputs from Keyboard without touching mouse.

As in microsoft calcuator we can given input frm keyboard itself and check output. Please reply

Read only

0 Likes
2,358

Did you define a proper input field for entering your data? Sure it is possible to use the keyboard as input. This is the same for custom fields as it is for your Standard SAP fields.

Read only

0 Likes
2,358

hi,

did you check in debuggin mode what ok code is set when you press the keyboard keys?

Read only

0 Likes
2,358

@Micky Oestreich

I have designed Calcualor screen with same as of Standard Calculator. Here i havnt Defined Two Input Fields for giving input and ,Field for giving Opreator value as '+' , '-' ,'*' ,'/'.

Read only

0 Likes
2,358

Hi,

Not sure if this helps for your actual question. But, How about reusing the Windows calculator instead of redesigning on your own? (I am assuming your operating system is Windows. In case of others, you can pass appropriate command name).

CALL FUNCTION 'GUI_RUN'
  EXPORTING
    command          = 'CALC'
*   PARAMETER        =
*   CD               =
* IMPORTING
*   RETURNCODE       =
          .

Thanks,

Vinod.

Read only

Former Member
0 Likes
2,358

hi,

you can assign a function code to that push button as well.

so you dont require mouse input.

Read only

0 Likes
2,358

@ S Jain

I didnt Understand how will you define function code so that it will pick input from keyboard itself.In PAI event we can check inside Case Statment for different FCODE . Will you please Elaborate this concept.

Read only

0 Likes
2,358

hi,

oops my mistake.

insted of function code i meant function key.

you can assign a ufnction key to the push button on the screen.

so even if the input comes from the keyboard or the mouse, the PAI event

will still be triggered.

regards,

sakshi