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 

Easytrieve code snippet - pull strings with "DCG"

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
ranga_subham
Intermediate


Joined: 31 Jan 2006
Posts: 255
Topics: 72

PostPosted: Sat Jan 18, 2014 9:52 pm    Post subject: Easytrieve code snippet - pull strings with "DCG" Reply with quote

Hi, Can you please help me with EASYTRIEVE code to achieve below output?

Input:- LRECL=400,RECFM=FB
Code:

INPUT1 DCG01 DCG02 ABY98 CLR84 DCM45
INPUT2 DCX09 FLJ94 DCG05 MAR85
INPUT3 FIN44 FPT34 DCR03 DGC18 DCG09 DCG#0 DCX99
INPUT4 FOT14 RPT32 TCR07 MGC15 DCG24
INPUT5 NON90 BOX84 CTT32 MOT45 COL25 FIN43
INPUT6 LAS99
...
...


The input has got million records. I would like to pull all the records having string starting with "DCG" to output using EASYTRIEVE. The string with "DCG" can appear within LRECL of 400 (66 possibilities in one record !!)

Expected Output:-
Code:

INPUT1 DCG01 DCG02
INPUT2 DCG05
INPUT3 DCG09 DCG#0
INPUT4 DCG24


Please help.

Thanks.
_________________
Ranga
*****
None of us is as smart as all of us - Ken Blanchard
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Sun Jan 19, 2014 10:53 pm    Post subject: Reply with quote

ranga_subham,

You have been a member of this forum for about 7 years and you haven't even searched the topics for a similar solution. Check these links. Change the samples to suit your requirement.

http://mvsforums.com/helpboards/viewtopic.php?p=8920#8920

http://mvsforums.com/helpboards/viewtopic.php?p=19400#19400

http://mvsforums.com/helpboards/viewtopic.php?p=42807#42807
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ranga_subham
Intermediate


Joined: 31 Jan 2006
Posts: 255
Topics: 72

PostPosted: Mon Jan 20, 2014 2:44 am    Post subject: thanks Reply with quote

Thanks Kolusu.....I will try this
_________________
Ranga
*****
None of us is as smart as all of us - Ken Blanchard
Back to top
View user's profile Send private message
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Tue Jan 21, 2014 12:36 pm    Post subject: Reply with quote

Is there some reason to use Easytrieve?

I suspect your sort product would show better performance . . .
_________________
All the best,

di
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Jan 21, 2014 4:12 pm    Post subject: Reply with quote

As Papadi pointed out we can use DFSORT parse function to get the desired results. With DFSORT V2R1 which was available from Sep 30th 2013 you can use REPEAT=n for parsing fields with same length.

The following DFSORT JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                       
----+----1----+----2----+----3----+----4----+----5----+----6----+----7
INPUT1 DCG01 DCG02 ABY98 CLR84 DCM45                                 
INPUT2 DCX09 FLJ94 DCG05 MAR85                                       
INPUT3 FIN44 FPT34 DCR03 DGC18 DCG09 DCG#0 DCX99                     
INPUT4 FOT14 RPT32 TCR07 MGC15 DCG24                                 
INPUT5 NON90 BOX84 CTT32 MOT45 COL25 FIN43                           
INPUT6 LAS99                                                         
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                       
  OPTION COPY                                                         
  INREC PARSE=(%01=(ABSPOS=7,STARTAT=C'DCG',ENDAT=C' ',FIXLEN=6),     
               %02=(STARTAT=C'DCG',ENDAT=C' ',FIXLEN=6,REPEAT=65)),   
       BUILD=(1,7,                                                   
              %01,%02,%03,%04,%05,%06,%07,%08,%09,%10,               
              %11,%12,%13,%14,%15,%16,%17,%18,%19,%20,               
              %21,%22,%23,%24,%25,%26,%27,%28,%29,%30,               
              %31,%32,%33,%34,%35,%36,%37,%38,%39,%40,               
              %41,%42,%43,%44,%45,%46,%47,%48,%49,%50,               
              %51,%52,%53,%54,%55,%56,%57,%58,%59,%60,               
              %61,%62,%63,%64,%65,%66)                               
                                                                     
  OUTFIL OMIT=(8,6,CH,EQ,C' ')                                       
//*
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ranga_subham
Intermediate


Joined: 31 Jan 2006
Posts: 255
Topics: 72

PostPosted: Wed Jan 22, 2014 6:09 am    Post subject: thanks Reply with quote

Kolusu, thank you very much for SORT solution. I did not know that it was difficult to achieve it by Easytrieve due to its limited functionality (read it from one of your posts).

Thanks again.
_________________
Ranga
*****
None of us is as smart as all of us - Ken Blanchard
Back to top
View user's profile Send private message
ranga_subham
Intermediate


Joined: 31 Jan 2006
Posts: 255
Topics: 72

PostPosted: Wed Jan 22, 2014 6:12 am    Post subject: Reply with quote

Papadi/Kolusu, from doco, I learnt that only 100 parse are supported. A programmatic approach would not have such limitation......pls correct me if I am wrong....thanks again.
_________________
Ranga
*****
None of us is as smart as all of us - Ken Blanchard
Back to top
View user's profile Send private message
William Collins
Supermod


Joined: 03 Jun 2012
Posts: 437
Topics: 0

PostPosted: Wed Jan 22, 2014 10:06 am    Post subject: Reply with quote

66 is less than 100. What problem does it give you? Current DFSORT has more PARSE fields, which you'd know if you'd followed up on Kolusu's comment on the subject.

What do you feel is Easytrieve Plus's "limited functionality"? No support for the DWIW and DWIM commands?

Can you explain, exactly, what the state of your requirement is. You have a SORT solution which will work for the record-length that you stated that you have. You have some Easytrieve Plus examples. Are you now happy, or what is it that makes you unhappy?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Jan 22, 2014 11:56 am    Post subject: Re: thanks Reply with quote

ranga_subham wrote:
Kolusu, thank you very much for SORT solution. I did not know that it was difficult to achieve it by Easytrieve due to its limited functionality (read it from one of your posts).

Thanks again.


ranga_subham,

Which post are you referring to? You have been given specific examples and you are still finding it difficult to complete the job you are given, when all you need is to just change the length of the string and the array to be searched? Wow!! Are you expecting us to give you fully tested code so that you can simply copy and paste it? Please lower your expectations if you think you can get complete code.

ranga_subham wrote:
Papadi/Kolusu, from doco, I learnt that only 100 parse are supported. A programmatic approach would not have such limitation......pls correct me if I am wrong....thanks again.


Lets be clear on something here. Your requirement of handling 66 occurrences fall within the existing limit of 100 for parse function. What is the problem here then? Secondly With DFSORT z/OS V2R1 which has been official released as of September 30 2013, You can now use up to 1000 parsed fields (%0-%999) with the PARSE function; the previous limit was 100 parsed fields (%0-%99).
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ranga_subham
Intermediate


Joined: 31 Jan 2006
Posts: 255
Topics: 72

PostPosted: Wed Jan 22, 2014 8:59 pm    Post subject: Reply with quote

wow......its increased to 1000......great news....I will take some more time to finish my easytrieve progam and put it here..... try and error Cool
_________________
Ranga
*****
None of us is as smart as all of us - Ken Blanchard
Back to top
View user's profile Send private message
ranga_subham
Intermediate


Joined: 31 Jan 2006
Posts: 255
Topics: 72

PostPosted: Wed Jan 29, 2014 9:43 am    Post subject: all I could do Reply with quote

Kolusu, this is all I could do with my Easytrieve knowledge (learning though)

Code:

//STEP0100 EXEC PGM=EZTPA00                       
//SYSPRINT DD SYSOUT=*                           
//SYSOUT   DD SYSOUT=*                           
//SYSSNAP  DD SYSOUT=*                           
//SYSUDUMP DD SYSOUT=*                           
//OUTPUT   DD SYSOUT=*,LRECL=80,RECFM=FB,BLKSIZE=0
//INFILE   DD *                                   
INPUT1 DCG01 DCG02 ABY98 CLR84 DCM45             
INPUT2 DCX09 FLJ94 DCG05 MAR85                   
INPUT3 FIN44 FPT34 DCR03 DGC18 DCG09 DCG#0 DCX99 
INPUT4 FOT14 RPT32 TCR07 MGC15 DCG24             
INPUT5 NON90 BOX84 CTT32 MOT45 COL25 FIN43       
INPUT6 LAS99                                     
//SYSIN    DD *                                   
  FILE INFILE                                     
       IN-REC          1 50 A                                           
       IN-FLD1         1 06 A                                           
       IN-FLD2         8 42 A                                           
       IN-DCG6 IN-FLD2   06 A OCCURS 7 INDEX IN-IDX                     
*                                                                       
  FILE OUTPUT                                                           
       O-REC           001 200 A                                       
*                                                                       
  WS-F7                W   06 A                                         
  WS-ARR1              W   018 A                                       
  WS-DCG6 WS-ARR1          006 A OCCURS 003 INDEX OT-IDX               
***********************************************************************
* MAINLINE                                                            *
***********************************************************************
 JOB INPUT INFILE                                                       
                                                                       
   MOVE IN-FLD1 TO WS-F7                                               
   IN-IDX = 1                                                           
   DO WHILE IN-IDX LE 7                                                 
      IF IN-DCG6(IN-IDX) = 'DCG01 ' 'DCG02 ' 'DCG05 ' 'DCG09 ' +
                           'DCG#0 ' 'DCG24 '                   
         DISPLAY WS-F7                                           
         DISPLAY IN-DCG6(IN-IDX)                                 
         MOVE IN-DCG6(IN-IDX) TO WS-DCG6(OT-IDX)                 
      END-IF                                                     
   IN-IDX = IN-IDX + 1                                           
   END-DO                                                       
/*                                                               


Not able to assign it to output (certainly something wrong Sad ) but displayed it Cool

Output:
Code:

INPUT1     
DCG01     
INPUT1     
DCG02     
INPUT2     
DCG05     
INPUT3     
DCG09     
INPUT3     
DCG#0     
INPUT4     
DCG24     


Later, as a trial, added below piece of code and got S0C4 -
Code:

         OT-IDX = OT-IDX + 1   
         DISPLAY WS-ARR1       


SYSPRINT:-
Code:

SORT (DEVICE SYSDA  ALTSEQ NO  MSG DEFAULT  MEMORY MAX   WORK   3)  VFM (   64)
INPUT1                                                                         
DCG01                                                                           
                                                                               
INPUT1                                                                         
DCG02                                                                           
    23 *******A006 PROGRAM INTERRUPT - CODE 4 (PROTECTION EXCP)                 
INTERRUPT OCCURRED AT 02AA BLOCK   1 FROM EP EASYTRIEVE PLUS 11.5-C  SP0- 1/29/1
INSTRUCTION AT 000172BA   IS D205830A7001                                       
FIRST  OPERAND ADDRESS 0000D7CD                                                 
SECOND OPERAND ADDRESS 0000E6D5                                                 
PSW+4 AT INTERRUPT  800172C0                                                   
REGISTERS AT INTERRUPT                                                         
 R0  00011870  R1  FFFEE790  R2  000111CE  R3  00023010  R4  00011000  R5  00013
 R8  0000D4C3  R9  00011250  R10 ACC075BC  R11 00017010  R12 857A1022  R13 0000B
FILE ID/NAME     RECORD ADDRESS     RECORD LENGTH      STATUS                   
 1/29/2014  9.40.52                           EASYTRIEVE PLUS 11.5-C  SP0       


Kolusu, please help.

Thanks.
_________________
Ranga
*****
None of us is as smart as all of us - Ken Blanchard
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Jan 29, 2014 1:01 pm    Post subject: Re: all I could do Reply with quote

ranga_subham wrote:
Kolusu, this is all I could do with my Easytrieve knowledge (learning though)
Not able to assign it to output (certainly something wrong Sad ) but displayed it Cool

Later, as a trial, added below piece of code and got S0C4 -

Kolusu, please help.

Thanks.


ranga_subham,

You need a PUT statement to write out to the OUTPUT, I don't see anything in regards to that and no wonder you cannot assign it to output.

You have an example code and yet you cannot adjust it to your requirements. *Sigh*

Here is an untested code.

Understand the code and know exactly how it is working, instead of simply copying it.

Code:

//SYSIN    DD *                                               
                                                               
  FILE INFILE
       IN-KEY           01 007 A
       IN-ARRAY         08 003 A OCCURS 132 INDEX IDX3
       IN-DCG6          08 006 A OCCURS 066 INDEX IDX6
                                                               
  FILE OUTPUT FB(0 0)               
       O-REC            01 403 A
       O-KEY            01 007 A
       O-ARRAY          08 006 A OCCURS 66 INDEX ODX

***********************************************************************
* MAINLINE                                                            *
***********************************************************************
                                                                       
 JOB INPUT INFILE                                                     
                                                                       
   IDX3   = 1
   IDX6   = 1
   ODX    = 1
   O-REC  = ' '
   O-KEY  = IN-KEY
                                             
   DO UNTIL IDX3 > 132                             
      IF IN-ARRAY(IDX3) = 'DCG'
         IDX6 = (IDX3 / 2 ) + 1
         MOVE IN-DCG6(IDX6) TO O-ARRAY(ODX)
         ODX  = ODX + 1
      END-IF
      IDX3 = IDX3 + 2
   END-DO

   IF O-ARRAY(1) > '      '
      PUT OUTPUT           
   END-IF                   
//*



Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ranga_subham
Intermediate


Joined: 31 Jan 2006
Posts: 255
Topics: 72

PostPosted: Tue Feb 04, 2014 3:20 am    Post subject: Reply with quote

Kolusu, thank you.......I've got the expected results Very Happy
_________________
Ranga
*****
None of us is as smart as all of us - Ken Blanchard
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
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