Application Development and Automation 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: 
Read only

Problem in Loop

Former Member
0 Likes
545

DATA: fields LIKE SVAL OCCURS 0 WITH HEADER LINE,

CHAR_FOUND(1),

answer(1),

FIFTEEN_DAYS LIKE SY-DATUM,

SCHED_QUAN LIKE CETT-MENGE,

QUANTITY LIKE CETT-MENGE.

CLEAR: fields,

CHAR_FOUND,

SCHED_QUAN.

REFRESH: fields.

  • IF f1 = 0.

fields-TABNAME = 'MSEG'.

fields-FIELDNAME = 'ERFMG'.

APPEND fields.

FIFTEEN_DAYS = SY-DATUM + 15.

CALL FUNCTION 'POPUP_GET_VALUES'

EXPORTING

NO_VALUE_CHECK = 'X'

POPUP_TITLE = 'QUANTITY TO RECEIVE'

  • START_COLUMN = '5'

  • START_ROW = '5'

  • IMPORTING

  • RETURNCODE =

TABLES

FIELDS = fields

EXCEPTIONS

ERROR_IN_FIELDS = 1

OTHER = 2

READ TABLE fields INDEX 1.

QUANTITY = fields-VALUE.

LOOP AT CETT.

IF SCHED_QUAN GE QUANTITY.

CHAR_FOUND = 'X'.

EXIT.

ELSEIF CETT-EINDT = FIFTEEN_DAYS.

CHAR_FOUND ='X'.

EXIT.

ELSE.

SCHED_QUAN = CETT-MENGE + SCHED_QUAN.

ENDIF.

ENDLOOP.

IF QUANTITY GE SCHED_QUAN OR CHAR_FOUND = 'X'.

F1 = SCHED_QUAN.

F2 = F1.

ELSEIF QUANTITY LT SCHED_QUAN.

CALL FUNCTION 'POPUP_WITH_2_BUTTONS_TO_CHOOSE'

EXPORTING

  • DEFAULTOPTION = '1'

DIAGNOSETEXT1 = 'ENTER'

  • DIAGNOSETEXT2 = ' '

  • DIAGNOSETEXT3 = ' '

TEXTLINE1 = 'DO YOU WANT TO INCLUDE DELIVERIES MORE THAN 15 DAYS IN THE FUTURE'

  • TEXTLINE2 = ' '

  • TEXTLINE3 = ' '

TEXT_OPTION1 = 'YES'

TEXT_OPTION2 = 'NO'

TITEL = 'USER EXIT'

IMPORTING

ANSWER = answer.

IF ANSWER = 1.

CLEAR SCHED_QUAN.

LOOP AT CETT.

IF SCHED_QUAN GE QUANTITY.

F1 = SCHED_QUAN.

F2 = F1.

EXIT.

ELSE.

SCHED_QUAN = CETT-MENGE + SCHED_QUAN.

AT LAST.

IF SCHED_QUAN GE QUANTITY.

F1 = SCHED_QUAN.

F2 = F1.

ENDIF.

ENDAT.

ENDIF.

ENDLOOP.

ENDIF.

ENDIF.

ENDIF.

ENDIF.

In the above we are checking if the 1) quantity to receive is equal or greater than scheduled quantities.. If that doesn't satisfy then 2) we are checking quantity to receieve is greater than or equal to sum of scheduled quantities in the next 15 days...

Still if the scheduled quantities is less than quantity to 3)receive if we are checking for more than 15 days by diplaying a pop up box...

For us 1,2 are working... When it is coming to 3 it is returning correct value but not displaying pop up window..

How to fix it.....Please help me..

4 REPLIES 4
Read only

Former Member
0 Likes
516

Hi Alexander,

If you create a program with only the call of the function "POPUP_WITH_2_BUTTONS_TO_CHOOSE" does the popup shows up?

If it doesn't show it might be a sap gui problem.

Hope it helps.

Regards,

Gilberto Li

Read only

0 Likes
516

Quantity to receive is 200. The scheduled quantity to receive within 15 days is 100. After 15 days it's next value is 300. In that case we are expecting POP UP BOX to display.

However if we enter 1000.... Then we are getting POPUP and code is executing....

How to fix this problem

Read only

0 Likes
516

Hi again,

I will agree with Rob, try the following pls:

IF QUANTITY GE SCHED_QUAN OR CHAR_FOUND = 'X'.
F1 = SCHED_QUAN.
F2 = F1. 

<b>ELSEIF QUANTITY LT SCHED_QUAN AND CHAR_FOUND <> 'X'.</b>

CALL FUNCTION 'POPUP_WITH_2_BUTTONS_TO_CHOOSE'
EXPORTING
* DEFAULTOPTION = '1'
DIAGNOSETEXT1 = 'ENTER'
* DIAGNOSETEXT2 = ' '
* DIAGNOSETEXT3 = ' '
TEXTLINE1 = 'DO YOU WANT TO INCLUDE DELIVERIES MORE THAN 15 DAYS IN THE FUTURE'
* TEXTLINE2 = ' '
* TEXTLINE3 = ' '
TEXT_OPTION1 = 'YES'
TEXT_OPTION2 = 'NO'
TITEL = 'USER EXIT'

Hope it helps.

Regards,

Gilberto Li

Read only

Former Member
0 Likes
516

I think the problem is that the IF also checks char_found = 'X', while the ELSEIF doesn't.

Rob