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 query

Former Member
0 Likes
887

hi experts how can i filter records by month of given date. I use the given below statement. but it gives error message. Pls anyone give solution.

SELECT VBELN POSNR EDATU

FROM VBEP

INTO TABLE T_VBEP

WHERE EDATU+4(2) LE 3.

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
847

Hi

First fetch all records from table.

then in the loop seggregate the records.

SELECT VBELN POSNR EDATU

FROM VBEP

INTO TABLE T_VBEP.

loop at t_vbep.

if t_vbep- EDATU+4(2) gt 4.

delete t_vbep index sy-tabix.

endif.

endloop.

Reward points if useful

Regards

Anji

8 REPLIES 8
Read only

Former Member
0 Likes
848

Hi

First fetch all records from table.

then in the loop seggregate the records.

SELECT VBELN POSNR EDATU

FROM VBEP

INTO TABLE T_VBEP.

loop at t_vbep.

if t_vbep- EDATU+4(2) gt 4.

delete t_vbep index sy-tabix.

endif.

endloop.

Reward points if useful

Regards

Anji

Read only

0 Likes
847

hi

is it possible in a single query ?

Read only

Former Member
0 Likes
847

Within select query the condition like edatu+4(2) is not possible,so use within loop endloop.

Reward Points if it is helpful

Thanks

Seshu

Read only

Former Member
0 Likes
847

You can also do it this way...


DATA: MONTH_INI TYPE SY-DATUM,
          MONTH_END TYPE SY-DATUM.

MONTH_INI = '20070501'.
MONTH_END = '20070531'.

SELECT VBELN POSNR EDATU
FROM VBEP
INTO TABLE T_VBEP
WHERE EDATU BETWEEN MONTH_INI AND MONTH_END.

Greetings,

Blag.

Read only

Former Member
0 Likes
847

Hi..

SELECT VBELN POSNR EDATU

FROM VBEP

INTO TABLE T_VBEP.

*WHERE EDATU+4(2) LE 3. * remove this line.

<b>delete t_vbep where edatu+4(2) gt 3.</b>

Read only

Former Member
0 Likes
847

parameter : s_date like sy-datum .

select vbeln posnr edatu from vbep into table t_vbep where edatu le s_date.

Girish

Read only

Former Member
0 Likes
847

Like this:


SELECT vbeln posnr edatu
  FROM vbep
  INTO TABLE t_vbep
  WHERE edatu LIKE '____03__'
     OR edatu LIKE '____02__'
     OR edatu LIKE '____01__'
     OR edatu LIKE '____00__'.

Rob

Read only

Former Member
0 Likes
847

parameter : <b>s_date LIKE T009B-POPER .</b>

data : begin_date like sy-datum , end_date like sy-datum.

call function module

G_POSTING_DATE_OF_PERIOD_GET

import parameters :

period = <b> s_date</b>

variant = '24' from the sap or else ask you fi consultant he will tell you the varaint of the period .

year = 2007

Export parameters

from_date = <b>begin_date</b>

to_date = <b>end_date .</b>

select vbeln posnr edatu from vbep into table t_vbep where <b>edatu between begin_date and end_date .</b>

i think this is what the exact technicality

Girish