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
 

 

Copying matched record

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

New User


Joined: 22 Feb 2010
Posts: 52
Location: Cochin

PostPosted: Thu Jun 16, 2011 5:41 pm    Post subject: Copying matched record
Reply with quote

I have the following requirement. Can any one please help me out.

Code:
File 1: (Type VB, Length 100)
----+----1----+----2
GRP3     RAM
GRP1     GOPAL
GRP3     SAM
GRP4     RAHUL

File 2: (Type FB, Length 50)
----+----1----+----2
XXXXXX1  GRP7
XXXXXX2  GRP3   
XXXXXX3  GRP8   


Expected Output:
----+----1----+----2
GRP3     RAM
GRP3     SAM


I need to copy all records from File 1 (Based on group, Field pos - 1,4) if a matching record for that group is found in File 2 (Field pos - 10,14) to an output file having the content and layout same as File 1.

File 1 may contain duplicate records (based on the matched field pos 1-4)
File 2 contain unique records (based on the matched field pos 10-14).
Back to top
View user's profile Send private message

sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Thu Jun 16, 2011 6:57 pm    Post subject:
Reply with quote

seahawk789,
Quote:
I need to copy all records from File 1 (Based on group, Field pos - 1,4)
Since input is VB,this would be position 5,4.

See if below works...
Code:
//STEP0001 EXEC PGM=SORT                 
//SYSOUT   DD  SYSOUT=*                 
//SORTJNF1 DD DISP=SHR,DSN=FILE1.VB100   
//SORTJNF2 DD DISP=SHR,DSN=FILE2.FB050   
//SORTOUT  DD  DSN=OUTPUT.FILE.VB100,   
//             DISP=(,CATLG,DELETE),     
//             UNIT=SYSDA               
//SYSIN    DD  *                         
  JOINKEYS FILES=F1,FIELDS=(05,4,A)     
  JOINKEYS FILES=F2,FIELDS=(10,4,A)     
  REFORMAT FIELDS=(F1:1,4,5)             
  SORT FIELDS=COPY                       
/*                                       

OUTPUT
Code:
GRP3     RAM
GRP3     SAM
Thanks,
Back to top
View user's profile Send private message
seahawk789

New User


Joined: 22 Feb 2010
Posts: 52
Location: Cochin

PostPosted: Thu Jun 16, 2011 8:14 pm    Post subject:
Reply with quote

Thanks.. Can u pls help me understand what is the significance of
Code:
REFORMAT FIELDS=(F1:1,4,5)
option?
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Thu Jun 16, 2011 8:57 pm    Post subject:
Reply with quote

seahawk789,
Since you wanted your output in the format of FILE1 (VB), reformat statement here creates variable length joined record which in this case is a Variable length record from FILE1.

Read about REFORMAT Statement here

Its not an option.

Thanks,
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Thu Jun 16, 2011 9:00 pm    Post subject:
Reply with quote

Looking at the other cards, F1 looks like the first file. 1,4 is the Record Descriptor Word for the file (first half-word contains record-length) and 5 is the start position of your data, with no "length" provided defaulst to the length of the current record.

So, hopefully, your output record is a complete copy of the record from your F1 input.

You have to, explicitly, or implicitly, include the RDW for building a variable length record, although the sort will control the value of the record-length itself. Since it is nothing to do with your data, to my mind it is much clearer sqlcode's way (1,4,5) than (1), which you might be able to get away with, or (1,20,21) (or whatever, "merging" the RDW with some real data).

However, you can check in the manual as well, link at the top of the page.

If you want to make it clearer to help you rememember, maybe look at SYMNAMES.

(F1:FILE-RDW,FIRST-BYTE-OF-DATA-TO-END-OF-RECORD)

as long as the two names are define correctly in SYMNAMES.

Never done this, but I hope it is somewhere close :-)
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Jun 16, 2011 11:29 pm    Post subject:
Reply with quote

(F1:1,4,5) would be the correct way to include the entire F1 record in its original form.

(F1:1) is not valid syntax. (F1:1,20,21) will change the RDW length for records shorter than 20 bytes.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Fri Jun 17, 2011 5:10 am    Post subject:
Reply with quote

On a poorly-chosen example, because it has only one data field, I was trying to highlight that it is better to seperate the RDW from any data definition.

Chapter 3. Using DFSORT Program Control Statements, INREC Control Statement wrote:


For variable-length records, the first item in the BUILD or FIELDS parameter
must specify or include the unedited 4-byte record descriptor word (RDW),
that is, you must start with 1,m with m equal to or greater than 4. If you want
to include the bytes from a specific position to the end of each input record at
the end of each reformatted output record, you can specify that starting
position (p) as the last item in the BUILD or FIELDS parameter


As a better example (well, better is the wrong word, because the one I chose does not work)

Code:
(F1:1,4,5,20,30) is better, from the point of view of ease of understanding, than
(F1:1,24,30)


To me, even better is with the SYMNAMES. The "Tricks" gives a method to generate SYMNAMES from a Cobol record layout, and SYMNAMES are far from difficult to code by hand either.

The example following the paragraph I quote above is worth looking at to see another way, to me, of making the code look better. Unfortunately I had great problems trying to get it into the Code Tags, so look it up yourselves, please.

Modeled on that example

Code:
INREC FIELDS=(UNEDITED-SORTIN-RDW,
              RDW-TO-DISPLAY-IN-DECIMAL,TO=ZD,LENGTH=5,
              DATA-SEPERATOR,
              ENTIRE-VARIABLE-INPUT-RECORD)


Where the SYMNAMES are defined as

Code:
UNEDITED-SORTIN-RDW,1,4
RDW-TO-DISPLAY-IN-DECIMAL,1,2,BI
DATA-SEPERATOR,Cā€™|ā€™
ENTIRE-VARIABLE-INPUT-RECORD,5


Now, how to get the TSOPs to code this sort of stuff from the examples given to them. Perhaps withold the most vital statement until the rest is "smartened up"?

OK, so won't work. But it would make theirs, and their colleagues', and their operators' lives so much easier. 3am phone call. "Dave, can you read me the first line in the SYSIN member?", "Yes, there's lots of numbers and commas"..... "Can you change that to "20,5" and try the job again?"... "What do you mean, it failed? Read the line to me. Where's the first bracket? Yes, I mean the bendy-thing. You typed over it?....."
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Jun 17, 2011 10:50 pm    Post subject:
Reply with quote

Quote:
(F1:1,4,5,20,30) is better, from the point of view of ease of understanding, than
(F1:1,24,30)


Oh, now I understand the point you were trying to make. I agree that for ease of human understanding, it's better to treat the RDW as a separate field, although DFSORT doesn't really care which way you code it.
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 copying data without knowing location arunsoods DFSORT/ICETOOL 6 Thu Jul 20, 2017 1:03 pm
No new posts Need to write record of PS File in ex... Chandan1993 JCL & VSAM 1 Wed Jun 07, 2017 1:35 am
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts Sort Large record length cmsmoon DFSORT/ICETOOL 14 Tue Apr 11, 2017 5:49 pm


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