‎2019 Jan 31 9:47 AM
Hello Experts,
I get an i_date with the following value from the table
ex: i_date = 'MM/DD/YYYY'. note: it can be changed by the user.
And o_date = '01/01/2019'.
How to find the patterns are matched or not.
I tried the below code, but I didn' t get my output.
TABLES: map_rul.
data: i_date type string,
o_date type string.
o_date = '01/01/2019'.
select SINGLE low from map_rul into i_date where context = 'LOAD' and code = 'FORMAT'.
write:/ 'Table date format:',i_date.
* Note: i_date value is 'MM/DD/YYYY'.
if o_date cp i_date.
WRITE: / 'Pattern matched'.
else.
write: / 'no pattern matched'.
ENDIF.
My code valuates the pattern and its value.
i just want to compare the pattern not a value.
any suggestions please...?
Thanks in advance
‎2019 Jan 31 10:21 AM
Have you read the ABAP help on CP? Does it anywhere say that you can use MM/DD/YY as a pattern? No - it doesn't. Always read the abap help if you don't know what a keyword does - don't guess and hope. You'll save time.
You could use the matches function with a suitable regex. Probably if you search on the net for a date matching regex, you'll find it.
‎2019 Jan 31 1:07 PM
‎2019 Jan 31 5:22 PM
To add to Matt's and Richard's mentions of regex (regular expression): check out program DEMO_REGEX_TOY in SE38 and play with the options. It comes with the documentation for what all - a lot! - is possible with regex. You can then use the demo-program and play with what you'd like to check.
‎2019 Jan 31 8:50 PM
You can refer code in FM DATE_CHECK_PLAUSIBILITY and write your own logic for checking date formats.
‎2019 Feb 01 12:49 AM
‎2019 Feb 01 11:06 AM
i think Irrespective of comparing you can get your desired pattern by using certain function modules so , when user enters in any format the code in your prog can convert into desired format so comparison may not required.
For format conversion there are lot of FM available u can check on google or go on this thread
‎2019 Feb 06 12:51 PM