Hi there,
I'm having a weird problem with the END OF option of the AT statement. I already knew that it can get tricky because it compares not only the specified field's content after AT END OF, but also all the fields to its left, in the structure.
But this still doesn't answer why am I getting very weird results here.
Basically, this is my scenario:
My internal table:
MATKL COLUMN B COLUMN C
140 xxxxxx yyyyyyy
140 cfsdd dasdsa
140 pdasd oasdas
150 dsadas dasdas
150 asdasd asdasd
.
.
170 xxxx xxxx
170 xxx xxxx
.
.
The code I'm having problems with is:
LOOP AT my_tab INTO my_struct WHERE date <= p_date.
....code
....code
AT END OF matkl .
CLEAR ls_t023t.
READ TABLE gt_t023t INTO ls_t023t WITH KEY matkl = my_struct-matkl spras = sy-langu.
ls_alv_rep-wgbez = ls_t023t-wgbez.
APPEND ls_alv_rep TO gt_alv_rep.
CLEAR ls_alv_rep.
ENDAT.
ENDLOOP.
The table is, of course, sorted by MATKL, and there are no fields left to MATKL.
For some reason, the code within the END OF is only being triggered for a small set of the MATKLs from my table. Of course, I'm taking into account the WHERE clause in the LOOP statement, but what I'm saying is that once the code enters the loop, I'd expect that each MATKL the loop processes, eventually enters the END OF code, after the last line for the given MATKL value. But what's happening is that, say I have 10 different MATKLs in my table, and all of them enter the code within the LOOP, only some of them reach the END OF code - the rest simply stops in the AT END OF line, then skips right away to ENDLOOP, continuing with the next line of the table (debugging).
There is no header line, no TABLES statement declared... this is a STANDARD TABLE.
Anyone has any idea of what I'm missing here ?
Thanks in advance,
Avraham