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: 

Creating a Calculator in Screen painter

sudhir_uppalapati
Participant
0 Kudos

Can any one send me the program to create a calculator in Screen Painter..

5 REPLIES 5

Former Member
0 Kudos

Hi Sudhir,

REfer this FM and check its program,

Screen 300 has been called.

FITRV_CALCULATOR

Or simply create your own.

By taking buttons and assiging UCODE and do simple operations.

Reward if useful!

Former Member
0 Kudos

Hi,

Create push buttons for the + , - , / , * , = in your dialog program.

Create an input field with the data type that can accept decimal places..

When the enter 12 then press the push button "+" button store the value 12 in a variable v1..Then clear the input field..

Then when the user enters another number..lets say "13"..

Then if the user presses the "=" button...Then sum the values from the variable v1 with the input field..

Hope this helps..

Check this sample code..

MODULE USER_COMMAND.

CASE SY-UCOMM.

WHEN 'ADDITION'.

  • ASSUMING THE INPUT FIELD NAME IS P_INPUT.

V_V1 = P_INPUT.

V_OPERATION = '+'.

CLEAR: P_INPUT.

WHEN 'EQUALTO'.

CASE V_OPERATION.

  • ADDITION

WHEN '+'.

  • SUM UP THE VALUES.

P_INPUT = P_INPUT + V_V1.

ENDCASE.

  • MULTIPLICATION

WHEN '*'.

  • MULTIPLY UP THE VALUES.

P_INPUT = P_INPUT * V_V1.

ENDCASE.

ENDCASE.

ENDMODULE.

Reward points if it helps..

Regards,

Omkar.

0 Kudos

HI,

Can u say me wat is the data type of V_OPERATION here.

0 Kudos

can any one give the complete program ... so as to understand as a new SAP user.

Former Member
0 Kudos

Hi Sudir,

first you go to se38 and create zpgm name and press create.

then save it and activate the screen and come back.

then go to se51 and create pgm name with screen no.

in layout take 3 input fields and 3 text fields for it as mentioned below.

then add four push buttons for add,sub,mul,div.

then write following code in PAI.

PAI.

Module user_command_1000_input

case sy-ucomm.

when 'add'.

field3 = field1+field2.

when 'sub'.

field3 = field1-field2.

when 'mul'.

field3 = field1*field2.

when 'div'.

field3 = field1/field2.

endcase.

endmodule.

Then finaly execute you can see a simple calculator.

Reward if helpful.

Regards

Raghavendra.D.S