Page 1 of 1

Help regarding the Sort card

PostPosted: Mon Dec 19, 2011 6:00 pm
by rahuil
Hello,
I have a requirement as follows:

Input: File with three fields

Empid. Empname Mgrid.

Output:

Empid. Empname Mgrname

Explanation: Input file consists of three fileds, in which mgrid is the field which contains the Mgr info.
Same id is present in the empid too, so we have to retreive the name of that emp and have to be given as
Mgr name in the output field which has those particular values in the input.

Eg. I/p: 1 a 3 O/p: 1 a c
2 b 3 2 b c
3 c 3 3 c c

Re: Help regarding the Sort card

PostPosted: Mon Dec 19, 2011 9:38 pm
by BillyBoyo
Input

1 A 3
2 B 3
3 C 3


Output

1 A C
2 A C
3 A C


Can you have MGRIDs which are not EMPIDs, ie which are not on file? Do you have duplicate EMPIDs?

Re: Help regarding the Sort card

PostPosted: Mon Dec 19, 2011 11:22 pm
by Frank Yaeger
rahuil,

You need to do a better job of explaining what you want to do. Please show an example of the records in your input file (relevant fields only) and what you expect for output. Use ubb code tags! Show the actual values. Explain the "rules" for getting from input to output. Give the starting position, length and format of each relevant field. Give the RECFM and LRECL of the input file. If the file can have duplicates within it, show that in your example.

Re: Help regarding the Sort card

PostPosted: Tue Dec 20, 2011 4:27 am
by BillyBoyo
Sorry, I made a total mess of your data. Is it like this:


empid  empname    mgrid
000010 JOHNSON   900003
000021 ROBERTS   900003
000038 SMITH     900018
000101 JONES     900003
900003 MR BOSS   900003
900018 MS CHIEF  900018


Managers being identified by empid = mgrid

And you want:
empid
000010 JOHNSON   MR BOSS
000021 ROBERTS   MR BOSS
000038 SMITH     MS CHIEF
000101 JONES     MR BOSS
900003 MR BOSS   MR BOSS
900018 MS CHIEF  MS CHIEF


Can there be duplicate records on the file (as far as a key value is concerned)?

Can there be references to MGRID which are not on the file?

Can there be Managers who do not have employees?

Do you want the managers on the output file?

Re: Help regarding the Sort card

PostPosted: Tue Dec 20, 2011 1:21 pm
by rahuil
Hello billy,

Your second post matches with my requirement.

All ids shuld be in file, no duplicates for empid.

Can you post code for such requirement?

Re: Help regarding the Sort card

PostPosted: Tue Dec 20, 2011 2:07 pm
by BillyBoyo
Get yourself familiar with the location of the DFSORT manuals, which are available on the web, and can be searched on the web or downloaded as PDFs.

It would be a JOINKEYS application that you need. This allows for the processing of file matching.

In your case, you want to match your input dataset "to itself". This at first seems odd, but hopefully you'll see what happens.

A very good source of sample code is the DFSORT forum here, there are also other such places on the web.

Re: Help regarding the Sort card

PostPosted: Thu Dec 22, 2011 2:48 am
by Frank Yaeger
You can use a DFSORT job like the following to do what you asked for:

//S1  EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//INA      DD DSN=...  input file
//INB      DD DSN=...  input file
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  JOINKEYS F1=INA,FIELDS=(19,6,A)
  JOINKEYS F2=INB,FIELDS=(1,6,A)
  REFORMAT FIELDS=(F1:1,18,F2:8,10)
  SORT FIELDS=(1,6,ZD,A)
/*