Push buttons in module pool are not working correctly
i have made a simple module pool program on water puzzle . i have 8, 5 and 3 liter container and i need to fill at least one with 4 liter of water to solve the problem. so i made 6 different push buttons for moving water quantity from one to other container.
the coding is as follows:
when 'mo85'. " for moving water from 8L container to 5L
when 'mo83'. " for moving water from 8L container to 3L "
when 'mo58'. " for moving water from 5L container to 8L
when 'mo53'. " for moving water from 5L container to 3L
when 'mo38'. " for moving water from 3L container to 8L
when 'mo35'. " for moving water from 3L container to 5L
and the screen looks as follows:
so when i press the any button from the six listed for the first time it works but when i press any other button from the six it does not work.
for example i moved water from 8l to 5l so i pressed button "move to 5l" as shown in image . it worked but when i tried other button say "move to 3l" it did not work. where as the clear and result buttons are working fine.
what to do?
VenkatRamesh V replied
View the code, hope it helpful to avoid nested conditions.
DATA : GLASS8(12) TYPE C VALUE '8',
GLASS5(12) TYPE C VALUE '1',
GLASS3(12) TYPE C,
lv_num TYPE i,
lv_result TYPE i.
CONSTANTS: c_val(01) value '5'.
IF glass8 IS NOT INITIAL.
IF glass5 EQ c_val.
lv_num = c_val.
ADD 1 to lv_num.
lv_result = glass5 + lv_num.
CHECK lv_result EQ c_val.
glass5 = glass5 + lv_num.
glass8 = glass8 - lv_num.