IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Format record to remove Leading zeroes


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Learncoholic

New User


Joined: 20 Sep 2007
Posts: 97
Location: India

PostPosted: Wed Apr 05, 2017 2:43 pm
Reply with quote

Hi,
I have a file with below data:
Code:

     01KG009999 IRRELEVANTTXT
     0000MN1125 IRRELEVANTTXT
     0100032205 IRRELEVANTTXT
     0000032209 IRRE1EAAN11XT
     1100121419 IRRELEVANTTXT
     1100254004 IRR0LEVANMMXT
     1100990214 IRRELEVANTTZZ
     1100991487 IRRELEVANTTXT



The requirement is:
1. Left Justify the first 15 bytes
2. If the first 15 bytes(excluding leading spaces) is Numeric, remove off the leading zeroes
3. If the first 15 bytes(excluding leading spaces) is NOT Numeric, DON'T remove off the leading zeroes

The I/P file is FB file of 80 bytes & O/P is required with similar specifications.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Wed Apr 05, 2017 4:03 pm
Reply with quote

Is this your expected output:
Code:

01KG009999      IRRELEVANTTXT
0000MN1125      IRRELEVANTTXT
100032205       IRRELEVANTTXT
32209           IRRE1EAAN11XT
1100121419      IRRELEVANTTXT
1100254004      IRR0LEVANMMXT
1100990214      IRRELEVANTTZZ
1100991487      IRRELEVANTTXT

?
Back to top
View user's profile Send private message
Learncoholic

New User


Joined: 20 Sep 2007
Posts: 97
Location: India

PostPosted: Wed Apr 05, 2017 8:32 pm
Reply with quote

Yes Nic. You are correct.
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Wed Apr 05, 2017 10:23 pm
Reply with quote

Code:
//SYSIN DD *
 OPTION COPY
 OUTREC IFTHEN=(WHEN=(1,10,FS,EQ,NUM),
        OVERLAY=(1:1,10,ZD,EDIT=(IIIIIIIIII),LENGTH=10,
               1:1,10,SQZ=(SHIFT=LEFT),11:11,14))
/*
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Apr 06, 2017 2:00 am
Reply with quote

Hey Rahul,

You might want to modify this slightly as the OP's first input field has leading spaces and is of length=15, and the 'overlay' still retains the original input data.

Learncoholic,

The number of leading blanks, will that remain the same or it can vary too?
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Thu Apr 06, 2017 4:34 am
Reply with quote

Yes Arun, I just looked at the data and missed the leading spaces.

I hope, the code that I posted, could guide the OP in right direction and he comes up with modified version according to his requirements.

.
Back to top
View user's profile Send private message
Learncoholic

New User


Joined: 20 Sep 2007
Posts: 97
Location: India

PostPosted: Thu Apr 06, 2017 2:43 pm
Reply with quote

Thanks Rahul & Raj.

Rahul:
Unfortunately your changes did not work. The following check is treating every record as Not Numeric due to preceding Blanks:

Code:
WHEN=(1,10,FS,EQ,NUM)


Arun:
Number of leading blanks will vary between the records.
The length of each key is 15 bytes.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Apr 06, 2017 9:01 pm
Reply with quote

You obviously didn't read all the words in all the messages. Nor did you show representative sample data.
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Thu Apr 06, 2017 9:46 pm
Reply with quote

If your input is like this:
Code:
     01KG009999 IRRELEVANTTXT
       00MN1125 IRRELEVANTTXT
     0100032205 IRRELEVANTTXT
      000032209 IRRE1EAAN11XT
     1100121419 IRRELEVANTTXT
     1100254004 IRR0LEVANMMXT
     1100990214 IRRELEVANTTZZ
     1100991487 IRRELEVANTTXT

And you want your output to be like this:
Code:
01KG009999      IRRELEVANTTXT
00MN1125        IRRELEVANTTXT
100032205       IRRELEVANTTXT
32209           IRRE1EAAN11XT
1100121419      IRRELEVANTTXT
1100254004      IRR0LEVANMMXT
1100990214      IRRELEVANTTZZ
1100991487      IRRELEVANTTXT

Then, it is not terribly difficult to change the above mentioned sort card.

You need to replace the leading spaces with zeroes to check if numeric and keep a copy of the original data (do this in Inrec) and use it for overlay edit and sqz.

But, as you have shown no signs of any kind of attempt/effort to achieve what you want, it would Not be worth to give you the code.

.
Back to top
View user's profile Send private message
Learncoholic

New User


Joined: 20 Sep 2007
Posts: 97
Location: India

PostPosted: Fri Apr 07, 2017 12:02 pm
Reply with quote

Rahul,
I tried using the below ICETOOL card:
Code:
//TOOLIN DD *                                                 
  COPY FROM(INDD01) TO(OUTDD01) USING(CNT1)                   
/*                                                           
//CNT1CNTL DD *                                               
  INREC  FINDREP=(IN=C' ',OUT=C'0',STARTPOS=1,ENDPOS=15)     
  OUTREC IFTHEN=(WHEN=(1,15,FS,EQ,NUM),                       
          OVERLAY=(1:1,15,ZD,EDIT=(IIIIIIIIIIIIIII),LENGTH=15,
                 1:1,15,SQZ=(SHIFT=LEFT),16:16,14))           
/*                                                           


The O/P thrown was:
Code:
0000001KG009999 IRRELEVANTTXT
000000000MN1125 IRRELEVANTTXT
100032205       IRRELEVANTTXT
32209           IRRE1EAAN11XT
1100121419      IRRELEVANTTXT
1100254004      IRR0LEVANMMXT
1100990214      IRRELEVANTTZZ
1100991487      IRRELEVANTTXT


The Non Numeric fields are appended with zeroes.
I tried with storing of original data from 100th Bytes in INREC.
However, I guess that OVERLAY/FINDREP/BUILD cannot go togehter with INREC.

I used 2 SORT card to achieve it. It is possible in one?
Back to top
View user's profile Send private message
Learncoholic

New User


Joined: 20 Sep 2007
Posts: 97
Location: India

PostPosted: Fri Apr 07, 2017 2:00 pm
Reply with quote

Rahul,
I managed to get the desired O/P in single SORT card:
Code:
INREC IFTHEN=(WHEN=INIT,                                     
              OVERLAY=(85:1,15)),                             
      IFTHEN=(WHEN=INIT,                                     
              FINDREP=(IN=C' ',OUT=C'0',STARTPOS=1,ENDPOS=15))
OUTREC IFTHEN=(WHEN=(1,15,FS,EQ,NUM),                         
        OVERLAY=(1:85,15,SFF,EDIT=(IIIIIIIIIIIIIII),LENGTH=15,
               1:1,15,SQZ=(SHIFT=LEFT),16:16,64)),           
       IFTHEN=(WHEN=NONE,                                     
        OVERLAY=(1:85,15,SQZ=(SHIFT=LEFT),16:16,64))         


However, the LRECL has been increased to 99 with 1-15 bytes being replicated from 85th byte.

Thanks
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Apr 07, 2017 5:16 pm
Reply with quote

Glad you were able to work it out, based on what Rahul suggested above.

You can combine all the IFTHENs into your INREC OR OUTREC. You don't need both. Use INREC/OUTREC IFOUTLEN=n to get rid of the padded bytes and restrict the record length to 'n' bytes.

Also you don't need the '16:16,64' in your OVERLAYs - OVERLAY retains the value of data positions which are not modified by it.
Back to top
View user's profile Send private message
Learncoholic

New User


Joined: 20 Sep 2007
Posts: 97
Location: India

PostPosted: Fri Apr 07, 2017 6:56 pm
Reply with quote

Arun,
I tried the below SORT card to get the O/P I required:
Code:

INREC IFTHEN=(WHEN=INIT,                                       
         OVERLAY=(85:1,15)),                                   
      IFTHEN=(WHEN=INIT,                                       
         FINDREP=(IN=C' ',OUT=C'0',STARTPOS=1,ENDPOS=15)),     
      IFTHEN=(WHEN=(1,15,FS,EQ,NUM),                           
         OVERLAY=(1:85,15,SFF,EDIT=(IIIIIIIIIIIIIII),LENGTH=15,
                  1:1,15,SQZ=(SHIFT=LEFT),16:16,64)),         
      IFTHEN=(WHEN=NONE,                                       
         OVERLAY=(1:85,15,SQZ=(SHIFT=LEFT),16:16,64)),         
         IFOUTLEN=80                                           


Thanks to Rahul & Arun for all the Help.
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Fri Apr 07, 2017 8:14 pm
Reply with quote

Hey, Good to hear that.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Apr 07, 2017 8:52 pm
Reply with quote

Cool. Like mentioned earlier, you could remove the data positions you don't intend to modify, from your OVERLAYs. No big deal here, but a thing to consider in the future.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 8
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
Search our Forums:

Back to Top