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
 

 

Finding record number and character position

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

New User


Joined: 16 May 2005
Posts: 15
Location: Bangalore

PostPosted: Mon Aug 09, 2010 11:07 pm    Post subject: Finding record number and character position
Reply with quote

I have requirement of finding a character position and record number in a file

below is the sample file

aaaaaaaa*123455abcdefgh
bbbbbbbbbbbbbbb*12312prprpr
aaaabbbbbbbbbbbbbcccccccccc
rrrrrrrrrrrrreeeeeeeeeeeeeeeeee
cccccc*aaaaaa123131231


From the above sample records i want to find the character '*' in each record

the output should be like below

Rec No | character posn
1 | 9
2 | 16
5 | 7

I want this to be achieved through dfsort.

Please anybody help me to achieve this .

Thanks,
Prasanna
Back to top
View user's profile Send private message

sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Mon Aug 09, 2010 11:41 pm    Post subject:
Reply with quote

prasannahcp,

What is LRECL and RECFM of the input file?

Thanks,
Back to top
View user's profile Send private message
prasannahcp

New User


Joined: 16 May 2005
Posts: 15
Location: Bangalore

PostPosted: Tue Aug 10, 2010 12:15 am    Post subject: Reply to: Finding record number and character position
Reply with quote

Rec length is 300
Rec FM is FB
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Tue Aug 10, 2010 12:33 am    Post subject:
Reply with quote

Sorry forgot to ask you one more question,
Could you possibly have more than one '*' in a single record?

Thanks,
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Tue Aug 10, 2010 3:46 am    Post subject:
Reply with quote

prasannahcp,
Below job assumes you could have only 1 '*' in the record. Even if you have multiple this reports, char. position of first '*'.

FYI, this could be combined in a single ICETOOL job but I don't know if there is any way to achieve the same in single pass.

Code:
//SORT01   EXEC PGM=SORT                                               
//SORTIN   DD  *                                                       
AAAAAAAA*123455ABCDEFGH*                                               
BBBBBBBBBBBBBBB*12312PRPRPR                                             
AAAABBBBBBBBBBBBBCCCCCCCCCC                                             
RRRRRRRRRRRRREEEEEEEEEEEEEEEEEE                                         
CCCCCC*AAAAAA123131231                                                 
/*                                                                     
//OUT      DD  DSN=YOURID.TEST.VB,                                     
//             DISP=(,CATLG,DELETE),                                   
//             UNIT=SYSDA                                               
//SYSIN DD *                                                           
 INREC IFTHEN=(WHEN=INIT,OVERLAY=(09:1,300,1:SEQNUM,8,ZD)),             
       IFTHEN=(WHEN=INIT,PARSE=(%01=(ENDAT=C'*',FIXLEN=308)),           
                         BUILD=(%01,JFY=(SHIFT=LEFT)))                 
 SORT FIELDS=COPY                                                       
 OUTFIL FNAMES=OUT,FTOV,VLTRIM=C' '                                     
/*                                                                     
//SYSOUT DD SYSOUT=*                                                   
//*                                                                     
//SORT02   EXEC PGM=SORT                                               
//SORTIN   DD  DISP=SHR,DSN=YOURID.TEST.VB                             
//SORTOUT  DD  SYSOUT=*                                                 
//SYSIN DD *                                                           
 OPTION VLSCMP                                                         
 SORT FIELDS=COPY                                                       
 OUTFIL VTOF,INCLUDE=(1,308,SS,EQ,C'*'),                               
             HEADER1=(1:'REC NO    | CHARACTER POSN',80:X),             
             BUILD=(5,8,ZD,11:C'|',14:1,2,BI,SUB,+12,M11,LENGTH=4,80:X)
/*                                                                     
//SYSOUT DD SYSOUT=*                                                   
//*                                                                     


OUTPUT
Code:
REC NO    | CHARACTER POSN
       1  |  0009         
       2  |  0016         
       5  |  0007         


Thanks,
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Aug 10, 2010 6:05 am    Post subject:
Reply with quote

prasannahcp,

Sqlcode1 has the right idea and his job needs a little tuning.
Code:

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DSN=Your input FB 300 file,DISP=SHR                                   
//SORTOUT  DD DSN=&&VB,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)         
//SYSIN    DD *                                                       
  SORT FIELDS=COPY                                                   
  INREC PARSE=(%00=(ENDAT=C'*',FIXLEN=300)),BUILD=(SEQNUM,8,ZD,%00)   
  OUTFIL INCLUDE=(9,300,SS,EQ,C'*'),FTOV,VLTRIM=C' '                 
//*                                                                   
//STEP0200 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DSN=&&VB,DISP=SHR                                   
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                       
  SORT FIELDS=COPY                                                   
  OUTFIL VTOF,BUILD=(5,8,ZD,C'|',1,2,BI,SUB,+12,EDIT=(IIIIT),30:X),   
  REMOVECC,HEADER1=(1:'REC NO   | CHARACTER POSN')                   
//*
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Tue Aug 10, 2010 6:24 am    Post subject:
Reply with quote

Kolusu,
Thanks for the correction. I guess, I am thinking too much in terms of IFTHEN.

Thanks,
Back to top
View user's profile Send private message
prasannahcp

New User


Joined: 16 May 2005
Posts: 15
Location: Bangalore

PostPosted: Tue Aug 10, 2010 8:30 pm    Post subject: Reply to: Finding record number and character position
Reply with quote

The above code is working fine for single character. But Actually i have a set of character to find like {'*','#',&','^','@',....}.

I need to find any of the characters from the above set present in the record.

Please help me
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Tue Aug 10, 2010 8:34 pm    Post subject:
Reply with quote

prasannahcp

huh? Could you give us all the possible special char. that you might have in the input record?

Is it possible to have multiple of them in the same record? If yes, how do you want output for them?

Thanks,
Back to top
View user's profile Send private message
prasannahcp

New User


Joined: 16 May 2005
Posts: 15
Location: Bangalore

PostPosted: Tue Aug 10, 2010 10:57 pm    Post subject: Reply to: Finding record number and character position
Reply with quote

Yes, it might come more than one character per row.

For now if i get for one character per row also it will be great. We are considering all the possible special character which is there on the keyboard.

AAAAAAAA*123455ABCDEFGH#
BBBBBBBBBBBBBBB*12312PRP&RPR
AAAABBBBBBBBBBBBB$CCCCCCCCCC
RRRRRRRRRRRRREEEEEEEEEEEEEEEEEE
C^CCCAAAAAA123131231

If multiple characters are coming on a single row
then i want the output to be

Rec No | character |character posn
1 | * | 9
1 | # | 24
2 | * | 16
2 | & | 25
3 | $ |18
5 | ^ |2
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Aug 10, 2010 11:18 pm    Post subject:
Reply with quote

Hello,

How is this information to be used?
Back to top
View user's profile Send private message
prasannahcp

New User


Joined: 16 May 2005
Posts: 15
Location: Bangalore

PostPosted: Tue Aug 10, 2010 11:50 pm    Post subject: Reply to: Finding record number and character position
Reply with quote

Information to be used is from a file and special characters are hard coded...
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Aug 11, 2010 12:06 am    Post subject:
Reply with quote

well, we could try again with the question:

dick scherrer wrote:
How is this information to be used?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Aug 11, 2010 12:55 am    Post subject:
Reply with quote

Hello,

Quote:
Information to be used is from a file and special characters are hard coded...
Huh icon_question.gif

How does answer the question of how the data is to be used. . .

Maybe another way to ask is:
How/where will this output file be used once it is created?
Back to top
View user's profile Send private message
prasannahcp

New User


Joined: 16 May 2005
Posts: 15
Location: Bangalore

PostPosted: Wed Aug 11, 2010 2:33 pm    Post subject: Reply to: Finding record number and character position
Reply with quote

Actually the requrement is to find the invalid characters....So i told i wanted to find special characters.. What i had given was a sample requirement..

I need to find the characters which are not there in the ASCII table.. So those which are not there in the chart are invalid characters...

We need to find out the character positon and records number where the invalid character is there... The output will be used manually...

Please help me..
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 988
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Wed Aug 11, 2010 3:14 pm    Post subject:
Reply with quote

Quote:
Actually the requrement is to find the invalid characters....


There are many characters other than the special characters which might be considered invalid. First, define what the valid characters are and then everything else is invalid. For example, X'00' might be considered invalid but it's not a special character.

Garry.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Aug 11, 2010 8:20 pm    Post subject: Reply to: Finding record number and character position
Reply with quote

prasannahcp,

Sort products do NOT have any built in features to determine the position of a string. You can manipulate for a single string or so, but it is still inefficient as you may have to read the file minimum of 2 times. If all you have is a hammer, everything looks like a nail.

on the other hand a COBOL program is just 10 lines (just the logic to parse apart from the usual setup of reading files) which is quite easy and very efficient.

IMHO write a Cobol program.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Wed Aug 11, 2010 8:56 pm    Post subject:
Reply with quote

I totally second Kolusu's opinion about using Cobol program and that's why I was holding off on posting my solution until I see his reply.

Unless you are totally obsessed with using DFSort use below card. I have used it for only 3 special char (*,#,$). You can add many as possible and make it more complex icon_smile.gif.

Code:
//SORT01   EXEC PGM=SORT                                               
//SORTIN   DD  *
AAAAAAAA*123455ABCDEFGH#         
BBBBBBBBBBBBBBB*12312PRPRPR$     
AAAABBBBBBBBBBBBBCCCCCCCCCC     
RRRRRRRRRRRRREEEEEEEEEEEEEEEEEE 
CCCCCC*AAAAAA123131231           
/*
//SORTOUT  DD DSN=&&VB,DISP=(,PASS),SPACE=(CYL,(5,5),RLSE) 
//SYSIN DD *                                                           
 INREC PARSE=(%01=(ENDAT=C'*',FIXLEN=300),                             
              %02=(ENDAT=C'#',FIXLEN=300),                             
              %03=(ENDAT=C'$',FIXLEN=300)),                             
       BUILD=(%01,%02,%03)                                             
 SORT FIELDS=COPY                                                       
 OUTFIL BUILD=(SEQNUM,8,ZD,001,300,/,                                   
               SEQNUM,8,ZD,301,300,/,                                   
               SEQNUM,8,ZD,601,300),FTOV,VLTRIM=C' '                   
/*                                                                     
//SYSOUT DD SYSOUT=*                                                   
//*                                                                     
//SORT02   EXEC PGM=SORT                                               
//SORTIN   DD  DSN=&&VB,DISP=SHR
//SORTOUT  DD  SYSOUT=*                                                 
//SYSIN DD *                                                           
 OPTION VLSHRT                                                         
 INREC IFTHEN=(WHEN=INIT,OVERLAY=(309:1,2,SEQNUM,8,ZD,RESTART=(5,8))), 
       IFTHEN=(WHEN=GROUP,BEGIN=(311,8,ZD,EQ,1),END=(311,8,ZD,EQ,3),   
               PUSH=(321:309,2)),                                       
       IFTHEN=(WHEN=GROUP,BEGIN=(311,8,ZD,EQ,2),END=(311,8,ZD,EQ,3),   
               PUSH=(323:309,2)),                                       
       IFTHEN=(WHEN=(9,300,SS,EQ,C'*'),OVERLAY=(319:C'*')),             
       IFTHEN=(WHEN=(9,300,SS,EQ,C'#'),OVERLAY=(319:C'#')),             
       IFTHEN=(WHEN=(9,300,SS,EQ,C'$'),OVERLAY=(319:C'$'))             
 SORT FIELDS=COPY                                                       
 OUTREC IFTHEN=(WHEN=(311,8,ZD,EQ,2,AND,319,1,CH,GT,C' '),             
       OVERLAY=(309:((309,2,BI,ADD,321,2,BI),SUB,+12),                 
                 TO=BI,LENGTH=2)),                                     
        IFTHEN=(WHEN=(311,8,ZD,EQ,3,AND,319,1,CH,GT,C' '),             
       OVERLAY=(309:((309,2,BI,ADD,321,2,BI,ADD,323,2,BI),SUB,+24),     
                 TO=BI,LENGTH=2))                                       
 OUTFIL VTOF,INCLUDE=(319,1,CH,GT,C' '),                               
   BUILD=(005,8,C'|',                                                   
          3X,319,1,5X,C'|',                                             
          309,2,BI,SUB,+12,EDIT=(IIIIT),40:X),                         
   REMOVECC,HEADER1=(1:'REC NO  |CHARACTER| CHARACTER POSN')           
/*                                                                     
//SYSOUT DD SYSOUT=*                                                   
//*                                                                     


OUTPUT
Code:
REC NO  |CHARACTER| CHARACTER POSN
00000001|   *     |    9           
00000001|   #     |   24           
00000002|   *     |   16           
00000002|   $     |   28           
00000005|   *     |    7           


Thanks,
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 How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts sort with previous record anatol DFSORT/ICETOOL 9 Thu Oct 06, 2016 2:36 am
This topic is locked: you cannot edit posts or make replies. DSList (3.4) cannot display Chinese c... jacobdng TSO/ISPF 4 Wed Oct 05, 2016 2:51 pm
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm
No new posts Change date (DD/MM/YY) in 2nd record ... uday kiran DFSORT/ICETOOL 12 Wed Sep 07, 2016 10:57 pm


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