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 

Extract first and fourth word

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


Joined: 17 Jul 2007
Posts: 6
Topics: 2
Location: India

PostPosted: Wed Jul 18, 2007 12:20 am    Post subject: Extract first and fourth word Reply with quote

Can I extract first and fifth words using DFSort, My problem is the input file was not allined prefectly

If I refrase my requirement , I need first word ( prefectly allingned )
and word following INCLUDE using DFSORT, any other JCL utility is OK

For example my input file looks like below
Code:

PBAT011        63  008012          INCLUDE LDSYR20
PBAT011      667  008016           INCLUDE   LDSYR00
PBAT011      671  008020              INCLUDE         LDOJT20
PBAT011      675  008024           INCLUDE LDOJT00
PBAT011      679  008028          INCLUDE   LDOTO20
PBAT011      683  008032           INCLUDE    LDOTO00
PBAT011      687  008036          INCLUDE LDOTT20


Thank u for ur time......
_________________
regards
Venkata Ratnam Mutyala
Back to top
View user's profile Send private message Yahoo Messenger
blitz2
Beginner


Joined: 23 Jan 2007
Posts: 84
Topics: 14

PostPosted: Wed Jul 18, 2007 2:37 am    Post subject: Reply with quote

Code:

"alloc f(inpfil) dsn('"userid.file"') shr reuse"
"execio * diskr inpfil (stem lines. finis"

do i=1 to lines.0
  line=word(lines.i, 1) || ' ' || word(lines.i, 5)
  lines.i = line
end

"alloc f(outpfil) dsn('"userid.file.out"') mod reuse"
"execio * diskw outpfil (stem lines. finis"
"free f(inpfil outpfil)"
exit



This is a simple rexx program that I have not tried. See if this works.
________
Washington medical marijuana dispensaries


Last edited by blitz2 on Thu Mar 10, 2011 5:31 pm; edited 1 time in total
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Wed Jul 18, 2007 4:35 am    Post subject: Reply with quote

This is untested and is a combination of extraction tricks in the DFSORT Tricks pdf.

Code:

//SORT    EXEC PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN    DD DSN= input file
//SORTOUT DD DSN= output file (FB 16)
//SYSIN      DD  *
  OPTION COPY
  INREC PARSE=(%=(ENDAT=C'INCLUDE'),
               %00=(STARTAFT=BLANKS,FIXLEN=8)),
        BUILD=(1,8,%00)
/*


The following is an explanation from the SortTricksPDF, substitute INCLUDE for COPY
Quote:
Here's how it works:

 ENDAT=C'COPY' finds the end of the 'COPY' string in each record. % is used because we don't need to
extact anything at this point.

 STARTAFT=BLANKS finds the next non-blank character after 'COPY'. FIXLEN=8 extracts the 8 bytes
starting at that non-blank into the %00 fixed parsed field.

 BUILD creates an output record with the 8-bytes we extracted into %00.

With the job above, if 'COPY' is not found in a record, the output record will contain blanks. If you don't want blank output records when the input doesn't have 'COPY', you can use DFSORT's substring search feature to only keep the records with 'COPY' in them:
INCLUDE COND=(1,n,SS,EQ,C'COPY')

_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Wed Jul 18, 2007 4:50 am    Post subject: Reply with quote

or using SYMNAMES
Code:

//SORT    EXEC PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES  DD  *
Fld1,1,8
Fld2,%00
/*
//SORTIN    DD  DSN= input file
//SORTOUT   DD  DSN= output file (FB 16)
//SYSIN     DD  *
  OPTION COPY
  INREC PARSE=(%=(ENDAT=C'INCLUDE'),
               Fld2=(STARTAFT=BLANKS,FIXLEN=8)),
        BUILD=(Fld1,Fld2)

_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
m_v_ratnam
Beginner


Joined: 17 Jul 2007
Posts: 6
Topics: 2
Location: India

PostPosted: Wed Jul 18, 2007 6:22 am    Post subject: Reply with quote

Hi Dick Brenholtz

Your script has worked well for my requirement. Thank you all for ur time to resolve my problem.

Very Happy Very Happy
_________________
regards
Venkata Ratnam Mutyala
Back to top
View user's profile Send private message Yahoo Messenger
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Wed Jul 18, 2007 7:41 am    Post subject: Reply with quote

m_v_ratnam,

thanks for the response, and I am very glad that it worked. Took me about 10 minutes to search manuals and find examples. Actually, DFSORT Tricks had everything that we needed.

To be honest, I have never used sort other than SORT FIELDS.

I provided you the answer, as I said, based on some really excellent documentation provided by the IBM DFSORT group. If an old fart like me can come up with a solution, anyone can. DFSORT documentation links can be found in Frank's signature on any post. As well as there is a sticky in the Utilities Forum 'Links to Reference Material'.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Jul 18, 2007 9:55 am    Post subject: Reply with quote

Way to go, Dick. Smile

Venkata,

For complete details on DFSORT's PARSE function, see:

www.ibm.com/servers/storage/support/software/sort/mvs/peug/
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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