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: 

Regarding module pool

Former Member
0 Kudos

Hi all,

I am new to module pool programming. Actually i have created a simple screen where i have two input filds and one output field and 5 buttons..

ADD,SUBTRACT,MULTIPY ,DIVIDE and EXIT.

so frnd in PAI i m not getting how to write the code for the following screen... so that i can put this logic.

If i enter two values and and push in any 4 buttons except exit it shuld give some result.

fnrds plzz help...

regards,

kavita

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi kavita,

I have done the same program. It works fine... try copying into ur's and run...

-> create a module pool program.

<b>PROGRAM ZNAN_TEST1.

data: input1 type string,

i_input1 like input1,

input2 type string,

i_input2 like input2,

output type string,

okcode type sy-ucomm,

save_okcode like okcode.

MODULE STATUS_0100 output.

case save_okcode.

when 'ADD'.

output = i_input1 + i_input2.

WHEN 'SUBTRACT'.

OUTPUT = I_INPUT1 - I_INPUT2.

WHEN 'MULTIPLY'.

OUTPUT = I_INPUT1 * I_INPUT2.

WHEN 'DIVIDE'.

OUTPUT = I_INPUT1 / I_INPUT2.

endcase.

endmodule.

MODULE USER_COMMAND_0100 input.

i_input1 = input1.

i_input2 = input2.

save_okcode = okcode.

endmodule.</b>

-> The Screen has the following items.

INPUT1 AN INPUT BOX

INPUT2 AN INPUT BOX

OUTPUT AN INPUT BOX with the OUTPUT ONLY option enabled.

ADD BUTTON WITH FCODE -> ADD

SUBTRACT BUTTON WITH FCODE -> SUBTRACT

MULTIPLY BUTTON WITH FCODE -> MULTIPLY

DIVIDE BUTTON WITH FCODE -> DIVIDE

DEFINE OKCODE ALSO.

-> screen code is as follows:

<b>PROCESS BEFORE OUTPUT.

MODULE STATUS_0100.

*

PROCESS AFTER INPUT.

MODULE USER_COMMAND_0100.</b>

This works fine!!

Pls. do let me know if it works!!

regards,

Naveenan.

17 REPLIES 17

Former Member
0 Kudos

check this program <b>demo_dynpro_push_button</b>

Former Member
0 Kudos

Hi,

Let the fields be Number1,Number2.

CASE sy-ucomm.

when '&ADD'.

outputfield = input1 + input2.

when '&SUB'.

outputfield = input1 - input2.

when '&MUL'.

outputfield = input1 * input2.

when '&DIV'.

outputfield = input1 / input2.

when '&EXIT'.

leave program.

Endcase.

Regards,

Priyanka.

0 Kudos

Hi Priyanka,

But how to link the text fields with variables.

i m unable to understand. Plz help me regarding this.

Regards,

kavita

0 Kudos

go to the layout editor of ur screen and click on the Dictionary/Program fields window(or click the function key F6), in the pop-up click on the button 'Get from Program' which lists all the variables declared in ur program, now select the variables and click on continue button.

The varibles that are declared in the program can now be seen on ur screen, now perform ur arithmetic operations on these fields in the PAI of ur screen and populate the value of the result in the corresponding varaible.

former_member378318
Contributor
0 Kudos

Lets say your two inoput fields are called X and Y and you output field is called Z.

Your PAI should look something like this:

PROCESS AFTER INPUT.

MODULE USER_COMMAND.

The code in your user command module should look something like this:

MODULE user_command INPUT.

CASE sy-ucomm.

WHEN 'ADD'.

Z = X + Y.

WHEN 'SUBTRACT'.

Z = X - Y.

WHEN 'MULTIPLY'.

Z = X * Y.

WHEN 'DIVIDE'.

Z = X / Y.

ENDCASE.

ENDMODULE.

You don;t really need anything in the PBO.

Hope it helps

Former Member
0 Kudos

hI FRNDS,

I HAVE CREATED A SCREEN LIKE

<code>

NUMBER1 TEXT-FIELD " INPUT FIELD1

NUMBER2 TEXT-FIELD " INPUT FIELD2

RESULT RESULT " OUTPUT FIELD

ADD SUBTRACT MULTIPLY DIVIDE EXIT </code>

When i enter 20 and 10 in input and press and of the below button then i shuld get the result in result output field.

Frnds i hav maintained the follwoing code, but in vain its not working out.

<code>

DATA : NUMBER1 TYPE I,

NUMBER2 TYPE I,

RESULT TYPE I.

CASE sy-ucomm.

when '&ADD'.

result = Number1 + number2.

when '&SUBTRACT'.

result = number1 - number2.

when '&MULTIPLY'.

result = number1 * number2.

when '&DIVIDE'.

result = number1 / number2.

when '&EXIT'.

leave program.

Endcase.

</code>

regards,

kavita

Message was edited by:

kavita kashyap

0 Kudos

u've to create 4 different push buttons(for each arithmetic operation) and assign the function codes(&ADD,&SUBSTRACT,&MULTIPLY,...) to each of them.

The function code of a pushbutton, checkbox, radio button, or dropdown box on the screen is set in the corresponding element attributes.

Message was edited by:

Rajesh

0 Kudos

Follow the simple example quoted by Rajesh demo_dynpro_push_button, how can you go wrong?

Former Member
0 Kudos

hiii,

data:a(10), b(10), c(10).

case sy-ucomm.

when 'a'.

c = a + b.

wnen 'e'.

c = a / b.

when 'l'.

leave program.

end case.

this is a sample prg

regards

pradeep

Former Member
0 Kudos

HI.

refer this code.

CASE sy-ucomm.

WHEN 'PB_CREATE'.

whatever do u want to code, write here

WHEN 'PB_UPDATE'.

whatever do u want to code, write here

WHEN 'PB_DISPLAY'.

whatever do u want to code, write here

WHEN 'PB_LIST'.

whatever do u want to code, write here

WHEN 'PB_SAVE'.

whatever do u want to code, write here

endcase.

Reward all helpfull answers.

Regards.

Jay

Former Member
0 Kudos

Hi , Can anyone give me their id so that i can send me wht i have done so that they can rectify me ...

regards,

kavita

Former Member
0 Kudos

Hi kavita,

-> U have created a screen. Say the buttons and function codes are as follows,

Two input fields be INPUT1 and INPUT2

The output field be OUTPUT

Five buttons have FCODE as ADD, SUBTRACT, MULTIPLY, DIVIDE and EXIT.

-> Define the screen fields in your program.

Data: input1 type string, input2 type string, output type string.

-> Your PAI (Process After Input) has the code of what is to be done once user performs any action on the screen.

So all you have to do is write a logic which stores the input screen fields and the okcode to temporary variables.

say, okcode to save_okcode. and intput1 to i_input1, input2 to i_input2...

-> Your PBO (Process Before Output) has the code to perform whatever you have to do before showing the changes on the screen.

So, write a logic like...

case save_okcode.

when 'ADD'.

output = input1 + input2.

endcase.

This should do..

regards,

Naveenan.

Former Member
0 Kudos

Hi frnds,

still i m not getting.. Plz look into my code again.....

When i m creating screen .. follwoing data i hav given

MODULE USER_COMMAND_9001 INPUT.

DATA : NUMBER1 TYPE I VALUE 10,

NUMBER2 TYPE I VALUE 20,

RESULT TYPE I.

CASE sy-ucomm.

when '&ADD'.

RESULT = NUMBER1 + NUMBER2.

when '&SUB'.

RESULT = NUMBER1 - NUMBER2.

when '&MUL'.

RESULT = NUMBER1 * NUMBER2.

when '&DIV'.

RESULT = NUMBER1 / NUMBER2.

when '&EXIT'.

leave program.

Endcase.

My issue is when i m entering data in number1 and number2 and press ADD button nothing is coming in result output.

i need the addition result shuld be shown in result output field.

regards,

kavita

0 Kudos

Try declaring NUMBER1, NUMBER2 and RESULT as globals in the TOP include of your dialog program. I know module declarations are global but moving them to the TOP include may help.

Former Member
0 Kudos

Hi ,

I don't see any problem with your code. You better check this out

' Whether the function code is entered in the output fields and are same as the ones you have given in the program' .

Former Member
0 Kudos

Hi kavita,

I have done the same program. It works fine... try copying into ur's and run...

-> create a module pool program.

<b>PROGRAM ZNAN_TEST1.

data: input1 type string,

i_input1 like input1,

input2 type string,

i_input2 like input2,

output type string,

okcode type sy-ucomm,

save_okcode like okcode.

MODULE STATUS_0100 output.

case save_okcode.

when 'ADD'.

output = i_input1 + i_input2.

WHEN 'SUBTRACT'.

OUTPUT = I_INPUT1 - I_INPUT2.

WHEN 'MULTIPLY'.

OUTPUT = I_INPUT1 * I_INPUT2.

WHEN 'DIVIDE'.

OUTPUT = I_INPUT1 / I_INPUT2.

endcase.

endmodule.

MODULE USER_COMMAND_0100 input.

i_input1 = input1.

i_input2 = input2.

save_okcode = okcode.

endmodule.</b>

-> The Screen has the following items.

INPUT1 AN INPUT BOX

INPUT2 AN INPUT BOX

OUTPUT AN INPUT BOX with the OUTPUT ONLY option enabled.

ADD BUTTON WITH FCODE -> ADD

SUBTRACT BUTTON WITH FCODE -> SUBTRACT

MULTIPLY BUTTON WITH FCODE -> MULTIPLY

DIVIDE BUTTON WITH FCODE -> DIVIDE

DEFINE OKCODE ALSO.

-> screen code is as follows:

<b>PROCESS BEFORE OUTPUT.

MODULE STATUS_0100.

*

PROCESS AFTER INPUT.

MODULE USER_COMMAND_0100.</b>

This works fine!!

Pls. do let me know if it works!!

regards,

Naveenan.

0 Kudos

Hi Dear,

     Please make sure that you have given I/O variables names as NUMBER1 AND NUMBER2 . If you did like so, please check your Function codes assigned.

Thanks,

Ramesh