Patrik,
Consider using sysval QDATETIME. Then, just pull out the substring. Two lines of code.
Format: YYYYMMDDHHNNSSXXXXXX
Roger Harman
COMMON Certified Application Developer - ILE RPG on IBM i on Power
-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Patrik Schindler
Sent: Tuesday, August 8, 2023 1:30 AM
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: CL: Numeric padding
Hello,
I want my Save 21 tapes are meant to have a label YYMMDD applied without much manual information. I began to write a CL program like this:
DCL VAR(&TAPDRV) TYPE(*CHAR) LEN(5) VALUE(TAP01)
DCL VAR(&SYSYR) TYPE(*CHAR) LEN(2)
DCL VAR(&SYSMON) TYPE(*CHAR) LEN(2)
DCL VAR(&SYSDAY) TYPE(*CHAR) LEN(2)
DCL VAR(&TAPLBL) TYPE(*CHAR) LEN(6)
RTVSYSVAL SYSVAL(QYEAR) RTNVAR(&SYSYR)
RTVSYSVAL SYSVAL(QMONTH) RTNVAR(&SYSMON)
RTVSYSVAL SYSVAL(QDAY) RTNVAR(&SYSDAY)
CHGVAR VAR(&TAPLBL) VALUE(&SYSYR *CAT &SYSMON *CAT &SYSDAY)
Unfortunately, the system values aren't padded with 0's when single-digit which creates ambiguity.
I could hard code 18 lines of "if day equals 1 then change variable to be 01", and so on. This seems to be pretty ugly. How would you solve this in CL(LE)?
Thanks!
:wq! PoC
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit:
https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at
https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.
As an Amazon Associate we earn from qualifying purchases.