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: 

sample code wanted

Former Member
0 Kudos
127

Hi,

I would like code that does the following:

Creates a selection screen with three input boxes. If all three input boxes contain numbers, it adds them and displays the result in a smaller screen or messagebox - otherwise, it loops continually until data is entered in all three fields.

thanks,

Kevin

1 ACCEPTED SOLUTION

Former Member
0 Kudos
106

I am just typing it in so please excuse me if there are some typos resulting in syntax errors.


parameters: p_nbr1 type i obligatory,
            p_nbr2 type i obligatory,
            p_nbr3 type i obligatory.

start-of-selection.

v_total = p_nbr1 + p_nbr2 + p_nbr3.

message i000(OO) with 'Your Total is' v_total.

Srinivas

6 REPLIES 6

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
106

Is this what you are looking for?



report   zrich_0001  .


parameters: p_parm1 type i,
            p_parm2 type i,
            p_parm3 type i.

data: result type i.

start-of-selection.

  if p_parm1 > 0
     and p_parm2 > 0
     and p_parm3 > 0.
    result = p_parm1 + p_parm2 + p_parm3.
    message s001(00) with result.

  endif.

You could also replace the START-OF-SELECTION statement with AT SELECTION-SCREEN. This way, you can just hit ENTER instead of Execute.

Regards,

Rich Heilman

Former Member
0 Kudos
106

PARAMETERS: p_1(10) TYPE n OBLIGATORY,

p_2(10) TYPE n OBLIGATORY,

p_3(10) TYPE n OBLIGATORY.

DATA: p_total(10) TYPE n,

g_msg(100).

p_total = p_1 + p_2 + p_3.

CONCATENATE 'The total of three variables is :'

p_total INTO g_msg SEPARATED BY space.

MESSAGE i000 WITH g_msg.

Please close the issue with appropriate points if it helps.

Thanks.

Vemu

Former Member
0 Kudos
107

I am just typing it in so please excuse me if there are some typos resulting in syntax errors.


parameters: p_nbr1 type i obligatory,
            p_nbr2 type i obligatory,
            p_nbr3 type i obligatory.

start-of-selection.

v_total = p_nbr1 + p_nbr2 + p_nbr3.

message i000(OO) with 'Your Total is' v_total.

Srinivas

0 Kudos
106

The addition 'OBLIGATORY' in my code will force the user to enter all the three values and I think that is what you wanted.

Srinivas

0 Kudos
106

I agree with Srinivas, instead of doing an IF statement, the OBLIGATORY extension is a better way if you want to "lock down" to the specific field. You will get error messages on each field untill they are filled, in my code, there is no error messages, it just doesn't do anything untill all are filled.

Not sure what you had in mind.

Regards,

Rich Heilman

0 Kudos
106

Kevin, please make sure that you close this post when you feel your question has been answered. Thanks.

Regards,

Rich Heilman