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 CSL format data to zoned decimal

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


Joined: 17 Dec 2002
Posts: 17
Topics: 2
Location: NJ, USA

PostPosted: Mon Apr 06, 2020 4:49 pm    Post subject: Convert CSL format data to zoned decimal Reply with quote

We had a need to convert the values in a field from CSL (character with a leading sign) format to zoned decimal. I checked the SORT manual but I didn't see an example there on how to do this. I coded an ICETOOL step that did the conversion using 2 passes thru the data.

For the future, is anyone aware of a way to perform the conversion in 1 pass thru the data?

The record length is 278 bytes. The field in question appears in bytes 142-152. This is how the input data looks:

Code:

4----+----5---
  -0000024.00
  +0000006.00
  +0000016.00


The sign appears in byte 142, the numeric value appears in bytes 143-152.

Pass 1 removed the decimal point at byte 150 by moving the data from bytes 143-149 to bytes 144-150 and placing a zero in byte 143.
Pass 2 tested the sign in byte 142. If the sign is +, it multiplied the value in bytes 143-152 by +1 and placed the result in zoned decimal format in bytes 143-152. If the sign is -, it multiplied the value in bytes 143-152 by -1 and placed the result in zoned decimal format in bytes 143-152.

This is how the data looks after the conversion:

Code:
4----+----5---
  -000000240}
  +000000060{
  +000000160{


I left the sign in byte 142 for Q/A purposes.

Here is ICETOOL step:

Code:

//STEP01 EXEC PGM=ICETOOL             
//SORTIN   DD DSN=INPUT.FILE,                   
//            DISP=SHR                           
//TEMP     DD UNIT=SYSDA,SPACE=(CYL,(200,200)),
//            DCB=(RECFM=FB,LRECL=278,BLKSIZE=0)
//SORTOUT  DD DSN=OUTPUT.FILE,                   
//            DISP=(NEW,CATLG,DELETE),           
//            UNIT=SYSDA,SPACE=(CYL,(200,200),RLSE),
//            DCB=(RECFM=FB,LRECL=278,BLKSIZE=0)
//TOOLIN   DD *                                 
  SORT FROM(SORTIN) TO(TEMP) USING(SRT1)         
  SORT FROM(TEMP) TO(SORTOUT) USING(SRT2)       
/*                                               
 //SRT1CNTL DD *                             
   SORT FIELDS=COPY                         
   OUTFIL OUTREC=(001:001,142,               
                  143:C'0',                 
                  144:143,07,               
                  151:151,02,               
                  153:153,126)               
 /*                                         
//SRT2CNTL DD *                                           
  SORT FIELDS=COPY                                         
  OUTFIL FNAMES=SORTOUT,                                   
    IFTHEN=(WHEN=(142,001,CH,EQ,C'+'),                     
           BUILD=(001:001,142,                             
                  143:143,10,ZD,MUL,+1,TO=ZD,LENGTH=10,   
                  153:153,126)),                           
    IFTHEN=(WHEN=(142,001,CH,EQ,C'-'),                     
           BUILD=(001:001,142,                             
                  143:143,10,ZD,MUL,-1,TO=ZD,LENGTH=10,   
                  153:153,126))                           
/*                                                         
//TOOLMSG  DD SYSOUT=H                                     
//DFSMSG   DD SYSOUT=H                                     
//SYSOUT   DD SYSOUT=H                                     
//SYSUDUMP DD SYSOUT=H
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Apr 06, 2020 6:10 pm    Post subject: Reply with quote

Spolacek,

It is quite simple and you don't even need 2 passes of data. All you need is use SFF format to convert it to ZD. Try this. I replaced the 142 byte also. I also removed the DCB parm in the JCL as DFSORT will automatically calculate it based on the INPUT/Control cards.
Code:

//STEP0100 EXEC PGM=SORT           
//SYSOUT   DD SYSOUT=*       
//SORTDIAG DD DUMMY     
//SORTIN   DD DISP=SHR,DSN=Your Input 278 byte file
//SORTOUT  DD DSN=OUTPUT.FILE,                   
//            DISP=(NEW,CATLG,DELETE),           
//            UNIT=SYSDA,SPACE=(CYL,(200,200),RLSE)
//SYSIN    DD *                                 
  OPTION COPY                                   
  INREC OVERLAY=(142:142,11,SFF,ZD,LENGTH=11)   
/*


The Output at position 142 will be as follows for the sample input data provided

Code:

0000000240}
00000000600
00000001600


If you really want to test you can just build the input field and get the target field using the following control cards
Code:

//SYSIN    DD *                                         
  OPTION COPY                                           
  INREC BUILD=(142,11,                   $ CSL FIELD   
               X,                        $ SPACE       
               142,11,SFF,ZD,LENGTH=11)  $ ZD FIELD     
/*     


PS: With ICETOOL SYSIN, SORTCNTL, SORTIN, SORTOUT, SORTINnn, and xxxxINnn (where xxxx is specified in a USING operand) should not be used as ddnames in ICETOOL operators nor supplied as DD statements.

This is documented in the restrictions for ICETOOL


https://www.ibm.com/support/knowledgecenter/SSLTBW_2.4.0/com.ibm.zos.v2r4.icea100/restr.htm
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Spolacek
Beginner


Joined: 17 Dec 2002
Posts: 17
Topics: 2
Location: NJ, USA

PostPosted: Tue Apr 07, 2020 8:33 am    Post subject: Reply with quote

Hello Kolusu

Your SORT job worked like a charm. Thanks for the quick response.

Also, thanks for the information about ICETOOL ddnames.
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 -> Utilities 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