× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



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.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.