How can I store time values (e.g.: 33h 24m 02s) in a TIME
variable since *HIVAL
- the max value - is 24h 00m 00s.
When storing it in a data structure (DS) sometimes (when a values is less than 10) e.g: 33:24:03 the value is displayed as 33.24.3 since the field is not padding with zeros automatically
Well you have already answered your own question, the limit is 24 hours.
I'm not sure what you are trying to accomplish, but I would suggest you use the %diff() Built-in Function (BIF) to get the difference between the two time/date/timestamp values and store it in an integer. And then to manipulate another time/timestamp field you could use the %seconds() BIF.
For example:
ctl-opt dftactgrp(*no) actgrp(*new);
ctl-opt timfmt(*iso);
dcl-s time1 time inz(t'09.25.00');
dcl-s time2 time inz(t'10.00.00');
dcl-s time3 time;
dcl-s SecondsDiff int(10);
dcl-s result char(1);
SecondsDiff = %diff(time2: time1: *seconds);
time3 = %time() + %seconds(SecondsDiff);
dsply ('In 35 minutes it will be: ' + %char(time3)) '*EXT' result;
*inlr = *on;
This is a very simplistic example, if you could give me more information to what you are trying to accomplish I could give a more specific example.
Here is a sample procedure that will do what you are requesting:
ctl-opt dftactgrp(*no) actgrp(*new);
dcl-s SecondsChar char(20);
dcl-s Result varchar(32);
dcl-s WaitAnyKey char(1);
dsply 'Enter an amount of seconds: ' '*EXT' SecondsChar;
Result = SecondsToDisplay(%int(SecondsChar));
dsply Result '*EXT' WaitAnyKey;
*inlr = *on;
dcl-proc SecondsToDisplay;
dcl-pi *n varchar(32);
Seconds int(10) value;
end-pi;
dcl-s Result varchar(32) inz('');
dcl-s CurrentValue int(10);
Seconds = %abs(Seconds);
//Get the days
CurrentValue = Seconds / 86400;
if (CurrentValue > 0);
Result = %char(CurrentValue) + 'd ';
Seconds = %rem(Seconds: 86400);
endif;
//Get the hours
CurrentValue = Seconds / 3600;
if (CurrentValue > 0 OR Result <> '');
Result += %char(CurrentValue) + 'h ';
Seconds = %rem(Seconds: 3600);
endif;
//Get the minutes
CurrentValue = Seconds / 60;
if (CurrentValue > 0 OR Result <> '');
Result += %char(CurrentValue) + 'm ';
Seconds = %rem(Seconds: 60);
endif;
//The seconds
Result += %char(Seconds) + 's';
return Result;
end-proc;
And some sample output:
DSPLY Enter an amount of seconds: 799240
DSPLY 9d 6h 0m 40s