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

ABAP and dates

Former Member
0 Likes
691

Hi there,

I was wondering if there was a way to check whether an inputted parameter was YYYYMM and not YYYYMMDD.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
668

Hi,

You can check like this also

At Selection-screen.

w_len = strlen( p_date ).

if w_len eq 6 and p_date+4(2) gt 12.

message 'Date format is wrong enter only YYYYMM'.

elseif w_len ne 6 .

message 'Date format is wrong enter only YYYYMM'.

endif.

Regards,

Rajitha.

6 REPLIES 6
Read only

Former Member
0 Likes
668

You can check the string length of that parameter.

e.g. Use STRLN(P_DATE)

Read only

bpawanchand
Active Contributor
0 Likes
668

Hi

Check out this Code Hope it gives you an idea

DATA :

w_dat1 TYPE sy-datum,

w_dat2 TYPE d VALUE '20080530'.

w_dat1 = sy-datum.

IF w_dat1(6) EQ w_dat2(6).

WRITE :

/ 'Both dates are same'.

ELSEIF w_dat1(6) NE w_dat2(6).

WRITE :

/ 'Both are Ne'.

ENDIF.

Regards

Pavan

Read only

Former Member
0 Likes
668

hi,

There is no such way i m afraid.

But you can validate that thing in ur code.

Create a parameter of 6 characters length not an 8 char long.

Then usin offset select the year and month part and validate the date accordingly.

Hope this will help.

Reward points if helpful.

Regards

Sumit Agarwal

Read only

Former Member
0 Likes
669

Hi,

You can check like this also

At Selection-screen.

w_len = strlen( p_date ).

if w_len eq 6 and p_date+4(2) gt 12.

message 'Date format is wrong enter only YYYYMM'.

elseif w_len ne 6 .

message 'Date format is wrong enter only YYYYMM'.

endif.

Regards,

Rajitha.

Read only

Former Member
0 Likes
668

Thanks guys,

I'll try Raji's idea. points awarded

Read only

Former Member
0 Likes
668

\[removed by moderator as it was just a copy and paste answer of someone else's work without giving a source \]

Edited by: Jan Stallkamp on Jun 30, 2008 2:56 PM

Edited by: Jan Stallkamp on Jun 30, 2008 2:59 PM