07-17-2008 5:25 AM
i am using Do enddo to check 40 fields lga01 lga02 lga03 in any one of these 40 fields if i found any value which statisfies my condition i need to pick the value and come out of this loop.if no value present in do endo loop then i need to display a message in the report value not found
07-17-2008 5:28 AM
Hi,
You can use EXIT command for it.
Syntax
DO 40 times.
(Value check operation)
IF (Value satisfied)
(Store value to global variable)
EXIT.
ELSEIF SY_INDEX EQ 40.
(Print the message).
ENDIF.
ENDDO.
Regards,
anirban
07-17-2008 5:30 AM
Hi Sachin,
Try the following:
data: w_temp type i.
Do 40 times.
if <condition>
w_temp = w_temp + 1.
w_value = value.
stop.
endif.
enddo.
if w_temp > 1.
message 'Not Found' Type I.
endif.
Hope this helps you.
Regards,
Chandra Sekhar
07-17-2008 5:32 AM
Use
DO.
if field1 eq something.
EXIT.
Else.
CONTINUE.
Endif.
if field2.
if field40 eq something.
EXIT.
else.
Message.
Endif.
ENDDO.
Regards
Kannaiah
07-17-2008 5:33 AM
Hi Sachin,
You can try something like as given below :
DO.
IF <condition> = lga01 or ... = lga02 or .. lga03 .
........
EXIT.
ELSEIF counter = 40.
message .................
EXIT.
ENDIF.
counter = counter + 1.
ENDDO.
With luck,
Pritam.
07-17-2008 5:34 AM
Hi,
I think following code will be useful to you.
DATA: g_lgart TYPE t512t-lgart.
DO 40 TIMES VARYING g_lgart
FROM p0008-lga01
NEXT p0008-lga02.
*condition on g_lgart
ENDDO.
07-17-2008 6:16 AM
Hi,
DO.. VARYING will help you resolve the issue.
Check the F1 help for the same.
Try the code given below.
Regards,
Wajid Hussain
* * * *
assuming p0008 has data
DATA: g_lgart TYPE t512t-lgart,
v_flag TYPE c.
DO 40 TIMES VARYING g_lgart
FROM p0008-lga01
NEXT p0008-lga02.
IF condition satisfied.
v_flag = 'X'.
EXIT.
ENDIF.
ENDDO.
IF NOT v_flag IS INITIAL.
WRITE: / g_lgart.
ENDIF.
07-17-2008 5:42 AM
Hi Sachin
You can try like this. I think this will work.
DATA: i TYPE i VALUE 0,
j TYPE i VALUE 0.
DO 40 TIMES.
IF i GT 100.
j = 1.
EXIT.
ENDIF.
ENDDO.
IF j NE 1.
MESSAGE 'not found' TYPE 'I'.
ENDIF.
07-17-2008 5:53 AM
Hi Sachin,
Try this code :
DO 40 TIMES.
IF lg01 = <value>.
w_value = <value>.
ELSEIF lg02 = <value>.
w_value = <value>.
.......
.......
......
ENDIF.
ENDDO.
If lg01 satisfies the condition it fetches the value into w_value and so on.
So it will give you the required value at one point.
Regards,
Swapna.