View previous topic :: View next topic |
Author |
Message |
nbdtrjk_1 Beginner
Joined: 14 Jun 2021 Posts: 11 Topics: 4
|
Posted: Tue Mar 15, 2022 9:35 pm Post subject: Convert Alphanumeric to Numeric Datatype in Ezytrieve |
|
|
Hi All,
How to convert Alphanumeric to Numeric value datatype in Ezytrieve(Something like NUMVAL in COBOL) ?
Code: |
Input(Alphanumeric 5 Bytes):
Merit
Class
1
492
Year
Output(Numeric 5 bytes):
00000
00000
00001
00492
00000 |
Thanks |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Tue Mar 15, 2022 11:03 pm Post subject: |
|
|
nbdtrjk_1,
Try this untested code
Code: |
//STEP0100 EXEC PGM=EZTPA00
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//INFILE DD *
Merit
Class
1
492
Year
//OUTPUT DD SYSOUT=*,
// DCB=(LRECL=80,RECFM=FB,BLKSIZE=0)
//*
//SYSIN DD *
FILE INFILE
INP-AMT 01 05 A
WS-INP-AN W 05 A
WS-INP-BYTE WS-INP-AN 05 A OCCURS 5
WS-INP-SUB W 01 N 0
WS-OUT-AN W 05 A
WS-OUT-NUM WS-OUT-AN 05 N 0
WS-OUT-BYTE WS-OUT-AN 01 A OCCURS 5
WS-OUT-SUB W 01 N 0
FILE OUTPUT FB(0 0)
O-AMT 01 05 N 0
***********************************************************
* MAINLINE *
***********************************************************
JOB INPUT INFILE
WS-INP-AN = INP-AMT
WS-OUT-AN = '00000'
WS-INP-SUB = 5
WS-OUT-SUB = 5
DO UNTIL WS-INP-SUB LT 1
IF WS-INP-BYTE(WS-INP-SUB) NOT NUMERIC
WS-INP-SUB = WS-INP-SUB - 1
ELSE
WS-OUT-BYTE(WS-OUT-SUB) = WS-INP-BYTE(WS-INP-SUB)
WS-INP-SUB = WS-INP-SUB - 1
WS-OUT-SUB = WS-OUT-SUB - 1
END-IF
END-DO
O-AMT = WS-OUT-NUM
PUT OUTPUT
/* |
Alternatively you can use DFSORT to convert it quite easily with just 1 statement.
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
Merit
Class
1
492
Year
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC BUILD=(01,05,UFF,EDIT=(TTTTT))
/* |
_________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
nbdtrjk_1 Beginner
Joined: 14 Jun 2021 Posts: 11 Topics: 4
|
Posted: Wed Mar 16, 2022 1:04 am Post subject: |
|
|
Thanks kolusu. Working fine as expected |
|
Back to top |
|
|
|
|