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: 

WRITE issue to display

d4xtian
Participant
0 Kudos

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

1 ACCEPTED SOLUTION

venkateswaran_k
Active Contributor

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

8 REPLIES 8

Sandra_Rossi
Active Contributor
0 Kudos

Remove OBLIGATORY and do:

IF p_angle1 = 0.
  MESSAGE 'p_angle1 is obligatory' TYPE 'E'.
ENDIF.

venkateswaran_k
Active Contributor

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

0 Kudos

Thanks you for the global If Statement.

Write, don't display anything ? i don't know why

fotso

Write will be displayed after completion of the program.

So use message statement.

0 Kudos

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

🙂 Display like is optional. Not necessary.. I removed it.

venkateswaran.k

You can edit your answer too, to not confuse future visitors 😉

d4xtian
Participant
0 Kudos

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