‎2007 Jun 28 4:00 PM
Hello Frnds,
I hav created a module pool program where my logic is
I have 2 inputs(Number1 and Number2 ) and one output (Result)
And i hav 2 buttons ADD and subtract.
So when ever i enter some data in number1 and Number2 and press Add then it shuld Add and display in Result field
But frnds i m unable to get the output, bcoz whenever i m giving the values in input its accepting and getting vanished and the result field remains disabled.
so can anyone help me regarding this.
Thanks & Regards,
suraj
‎2007 Jun 28 4:06 PM
Hi,
You need to have DATA declared in your program with the names same as the names that you have given for the FILEDS in the screen painter.
Data is transferred from screen to program only if the NAMES of the screen fields and the DATA declared in the program is same.
SO Do like this
in the program
DATA: field1 type i,
field2 type i,
result type i.
Name your screens fields as FIELD1, FIELD2 and RESULT.
in the PAI of the screen put
result = field1 + field2.
Regards,
Sesh
.
‎2007 Jun 28 4:07 PM
That means you have some problem with your flow logic
are you using the screen fields from program or dictionary
what ever may be , you have to declare them globally.
so that you will get values.
can you show your coding.
Regards
Vijay
‎2007 Jun 28 4:16 PM
Frnds this is wht i hav done...
First declared Number1(Text field ) Just beside that declared I/O field for that.
Same declared Number2(text field) and I/o field
Then declared Result (text field) and declared I/O field but its only output field.
Then declared Push buttons(ADD,SUBTRACT) AND GIVEN THE FUNCTION CODES FOR THOSE.
saved and activated.and then went to flow logic there i hav maintained follwing logic
<code>
REPORT ZMOD_DEMO.
DATA : NUMBER1 TYPE I ,
NUMBER2 TYPE I ,
RESULT TYPE I,
ok_code like sy-ucomm,
save_ok like ok_code.
&----
*& Module USER_COMMAND_9001 INPUT
&----
text
----
MODULE USER_COMMAND_9001 INPUT.
save_ok = ok_code.
clear ok_code.
CASE save_ok.
when '&ADD'.
RESULT = NUMBER1 + NUMBER2.
write 😕 result.
when '&SUB'.
RESULT = NUMBER1 - NUMBER2.
when '&MUL'.
RESULT = NUMBER1 * NUMBER2.
when '&DIV'.
RESULT = NUMBER1 / NUMBER2.
when '&EXIT'.
leave program.
Endcase.
ENDMODULE. " USER_COMMAND_9001 INPUT
</code>
Thanks®ards,
suraj
‎2007 Jun 28 4:52 PM
Hi Suraj,
You no need to use WRITE statement, as the values from your program variables wil automatically gets transferred to your Screen Variables if the names are same.
Now I have a question over here, what is the code you have written in PBO module. Just check you have not written any code which is clearing your RESULT variable.
Otherwise once again, just check the names of your screen variables and the program variables whether they are same or not. Make them same so that SAP can understand it and transfer the data from your program variable to screen variable.
Thanks & Regards,
Sandip Kamdar
‎2007 Jun 28 4:33 PM
‎2007 Jun 28 7:09 PM
Hi frnds,
What shuld i write in PBO. I am not getting shuld i write anything in PBO also for this.
looking for ur replies.
regards,
suraj
‎2007 Jun 29 6:21 AM
Frnds For this issue .. Is that i hav to write anything in PBO also...
regards,
suraj
‎2007 Jun 29 6:31 AM
Hello all,
Can anyone correct me if i am wrong anywhere?
Should i write anything in PBO.
Thanking u all.
regards,
suraj
Message was edited by:
suraj bansal
‎2007 Jun 29 1:40 PM
Hi Suraj
This code will help you to ADD and SUBTRACT the two input values,
MAIN PROGRAM*******
&----
*& Module pool ZADD *
*& *
&----
*& *
*& *
&----
PROGRAM ZADD.
DATA: T1(10),
T2(10) ,
RES(10),
ADD(10),
SUB(10),
OK_CODE LIKE SY-UCOMM.
INCLUDE ZADD_PBO.
INCLUDE ZADD_PAI.
PROCESS BEFORE OUTPUT.
MODULE STATUS_1000.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_1000.
----
***INCLUDE ZADD_PBO .
----
&----
*& Module STATUS_1000 OUTPUT
&----
text
----
MODULE STATUS_1000 OUTPUT.
SET PF-STATUS 'PF01'.
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_1000 OUTPUT
&----
*& Module USER_COMMAND_1000 INPUT
&----
text
----
MODULE USER_COMMAND_1000 INPUT.
CASE OK_CODE.
WHEN 'ADDITION'.
ADD = T1 + T2.
WHEN 'SUBTRACT'.
SUB = T1 - T2.
ENDCASE.
ENDMODULE. " USER_COMMAND_1000 INPUT
IF USEFULL GIVE REWARD