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: 

Need to display possible dates in dropdown in selection screen when input is date in any format?

newbee01334
Explorer
0 Kudos

I Want to display dropdown list for entered date in selection screen.
the dropdown list should contain possible combination of dates(YYYYMMDD) which are possible.
example: 1123
output in dropdown list:

20230101
20110203
20110302
20120103

20120301

5 REPLIES 5

Sandra_Rossi
Active Contributor

Is your question about the logic or about Dropdown?

Dropdown (in dynpro) is the same whatever it's a date or any other kind of field, and you can find many answers in the Web.

The logic is more complex.

newbee01334
Explorer
0 Kudos

Thanks for the response kumar.
Can You elaborate step 6.

newbee01334
Explorer
0 Kudos

Hi Sandra ,
I need help in the logic part.
thanks

matt
Active Contributor

Descrobe how you expect it to work. That's the logic you need to implement. If you can't describe how you want it to work, we can't help you.

I can see how 1123 could be 1.1.23 (DDMMYYYY) or 11.2.3 (YYYYMMDD) or 11.3.2 (YYYYDDMM) but not how it could become 2012.01.03 or 2012.03.01.

What troubles me more is why would you need this? In over 40 years of using IT applications, I've never seen such a requirement. I think it would be more confusing than helpful.

Sandra_Rossi
Active Contributor

I guess it's an exercise, because by default

PARAMETERS p_date TYPE d.

1123 is invalid. 010123 is valid and is interpreted by SAP according to the user's date format. If the format is DDMMYYYY, 010123 is interpreted as 01012023.

Now, concerning your exercise, here are a few tips.

Based on your example, 1123, you have to find all possibilities what it means.

It's composed of 3 elements of contiguous characters of size 1, 1 and 2. Other orders are possible: 1, 2, 1 or 2, 1, 1.

So, 1123 can represent:

  • 1 - 1 - 23
  • 1 - 12 - 3
  • 11 - 2 - 3

An element of 1 character between 1 and 9 may represent a day, a month or a year.

An element of 1 character which is 0 can represent only a year.

An element of 2 characters between 1 and 12 may represent a day, a month or a year.

An element of 2 characters between 13 and 31 may represent either a month or a year, but not a day.

An element of 2 characters which is 00 or is between 32 and 99 can represent only a year.

For each combination, you must find the possible combinations

  • 1 - 1 - 23 may correspond to DMY - DMY - Y. As Y MUST be in the 3rd group, the last possibility is DM - DM - Y, and you can loop at combinations: D - M - Y and M - D - Y.
  • 1 - 12 - 3 may correspond to DMY - DMY - DMY. You have 6 possibilities: D - M - Y, D - Y - M, M - D - Y, etc.

Note that in your example, you have years 2000 represented, in SAP if a user is typing the dates "010140" to "010199" in DDMMYYYY format, they are interpreted as years 1940 to 1999, while "010100" to "010139" they are interpreted as years 2000 to 2039.

I hope it will help you, good luck!