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: 

Calculator in Module Pool

Former Member
0 Kudos

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

Kanagaraja_L
Active Contributor
0 Kudos

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

Kanagaraja_L
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

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.

0 Kudos

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

0 Kudos

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.

0 Kudos

hi,

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

0 Kudos

@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 '+' , '-' ,'*' ,'/'.

0 Kudos

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.

Former Member
0 Kudos

hi,

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

so you dont require mouse input.

0 Kudos

@ 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.

0 Kudos

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