Search
Search

# Problem in Loop

Hai Friends,

The following is my coding

```LOOP AT  IT_OUTPUT2 ASSIGNING <FS_OUTPUT2>.
LOOP AT IT_TOTALS1 ASSIGNING <FS_TOTALS1> WHERE ZKOSTL = <FS_OUTPUT2>-ZKOSTL
AND   ZMCNO  = <FS_OUTPUT2>-ZMCNO
AND   ZSHIFT = <FS_OUTPUT2>-ZSHIFT
AND   TOTALS = <FS_OUTPUT2>-TOTALS.
CASE <FS_OUTPUT2>-ZSHIFT.

WHEN '1'.
IF SY-SUBRC = 0.
IF NOT <FS_TOTALS1>-TOTALS IS INITIAL.
<FS_OUTPUT2>-ZSHIFT01 = ( <FS_OUTPUT2>-ZSHIFT01 / <FS_TOTALS1>-TOTALS ).
ENDIF.
ENDIF.

WHEN '2'.
IF SY-SUBRC = 0.
IF NOT <FS_TOTALS1>-TOTALS IS INITIAL.
<FS_OUTPUT2>-ZSHIFT02 = ( <FS_OUTPUT2>-ZSHIFT02 / <FS_TOTALS1>-TOTALS ).
ENDIF.
ENDIF.

WHEN '3'.
IF SY-SUBRC = 0.
IF NOT <FS_TOTALS1>-TOTALS IS INITIAL.
<FS_OUTPUT2>-ZSHIFT03 = ( <FS_OUTPUT2>-ZSHIFT03 / <FS_TOTALS1>-TOTALS ).
ENDIF.
ENDIF.
ENDCASE.
ENDLOOP.
ENDLOOP.```

For me only the shift-1 is calculating and not the 2nd and 3rd.

IT_OUTPUT2 has the following values

```ZKOSTL ZMCNO ZSHIFT1 ZSHIFT2 ZSHIFT3

101        001        162        149        324
101        002         820        105       458
101        003        120        165       458
101        004         120        805       458```

IT_TOTALS has the following values

ZKOSTL SHIFT ZMCNO TOTALS

101 1 001 20

101 2 001 12

101 3 001 2

101 1 002 2

101 2 002 6

101 3 002 2

I want 162/20 , 149/12, 324/2

820/2, 105/6, 458/2

right now i am getting the divided value only for shift1 for all ZMCNO. Kindly explain me.

##### Former MemberOctober 01, 2008 at 15:04 PM0 Likes
View more on this topic or