06-08-2009 10:57 AM
Dear Experts
I have a Z database table.
In that i have three fields.
Review Cycle Review step GUID of object
1 1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1 2 xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2 1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2 2 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
3 1
Here my requirwement for output dispay is that i need to select review_cycle 3 only.
Should i add counter in the loop when i loop at this internal table and display the counter value ?
Thanks in advance
06-08-2009 11:04 AM
Hi Swarna,
See if this sample code helps you,
SELECT SINGLE MAX( etimes )
FROM zmailhist
INTO wa-etimes
WHERE vbeln EQ p_vbeln AND
kunnr EQ p_kunnr.
wa-etimes = wa-etimes + 1.
ELSE.
wa-etimes = 1.
ENDIF.
Revert back for further help
06-08-2009 11:04 AM
-How to select a max value in a database table for display-
if u wnat to select the max value in Review Cycle
then from database query use " select max ".
if its ins itab then sort based on that field descending and read it
06-08-2009 11:04 AM
Hi Swarna,
See if this sample code helps you,
SELECT SINGLE MAX( etimes )
FROM zmailhist
INTO wa-etimes
WHERE vbeln EQ p_vbeln AND
kunnr EQ p_kunnr.
wa-etimes = wa-etimes + 1.
ELSE.
wa-etimes = 1.
ENDIF.
Revert back for further help
06-08-2009 11:09 AM
SELECT SINGLE MAX( BELNR ) FROM BKPF INTO V_LAST_BELNR.
this fetches you the record with maximum belnr. (the first maximum)
Edited by: Sumit Nene on Jun 8, 2009 12:09 PM
06-08-2009 11:35 AM
Hi Swarna,
select single max( review_cycle )
from db_tab
into work_area.
if review_cycle with value > 3 exists it gets u the greater value..
u shl use where condition..
select single review_cycle
from db_tab
into work_area
where review_cycle = 3.
chk sy-subrc.
Regards.
06-08-2009 11:42 AM
Hi Swarna
Try this code.
DATA:
T_ITAB LIKE TABLE OF ZTABLE,
FS_ITAB LIKE LINE OF T_ITAB,
WA_ITAB TYPE ZTABLE-REVIEW_CYCLE .
SELECT * FROM ZTABLE INTO TABLE T_ITAB.
SORT T_ITAB DESCENDING BY REVIEW_CYCLE .
READ TABLE T_ITAB INTO FS_ITAB INDEX 1.
MOVE FS_ITAB-REVIEW_CYCLE TO WA_ITAB.
LOOP AT T_ITAB INTO FS_ITAB.
IF FS_ITAB-REVIEW_CYCLE EQ WA_ITAB.
WRITE:/
FS_ITAB-REVIEW_CYCLE ,
FS_ITAB-REVIEW_STEP,
FS_ITAB-GUID.
ENDIF.
ENDLOOP.
Regards
Hareesh Menon