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

Select Max problem

Former Member
0 Likes
832

Hi currently i have this sql error problem which i do not know how to solve. below are my codes. I think there is something wrong with my sql statement.

DATA: M_TABLE TYPE TABNAME,

COLUMN_FIELD(14) TYPE C,

VALUE2 TYPE P DECIMAL 1.

M_TABLE = 'ZTABLE'.

COLUMN_FIELD = 'GPA'."example 2.1

SELECT MAX( COLUMN_FIELD ) FROM (M_TABLE) INTO VALUE2.

============================================

After solving this problem, i have another problem. Now my column_field 'GPA' is to decimal 1 as i have declared. But if i need to do it in dynamic example if another column field is money which i do not know the decimal will be placing at where, how should i declare it?

5 REPLIES 5
Read only

Former Member
0 Likes
783

HI,

do like this.

DATA: M_TABLE TYPE TABNAME,

COLUMN_FIELD(14) TYPE C,

VALUE2(10)." TYPE P DECIMALs 1.

M_TABLE = 'MARA'.

COLUMN_FIELD = 'MATNR'."example 2.1

SELECT MAX( MATNR ) FROM (M_TABLE) INTO VALUE2.

write:/ value2.

rgds,

bharat.

Read only

0 Likes
783

Hi but can i do this? Put the variable column_field in the select statement? because the field might change. Now i only hard code it.

SELECT MAX( COLUMN_FIELD ) FROM (M_TABLE) INTO VALUE2.

Read only

Former Member
0 Likes
783

I have this error message when i execute my program.

SAPSQL_INVALID_FIELDNAME

Read only

0 Likes
783

Hi,

Check this code. It might help you to solve the problem.

DATA: itab TYPE STANDARD TABLE OF spfli,

wa LIKE LINE OF itab.

DATA: line(72) TYPE c,

list LIKE TABLE OF line(72).

START-OF-SELECTION.

line = ' AIRPFROM AIRPTO '.

APPEND line TO list.

SELECT DISTINCT (list)

INTO CORRESPONDING FIELDS OF TABLE itab

FROM spfli.

IF sy-subrc EQ 0.

LOOP AT itab INTO wa.

WRITE 😕 wa-airpfrom,wa-airpto.

ENDLOOP.

ENDIF.

Reward Points, if useful.

Regards,

Manoj Kumar

Read only

Former Member
0 Likes
783

SOLVED. THANKS 😃