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.
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 )
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.
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 )
Joined: 14 Mar 2007 Posts: 8797 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.
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.
Code:
PUSH=(5:SEQ=8))
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.
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.
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
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.