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
 

 

Get particular entries with a string to output

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Mon Dec 23, 2013 8:57 pm    Post subject: Get particular entries with a string to output
Reply with quote

Hi,

I have a file (LRECL=80,RECFM=FB) as shown below -

Input:-
Code:

AB123 CD12C GX139 DCGVN DCG98 XY22Y DCGUN
CD12C DCGTN UB153 DCGT7 DCGMN
DCGBN AB123 DCG06 CD12C DHGON XY22Y GX139
XY22Y DCGXN AB123 DCG19 CD12C DCGIN
DCGHN AB123 DCG48 CD12C DCGON MERBL HENRY DCGXI


I would like to pull all the strings that start with "DCG" to output file.

Expected Output:
Code:

DCGVN DCG98 DCGUN
DCGTN DCGT7 DCGMN
DCGBN DCG06
DCGXN DCG19 DCGIN
DCGHN DCG48 DCGON DCGXI


I have tried INREC PARSE with substring search but getting first occurence only. Please help.

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

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Mon Dec 23, 2013 9:28 pm    Post subject: Reply to: Get particular entries with a string to output
Reply with quote

PARSE is what you want, so you'd best show what you tried that didn't work.
Back to top
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Tue Dec 24, 2013 8:20 am    Post subject:
Reply with quote

Hi Ramsri,

Could you give us the code you've tried?
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Tue Dec 24, 2013 1:10 pm    Post subject: Reply to: Get particular entries with a string to output
Reply with quote

This is what I tried and its output -

Sort Card:
Code:

//STEP0001 EXEC PGM=SORT                               
//SORTIN   DD *                                         
AB123 CD12C GX139 DCGVN DCG98 XY22Y DCGUN               
CD12C DCGTN UB153 DCGT7 DCGMN                           
DCGBN AB123 DCG06 CD12C DHGON XY22Y GX139               
XY22Y DCGXN AB123 DCG19 CD12C DCGIN                     
DCGHN AB123 DCG48 CD12C DCGON MERBL HENRY DCGXI         
//SORTOUT  DD SYSOUT=*                                 
//SYSOUT   DD SYSOUT=*                                 
//SYSIN    DD *                                         
  SORT FIELDS=COPY                                     
  INREC IFTHEN=(WHEN=(1,80,SS,EQ,C'DCG'),               
        PARSE=(%01=(ABSPOS=1,STARTAT=C'DCG',FIXLEN=5)),
               BUILD=(%01))                             


Output:-
Code:

DCGVN
DCGTN
DCGBN
DCGXN
DCGHN


Expected Output:-
Code:

DCGVN DCG98 DCGUN
DCGTN DCGT7 DCGMN
DCGBN DCG06
DCGXN DCG19 DCGIN
DCGHN DCG48 DCGON DCGXI


What should I change in sort card to get expected results?
Thanks.
Back to top
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Tue Dec 24, 2013 1:47 pm    Post subject: Reply to: Get particular entries with a string to output
Reply with quote

Ramsri,

You can try this code -

Code:


//SORT1     EXEC PGM=SORT
//SPRINT DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
AB123 CD12C GX139 DCGVN DCG98 XY22Y DCGUN
CD12C DCGTN UB153 DCGT7 DCGMN
DCGBN AB123 DCG06 CD12C DHGON XY22Y GX139
XY22Y DCGXN AB123 DCG19 CD12C DCGIN
DCGHN AB123 DCG48 CD12C DCGON MERBL HENRY DCGXI
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  INREC IFTHEN=(WHEN=(37,3,CH,NE,C'DCG'),
                  BUILD=(1,36,37:43,5,43:5X),HIT=NEXT),
        IFTHEN=(WHEN=(31,3,CH,NE,C'DCG'),
                  BUILD=(1,30,31:37,5,37:43,5),HIT=NEXT),
        IFTHEN=(WHEN=(25,3,CH,NE,C'DCG'),
                  BUILD=(1,24,25:31,5,31:37,5,37:43,5),HIT=NEXT),
        IFTHEN=(WHEN=(19,3,CH,NE,C'DCG'),
                  BUILD=(1,18,19:25,5,25:31,5,31:37,5),HIT=NEXT),
        IFTHEN=(WHEN=(13,3,CH,NE,C'DCG'),
                  BUILD=(1,12,13:19,5,19:25,5,25:31,5),HIT=NEXT),
   IFTHEN=(WHEN=(07,3,CH,NE,C'DCG'),
             BUILD=(1,6,7:13,5,13:19,5,19:25,5),HIT=NEXT),
        IFTHEN=(WHEN=(01,3,CH,NE,C'DCG'),
                  BUILD=(1:7,5,7:13,5,13:19,5,19:25,5))
   SORT FIELDS=COPY
   


Output :-

Code:

DCGVN DCG98 DCGUN     
DCGTN DCGT7 DCGMN     
DCGBN DCG06           
DCGXN DCG19 DCGIN     
DCGHN DCG48 DCGON DCGXI


Regards,
-3nadh
Back to top
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Tue Dec 24, 2013 2:00 pm    Post subject:
Reply with quote

Ramsri,

Alternatively, you can use this as well.

Code:

//STEP0001 EXEC PGM=SORT                       
//SORTIN   DD *                                 
AB123 CD12C GX139 DCGVN DCG98 XY22Y DCGUN       
CD12C DCGTN UB153 DCGT7 DCGMN                   
DCGBN AB123 DCG06 CD12C DHGON XY22Y GX139       
XY22Y DCGXN AB123 DCG19 CD12C DCGIN             
DCGHN AB123 DCG48 CD12C DCGON MERBL HENRY DCGXI
//SORTOUT  DD SYSOUT=*                         
//SYSOUT   DD SYSOUT=*                         
//SYSIN    DD *                                 
  SORT FIELDS=COPY                             
  OUTREC PARSE=(%01=(STARTAT=C'DCG',FIXLEN=6), 
               %02=(STARTAT=C'DCG',FIXLEN=6),   
               %03=(STARTAT=C'DCG',FIXLEN=6),   
               %04=(STARTAT=C'DCG',FIXLEN=6),   
               %05=(STARTAT=C'DCG',FIXLEN=6),   
               %06=(STARTAT=C'DCG',FIXLEN=6),   
               %07=(STARTAT=C'DCG',FIXLEN=6),   
               %08=(STARTAT=C'DCG',FIXLEN=6)), 
        BUILD=(%01,%02,%03,%04,%05,%06,%07,%08)             


output:
Code:

DCGVN DCG98 DCGUN     
DCGTN DCGT7 DCGMN     
DCGBN DCG06           
DCGXN DCG19 DCGIN     
DCGHN DCG48 DCGON DCGXI
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Tue Dec 24, 2013 2:05 pm    Post subject: Reply to: Get particular entries with a string to output
Reply with quote

3nadh and Suresh, thanks for the solutions. I wonder how to work it out if an input records has got more than 30 "DCG" coming in !! I thought SORT could provide a simpler solution icon_confused.gif Looks like I need to try Easytrieve.

Thanks again.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Tue Dec 24, 2013 2:44 pm    Post subject: Reply to: Get particular entries with a string to output
Reply with quote

3nadh, based on your idea, I have written below code but does not get SQZ working......can you please help?

Code:

SORT FIELDS=COPY                                                   
INREC IFTHEN=(WHEN=(1,3,CH,EQ,C'DCG'),OVERLAY=(50:1,5),HIT=NEXT), 
      IFTHEN=(WHEN=(7,3,CH,EQ,C'DCG'),OVERLAY=(56:7,5),HIT=NEXT), 
      IFTHEN=(WHEN=(13,3,CH,EQ,C'DCG'),OVERLAY=(62:13,5),HIT=NEXT),
      IFTHEN=(WHEN=(19,3,CH,EQ,C'DCG'),OVERLAY=(68:19,5),HIT=NEXT),
      IFTHEN=(WHEN=(25,3,CH,EQ,C'DCG'),OVERLAY=(74:25,5),HIT=NEXT),
      IFTHEN=(WHEN=(31,3,CH,EQ,C'DCG'),OVERLAY=(80:31,5),HIT=NEXT),
      IFTHEN=(WHEN=(37,3,CH,EQ,C'DCG'),OVERLAY=(86:37,5),HIT=NEXT),
      IFTHEN=(WHEN=(43,3,CH,EQ,C'DCG'),OVERLAY=(92:43,5),HIT=NEXT)
OUTREC BUILD=(50,5,X,56,5,X,62,5,X,68,5,X,74,5,X,80,5,X,86,       
              5,X,92,5,SQZ=(SHIFT=LEFT))                           


Output with above card:-
Code:

                  DCGVN DCG98       DCGUN     
      DCGTN       DCGT7 DCGMN                 
DCGBN       DCG06                             
      DCGXN       DCG19       DCGIN           
DCGHN       DCG48       DCGON             DCGXI


Thanks.
Back to top
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Tue Dec 24, 2013 3:13 pm    Post subject: Reply to: Get particular entries with a string to output
Reply with quote

Ramsri,

Quote:

I wonder how to work it out if an input records has got more than 30 "DCG" coming in !! I thought SORT could provide a simpler solution Looks like I need to try Easytrieve.


If your input contains 30 "DCG" then you can try Suresh's code which is pretty simple than mine.


Thanks
-3nadh
Back to top
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Tue Dec 24, 2013 3:33 pm    Post subject: Reply to: Get particular entries with a string to output
Reply with quote

Ramsri,

And i observed that your sort card doing manipulation from left to Right where as mine it is doing from Right to Left...

My Code -
Code:

//SYSIN    DD *
  INREC IFTHEN=(WHEN=(37,3,CH,NE,C'DCG'),
                  BUILD=(1,36,37:43,5,43:5X),HIT=NEXT),
        IFTHEN=(WHEN=(31,3,CH,NE,C'DCG'),
                  BUILD=(1,30,31:37,5,37:43,5),HIT=NEXT),
        IFTHEN=(WHEN=(25,3,CH,NE,C'DCG'),
                  BUILD=(1,24,25:31,5,31:37,5,37:43,5),HIT=NEXT),
-
-
-


Your code -

Code:

SORT FIELDS=COPY                                                   
INREC IFTHEN=(WHEN=(1,3,CH,EQ,C'DCG'),OVERLAY=(50:1,5),HIT=NEXT), 
      IFTHEN=(WHEN=(7,3,CH,EQ,C'DCG'),OVERLAY=(56:7,5),HIT=NEXT), 
      IFTHEN=(WHEN=(13,3,CH,EQ,C'DCG'),OVERLAY=(62:13,5),HIT=NEXT),
      IFTHEN=(WHEN=(19,3,CH,EQ,C'DCG'),OVERLAY=(68:19,5),HIT=NEXT),
-
-
-
-


So, please change accordingly and Check again...

Thanks
-3nadh
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Tue Dec 24, 2013 3:40 pm    Post subject: Reply to: Get particular entries with a string to output
Reply with quote

The problem with the existing PARSE suggestions is that they will pick up "embedded" DCGs (have some in your test data, your test data is for testing, so it should actually test things).

Code:
  SORT FIELDS=COPY                             
  INREC IFTHEN=(WHEN=INIT,BUILD=(X,1,80),
               IFTHEN=(WHEN=INIT,                 
            PARSE=(%01=(STARTAT=C' DCG',FIXLEN=7),
               %02=(STARTAT=C' DCG',FIXLEN=7),   
               %03=(STARTAT=C' DCG',FIXLEN=7),   
               %04=(STARTAT=C' DCG',FIXLEN=7),   
               %05=(STARTAT=C' DCG',FIXLEN=7),   
               %06=(STARTAT=C' DCG',FIXLEN=7),   
               %07=(STARTAT=C' DCG',FIXLEN=7),   
               %08=(STARTAT=C' DCG',FIXLEN=7)),
               IFTHEN=(WHEN=INIT,                 
        BUILD=(%01,%02,%03,%04,%05,%06,%07,%08,82:X)),
               IFTHEN=(WHEN=INIT,                 
        BUILD=(2,80)),


Inserts a blank at the start of the record. Starts a PARSEd field only with " DCG". Puts line back together with only extracted data, and ensuring blank-padding up to and including 82 if necessary (you can get up to 11 fields into your 80-byte records ramsri, not 30). Removes the leading blank. Untested, but you should get the picture.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Tue Dec 24, 2013 3:59 pm    Post subject: Reply to: Get particular entries with a string to output
Reply with quote

Bill, this is the output I got with your sort card icon_confused.gif

Code:

DCGVN  DCGUN             
DCGTN  DCGT7             
DCGBN  DCG06             
DCGXN  DCG19  DCGIN       
DCGHN  DCG48  DCGON  DCGXI


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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Tue Dec 24, 2013 4:21 pm    Post subject: Reply to: Get particular entries with a string to output
Reply with quote

Are you complaining about the spacing? If so, I'd have hoped that was something you could cope with yourself. I erroneously changed the lengths from 6 to 7, not realising the text was in groups of five so there was a trailing blank already (which I make leading, and keep the trailing one).

If you think PARSE isn't working you'd best show your input data.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Tue Dec 24, 2013 6:30 pm    Post subject: Reply to: Get particular entries with a string to output
Reply with quote

Bill, your idea has worked.....I got errors with your code thus modified it and it has worked.......no issues.

Thanks a lot.
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts Syncsort - Hard coded Value in output PORYES SYNCSORT 1 Thu Nov 03, 2016 9:23 am
No new posts output data in CSV Format janmejay COBOL Programming 8 Sat Oct 15, 2016 2:20 pm
This topic is locked: you cannot edit posts or make replies. output data in CSV Format janmejay DFSORT/ICETOOL 3 Sat Oct 15, 2016 2:16 pm
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am


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