|
View previous topic :: View next topic
|
| Author |
Message |
V S Amarendra Reddy
Active User

Joined: 13 Sep 2006 Posts: 221 Location: USA
|
|
|
|
Hi,
The input file is FB, LRECL is 80 and the input file layout is as below. The output file is also FB/80.
| Code: |
HD123
DB111
DT222
DT333
DT444
HDXXX
DBABC
HDYHZ
DBJJJ
DT101
|
Expected Output:
| Code: |
HD123
DB111
DT222
DT333
DT444
HDYHZ
DBJJJ
DT101
|
Requirement: The input file has 1 HD record, 1 DB record and multiple DT records. The output should only contain the group of records that has atleast one DT record. As we can see in the output, the second group did not have a DT record, so it shouldn't be in the output.
Can this be done using SYNCSORT? |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2276 Location: USA
|
|
|
|
| V S Amarendra Reddy wrote: |
| Can this be done using SYNCSORT? |
As usually, the question is not in SYNCSORT or whatever else, but: in the ability of developer to evaluate the logical algorithm - what is the sequence of operations for the task to be done, at all?
After the problem above is resolved, then the appropriate tool could be chosen.
Doesn't make any sense to do it vice versa. |
|
| Back to top |
|
 |
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
If the data set is Not too big then, as a simple solution, you can read the data set in reverse using SEQ and use WHEN=GROUP where the Group BEGIN with 'DT' record and END with 'HD' record. At the end, reverse the order again to get your expected output.
. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2276 Location: USA
|
|
|
|
With SYNCSORT, it requires two separate job steps
| Code: |
//*==================================
//GROUPS EXEC PGM=SYNCSORT
//*
//SYSOUT DD SYSOUT=*
//*
//SORTIN DD *
HD123
DB111
DT222
DT333
DT444
HDXXX
DBABC
HDYHZ
DBJJJ
DT101
//*
//NUMBERED DD DISP=(NEW,PASS),
// SPACE=(TRK,(10,10)),
// DSN=&&NUMBERED
//GROUPS DD DISP=(NEW,PASS),
// SPACE=(TRK,(10,10)),
// DSN=&&GROUPS
//SYSIN DD *
INREC IFTHEN=(WHEN=GROUP,
BEGIN=(1,2,CH,EQ,C'HD'),
PUSH=(10:ID=3,SEQ=3))
SORT FIELDS=COPY
OUTFIL FNAMES=NUMBERED
OUTFIL FNAMES=GROUPS,
NODETAIL,REMOVECC,
INCLUDE=(1,2,CH,EQ,C'DT'),
SECTIONS=(10,3,
TRAILER3=(1,15))
END
//*
//*===========================================
//SELECT EXEC PGM=SYNCSORT
//*
//SYSOUT DD SYSOUT=*
//*
//NUMBERED DD DISP=(OLD,DELETE),DSN=&&NUMBERED
//GROUPS DD DISP=(OLD,DELETE),DSN=&&GROUPS
//*
//SORTOUT DD SYSOUT=*
//*
//SYSIN DD *
JOINKEYS F1=NUMBERED,
FIELDS=(10,3,A),
SORTED
JOINKEYS F2=GROUPS,
FIELDS=(10,3,A),
SORTED
REFORMAT FIELDS=(F1:1,15)
SORT FIELDS=(10,3,CH,A,
13,3,CH,A)
OUTREC BUILD=(1,5)
END
//*
//*======================================== |
|
|
| Back to top |
|
 |
V S Amarendra Reddy
Active User

Joined: 13 Sep 2006 Posts: 221 Location: USA
|
|
|
|
Thank you sergeyken, it worked nicely.
Thank you Rahul for the idea as well. |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
Amar,
I don't have SYNCTOOL, but you could try something like this which does not involve SORTing. Assign group ID for each group and select groups having more than 2 records.
| Code: |
//STEP01 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//OUT DD SYSOUT=*
//IN DD DISP=SHR,DSN = input data set (FB/LRECL=80)
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(81,8,CH) HIGHER(2) USING(CTL1)
//CTL1CNTL DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'HD'),
PUSH=(81:ID=8))
OUTFIL BUILD=(1,80)
//* |
|
|
| Back to top |
|
 |
V S Amarendra Reddy
Active User

Joined: 13 Sep 2006 Posts: 221 Location: USA
|
|
|
|
Wow... You really provide slick solutions Arun...
Thank you very much... I will try and let you know. |
|
| Back to top |
|
 |
V S Amarendra Reddy
Active User

Joined: 13 Sep 2006 Posts: 221 Location: USA
|
|
|
|
Arun,
I just tested this card, and it worked beautifully.
Thank you very much
 |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
| Amar - You're welcome. Thanks for letting know! |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2276 Location: USA
|
|
|
|
| Posts about ICETOOL under SYNCSORT, and vice versa, are prohibited by moderators (for unknown reason), isn't it? |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
| sergeyken wrote: |
| Posts about ICETOOL under SYNCSORT, and vice versa, are prohibited by moderators (for unknown reason), isn't it? |
That is not true. But posting solutions that are not compatible with the other product is not recommended and such posts could be edited/removed.
Syncsort has made 'ICETOOL' an alias to their product - 'SYNCTOOL'. So PGM=SYNCTOOL and PGM=ICETOOL can be used interchangeably at a typical Syncsort site unless there are any site specific restrictions. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|