Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Reformat for specific values of a field

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

New User


Joined: 12 Jan 2010
Posts: 22
Location: india

PostPosted: Wed Oct 07, 2015 1:04 pm    Post subject: Reformat for specific values of a field
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed Oct 07, 2015 1:18 pm    Post subject: Reply to: Reformat for specific values of a field
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: 22
Location: india

PostPosted: Wed Oct 07, 2015 1:48 pm    Post subject: Reply to: Reformat for specific values of a field
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed Oct 07, 2015 2:26 pm    Post subject: Reply to: Reformat for specific values of a field
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: 22
Location: india

PostPosted: Wed Oct 07, 2015 3:20 pm    Post subject: Reply to: Reformat for specific values of a field
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed Oct 07, 2015 3:43 pm    Post subject: Reply to: Reformat for specific values of a field
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: 22
Location: india

PostPosted: Wed Oct 07, 2015 5:05 pm    Post subject: Reply to: Reformat for specific values of a field
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    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 Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts Overlaying one set of charater values... Kevin Lindsley SYNCSORT 7 Sat Nov 05, 2016 3:21 am
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us