MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Convert Alphanumeric to Numeric Datatype in Ezytrieve

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
nbdtrjk_1
Beginner


Joined: 14 Jun 2021
Posts: 11
Topics: 4

PostPosted: Tue Mar 15, 2022 9:35 pm    Post subject: Convert Alphanumeric to Numeric Datatype in Ezytrieve Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12354
Topics: 75
Location: San Jose

PostPosted: Tue Mar 15, 2022 11:03 pm    Post subject: Reply with quote

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 - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nbdtrjk_1
Beginner


Joined: 14 Jun 2021
Posts: 11
Topics: 4

PostPosted: Wed Mar 16, 2022 1:04 am    Post subject: Reply with quote

Thanks kolusu. Working fine as expected
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group