View previous topic :: View next topic
|
Author |
Message |
Nitin Bhargava
New User
Joined: 22 May 2012 Posts: 32 Location: india
|
|
|
|
Hi All,
Whether it is possible to do the following using sort or Icetool?
I am having a record which looks like
Code: |
Line 1 Line2 Line3 Line4 City
ABCDE FGHI KLM EFGHT ARGENTINA
ABC DI EFGH NEW YORK |
The copybook of this record is
ADDRESS LINE 1: PIC X(30)
ADDRESS LINE 2: PIC X(30)
ADDRESS LINE 3: PIC X(30)
ADDRESS LINE 4: PIC X(30)
CITY : PIC X(15)
I have to join the record and move it into a file having LRECL as 50 and its a FB. The condition is to select only the fields which are populated and ignore rest of the bytes (whenever there are two continuous spaces ignore rest of the bytes).
The output I am expecting will look like:
Code: |
ABCDE FGHI KLM EFGHT ARGENTINA
ABC DI EFGH NEWYORK |
|
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
Hello,
For the input field ABC DI output is ABC DI
But for input field NEW YORK output is NEWYORK
Is this correct input/output data, do you want blank suppressed for the country field alone? |
|
Back to top |
|
|
xknight
Active User
Joined: 22 Jan 2008 Posts: 117 Location: Liberty city
|
|
|
|
Hello,
Assuming the city field does not need to be suppressed.
Try the below snippet,
Code: |
//DOIT EXEC PGM=SORT
//SORTIN DD *
ABCDE FGHI KLM EFGHT ARGENTINA
ABC DI EFGH NEWYORK
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC BUILD=(1,80,SQZ=(SHIFT=LEFT,MID=C' '))
/* |
|
|
Back to top |
|
|
knickraj Warnings : 1 New User
Joined: 11 Jun 2007 Posts: 50 Location: Euro
|
|
|
|
you may try this
Code: |
BUILD=(1,50,SQZ=(SHIFT=LEFT,PAIR=QUOTE,MID=C' '))) |
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
OK, guys, helpful. City is shown as shifted, PAIR=QUOTE is not needed (no quotes in example data).
What about the output size of 50 and the fact that the data, including blanks, occupies 135 bytes. How much of that will BUILD with 1,50 or 1,80 get?
So, you need all the data, and an output length of 50.
Nitin Bhargava,
You realise it will be quite easy to loose data going to a length of 50? Is the name the most significant item for you, or the city? |
|
Back to top |
|
|
knickraj Warnings : 1 New User
Joined: 11 Jun 2007 Posts: 50 Location: Euro
|
|
|
|
Apologies for a wrong post |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
No problem. TS has wondered off anyway, it seems.
Code: |
OPTION COPY
INREC BUILD=(1,135,SQZ=(SHIFT=LEFT,MID=C' '))
OUTREC BUILD=(1,50)
|
Code: |
OPTION COPY
INREC BUILD=(1,135,SQZ=(SHIFT=LEFT,MID=C' '))
OUTREC IFOUTLEN=50,
IFTHEN=(WHEN=(51,85,CH,NE,C' '),OVERLAY=(50:C'?')) |
Code: |
OPTION COPY
INREC IFOUTLEN=50,
IFTHEN=(WHEN=INIT,BUILD=(1,135,SQZ=(SHIFT=LEFT,MID=C' '))),
IFTHEN=(WHEN=(51,85,CH,NE,C' '),OVERLAY=(50:C'?'))
|
Not asked for, but I thought I'd do a flag for the truncation. Since one character is already lost, at least, I'm thinking the 50th can be utilised for this :-) |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Bill,
I guess you forgot that SQZ has LENGTH parm which can be used to set the length.
Code: |
INREC BUILD=(1,135,SQZ=(SHIFT=LEFT,MID=C' ',LENGTH=50)) |
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Ahh... I just can't leave the "quart into a pint pot" alone. My full name is 27 characters. My "city" is nine. How the postie finds the place is 17. "Zip" is 8 plus a space. That leaves off the actual city, and the region (another 12). Then there is the road name, which I never use anyway. If I "chop" it early, I can't do the comparison :-)
I agree, Kolusu, your way is the best way to truncate the data, as the TS/OP wanted :-) |
|
Back to top |
|
|
Nitin Bhargava
New User
Joined: 22 May 2012 Posts: 32 Location: india
|
|
|
|
Thanks bill, Kolusu.
Bill,
The name, zip and region is having a diffrent variable in my copybook. I have to join only this 5 fields to make a complete address. But anyway i will check it once with my production files whether anything is getting truncated.
Thanks again for all.
Regards |
|
Back to top |
|
|
xknight
Active User
Joined: 22 Jan 2008 Posts: 117 Location: Liberty city
|
|
|
|
Quote: |
What about the output size of 50 |
Thank you bill for pointing it out. |
|
Back to top |
|
|
|