08-21-2022 10:32 PM
I wrote a program which calulate the third angle of a triangle after the user provide the First Two one.
I create a button to made the calculation, but it didn't display it...
how to forbid the user to put 0 on any field...of course the "Obligatory" do the job, but if it wasn't one how to do that.
and in the same time i put a button to leave the program even if the field are empty...
Thanks.
DATA: v_angle3 TYPE i,
v_sum_angle TYPE i.
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE TEXT-001.
PARAMETERS: p_angle1 TYPE i OBLIGATORY,
p_angle2 TYPE i OBLIGATORY.
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN PUSHBUTTON 38(9) bt1 USER-COMMAND fc1.
SELECTION-SCREEN PUSHBUTTON 26(9) bt2 USER-COMMAND fc2.
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN PUSHBUTTON 26(9) bt3 USER-COMMAND fc3.
SELECTION-SCREEN END OF BLOCK blk1.
INITIALIZATION.
bt1 = 'Calculer'.
bt2 = 'Reset'.
bt3 = 'Sortir'.
AT SELECTION-SCREEN.
CASE sy-ucomm.
WHEN 'FC1'.
v_sum_angle = p_angle1 + p_angle2.
v_angle3 = 180 - v_sum_angle.
IF p_angle1 > 178.
message 'Number not allow' type 'E'.
ELSE.
write: 'L angle est de:',v_angle3 LEFT-JUSTIFIED,'degré' LEFT-JUSTIFIED.
ENDIF.
WHEN 'FC2'.
CLEAR : p_angle1,
p_angle2.
MESSAGE 'Les Champs ont été effacés' TYPE 'I'.
WHEN 'FC3'.
LEAVE PROGRAM.
ENDCASE.
Thanks you folks to read so far here you are a love...
08-22-2022 7:54 AM
Hi
You can modify your program as below:
This will smoothly gives message even though they enter 0.
PARAMETERS: p_angle1 TYPE i , "Remove obligatory
p_angle2 TYPE i .
In case section, add the wrapper IF statement as below
WHEN 'FC1'.
IF ( p_angle1 > 0 and p_angle2 > 0 ) "<=====Add a global if statement.
v_sum_angle = p_angle1 + p_angle2.
v_angle3 = 180 - v_sum_angle.
IF p_angle1 > 178.
message 'Number not allow' type 'E'.
ELSE.
write: 'L angle est de:',v_angle3 LEFT-JUSTIFIED,'degré' LEFT-JUSTIFIED.
ENDIF.
ELSE. "<=====Add a global if statement.
message 'Check your input' type 'S'.
ENDIF. "<=====Add a global if statement.
Regards,
Venkat
08-22-2022 7:41 AM
Remove OBLIGATORY and do:
IF p_angle1 = 0.
MESSAGE 'p_angle1 is obligatory' TYPE 'E'.
ENDIF.
08-22-2022 7:54 AM
Hi
You can modify your program as below:
This will smoothly gives message even though they enter 0.
PARAMETERS: p_angle1 TYPE i , "Remove obligatory
p_angle2 TYPE i .
In case section, add the wrapper IF statement as below
WHEN 'FC1'.
IF ( p_angle1 > 0 and p_angle2 > 0 ) "<=====Add a global if statement.
v_sum_angle = p_angle1 + p_angle2.
v_angle3 = 180 - v_sum_angle.
IF p_angle1 > 178.
message 'Number not allow' type 'E'.
ELSE.
write: 'L angle est de:',v_angle3 LEFT-JUSTIFIED,'degré' LEFT-JUSTIFIED.
ENDIF.
ELSE. "<=====Add a global if statement.
message 'Check your input' type 'S'.
ENDIF. "<=====Add a global if statement.
Regards,
Venkat
08-22-2022 9:15 AM
Thanks you for the global If Statement.
Write, don't display anything ? i don't know why
08-22-2022 9:21 AM
fotso
Write will be displayed after completion of the program.
So use message statement.
08-22-2022 9:29 AM
I have another question about the following:
message 'Check your input' type 'S' DISPLAY LIKE 'S'
Why use "DISPLAY LIKE 'S' " in this case as TYPE is already 'S' ?
I know that the difference is the type of icon which ll display ?
Thanks
08-22-2022 9:40 AM
08-22-2022 9:48 AM
venkateswaran.k
You can edit your answer too, to not confuse future visitors 😉
08-22-2022 1:39 PM
It could help newbie..
This is how you display message with parameters
message i002(ZPOANGLE) with v_angle3.
Before you need to create a Message Class, by going to T-code SE91 Message Maintenance