Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Push buttons in module pool are not working correctly

Hi all,

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:

case ok_code.

when 'mo85'.      " for moving water from 8L container to 5L

     perform first_routine.

when 'mo83'.      " for moving water from 8L container to 3L       "

     perform second_routine.

when 'mo58'.      " for moving water from 5L container to 8L

     perform third_routine.

when 'mo53'.      " for moving water from 5L container to 3L

     perform fourth_routine.

when 'mo38'.      " for moving water from 3L container to 8L

     perform fifth_routine.

when 'mo35'.      " for moving water from 3L container to 5L

     perform sixth_routine.

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?

Tags:
replied

Hi Niketa,

View the code, hope it helpful to avoid nested conditions.

DATA : GLASS8(12) TYPE 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.

CLEAR: lv_num.

DO.

CLEAR  lv_result.

IF glass5 EQ c_val.

lv_num = c_val.

EXIT.

ELSE.

ADD 1 to lv_num.

lv_result = glass5 + lv_num.

CHECK lv_result EQ c_val.

EXIT.

ENDIF.

ENDDO.

glass5 = glass5 + lv_num.

glass8 = glass8 - lv_num.

ENDIF.

Regards,

Venkat.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question