Hi Gary,
That was interesting especially tha part about SPECIAL files. Do they
still use the SPECIAL files? Thanks a ton for the details
Thanks,
Prakash
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Gary Bowers
Sent: March 17, 2008 9:55 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: RE: Numeric to character conversion in RPGIII
RPGIII. numeric conversion to character with zero-suppression.
Well, FIRST. RPGIII DID support external calls. SO, you could call a
nice program to handle the task. (that program could be ANYTHING that
DOES support the native,easy approach that had been suggested.) Nice,
simple, clean, clear.. but does not adhere to RPGIII throughout.
But SECOND, if they are BENT on not bending the RPGIII requirement, and
the code absolutely positively HAS to be RPGIII, you can use something
like this..
---
Make a 1 record, non-keyed disk workfile in QTEMP, and reference it in
your program as an internally described file, say 80 bytes. enough to
handle any editing you'd like.
It involved writing to a (direct) update disk workfile . always record#
1.
This was done with an EXCPT/update output operation. The numeric field
had it's edit code/word applied. 'Z' for zero-suppression, 'Y' for date,
fancy editwords for telephone number or social-security-number, etc.
Nice thing is that it includes decimals, commas, negative signs -
depending on which edit work you use. For instance:
F WORKFILE UF F 80 DISK
C EXCPT BALFMT
.
OWORKFILE E BALFMT
O BALAMT Z
Then they would turn around and read (CHAIN to record#1) from the file.
and move the input buffer (which held the edited bytes put out by the
previous EXCPT). Ta Daaa. The 'edited' field is moved into a character
field.
C 1 CHAIN WORKFILE
C MOVEL WRKBUF BALCHR
Now, if you don't like that there is a slow disk workfile needed, you
can use the SPECIAL file (another seldom used but valid RPGIII syntax).
Change
the CHAIN to a READ, and you are done. Your little SPECIAL
file-handling
program can also be RPGIII syntax. It does basically NOTHING. Just
allows the same buffer that was previously written to be used for input
on the READ. No disk activity needed, and it improves by a factor of
1000-10000.
Fast, but still ugly ;)
F WORKFILE UF F 80 SPECIAL
I'm sure these clever folks know some RPGIII syntax way of doing it.
But, just thought you'd get a kick out of it.
Another technique was to call a CL program, passing in a number to
zero-suppress. Then running a RTVMSGD with a specially-defined message
to get back the zero-suppressed result. Calls an external program, but
everything is still 100% Old/S38 syntax.
I am SOOO embarrassed I remembered these ;)
--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing
list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.