IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Can we delete first occurrence of string from PS file


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
snehal

New User


Joined: 12 Dec 2006
Posts: 14
Location: pune

PostPosted: Wed Dec 19, 2012 12:38 pm
Reply with quote

Hi,

I have to delete first occurence of string from input file (Record format : VBA and LRECL=1024). I want to search particular hex value in the file and omit only that record.

Can anyone help me to solve this?

Thanks,
Snehal
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Dec 19, 2012 12:44 pm
Reply with quote

Does the HEX value occur in any position?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Dec 19, 2012 1:47 pm
Reply with quote

Which do you want to do? Omit a record or delete some data?

Can you show some sample input and expected output, please?

SS on OMIT/INCLUDE or FINDREP are likely to be what you want, but as Pandora-Box is hinting, if you are going for a hex value, you have to be really sure it can't just exist naturally in a packed/binary field on a record.
Back to top
View user's profile Send private message
snehal

New User


Joined: 12 Dec 2006
Posts: 14
Location: pune

PostPosted: Wed Dec 19, 2012 2:53 pm
Reply with quote

Hi Bill,

Hex value will pe at position 1 in the file. But it doesn't appear only in one record. It can be present in many records.
I want to delete record when the hex value appears first time.
I tried below card :
Code:
//SYSIN    DD *
  OPTION COPY,STOPAFT=1
  OMIT COND=(5,3,SS,EQ,X'4E065E')
/*

But it didn't work.

Data from I/P file: I put HEX ON in file

Code:
        DJDE âáåñ+,,,,,,,,,,,,,à
44444444CDCC44444432323323233224
00000000414502579ED80E00C0E009C4
--------------------------------
        +,;,,2,,,,,,,,,,
4444444440500F00022222204444444444444444
00000000E6E042C0500000010000000000000000
--------------------------------
        DJDE ãááà, íì,á+à,
44444444CDCC44444345524443444444
00000000414506554D158C5E4B000000
--------------------------------
1,,
F2044444444444444444444444444444
10100000000000000000000000000000
--------------------------------
        +,;,,2,,,,,,,,,,
4444444440500F00022222204444444444444444
00000000E6E042C0500000010000000000000000

I want to delete record where first occurrence of Hex value X'4e065e' is found.

Thanks,
Snehal
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Dec 19, 2012 3:32 pm
Reply with quote

Well, you won't be able to use INCLUDE/OMIT.

You could use IFTHEN=(WHEN=(logexp with SS and OVERLAY a SEQNUM, then on OUTFIL OMIT get rid of the record which has a sequence number of one, and shorten the records to drop the sequence number.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Dec 19, 2012 3:33 pm
Reply with quote

This should get you what needed...

Code:

  SORT FIELDS=COPY
  INREC IFTHEN=(WHEN=GROUP,
                BEGIN=(6,3,CH,EQ,X'4E065E'),
                 PUSH=(1025:ID=4,1029:SEQ=8))
  OUTFIL OMIT=(1025,4,ZD,EQ,1,AND,1029,8,ZD,EQ,1),BUILD=(1,1024)
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Dec 19, 2012 3:47 pm
Reply with quote

May be slightly better

Code:
  SORT FIELDS=COPY
  INREC IFTHEN=(WHEN=GROUP,
                BEGIN=(5,3,CH,EQ,X'4E065E'), RECORDS=1,
                 PUSH=(1025:ID=4))
  OUTFIL OMIT=(1025,4,ZD,EQ,1,AND,5,3,CH,EQ,X'4E065E'),BUILD=(1,1024)
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Dec 19, 2012 4:03 pm
Reply with quote

What's going on here? TS's data doesn't match their words, and we're coming with code? :-)

The test data shown is variable-length.

The hex value (which is actually "+,;"), where it is shown, is at a fixed position (despite the request to "search") of 13,3 in a VBA.

I don't know why the GROUP is being used. Why not logexp and a simple OVERLAY (there is no need to propagate data across other records, or to use ID, or whatever, unless I'm missing something).

Padora-Box at least has RECORDS=1 (although, as a comment, through typo).

Isn't all we need to know is that it is the first occurrence of the thing? No need for first occurrence of first group, is there?
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Dec 19, 2012 4:16 pm
Reply with quote

I used a GROUP and records=1 because we dont need to overlay all the records and we can pick the first OVERLAYed record icon_smile.gif

Quote:
Escapa at least has RECORDS=1 (although, as a comment, through typo).


It was me icon_wink.gif
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Dec 19, 2012 4:29 pm
Reply with quote

Sorry, mixed up with the "Topic Review". Corrected.

Why GROUP at all, was the main question.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Dec 19, 2012 4:35 pm
Reply with quote

I used GROUP for RECORDS=1 because RECORDS=n is supported only in group just to ensure overlaying all records not needed

But yes GROUP is not needed an overlay with SEQUENCE number should suffice icon_redface.gif

I was looking for something like to mix STOPAFT=1 & OVERLAY so that just to remove 1 record we dont need to overlay for all or even few

Still thinking on that .. I am not sure atm if its possible
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Dec 19, 2012 11:31 pm
Reply with quote

Escapa wrote:
This should get you what needed...

Pandora-Box wrote:
May be slightly better


I really appreciate your enthusiasm to help with solutions, but please pay attention to RECFM of OP. Both of your solutions will make all the records in the Variable block file to have the max length , there by ruining the very concept of VB files. Try displaying the RDW before and after your jobs and see how the RDW is updated to the max value. Moreover you have complicated a simple request. You really don't need WHEN=GROUP in here.

Bill Woodger wrote:
The hex value (which is actually "+,;"), where it is shown, is at a fixed position (despite the request to "search") of 13,3 in a VBA.


For VBA files the actual data starts in position 6 as the first 5 bytes have( 4 bytes RDW + 1 byte Carriage control character). So if you add a seqnum for 8 bytes the search key begins at 14. icon_wink.gif

snehal,

Use the following DFSORT JCL which will give you the desired results.
Code:

//STEP0100 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD DISP=SHR,DSN=Your Input VBA file
//SORTOUT  DD SYSOUT=*                                         
//SYSIN    DD *                                                 
  OPTION COPY                                                   
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,8X,5)),                   
  IFTHEN=(WHEN=(14,3,CH,EQ,X'4E065E'),OVERLAY=(5:SEQNUM,8,ZD)) 

  OUTFIL OMIT=(5,8,ZD,EQ,1),BUILD=(1,4,13)                     
//*
Back to top
View user's profile Send private message
snehal

New User


Joined: 12 Dec 2006
Posts: 14
Location: pune

PostPosted: Thu Dec 20, 2012 4:20 pm
Reply with quote

Thanks a lot Skolusu.

Solution given by you worked fine for me.

Snehal
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Thu Dec 20, 2012 6:42 pm
Reply with quote

Thanks Kolusu

I was aware of this solution but I had a wrong assumption about my solution
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
Search our Forums:

Back to Top