MySQL Forums
Forum List  »  Newbie

Re: MySQL - creating forecast based on inputs
Posted by: Frank Cinatro
Date: October 31, 2016 02:29PM

Peter,

Yes, I've done similar codes. This one I'm just confused how to manipulate my codes to fit the criteria.

Here is an example:

REPORT Z00CALC_MOD_PROG.


PARAMETERS par_num1(2) TYPE p.
PARAMETERS par_num2(2) TYPE p.
PARAMETERS par_code(1) TYPE c.

*-------------- variables --------------------------------------------*

DATA calc_result(4) TYPE p.

*-------------- constants --------------------------------------------*

CONSTANTS con_num1(12) TYPE c VALUE 'Number One: '.
CONSTANTS con_num2(12) TYPE c VALUE 'Number Two: '.

CONSTANTS con_result(8) TYPE c VALUE 'Result: '.

CONSTANTS con_add(1) TYPE c VALUE 'A'.
CONSTANTS con_sub(1) TYPE c VALUE 'S'.

CONSTANTS con_error(17) TYPE c VALUE 'Invalid Operation'.

* ------------- main program -----------------------------------------*


WRITE TEXT-001.
START-OF-SELECTION.

* here is how you would do the calculation using an IF

case par_code.

When 'A'.
perform Calc_Add.
Perform Status.

When 'S'.
perform Calc_Sub.
Perform Status.

When 'M'.
perform Calc_Mul.
Perform Status.

when others.
WRITE / con_error.

Endcase.

Form Calc_Add.

calc_result = par_num1 + par_num2.

WRITE: /, con_result, calc_result.

Endform.

Form Calc_Sub.
calc_result = par_num1 - par_num2.

WRITE: /, con_result, calc_result.
Endform.


Form Calc_Mul.
calc_result = par_num1 * par_num2.

WRITE: /, con_result, calc_result.
Endform.




*Perform the IF statement
Form Status.
If calc_result < 50 .
format color 7.
write: / , 'UNDERFLOW'.
elseif calc_result >= 50 AND calc_result <= 100.
format color 5.
write: / , 'NORMAL'.
else.
format color 1.
write: / , 'OVERFLOW'.
endif.
endform.

Could you help manipulate it? It's not "homework", rather just practice for an upcoming test.

Options: ReplyQuote


Subject
Written By
Posted
Re: MySQL - creating forecast based on inputs
October 31, 2016 02:29PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.