|
View previous topic :: View next topic
|
| Author |
Message |
vnktrrd
New User
Joined: 12 Jan 2010 Posts: 34 Location: New York
|
|
|
|
Hi,
This is my joinkeys.Output file length is 91.
| Code: |
JOINKEYS FILE=F1,FIELDS=(1,10,A,37,3,A)
JOINKEYS FILE=F2,FIELDS=(5,10,A,32,3,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,49,F2:37,1,F2:39,9,F2:49,15,F2:65,15,F2:81,2)
SORT FIELDS=COPY |
I want to add below requirement to the above. Pls help.
When the keys match I am reformatting the output file. In the file F1 I have a field at position 12 of length 4. For only specific values of this fleld, I want to append the fields from F2 in reformatting otherwise put spaces from 50 till 91.
Code'd |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Include the match-marker (as the last field), a question-mark (?), in the REFORMAT statement.
When that position has a value of "B", you have a match. You can use IFTHEN=(WHEN=(logicalexpression, where your logicalexpression contains AND and OR (if necessary) and squish your fields with OVERLAY=(50:41X) or whatever the exact thing is. use IFOUTLEN=91 to get rid of the match-marker on the output. |
|
| Back to top |
|
 |
vnktrrd
New User
Joined: 12 Jan 2010 Posts: 34 Location: New York
|
|
|
|
Hi,
Just wanted toconfirm if my understanding is correct.
| Code: |
JOINKEYS FILE=F1,FIELDS=(1,10,A,37,3,A)
JOINKEYS FILE=F2,FIELDS=(5,10,A,32,3,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,49,?,F2:37,42)
SORT FIELDS=COPY
OUTFIL IFOUTLEN=91,
IFTHEN=(WHEN=(12,4,CH,EQ,C'A',OR,
12,4,CH,EQ,C'B',),
OVERLAY=(50:42X,C' ')) |
With OVERLAY what I mean is to fill spaces in output file from 50 till 42 whereever F1 has 'A' or 'B' at 12th position. And would also like to know what happens for other values at position 12.
Thanks.
Code'd again |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Please use the Code tags for anything which requires the preservation of spacing.
| Code: |
JOINKEYS FILE=F1,FIELDS=(1,10,A,37,3,A)
JOINKEYS FILE=F2,FIELDS=(5,10,A,32,3,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,49,F2:37,42,?)
SORT FIELDS=COPY
OUTFIL IFOUTLEN=91,
IFTHEN=(WHEN=(12,4,CH,EQ,C'A',OR,
12,4,CH,EQ,C'B',),
OVERLAY=(50:42X)) |
Moving the match-marker to the end of the record allows it to be dropped easily and economically with the IFOUTLEN.
You need to expand your condition to test byte 92 for B if you only want to do this for matches, then AND it with your existing condition.
Anything which doesn't match the IFTHEN will just be the REFORMAT record as-is (excluding the match-marker). |
|
| Back to top |
|
 |
vnktrrd
New User
Joined: 12 Jan 2010 Posts: 34 Location: New York
|
|
|
|
I have used below code and my intention is to overlay with spaces in output file starting at 50th position and lenght of 48 whereever there is no 'A' or 'B' at 12th position in file F1 for all matched records. But its overlaying every record with spaces. Pls help.
| Code: |
JOINKEYS FILE=F1,FIELDS=(1,10,A,37,3,A)
JOINKEYS FILE=F2,FIELDS=(5,10,A,32,3,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,49,F2:36,48,?)
SORT FIELDS=COPY
OUTFIL IFOUTLEN=97,
IFTHEN=(WHEN=((12,4,CH,NE,C'A',OR,
12,4,CH,NE,C'B'),AND,
98,1,CH,EQ,C'B'),
OVERLAY=(50:48X)) |
Thanks.
Code'd, yet again |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
If something doesn't work, check your logic.
Do you really want to test a four-byte field for a one-byte value?
| Code: |
IFTHEN=(WHEN=((12,4,CH,NE,C'A',OR,
12,4,CH,NE,C'B'),AND,
98,1,CH,EQ,C'B'), |
You've coded that in a really tortuous manner, which in addition to possibly the wrong length you've hit every match.
If match-marker equal to "B" AND ( flag equal to "A" or flag equal to "B") is the statement you need. |
|
| Back to top |
|
 |
vnktrrd
New User
Joined: 12 Jan 2010 Posts: 34 Location: New York
|
|
|
|
| Sorry. That was logic error. I fixed it and its working miracles. Thanks a lot for the help. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|