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: 

Check a range of values in the pai section of a dynpro

Former Member
0 Kudos

Hi,

I have a week timetable, and for each day the user has to introduce a range of hours. I need to control that the hours the user introduces is in a correct format (hh:mm).

I've seen that it's possible to set the valid range of values of an element using a field section on the dynpro's PAI (Input checks in the flow logic). Something like this:

chain

field: field1, field2, ...

values between 00:00 to 23:59

endchain

But I don't know how can I use this to set a range of values in the time format.

Is it possible?

thanks in advance

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Instead of doing through chain endchain..you can just intoduce a module in PAI , say Module Time_format.

now in this module you can chack/change the time format as per your requirements.

or if you want something else..please clarify.

7 REPLIES 7

Former Member
0 Kudos

Instead of doing through chain endchain..you can just intoduce a module in PAI , say Module Time_format.

now in this module you can chack/change the time format as per your requirements.

or if you want something else..please clarify.

0 Kudos

But what happens if the user inserts for example 24:65?, In this case I need to show an error saying that it isn't a valid time.

0 Kudos

Hi,

use field type sy-uzeit and you need no own check

Andreas

0 Kudos

Hi Javier,

Inside the module, you can write a logic to raise an error if the entered time is not within a range.

in the pai setion, write the statement.

module time_validate.

double click on the module name and create a module in a module pool program.

In that module, you can write a logic which check for the validity of the time entered by the user.

Eg:

module time_validate.

  • Write your logic.

endmodule.

Regards,

Ravi

0 Kudos

see you can create a module like the coding done inside of the form validate_time this.you can run this code to see if it solves your problem.

Report ZANID_TEST2 Message-ID ZM.

parameters: p_time(5).

start-of-selection.

perform validate_time.

&----


*& Form validate_time

&----


form validate_time.

data: d_hours(2),

d_minutes(2).

data: hours type i,

minutes type i.

split p_time at ':' into d_hours d_minutes.

hours = d_hours.

minutes = d_minutes.

if hours > 24 or hours < 0.

message e307 with 'Invalid Hour'.

endif.

if minutes > 60 or minutes < 0.

message e307 with 'Invalid Minutes'.

endif.

endform. " validate_time

0 Kudos

yes,

solution provide by Andreas Mann is the best & simple i think.

you can declare those time variable of your program " ..like sy-uzeit".

activate the program-> goto screen layout-> instead of drawing input field, you import the variable into screen from progarm.

you will automatically get the time format validation.

Message was edited by: Anid

Former Member
0 Kudos

OK, the problem was solved with the idea of Andreas, thanks to everybody

javi