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

Reformat for specific values of a field


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

New User


Joined: 12 Jan 2010
Posts: 34
Location: New York

PostPosted: Wed Oct 07, 2015 1:04 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Wed Oct 07, 2015 1:18 pm
Reply with quote

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
View user's profile Send private message
vnktrrd

New User


Joined: 12 Jan 2010
Posts: 34
Location: New York

PostPosted: Wed Oct 07, 2015 1:48 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Wed Oct 07, 2015 2:26 pm
Reply with quote

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
View user's profile Send private message
vnktrrd

New User


Joined: 12 Jan 2010
Posts: 34
Location: New York

PostPosted: Wed Oct 07, 2015 3:20 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Wed Oct 07, 2015 3:43 pm
Reply with quote

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
View user's profile Send private message
vnktrrd

New User


Joined: 12 Jan 2010
Posts: 34
Location: New York

PostPosted: Wed Oct 07, 2015 5:05 pm
Reply with quote

Sorry. That was logic error. I fixed it and its working miracles. Thanks a lot for the help.
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 INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts How to Reformat a file using File Man... All Other Mainframe Topics 14
Search our Forums:

Back to Top