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 

Easytrieve convert alphanumeric to numeric

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


Joined: 22 Sep 2006
Posts: 11
Topics: 5

PostPosted: Mon Dec 18, 2006 2:02 pm    Post subject: Easytrieve convert alphanumeric to numeric Reply with quote

I want to write record for a certain recor length range.

My input is like this.
Code:

MCAAAMWD OUTFILE  DSN=abc.ccc                            RECFM=VB   LRECL=2977 
MCAAAMWD SORTOUT  DSN=abc2.x                             RECFM=FB   LRECL=90   
MCAAAMWD SORTOUT  DSN=xxx                                RECFM=VB   LRECL=2977 
MCAAAMWD OUTRPT   DSN=xxx                                RECFM=FB   LRECL=90   
MCAAAMWD OUTFILE  DSN= .                                 RECFM=FB   LRECL=96   
MCAAAMWD OUTRPT   DSN= .                                 RECFM=FB   LRECL=133   
MCAAHA02 TAPEIRS  DSN= .                                 RECFM=U    LRECL=750   
MCAAHA02 TAPESFTB DSN= .                                 RECFM=U    LRECL=750   


If I define the last four bytes as numeric, EasyTrieve put zeros in the last two of those four bytes. Then I don't get the right results when I select records with the field = 10 thru 800 options. How can I fix this?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Dec 18, 2006 2:49 pm    Post subject: Reply with quote

serobinson,


Here is an example program for formating the alphanumeric values.

Code:

//STEP0100 EXEC PGM=EZTPA00                   
//*                                           
//STEPLIB  DD DSN=EASYTREV.LOADLIB,
//            DISP=SHR                       
//SYSPRINT DD SYSOUT=*                       
//SYSOUT   DD SYSOUT=*                       
//SYSSNAP  DD SYSOUT=*                       
//SYSUDUMP DD SYSOUT=*                       
//INFILE   DD *                               
                                             
1                                             
22                                           
333                                           
4444                                         
55555                                         
666666                                       
7777777                                       
88888888                                     
999999999                                     
//OUTPUT   DD SYSOUT=*,                       
//            LRECL=9                         
**********************************************************************
*  THIS PROGRAM USES THE REFERENCE MODIFICATION IN EASYTRIEVE AND    *
*  PAD  ZEROES TO THE LEFT OF THE FIELD                              *
*                                                                    *
*  THE FOLLOWING IS THE SAMPLE REPRENSTATION OF THE INPUT AND OUTPUT *
*                                                                    *
*     INPUT :                                OUTPUT :                *
*                                            000000000               *
*     1                                      000000001               *
*     22                                     000000022               *
*     333                                    000000333               *
*     4444                                   000004444               *
*     55555                                  000055555               *
*     666666                                 000666666               *
*     7777777                                007777777               *
*     88888888                               088888888               *
*     999999999                              999999999               *
**********************************************************************
  FILE INFILE                                                         
       I-REC          01 01 A OCCURS 9 INDEX IDX                     
                                                                     
  FILE OUTPUT                                                         
       O-REC          01 01 A OCCURS 9 INDEX ODX                     
                                                                     
  S-SPACE-FOUND   W 01 A                                             
  W-PADZERO-LEN   W 02 B 0                                           
  W-STR-LEN       W 02 B 0                                           

***********************************************************************
* MAINLINE                                                            *
***********************************************************************
                                                                       
 JOB INPUT INFILE                                                     
                                                                       
    S-SPACE-FOUND  = 'N'                                               
    IDX            = 1                                                 
    W-PADZERO-LEN  = 0                                                 
    W-STR-LEN      = 0                                                 
                                                                       
    DO UNTIL IDX > 10 OR S-SPACE-FOUND = 'Y'                           
       IF I-REC(IDX)  = ' '                                           
                                                                       
          S-SPACE-FOUND  = 'Y'                                         
          W-PADZERO-LEN  = (9 - IDX) + 1                               
          ODX            = (9 - IDX) + 2                               
          W-STR-LEN      = IDX - 1                                     
                                                                       
          CASE IDX                                                     
               WHEN 1                                                 
                    MOVE '000000000' TO  O-REC(1)  W-PADZERO-LEN       
               WHEN 2                                                 
                    MOVE '00000000'  TO  O-REC(1)  W-PADZERO-LEN       
               WHEN 3                                                 
                    MOVE '0000000'   TO  O-REC(1)  W-PADZERO-LEN       
               WHEN 4                                                 
                    MOVE '000000'    TO  O-REC(1)  W-PADZERO-LEN       
               WHEN 5                                                 
                    MOVE '00000'     TO  O-REC(1)  W-PADZERO-LEN       
               WHEN 6                                                 
                    MOVE '0000'      TO  O-REC(1)  W-PADZERO-LEN       
               WHEN 7                                                 
                    MOVE '000'       TO  O-REC(1)  W-PADZERO-LEN       
               WHEN 8                                                 
                    MOVE '00'        TO  O-REC(1)  W-PADZERO-LEN       
               WHEN 9                                                 
                    MOVE '0'         TO  O-REC(1)  W-PADZERO-LEN       
          END-CASE                                                     
          MOVE I-REC(1) IDX  TO O-REC(ODX) W-STR-LEN   
       END-IF                                           
       IDX = IDX + 1                                   
    END-DO                                             
    PUT OUTPUT                                         
                                                       
/*                                                     


Alternatively if you have DFSORT in your shop you can use UFF format and reformat the left justified numeric field.

ex:

Code:

//STEP0100 EXEC PGM=SORT                       
//SYSOUT   DD SYSOUT=*                         
//SORTIN   DD *                                 
                                               
1                                               
22                                             
333                                             
4444                                           
55555                                           
666666                                         
7777777                                         
88888888                                       
999999999                                       
//SORTOUT  DD SYSOUT=*                         
//SYSIN    DD *                                 
  SORT FIELDS=COPY                               
  OUTREC OVERLAY=(01,09,UFF,EDIT=(TTTTTTTTT))   
/*


Hope this helps...

Cheers

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


Joined: 22 Sep 2006
Posts: 11
Topics: 5

PostPosted: Mon Dec 18, 2006 2:57 pm    Post subject: Reply with quote

The sort solution looks easier. Can syncsort do that ?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Dec 18, 2006 3:02 pm    Post subject: Reply with quote

Quote:

The sort solution looks easier. Can syncsort do that ?


Well it depends on the version of syncsort you got. Try running the above sort code as is and see if it runs successfully. If your job abends with an asterick underneath UFF then you don't have the latest version of syncsort.

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


Joined: 22 Sep 2006
Posts: 11
Topics: 5

PostPosted: Mon Dec 18, 2006 3:49 pm    Post subject: Reply with quote

No dice. The easytrieve program works. brilliant!!!
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