Application Development 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: 

ABAP: Compare year parameter with date

aneel_munawar
Participant
0 Kudos

Dear Abap experts,

I want to compare the date with year. How can I do this. I tried this but error.

Regards,

Aneel


select     pa2001~aedtm     pa2001~begda     pa2001~endda     pa2001~abwtg     pa2001~awart

   from pa2001 into corresponding fields of table tvbap

  where pa2001~pernr eq so_pernr and pa2001~endda+0(4) eq so_year.

1 ACCEPTED SOLUTION

aneel_munawar
Participant
0 Kudos

Dear All,

I have applied this solution which is more easy I think.  Giving for the help of others.

concatenate  '%' so_year '%' into so_year.

  selectfrom pa2001 into corresponding fields of table tvbap

  where pa2001~pernr eq so_pernr and  pa2001~endda like  so_year.

Regards,

Aneel

7 REPLIES 7

SharathSYM
Contributor
0 Kudos

You cannot give this in a select statement.

remove that last condition and pa2001~endda+0(4) eq so_year.

Loop tvbap into tvbap_line where endda EQ so_year.

     append tvbap_line INTO tvbap_2.     "copy into another table

endloop.

Former Member
0 Kudos

Hi,

The select statement seems correct just with this correction:

and pa2001~endda+0(4) IN so_year.

Regards,

Suren.

0 Kudos

Dear Suren,

pa2001~endda+0(4) IN so_year is not working.


Regards

Aneel


raymond_giuseppi
Active Contributor
0 Kudos

Did you try to convert you year parameter in a range of date (from january 1st to december 31...)

(just define a range, fill it in a AT SELECTION-SCREEN ON year form, no need to ask user...)

Regards,

Raymond

former_member458055
Participant
0 Kudos

Hi,

can you try like this?

declere - range : date.

take years (so_year) start date and end date and create that in date range.

and pass that to your select query.

Regards-

Makarand

aneel_munawar
Participant
0 Kudos

Dear All,

Thanks for your help. Let me check these solution and come back to you.

Regards,

Aneel

aneel_munawar
Participant
0 Kudos

Dear All,

I have applied this solution which is more easy I think.  Giving for the help of others.

concatenate  '%' so_year '%' into so_year.

  selectfrom pa2001 into corresponding fields of table tvbap

  where pa2001~pernr eq so_pernr and  pa2001~endda like  so_year.

Regards,

Aneel