2007 May 31 9:54 AM
hi,
i need to extract the highest number for vbeln.
example 12000012, 12000014, 12000018, then i will retrieve 12000018.
1)may i know below can return accurately? do i need to have group by?
2)also can have order by for select single? for this select statement i do not have max( ) but i got error.
SELECT SINGLE max( vbeln ) INTO wa_report-inv FROM vbfa
WHERE vbelv = wa_report-vgbel AND
posnv = wa_report-vgpos AND
vbtyp_n = 'U'.
thanks
2007 May 31 9:57 AM
Hi
Declare an ITAB with required fields
if not wa_report-vgbel [] is initial.
SELECT vbeln INTO table Itab FROM vbfa
WHERE vbelv = wa_report-vgbel AND
posnv = wa_report-vgpos AND
vbtyp_n = 'U'.
endif.
Sort ITAB by vbeln decending .
read table itab index 1.
if sy-subrc = 0.
<b>required VBELN (highest) = itab-vbeln.</b>
endif.
Reward points if useful
Regards
Anji
put them in an internal table.
sort itab by vbeln.
loop at itab.
endloop.
now the last entry is that you want.
reward with points if its helpful.
2007 May 31 9:56 AM
hi,
i hope aggregate objects will not work single statement.so better remove single from select statement.
reward points if it is helpful
regards,
sangeetha.a
2007 May 31 9:57 AM
Hi
Declare an ITAB with required fields
if not wa_report-vgbel [] is initial.
SELECT vbeln INTO table Itab FROM vbfa
WHERE vbelv = wa_report-vgbel AND
posnv = wa_report-vgpos AND
vbtyp_n = 'U'.
endif.
Sort ITAB by vbeln decending .
read table itab index 1.
if sy-subrc = 0.
<b>required VBELN (highest) = itab-vbeln.</b>
endif.
Reward points if useful
Regards
Anji
2007 May 31 9:57 AM
Hi Eliana,
SINGLE is not required for MAX( VBELN ) as MAX( VBELN ) will itself picks highest vbeln from the table.
Check this code.
<b>SELECT max( vbeln )</b> INTO wa_report-inv FROM vbfa
WHERE vbelv = wa_report-vgbel AND
posnv = wa_report-vgpos AND
vbtyp_n = 'U'.
Thanks,
Vinay
2007 May 31 10:03 AM
Hi elina,
this will work fine..
check this one
TABLES: sflight.
DATA wa_report LIKE sflight.
SELECT SINGLE MAX( seatsocc ) INTO wa_report-seatsocc
FROM sflight
WHERE carrid = 'AA'.
Regards
Sarath
2007 May 31 10:41 AM
Hi,
You can do like this,
SELECT vbeln INTO it_report FROM vbfa
WHERE vbelv = wa_report-vgbel AND
posnv = wa_report-vgpos AND
vbtyp_n = 'U'.
sort it_report by inv descending.
read table it_report index1.
regards,
sudha.
2007 May 31 10:44 AM
put them in an internal table.
sort itab by vbeln.
loop at itab.
endloop.
now the last entry is that you want.
reward with points if its helpful.
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |