Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Cannot use select max(field) from table into var

Former Member
0 Likes
503

Hi

I would like to select the latest date from a table. Therefore I througt that I could use the following statement (see context below):

select max(/BIC/FCVERDATE) from /BIC/AAPO_O1000 into FCVERDATE.

but there is no accept - I get the message: "E: Unknow column name MAX(/BIC/FCVERDATE). Not determined until runtime, you cannot specifi a field list."

I dont get it - why can I not use the max statement i works with the statement below, but I guess the statement below performs bad:

DATA: FCVERDATE LIKE /BIC/AAPO_O1000-/BIC/FCVERDATE.

....

select /BIC/FCVERDATE from /BIC/AAPO_O1000 into FCVERDATE up to 1 rows order by /BIC/FCVERDATE.

endselect.

*select max(/BIC/FCVERDATE) from /BIC/AAPO_O1000 into FCVERDATE.

select * from /BIC/AAPO_O1000 into table TAB_APOO10

WHERE /BIC/FCVERDATE = FCVERDATE.

LOOP AT DATA_PACKAGE.

...

Please let me know if you have a nice solution to get the latest date.

regards,

Torben

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
480

select max( /BIC/FCVERDATE ) from /BIC/AAPO_O1000 into FCVERDATE.

include space after ( and before ).

Regards,

Ravi

Hi

I would like to select the latest date from a table. Therefore I througt that I could use the following statement (see context below):

select max(/BIC/FCVERDATE) from /BIC/AAPO_O1000 into FCVERDATE.

but there is no accept - I get the message: "E: Unknow column name MAX(/BIC/FCVERDATE). Not determined until runtime, you cannot specifi a field list."

I dont get it - why can I not use the max statement i works with the statement below, but I guess the statement below performs bad:

DATA: FCVERDATE LIKE /BIC/AAPO_O1000-/BIC/FCVERDATE.

....

select /BIC/FCVERDATE from /BIC/AAPO_O1000 into FCVERDATE up to 1 rows order by /BIC/FCVERDATE.

endselect.

*select max(/BIC/FCVERDATE) from /BIC/AAPO_O1000 into FCVERDATE.

select * from /BIC/AAPO_O1000 into table TAB_APOO10

WHERE /BIC/FCVERDATE = FCVERDATE.

LOOP AT DATA_PACKAGE.

...

Please let me know if you have a nice solution to get the latest date.

regards,

Torben

3 REPLIES 3
Read only

Former Member
0 Likes
480

Hi,

instead u can

Select /BIC/FCVERDATE from /BIC/AAPO_O1000 
                    into TABLE i_FCVERDATE.
if sy-subrc = 0.
SORT  i_FCVERDATE dscending by /BIC/FCVERDATE. 
READ TABLE  i_FCVERDATE WITH KEY index 1.
if sy-subrc = 0.
.................
endif.
endif.

this wont have any perforamnce issue also.

Read only

Former Member
0 Likes
481

select max( /BIC/FCVERDATE ) from /BIC/AAPO_O1000 into FCVERDATE.

include space after ( and before ).

Regards,

Ravi

Read only

0 Likes
480

Thank you!