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

substring in select statement

Former Member
0 Likes
1,238

i have a selection screen where year is only input field, and in my table there is a date field, so i have to retrieve the data only of the given year only, so how do i substring the date field of that table and compare with my input in select statement

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
895

Hi

Try sth like this:

PARAMETERS p_year(4) TYPE n.

DATA: it_flight TYPE TABLE OF sflight,

year_start TYPE d,

year_end TYPE d.

START-OF-SELECTION.

CONCATENATE p_year '0101' INTO year_start.

CONCATENATE p_year '1231' INTO year_end.

SELECT * FROM sflight INTO TABLE it_flight WHERE fldate BETWEEN year_start AND year_end.

Best regards,

Katarzyna Rafalska

4 REPLIES 4
Read only

Former Member
0 Likes
896

Hi

Try sth like this:

PARAMETERS p_year(4) TYPE n.

DATA: it_flight TYPE TABLE OF sflight,

year_start TYPE d,

year_end TYPE d.

START-OF-SELECTION.

CONCATENATE p_year '0101' INTO year_start.

CONCATENATE p_year '1231' INTO year_end.

SELECT * FROM sflight INTO TABLE it_flight WHERE fldate BETWEEN year_start AND year_end.

Best regards,

Katarzyna Rafalska

Read only

Former Member
0 Likes
895

If your corresponding database table has the year field and you want to get the data according to the fiscal year

then try the following ways : .

.

parameters : p_date type datum. " Ur date field.

data : g _year type i.

at selection-screen:.

move p_date+0(4) to g_year.

Then pass g_year in your where clause.

or you can use the FM.

CALL FUNCTION 'GET_CURRENT_YEAR'

    EXPORTING

      bukrs = u2018ur company code'u2019

      date  = ur date field.

    IMPORTING

*      currm = fiscalmonth

      curry = g_year.

here also pass g_year in your where clause.

Regards

Abhinab.

Read only

Former Member
0 Likes
895

Please Press F1 on CS.

Using Contain string you can check the current year in date.

Hope this helps you.

Read only

Former Member
0 Likes
895

After a long time i saw my question and acknowledge that i know the answer...:)


TABLES: FAGLFLEXA.

SELECT * INTO FAGLFLEXA
  FROM FAGLFLEXA
  WHERE BUDAT LIKE '2011%'.
ENDSELECT.

WRITE: SY-DBCNT.