2006 Sep 08 4:23 AM
Hello experts,
I was wondering on why does my loop with where clause does not work. Here is my code:
LOOP AT it_finaltab ASSIGNING <wa_finaltab>
where funcloc = <fs_finaltab>-funcloc.
endloop.
I am sure that my itab(it_finaltab) has records which will satisfy my condition. Help
would be greatly appreciated. Thanks a lot!
2006 Sep 08 4:28 AM
The problem is in writing loop statement.
Your statement is
LOOP AT it_finaltab ASSIGNING <wa_finaltab>
where funcloc = <fs_finaltab>-funcloc.
endloop.
Instead write in this way:
<b>LOOP AT it_finaltab ASSIGNING <wa_finaltab>
where funcloc = <comparing value>.
endloop.</b>
The <comparing value> must contain some value not the <fs_finaltab>-funcloc.
You are looping on it_finaltab and putting the value in field symbol and comparing the funcloc with field symbol.
This is not possible.
Best Regards,
Tarun
The problem is in writing loop statement.
Your statement is
LOOP AT it_finaltab ASSIGNING <wa_finaltab>
where funcloc = <fs_finaltab>-funcloc.
endloop.
Instead write in this way:
<b>LOOP AT it_finaltab ASSIGNING <wa_finaltab>
where funcloc = <comparing value>.
endloop.</b>
The <comparing value> must contain some value not the <fs_finaltab>-funcloc.
You are looping on it_finaltab and putting the value in field symbol and comparing the funcloc with field symbol.
This is not possible.
Best Regards,
Tarun
2006 Sep 08 4:28 AM
The problem is in writing loop statement.
Your statement is
LOOP AT it_finaltab ASSIGNING <wa_finaltab>
where funcloc = <fs_finaltab>-funcloc.
endloop.
Instead write in this way:
<b>LOOP AT it_finaltab ASSIGNING <wa_finaltab>
where funcloc = <comparing value>.
endloop.</b>
The <comparing value> must contain some value not the <fs_finaltab>-funcloc.
You are looping on it_finaltab and putting the value in field symbol and comparing the funcloc with field symbol.
This is not possible.
Best Regards,
Tarun
2006 Sep 08 4:31 AM
from where you r populating the value <b><fs_finaltab>-funcloc</b> which was used in the where condition
anywayz check this
To assign the contents of the current loop line to a field symbol, specify <result> as follows:
LOOP AT <itab> ASSIGNING <FS> <conditions>.
In each loop pass, the field symbol <FS> points to the table entry read in that pass. If the line type is structured, you should specify the same type for the field symbol when you declare it. This allows you to address the components of the field symbol. If you cannot specify the type statically, you must use further field symbols and the technique of assigning components of structures to address the components of the structure.
The end of the loop does not affect the field symbol, that is, after ENDLOOP it is still assigned to the same line as in the final loop pass. If no table entries are processed in the loop, because the table is entry, or no line meets the condition <condition>, the field symbol is not changed.
e.g.
DATA: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA ITAB LIKE SORTED TABLE OF LINE WITH UNIQUE KEY COL1.
FIELD-SYMBOLS <FS> LIKE LINE OF ITAB.
DO 4 TIMES.
LINE-COL1 = SY-INDEX.
LINE-COL2 = SY-INDEX ** 2.
APPEND LINE TO ITAB.
ENDDO.
READ TABLE ITAB WITH TABLE KEY COL1 = 2 ASSIGNING <FS>.
<FS>-COL2 = 100.
READ TABLE ITAB WITH TABLE KEY COL1 = 3 ASSIGNING <FS>.
DELETE ITAB INDEX 3.
IF <FS> IS ASSIGNED.
WRITE '<FS> is assigned!'.
ENDIF.
LOOP AT ITAB ASSIGNING <FS>.
WRITE: / <FS>-COL1, <FS>-COL2.
ENDLOOP.
The output is:
1 1
2 100
4 16
The example fills a sorted table ITAB with 4 lines. The second line is assigned to the field symbol <FS> (which has the same type), and modified using it. The third line is assigned to <FS> and then deleted. Consequently, the logical expression in the IF statement is untrue. <FS> is used to display the table lines in the LOOP. Afterwards, it points to the third line of the table.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |