Count of bytes between strings



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Count of bytes between strings

Postby jnkarthik » Tue Oct 26, 2010 10:50 pm

Hello All,

I have a large Variable length record file.
My requirement is to count the bytes between particular strings i.e.,If I have a file something like below. I need to count the bytes from xyz to next xyz. In case of last set till the end of file. Can some one could advise whether it is achievable through DFSORT utilities? If not which will be better option - REXX, Easytrieve or Only Cobol?
xyz
abcdedfgggggggggg
abccccccddddddddddddddddef
aaaaaaaaaaaaaaaaaaaaa

xyz
bbbbbbbbb
bcvcfdggggggggggggggggggggg
ddddddddddddd
vdffdfvb

xyz
ccccccccccccccddddddddddddddd
eeeeffffggggggggg
eeeeeeeefffff
jnkarthik
 
Posts: 14
Joined: Wed Oct 20, 2010 3:45 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Count of bytes between strings

Postby skolusu » Tue Oct 26, 2010 11:30 pm

Jnkarthik,

You haven't shown the desired output. Assuming that you want to count the bytes between the groups, the following DFSORT JCL will give you the desired results


//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DSN=Your input VB file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                   
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,1,2,BI,SUB,+4,BI,LENGTH=2,5,3)),
  IFTHEN=(WHEN=GROUP,BEGIN=(7,3,CH,EQ,C'XYZ'),PUSH=(10:ID=8))       
  OUTFIL REMOVECC,NODETAIL,VTOF,BUILD=(80X),                         
  SECTIONS=(10,8,                                                   
  TRAILER3=('TOTAL BYTES FOR GROUP XYZ ',10,8,X,                     
             TOT=(5,2,BI,M10,LENGTH=8)))                             
//*


The output from the above is
TOTAL BYTES FOR GROUP XYZ 00000001       67
TOTAL BYTES FOR GROUP XYZ 00000002       60
TOTAL BYTES FOR GROUP XYZ 00000003       62


if that is not what you want , then you need to do a better job of describing your requirements.
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: Count of bytes between strings

Postby jnkarthik » Wed Oct 27, 2010 3:24 pm

Thanks Mr.Kolusu,

It looks like it will help for my requirement. Sorry I have not detailed you clearly on my requirement in my first instance (Which I struggle always :-) )

Could you please brief how this works... Very simple steps but doing complex things over here.
Below is how my input file will look like which will repeats with hexa decimal x'5044462D312E330A' (i.e., my xyz) and need to identify the count of bytes between this. I will try to change the code based on your guidence. If you could brief how it work it might ease it.

&àã.....
...?¦.....äÊÁ/È?Ê..áÌËÈÊÁ/_.àÑ/%?ÅÍÁ.îÁÊËÑ?>..........
äÊÁ/ÈÑ?>à/ÈÁ......................
ÍÈÇ?Ê..êÁÅÑËÈÁÊÁÀ.È?..+|êïñäç...
èÑÈ%Á..ç..¬ øø%ÑÄ/ÈÑ?>¬.&¬<<íè¬î.....øÇ/ËÁ....
..Á>À?¦.
&àã.ã?>È..ã.....
.......?¦.
..
è`øÁ..ã?>È.
ëÍÂÈ`øÁ..è`øÁ..
á>Ä?ÀÑ>Å..............ê.
â/ËÁã?>È..çÁ%ÎÁÈÑÄ/.
..Á>À?¦..
&àã.ã?>È..ã.....
.......?¦.
..



Thanks a lot for your response.
jnkarthik
 
Posts: 14
Joined: Wed Oct 20, 2010 3:45 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Count of bytes between strings

Postby jnkarthik » Wed Oct 27, 2010 3:50 pm

Hello Again, Sorry is it possible to get the byte count in hexa decimal format?
jnkarthik
 
Posts: 14
Joined: Wed Oct 20, 2010 3:45 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Count of bytes between strings

Postby NicC » Wed Oct 27, 2010 6:55 pm

hexa decimal format

Do you mean that if the count is 16 decimal you want it reported as 10 hexadecimal?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Count of bytes between strings

Postby jnkarthik » Wed Oct 27, 2010 9:24 pm

Hello NicC,

Thanks for the response. Yes you are correct. Is it possible to achieve?
jnkarthik
 
Posts: 14
Joined: Wed Oct 20, 2010 3:45 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Count of bytes between strings

Postby jnkarthik » Thu Oct 28, 2010 2:02 pm

Could some one able to respond on my query please?
jnkarthik
 
Posts: 14
Joined: Wed Oct 20, 2010 3:45 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Count of bytes between strings

Postby jnkarthik » Thu Oct 28, 2010 9:44 pm

Hello All,
To be more clear on my requriement,
I have binary file something as below and I need to find the byte count between &àã..... which is hexa decimal x'5044462D312E330A'. Can that be achieved via sort?
&àã.....
...?¦.....äÊÁ/È?Ê..áÌËÈÊÁ/_.àÑ/%?ÅÍÁ.îÁÊËÑ?>..........
äÊÁ/ÈÑ?>à/ÈÁ......................
 ÍÈÇ?Ê..êÁÅÑËÈÁÊÁÀ.È?..+|êïñäç...
èÑÈ%Á..ç..¬ øø%ÑÄ/ÈÑ?>¬.&¬<<íè¬î.....øÇ/ËÁ....
..Á>À?¦.
&àã.ã?>È..ã.....
.......?¦.
..
è`øÁ..ã?>È.
ëÍÂÈ`øÁ..è`øÁ..
á>Ä?ÀÑ>Å..............ê.
â/ËÁã?>È..çÁ%ÎÁÈÑÄ/.
..Á>À?¦..
&àã.ã?>È..ã.....
.......?¦.
..
...?¦.....è`øÁ..á>Ä?ÀÑ>Å..â/ËÁá>Ä?ÀÑ>Å..ïÑ> >ËÑá>Ä?ÀÑ>Å..àÑÃÃÁÊÁ>ÄÁË.£.
...Ëø/ÄÁ..ÁÌÄ%/_..ÉÍ?ÈÁÀÂ%..>Í_ÂÁÊËÑÅ>..À?%%/Ê..øÁÊÄÁ>È../_øÁÊË/>À..ÉÍ?ÈÁÊÑÅÇÈ..
øÁÊÑ?À..Ë%/ËÇ..:ÁÊ?..?>Á..ÈÏ?..ÈÇÊÁÁ..Ã?ÍÊ..ÃÑÎÁ..ËÑÌ..ËÁÎÁ>..ÁÑÅÇÈ..>Ñ>Á..Ä?%?>
 ..â..ä..à..á..ã..å..ç..ñ..$.....<..(..+..|..&..é..ê..ë..è..í..î..ï..ì..ß..!..ÂÊ
Í>ÀÁÊËÄ?ÊÁ..ÅÊ/ÎÁ../..Â..Ä..À..Á..Ã..Å..Ç..Ñ..¦..,..%.._..>..?..ø..É..Ê..Ë..È..Í
.>?ÈÀÁÃ..áÍÊ?...>?ÈÀÁÃ..ÉÍ?ÈÁËÑ>Å%Â/ËÁ..Ã%?ÊÑ>..ÉÍ?ÈÁÀÂ%Â/ËÁ..Á%%ÑøËÑË..À/ÅÅÁÊ..
|á...>?ÈÀÁÃ..!Ä/Ê?>...>?ÈÀÁÃ...>?ÈÀÁÃ..ÉÍ?ÈÁ%ÁÃÈ..ÉÍ?ÈÁÊÑÅÇÈ..ÉÍ?ÈÁÀÂ%%ÁÃÈ..ÉÍ?È
&àã.....
...?¦.....äÊÁ/È?Ê..áÌËÈÊÁ/_.àÑ/%?ÅÍÁ.îÁÊËÑ?>..........
äÊÁ/ÈÑ?>à/ÈÁ......................
 ÍÈÇ?Ê..êÁÅÑËÈÁÊÁÀ.È?..+|êïñäç...
èÑÈ%Á..ç..¬ øø%ÑÄ/ÈÑ?>¬.&¬<<íè¬î.....øÇ/ËÁ....
..Á>À?¦.
&àã.ã?>È..ã.....
.......?¦.
jnkarthik
 
Posts: 14
Joined: Wed Oct 20, 2010 3:45 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Count of bytes between strings

Postby skolusu » Thu Oct 28, 2010 10:10 pm

Jnkarthik,

I still don't understand what the final output is. You keep changing your version from displayable data to hex data.

If all you want is to validate hex data of X'5044462D312E330A' at position 5 (since your input is VB) then it is very simple. Use the following DFSORT JCL

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DSN=Your input VB file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                   
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,1,2,BI,SUB,+4,BI,LENGTH=2,5,8)),
  IFTHEN=(WHEN=GROUP,BEGIN=(7,8,CH,EQ,X'5044462D312E330A'),         
  PUSH=(15:ID=8))                                                   
  OUTFIL REMOVECC,NODETAIL,VTOF,BUILD=(80X),                         
  SECTIONS=(15,8,                                                   
  TRAILER3=('TOTAL BYTES FOR GROUP ',15,8,X,                         
             TOT=(5,2,BI,M10,LENGTH=8)))                             
//*


This will produce a report like this

TOTAL BYTES FOR GROUP 00000001       72
TOTAL BYTES FOR GROUP 00000002       65
TOTAL BYTES FOR GROUP 00000003       67


Do you need the byte count in hex ? like this ?

TOTAL BYTES FOR GROUP 00000001 404040404040F7F2
TOTAL BYTES FOR GROUP 00000002 404040404040F6F5
TOTAL BYTES FOR GROUP 00000003 404040404040F6F7
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: Count of bytes between strings

Postby jnkarthik » Fri Oct 29, 2010 12:31 am

Thanks Mr. Kolusu,
The output what you are producing is what I required exactly.
I tried your sample and it is working but I have 29 groups in my input file but the output produced only for one group. May be it has not found the searching criteria properly not sure why it is? Since it has taken the complete file, It produced me the complete file byte count instead of the group. Could you tell why this is so?
jnkarthik
 
Posts: 14
Joined: Wed Oct 20, 2010 3:45 pm
Has thanked: 0 time
Been thanked: 0 time

Next

Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post