Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Format record to remove Leading zeroes

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Learncoholic

New User


Joined: 20 Sep 2007
Posts: 88
Location: India

PostPosted: Wed Apr 05, 2017 2:43 pm    Post subject: Format record to remove Leading zeroes
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: 1922
Location: UK

PostPosted: Wed Apr 05, 2017 4:03 pm    Post subject:
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: 88
Location: India

PostPosted: Wed Apr 05, 2017 8:32 pm    Post subject:
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: 408
Location: USA

PostPosted: Wed Apr 05, 2017 10:23 pm    Post subject: Reply to: Format record to remove Leading zeroes
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: 2285
Location: @my desk

PostPosted: Thu Apr 06, 2017 2:00 am    Post subject:
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: 408
Location: USA

PostPosted: Thu Apr 06, 2017 4:34 am    Post subject: Reply to: Format record to remove Leading zeroes
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: 88
Location: India

PostPosted: Thu Apr 06, 2017 2:43 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Thu Apr 06, 2017 9:01 pm    Post subject: Reply to: Format record to remove Leading zeroes
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: 408
Location: USA

PostPosted: Thu Apr 06, 2017 9:46 pm    Post subject: Reply to: Format record to remove Leading zeroes
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: 88
Location: India

PostPosted: Fri Apr 07, 2017 12:02 pm    Post subject:
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: 88
Location: India

PostPosted: Fri Apr 07, 2017 2:00 pm    Post subject:
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: 2285
Location: @my desk

PostPosted: Fri Apr 07, 2017 5:16 pm    Post subject:
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: 88
Location: India

PostPosted: Fri Apr 07, 2017 6:56 pm    Post subject:
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: 408
Location: USA

PostPosted: Fri Apr 07, 2017 8:14 pm    Post subject: Reply to: Format record to remove Leading zeroes
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: 2285
Location: @my desk

PostPosted: Fri Apr 07, 2017 8:52 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Extract Record using range of Data scorp_rahul23 DFSORT/ICETOOL 3 Wed Nov 15, 2017 11:54 pm
No new posts Squeeze record left so that zeroes ar... Vignesh Sid SYNCSORT 5 Fri Nov 10, 2017 1:40 pm
No new posts Formatting multiple records to a sing... Vignesh Sid SYNCSORT 3 Tue Nov 07, 2017 12:22 pm
No new posts Format Last Record differently from r... Learncoholic DFSORT/ICETOOL 5 Tue Oct 24, 2017 12:01 pm
No new posts Format issues using XMITIP MSGDD ssdjp1 CLIST & REXX 5 Mon Oct 23, 2017 8:47 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us