2009 Apr 14 8:34 AM
Hi,
Can someone help me with what is wrong in the following query...How to use the max function
in ABAP program select statement??
Thanks..
LOOP AT IT_ANLA_ANLZ INTO WRK_ANLA_ANLZ.
SELECT KANSW
FROM ANLC INTO TABLE IT_ANLC WHERE GJAHR IN ( SELECT MAX(GJAHR) FROM ANLC ) and ANLN1 = WRK_ANLA_ANLZ-ANLN1
AND BUKRS = WRK_ANLA_ANLZ-BUKRS .
APPEND IT_ANLC.
ENDLOOP.
2009 Apr 14 8:51 AM
Hi,
it should be like:
SELECT KANSW
FROM ANLC INTO TABLE IT_ANLC WHERE GJAHR IN ( SELECT MAX( GJAHR ) FROM ANLC ) and ANLN1 = WRK_ANLA_ANLZ-ANLN1
AND BUKRS = WRK_ANLA_ANLZ-BUKRS .
U should give space for GJAHR in brackets. U replace ur code by above..
Hope it works!!
Regards,
Pavan
Hi,
Can someone help me with what is wrong in the following query...How to use the max function
in ABAP program select statement??
Thanks..
LOOP AT IT_ANLA_ANLZ INTO WRK_ANLA_ANLZ.
SELECT KANSW
FROM ANLC INTO TABLE IT_ANLC WHERE GJAHR IN ( SELECT MAX(GJAHR) FROM ANLC ) and ANLN1 = WRK_ANLA_ANLZ-ANLN1
AND BUKRS = WRK_ANLA_ANLZ-BUKRS .
APPEND IT_ANLC.
ENDLOOP.
2009 Apr 14 8:38 AM
Hi,
You have write your select query once,
and then loop on the internal table into
which data will get populated for its display.
SELECT KANSW
FROM ANLC INTO TABLE IT_ANLC WHERE GJAHR IN
( SELECT MAX(GJAHR) FROM ANLC ) and ANLN1 = WRK_ANLA_ANLZ-ANLN1
AND BUKRS = WRK_ANLA_ANLZ-BUKRS .
Then loop at internal table:
LOOP AT IT_ANLA_ANLZ INTO WRK_ANLA_ANLZ.
write: / wrk_anla_anlz-fields.
Endloop.
Hope it helps
Regards
Mansi
2009 Apr 14 8:41 AM
Hi,
Refer:
DATA : V_GJAHR TYPE ANLC-GJAHR.
DATA : WA_ANLC LIKE LINE OF IT_ANLC.
SELECT MAX(GJAHR) FROM ANLC INTO V_GJAHR.
LOOP AT IT_ANLA_ANLZ INTO WRK_ANLA_ANLZ.
SELECT KANSW
FROM ANLC INTO WA_ANLC WHERE GJAHR = V_GJAHR
AND ANLN1 = WRK_ANLA_ANLZ-ANLN1
AND BUKRS = WRK_ANLA_ANLZ-BUKRS .
APPEND WA_ANLC TO IT_ANLC.
CLEAR WA_ANLC.
ENDLOOP.
Hope this helps you.
Regards,
Tarun
2009 Apr 14 8:50 AM
u can store the data of table ANLC into internal table IT_ANLC and then,
SORT IT_ANLC by GJAHR descending.
Read table IT_ANLC index 1 into wa_ANLC.
now the field wa_ANLC-GJAHR has the value of max year. now u can continue with the same code and compare gjahr with wa_ANLC-gjahr instead of using max.
2009 Apr 14 8:51 AM
Hi,
it should be like:
SELECT KANSW
FROM ANLC INTO TABLE IT_ANLC WHERE GJAHR IN ( SELECT MAX( GJAHR ) FROM ANLC ) and ANLN1 = WRK_ANLA_ANLZ-ANLN1
AND BUKRS = WRK_ANLA_ANLZ-BUKRS .
U should give space for GJAHR in brackets. U replace ur code by above..
Hope it works!!
Regards,
Pavan
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |