MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Delete first record if it is blank
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Tue Apr 04, 2006 10:43 am    Post subject: Delete first record if it is blank Reply with quote

Hi,

I have an input file with the following parameters.
LRECL=500 and RECFM=FB.

I want to delete the only first record from this file if the record is empty.

E.g.: Original file
Code:


APBH 280 04032006
APCA 280 03232006 3876823    Keith BERGMOSER
APCA 280 03312006 3879719    ARDELINA  QUIAMAS
APCA 280 03312006 3880153    DEBRA L GANE
APCA 280 04012006 3880326    MIGUEL  ROBLES
APGD 280 07162004 3612345    Keith BERGMOSER
APGD 280 03312006 3873803    RIJINA JAJOU
APGD 280 03312006 3878396    JOSEPH KOSTESICH OD


After deleting the first blank record the file should be as below.
Code:
APBH 280 04032006
APCA 280 03232006 3876823    Keith BERGMOSER
APCA 280 03312006 3879719    ARDELINA  QUIAMAS
APCA 280 03312006 3880153    DEBRA L GANE
APCA 280 04012006 3880326    MIGUEL  ROBLES
APGD 280 07162004 3612345    Keith BERGMOSER
APGD 280 03312006 3873803    RIJINA JAJOU
APGD 280 03312006 3878396    JOSEPH KOSTESICH OD


Please let me know how can we handle this.
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Tue Apr 04, 2006 10:59 am    Post subject: Reply with quote

vkphani,

It is very easy. Add a seqnum at the end of every record using OUTREC FIELDS and now check for all spaces in the first 500 bytes only seqnum 1 using OMIT on OUTFIL and while writing out chop off the seqnum that you added.

Try this sysin cards.

Code:

//SYSIN    DD *                       
  SORT FIELDS=COPY                     
  OUTREC FIELDS=(1,500,SEQNUM,8,ZD)     
  OUTFIL OMIT=(501,008,ZD,EQ,1,AND,     
               001,256,CH,EQ,C' ',AND, 
               257,244,CH,EQ,C' '),     
  OUTREC=(1,500)                       
/*


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Thu May 04, 2006 10:15 am    Post subject: Reply with quote

I am trying to delete a blank record from the input file and writing to the output file after deleting. The blank record can present at any position, not necessarily the first record.My original code looks like below:

Code:
//SORTIN   DD DSN=D2IL.BPDD.LSZ127.APPRO.LETTERS.CPKRISH,DISP=SHR
//*
//SORTOUT  DD DSN=D2IL.BPDD.APPRO.LETTERS.SORTED,DISP=SHR
//*
//SYSIN    DD *
  SORT FIELDS=(1,4,CH,A,19,10,CH,A)
/*


As per Kolusu's SYSIN card, I have changed the code as below:

Code:
//SORTIN   DD DSN=D2IL.BPDD.LSZ127.APPRO.LETTERS.CPKRISH,DISP=SHR
//*
//SORTOUT  DD DSN=D2IL.BPDD.APPRO.LETTERS.SORTED,DISP=SHR
//*
//SYSIN    DD *
  SORT FIELDS=(1,4,CH,A,19,10,CH,A)
  OUTREC FIELDS=(1,500,SEQNUM,8,ZD)
  OUTFIL OMIT=(501,008,ZD,EQ,1,AND,
               001,256,CH,EQ,C'.',AND,
               257,244,CH,EQ,C'.'),
  OUTREC=(1,500)
/*


This modified code works if and only of the first line is blank. If I want to check in the entire file what to do? LRECL of both the files is 500 and format is FB.

Please help me with this.
Back to top
View user's profile Send private message Send e-mail
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu May 04, 2006 11:12 am    Post subject: Reply with quote

That's a much simpler case. You can just use these DFSORT control statements:

Code:

    OMIT COND=(1,256,CH,EQ,C' ',AND,257,244,CH,EQ,C' ')
    SORT FIELDS=(1,4,CH,A,19,10,CH,A)


This will delete all of the blank records anywhere in the file.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Thu May 04, 2006 11:48 am    Post subject: Reply with quote

Thanks a lot for the help Yaeger.
But I donot know why this SYSIN card is not working.

The data in the input file is as below:
Code:

000165  APTL 096 07162004 3612345    Mary Smith
000166  APMI 096 03232006 3876838    Mary Smith
000167  APCA 096 03232006 3876836    Mary Smith
000168  APGD 096 03232006 3873908    Mary Smith
000169


The data in the output file is coming as below:
Code:

000001
000002  APBH 096 05012006
000003  APCA 096 03232006 3876836    Mary Smith
000004  APCA 096 04292006 3887901    PHILIP BESHOFF
000005  APCA 096 04282006 3889190    MICHAEL SIMKO
000006  APCA 096 04282006 3889221    TAYLER CARANO


The blank record is present in the last line in the input file. This blank record is coming at the first line in the output file. It is not getting deleted. Please help me with this.
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu May 04, 2006 12:52 pm    Post subject: Reply with quote

Quote:

The blank record is present in the last line in the input file. This blank record is coming at the first line in the output file. It is not getting deleted. Please help me with this.


Are you sure that the last record is all spaces ? Do a hex on post the contents of just the last record.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu May 04, 2006 1:07 pm    Post subject: Reply with quote

Well, since the "blank line" is sorted to the top, it obviously has a blank in position 1 (blank = X'40' sorts before 'A' = X'C1'), but that's all we know from the information you posted. As Kolusu says, you need to display the line in hex to see if it is really all blanks = X'40's. You can use this DFSORT job to display the lines that start with a blank in position 1 in hex:

Code:

//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  OPTION COPY
  INCLUDE COND=(1,1,CH,EQ,X'40')
  OUTREC FIELDS=(1,150,HEX)
/*


Then you can look at the //SYSOUT output to see if those lines are all blanks = X'40's.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort


Last edited by Frank Yaeger on Thu May 04, 2006 2:41 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Thu May 04, 2006 1:43 pm    Post subject: Reply with quote

Contents of the blank line in HEX mode are

Code:

434444444444444444444444444
0F0000000000000000000000000
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu May 04, 2006 1:48 pm    Post subject: Reply with quote

vkphani wrote:
Contents of the blank line in HEX mode are


434444444444444444444444444
0F0000000000000000000000000


Vkphani,

The bold item is not a space.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Thu May 04, 2006 1:53 pm    Post subject: Reply with quote

Kolusu,

I tried with the below SYSIN card.

Code:

OMIT COND=(1,256,CH,EQ,X'03F4',AND,257,244,CH,EQ,X'03F4')
SORT FIELDS=(1,4,CH,A,19,10,CH,A)


But it is not deleting.
Back to top
View user's profile Send private message Send e-mail
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Thu May 04, 2006 2:04 pm    Post subject: Reply with quote

Yaeger,

I got the RC=16 after submitting the code given by you.

Code:

SYSIN :
  INCLUDE COND=(1,1,CH,EQ,X'40')
  OUTREC FIELDS=(1,150,HEX)
WER164B  1,028K BYTES OF VIRTUAL STORAGE AVAILABLE, MAX REQUESTED,
WER164B     0 BYTES RESERVE REQUESTED, 1,004K BYTES USED
WER146B  20K BYTES OF EMERGENCY SPACE ALLOCATED
WER267A  SORT STATEMENT    : STATEMENT NOT FOUND
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu May 04, 2006 2:10 pm    Post subject: Reply with quote

vkphani,

Quote:

WER267A SORT STATEMENT : STATEMENT NOT FOUND


That should give you a clue .You are missing SORT FIELDS=COPY.

Your orginal requirement was to skip the record if all the 500 bytes are spaces. Now it is different. Do you need to skip records if x'40' or x'3f' is found anywhere in the record?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Thu May 04, 2006 2:15 pm    Post subject: Reply with quote

Yes Kolusu,

I need to skip record if x'40' 0r x'3f' is found anywhere in the record.
Back to top
View user's profile Send private message Send e-mail
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Thu May 04, 2006 2:22 pm    Post subject: Reply with quote

I am able to delete with the following SYSIN card.

Code:

OMIT COND=(2,1,CH,EQ,X'3F')
SORT FIELDS=(1,4,CH,A,19,10,CH,A)
Back to top
View user's profile Send private message Send e-mail
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu May 04, 2006 2:39 pm    Post subject: Reply with quote

Kolusu,

Don't you love it. Rolling Eyes
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group