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
 

 

Delete Current Record based on previous Record

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

New User


Joined: 03 Jan 2007
Posts: 2
Location: chennai

PostPosted: Mon Feb 13, 2012 2:17 pm    Post subject: Delete Current Record based on previous Record
Reply with quote

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
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Feb 13, 2012 2:53 pm    Post subject: Reply to: Delete Current Record based on previous Record
Reply with quote

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
View user's profile Send private message
Vamshi Veludandi

New User


Joined: 17 Mar 2009
Posts: 23
Location: Bangalore

PostPosted: Mon Feb 13, 2012 3:43 pm    Post subject: Reply to: Delete Current Record based on previous Record
Reply with quote

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
View user's profile Send private message
elango_K

New User


Joined: 18 Aug 2011
Posts: 44
Location: India

PostPosted: Mon Feb 13, 2012 3:57 pm    Post subject:
Reply with quote

Hi Vamshi,

What is the DCB of your input file??
Back to top
View user's profile Send private message
Vamshi Veludandi

New User


Joined: 17 Mar 2009
Posts: 23
Location: Bangalore

PostPosted: Mon Feb 13, 2012 4:04 pm    Post subject:
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Mon Feb 13, 2012 4:11 pm    Post subject: Reply to: Delete Current Record based on previous Record
Reply with quote

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
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Feb 13, 2012 4:25 pm    Post subject: Reply to: Delete Current Record based on previous Record
Reply with quote

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
View user's profile Send private message
Vamshi Veludandi

New User


Joined: 17 Mar 2009
Posts: 23
Location: Bangalore

PostPosted: Mon Feb 13, 2012 5:01 pm    Post subject: Re: Reply to: Delete Current Record based on previous Record
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Mon Feb 13, 2012 5:03 pm    Post subject: Reply to: Delete Current Record based on previous Record
Reply with quote

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
View user's profile Send private message
Vamshi Veludandi

New User


Joined: 17 Mar 2009
Posts: 23
Location: Bangalore

PostPosted: Mon Feb 13, 2012 5:04 pm    Post subject: Reply to: Delete Current Record based on previous Record
Reply with quote

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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Mon Feb 13, 2012 7:28 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Feb 13, 2012 8:28 pm    Post subject: Reply to: Delete Current Record based on previous Record
Reply with quote

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.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Feb 13, 2012 9:56 pm    Post subject: Re: Reply to: Delete Current Record based on previous Record
Reply with quote

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 icon_wink.gif
Back to top
View user's profile Send private message
Vamshi Veludandi

New User


Joined: 17 Mar 2009
Posts: 23
Location: Bangalore

PostPosted: Tue Feb 14, 2012 7:33 am    Post subject: Re: Reply to: Delete Current Record based on previous Record
Reply with quote

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
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 JCL to delete component in a package sundaram.naveen Compuware & Other Tools 14 Tue Nov 29, 2016 6:21 pm
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts How to get previous month in SYMNAMES Suganya87 SYNCSORT 9 Fri Oct 28, 2016 1:37 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


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