|
View previous topic :: View next topic
|
| Author |
Message |
Learncoholic
New User
Joined: 20 Sep 2007 Posts: 97 Location: India
|
|
|
|
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 |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
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 |
|
 |
Learncoholic
New User
Joined: 20 Sep 2007 Posts: 97 Location: India
|
|
|
|
| Yes Nic. You are correct. |
|
| Back to top |
|
 |
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
| 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 |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
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 |
|
 |
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
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 |
|
 |
Learncoholic
New User
Joined: 20 Sep 2007 Posts: 97 Location: India
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| You obviously didn't read all the words in all the messages. Nor did you show representative sample data. |
|
| Back to top |
|
 |
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
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 |
|
 |
Learncoholic
New User
Joined: 20 Sep 2007 Posts: 97 Location: India
|
|
|
|
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 |
|
 |
Learncoholic
New User
Joined: 20 Sep 2007 Posts: 97 Location: India
|
|
|
|
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 |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
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 |
|
 |
Learncoholic
New User
Joined: 20 Sep 2007 Posts: 97 Location: India
|
|
|
|
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 |
|
 |
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
| Hey, Good to hear that. |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
| 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 |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|