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: 

problem facing with dates??

Former Member
0 Kudos

I am creating a program for birthday sms sending to our customers.

I am fetching birthdate from knvk-gbdat.

when i enter manually the birht date of customer say 22.05.2001 it is getting

executed.

but if the year in the same date is changed than showing no record.

i have applied select querry..

date-low  = sy-datum.
   date-high = sy-datum.


APPEND date .
   CLEAR: date .

  day = sy-datum+6(2).
   month = sy-datum+4(2).

select a~gbdat a~parau b~kunnr b~telf2 from knvk as a inner join kna1 as b
      on  a~kunnr = b~kunnr into table it_data where b~kunnr in s_kunnr.
     AND a~gbdat in date.

loop at it_data into wa_data.
      b_day = wa_data-gbdat+6(2).
     b_month = wa_data-gbdat+4(2).

if ( b_day = day and b_month = month ) .

wa_final-gbdat = wa_data-gbdat.
   wa_final-parau = wa_data-parau.
   wa_final-kunnr = wa_data-kunnr.
   wa_final-telf2 = wa_data-telf2.

endif.

please suggest what to do????

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

you have give GBDAT as today's date then how will u get older records.

Change select to and try it will give u correct records.

select a~gbdat a~parau b~kunnr b~telf2 from knvk as a inner join kna1 as b

      on  a~kunnr = b~kunnr into table it_data where b~kunnr in s_kunnr.

     AND a~gbdat < sy-datum.

8 REPLIES 8

FredericGirod
Active Contributor
0 Kudos

Hi Hemant,

first stop using using "as a", "as b",  kna1~kunnr is more simple to read

and why do you play with day & month ?   just compare wa_date-gldat+4(4) eq sy-datum+4(4)

with that you will compare the date omitting the year

regards

Fred

former_member190103
Participant
0 Kudos

Hi Hemant,

do you have entries in that table corrsponding to that given date/year.

While excuting did you get any error message.

post the total logic.

thanks

sravan

0 Kudos

Hi sravan ,

I do have entries corresponding to the given date.

problem is ..i have maintained current date on selection screen field...and if the customer .

for example..todays date is 22.05.2013 so this will be on selection screen ...and if the date in the master is 22.05.2001 and if execute this without changing the year on selection screen..

it is showing no records..but when i enter the same date of the master on slec screen it is showing th data..

problem is i cant enter manually becoz it will be scheduled in background and if there is a b'day of any customer say on 25 may then sms should go at that day to cust but as of now sms will not go bcoz in master the cust is having b'day on 25.05.2001 .

thanks

hemant

Former Member
0 Kudos

Hi,

you have give GBDAT as today's date then how will u get older records.

Change select to and try it will give u correct records.

select a~gbdat a~parau b~kunnr b~telf2 from knvk as a inner join kna1 as b

      on  a~kunnr = b~kunnr into table it_data where b~kunnr in s_kunnr.

     AND a~gbdat < sy-datum.

Former Member
0 Kudos

Hi

You could set up the following variable:

DATA lv_date_pattern  TYPE string.

CONCATENATE '%'  sy-datum+4(2) sy-datum+6(2) INTO lv_date_pattern.

And then replace the following line in your SELECT:

AND a~gbdat in date.

with:

AND a~gbdat LIKE lv_date_pattern

Your internal table will then only contain the records you want... no need to compare the days or months inside your loop. It will also reduce the amount of data you need to pull back from the database so should hopefully improve performance.

Regards

Glen

0 Kudos

Hi Glen,

I posted same earlier  but is not working so i changed my Query.

0 Kudos

Hi Sai

It works for me. I don't know why it wouldn't for you.

Your code will work too but if s_kunnr is left empty then the SELECT statement will return a record for every contact person in every customer in the system. If you have a large Customer Master then this will result in a lot of unnecessary communication between the database and application servers. I recommend reducing the data returned from the SELECT statement.

Regards

Glen

eyup_aksoy
Explorer
0 Kudos

hi,

if you explain or send you want to get data from tables.

We can tell you mistakes. in appearance, there are logical mistakes, not technical.