|
View previous topic :: View next topic
|
| Author |
Message |
kalyan418
New User
Joined: 03 Jan 2007 Posts: 2 Location: chennai
|
|
|
|
I have requirement where in i have to delete the current record based on its previous record. For example
| Code: |
AAA
BBB
XXX
$$$
ABC
EFG
XXX
123
$$$
xyz
|
Output
| Code: |
AAA
BBB
XXX
ABC
EFG
XXX
123
$$$
xyz
|
I need to delete the record $$$ if and only if its previous record is XXX.
I am able to delete a duplicate record using sort but in this case its not a duplicate record.
Is it possible to get the job done using sort. Please provide the code snippet. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You can try this. Consider the test data I've used, in case you need to modify your requirement.
| Code: |
//DROPAFT EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,
BEGIN=(1,3,CH,EQ,C'XXX'),
END=(1,3,CH,EQ,C'$$$'),
PUSH=(81:SEQ=8))
OUTFIL OMIT=(01,03,CH,EQ,C'$$$',
AND,
81,08,ZD,EQ,2)
/*
//SORTIN DD *
AAA
BBB
XXX
$$$
XXX
$$$
$$$
ABC
EFG
XXX
123
$$$
XXX
123
$$$
$$$
xyz
|
Output
| Code: |
AAA
BBB
XXX
XXX
$$$
ABC
EFG
XXX
123
$$$
XXX
123
$$$
$$$
xyz |
|
|
| Back to top |
|
 |
Vamshi Veludandi
New User
Joined: 17 Mar 2009 Posts: 27 Location: Bangalore
|
|
|
|
Hi Bill,
I tried your code and its working fine.
But when I tried the same for a Variable Length Record (2000)
its ending with USER COMPLETION CODE=0218
| Code: |
//STEP1 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD DISP=SHR,DSN=AAA.BBB.CCC.INPUT
//SORTOUT DD DSN=AAA.BBB.CCC.OUTPUT,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(1,1),RLSE),
// DCB=(RECFM=VB,LRECL=0,BLKSIZE=0)
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,
BEGIN=(5,4,CH,EQ,C'XXX '),
END=(5,4,CH,EQ,C'$$$ '),
PUSH=(2001:SEQ=8))
OUTFIL OMIT=(5,4,CH,EQ,C'$$$ ',AND,2001,8,ZD,EQ,2),
BUILD=(1,2000)
/* |
| Code: |
ICE218A 3 73 BYTE VARIABLE RECORD IS SHORTER THAN 2000 BYTE MINIMUM FOR SORTOUT FIELDS
|
Any idea why its abending ?
Regards,
Vamshi |
|
| Back to top |
|
 |
elango_K
New User
Joined: 18 Aug 2011 Posts: 44 Location: India
|
|
|
|
Hi Vamshi,
What is the DCB of your input file?? |
|
| Back to top |
|
 |
Vamshi Veludandi
New User
Joined: 17 Mar 2009 Posts: 27 Location: Bangalore
|
|
|
|
Hi Elango,
Input file DCB Parameters are
Organization . . . : PS
Record format . . . : VB
Record length . . . : 2000
Block size . . . . : 27998
| elango_K wrote: |
Hi Vamshi,
What is the DCB of your input file?? |
Regards,
Vamshi. |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
Vamshi!
do not piggy back on somebody' s else topics
it makes difficult for people trying to help to follow a logical reply flow
( furthermore it is considered bad manners ) |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I think the two TS's may be the same person, or at least working together.
You have records of different lengths, probably even different types, on you VB file. You will need to identify the records you want to deal with.
If all of those records are the same length, you can go ahead with the PUSH to the end of the record. If not the same legnth already, you will be making them the same length, so you'll need some slightly different code. |
|
| Back to top |
|
 |
Vamshi Veludandi
New User
Joined: 17 Mar 2009 Posts: 27 Location: Bangalore
|
|
|
|
Actually, we both work together. Otherwise wouldn't have raised queries on someone else's topic.
| enrico-sorichetti wrote: |
Vamshi!
do not piggy back on somebody' s else topics
it makes difficult for people trying to help to follow a logical reply flow
( furthermore it is considered bad manners ) |
|
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
| Quote: |
Otherwise wouldn't have raised queries on someone else's topic.
|
it does not make any difference ! it' s still considered bad forum etiquette |
|
| Back to top |
|
 |
Vamshi Veludandi
New User
Joined: 17 Mar 2009 Posts: 27 Location: Bangalore
|
|
|
|
I was able to get the job done by converting the dataset from VB to FB, delete the required records and the convert the dataset back to VB from FB.
Thanks a lot,
Vamshi. |
|
| Back to top |
|
 |
expat
Global Moderator

Joined: 14 Mar 2007 Posts: 8798 Location: Welsh Wales
|
|
|
|
I believe that either Frank or Kolusu resolved the same problem in a single pass of the data, because if your data volume is high then you are just wasting resource by multiple passes on the data.
I recall that the fix was to put the sequence number in the first eight bytes rather than at the end of a variable length record.
Also pretty sure that this is shown in the DFSORT smart tricks document which can be accessed from the documentation sticky at the top of the forum. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
This is the sort of thing expat and I are alluding to.
| Code: |
| INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,8X,5)), |
and change the PUSH from 81 to 5 (first available byte after RDW.
You might feel that the SEQ doesn't need to be 8, but I'd keep it at least 10 times too big to always be safe. If you want to adjust the length, adjust the blanks in the BUILD from 8X to the length you choose. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| Vamshi Veludandi wrote: |
I was able to get the job done by converting the dataset from VB to FB, delete the required records and the convert the dataset back to VB from FB.
|
Vamshi,
You are wasting a lot of resources doing that way. And by appending an ID num at the end of a VB file, you ruined the very basic concept of VB files. You made all the variable records of the same length. Here is a DFSORT JCL which will give you the desired results in a single pass.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=Your input VB 2000 byte file,DISP=SHR
//SORTOUT DD DSN=AAA.BBB.CCC.OUTPUT,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(X,Y),RLSE),
//*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,3X,5)),
IFTHEN=(WHEN=GROUP,BEGIN=(8,3,CH,EQ,C'XXX'),PUSH=(5:8,3),RECORDS=2)
OUTFIL OMIT=(5,6,CH,EQ,C'XXX$$$'),BUILD=(1,4,8)
//* |
| Bill Woodger wrote: |
| You might feel that the SEQ doesn't need to be 8, but I'd keep it at least 10 times too big to always be safe. If you want to adjust the length, adjust the blanks in the BUILD from 8X to the length you choose. |
In this case you don't need seqnum as you can restrict the push to just 2 records with RECORDS=n keyword  |
|
| Back to top |
|
 |
Vamshi Veludandi
New User
Joined: 17 Mar 2009 Posts: 27 Location: Bangalore
|
|
|
|
Hi kolusu,
I always knew that converting the file from VB to FB and then back to VB from FB doesn't make much sense when you have a much better approach. But just got struck up wondering why appending the ID number at the end of the file is working for FB but not for a VB file.
| Skolusu wrote: |
[quote
Vamshi,
You are wasting a lot of resources doing that way. And by appending an ID num at the end of a VB file, you ruined the very basic concept of VB files. You made all the variable records of the same length. Here is a DFSORT JCL which will give you the desired results in a single pass.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=Your input VB 2000 byte file,DISP=SHR
//SORTOUT DD DSN=AAA.BBB.CCC.OUTPUT,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(X,Y),RLSE),
//*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,3X,5)),
IFTHEN=(WHEN=GROUP,BEGIN=(8,3,CH,EQ,C'XXX'),PUSH=(5:8,3),RECORDS=2)
OUTFIL OMIT=(5,6,CH,EQ,C'XXX$$$'),BUILD=(1,4,8)
//* |
|
Thanks for the code snippet. Will try with it now.
Thank a lot,
Vamshi. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|