‎2009 Jun 04 6:42 PM
Hello all,
I am facing a problem in finding maximum number by using a select stmt.
I had a table contain fields in this seq .
z_doc table:
1.PERNR type pernr
2. Doc_type type C
3.Doc_ID type NUMC
I want to find large number in DOC_ID .
I used select statement as
Select max (doc_id) from Z_doc into wa.
But i am not getting the large number in that .
Pls help me in this issue ..Thanking you.
URS ,
Suman
‎2009 Jun 04 7:28 PM
Hi Suman,
Alternative way :
1.select all the records into a table.
2.sort the table by docid descending.
3.read the table at index 1.
regards,
Dinesh
‎2009 Jun 04 7:06 PM
Hi Suman,
Try this:
data: l_doc_id type numc.
..
..
Select max (doc_id) from z_doc into l_doc_id.
george
‎2009 Jun 04 7:28 PM
Hi Suman,
Alternative way :
1.select all the records into a table.
2.sort the table by docid descending.
3.read the table at index 1.
regards,
Dinesh
‎2009 Jun 05 3:00 AM
Hi Suman,
You cannot get that value to a Work Area or a structure,,..
It should be retrieve to a field,,, make sure that in
Select max (doc_id) from Z_doc into wa , WA is a field of doc_id type.
Thanks & regards,
Dileep .C
‎2009 Jun 05 3:32 AM
Hi Suman,
Try below one, your query is right but you need to give INTO <fieldname> not <work area>.
TABLES ztest_pernr.
SELECT SINGLE MAX( doc_id ) FROM ztest_pernr INTO ztest_pernr-doc_id .
WRITE ztest_pernr-doc_id.Thanks
Venkat
‎2009 Jun 05 8:33 AM
Hello all,
I am facing a problem in finding maximum number by using a select stmt.
I had a table contain fields in this seq .
z_doc table:
1.PERNR type pernr
2. Doc_type type C
3.Doc_ID type NUMC
I want to find large number in DOC_ID .
I used select statement as
Select max (doc_id) from Z_doc into wa.
But i am not getting the large number in that .
Here the problem is Table is a DB table and it is sorting depends on PERNR.
So the value corresponding to highest perner getting as large doc_id.
We want to retried it by select stmt only becoz there are 50lacs data in that doc id.
Pls help me in this issue ..Thanking you.
URS ,
Suman
‎2009 Jun 05 8:37 AM
Hi Suman,
Try below one, your query is right but you need to give INTO <fieldname> not <work area>.
Thanks
Venkat.O
TABLES ztest_pernr.
SELECT SINGLE MAX( doc_id ) FROM ztest_pernr INTO ztest_pernr-doc_id .
WRITE ztest_pernr-doc_id.
‎2009 Jun 05 9:05 AM
Hi,
SELECT MAX( FIELDNAME ) INTO TABLENAME-FIELDNAME FROM TABLE NAME
WHERE FIELDNAME = <VARIABLE> OR <PARAMETER>.
If you use more than one field in select statement then use group by cause.
SELECT MAX( FIELDNAME ) fieldname2 fieldname 3 INTO ( TABLENAME-FIELDNAME, TABLENAME-FIELDNAME2, TABLENAME-FIELDNAME3 ) FROM TABLE NAME
WHERE FIELDNAME = <VARIABLE> OR <PARAMETER>
group by fieldname filedname2 fieldname3.
Aswarth
‎2011 Feb 19 3:21 PM