Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Copying only first and last word from a record

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT
View previous topic :: :: View next topic  
Author Message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 271
Location: Mumbai

PostPosted: Wed Jan 31, 2018 4:19 pm    Post subject: Copying only first and last word from a record
Reply with quote

Hi All,

I tries to search on forum for this requirement but could not find appropriate post.

My input file is as below

Code:
TestA, testA1 testA2 testA3
TestB, testB1 testB2
TestC, testC1 testC2 testC3 TestC4


And I need output file as below
Code:

TestA testA3
TestB testB2
TestC TestC4


Basically I want to copy only first and last word from records. Its FB file of length 40.

is it possible to do with Syncsort?

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

RahulG31

Active User


Joined: 20 Dec 2014
Posts: 414
Location: USA

PostPosted: Wed Jan 31, 2018 10:51 pm    Post subject: Reply to: Copying only first and last word from a record
Reply with quote

It should Not be too difficult with PARSE considering the LRECL is only 40 bytes so you can fit in only a few words:
Code:
 INREC IFTHEN=(WHEN=INIT,PARSE=(%00=(ENDBEFR=C', ',FIXLEN=10),
              %01=(ENDBEFR=C' ',FIXLEN=10),
              %02=(ENDBEFR=C' ',FIXLEN=10),
              %03=(ENDBEFR=C' ',FIXLEN=10),
              %04=(FIXLEN=10)),BUILD=(%00,%01,%02,%03,%04)),
      IFTHEN=(WHEN=(41,1,CH,NE,C' '),
      BUILD=(%00,C' ',%04)),
      IFTHEN=(WHEN=(31,1,CH,NE,C' '),
      BUILD=(%00,C' ',%03)),
      IFTHEN=(WHEN=(21,1,CH,NE,C' '),
      BUILD=(%00,C' ',%02)),
      IFTHEN=(WHEN=(11,1,CH,NE,C' '),
      BUILD=(%00,C' ',%01))
 OPTION COPY


It may Not be the best solution but you can work from here.

If you are concerned about the spaces then you may use FINDREP=(INOUT=(C' ',C'~') and JFY=(SHIFT=RIGHT) and SQZ=(SHIFT=LEFT) wherever needed.

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

Active User


Joined: 29 Apr 2008
Posts: 261
Location: Maryland

PostPosted: Thu Feb 01, 2018 12:22 am    Post subject: Re: Reply to: Copying only first and last word from a record
Reply with quote

Can be enhanced, to make the code more flexible, to handle free-text input.
RahulG31 wrote:
Code:
 INREC IFTHEN=(WHEN=INIT,
         PARSE=(%00=(STARTAT=NONBLANK,ENDBEFR=C',',ENDBEFR=BLANKS,FIXLEN=10),
                %01=(STARTAT=NONBLANK,ENDBEFR=C',',ENDBEFR=BLANKS,FIXLEN=10),
                %02=(STARTAT=NONBLANK,ENDBEFR=C',',ENDBEFR=BLANKS,FIXLEN=10),
                %03=(STARTAT=NONBLANK,ENDBEFR=C',',ENDBEFR=BLANKS,FIXLEN=10),
                %04=(STARTAT=NONBLANK,ENDBEFR=C',',ENDBEFR=BLANKS,FIXLEN=10)),
         BUILD=(%00,%01,%02,%03,%04)),
      IFTHEN=(WHEN=(41,1,CH,NE,C' '),
         BUILD=(%00,C' ',%04)),
      IFTHEN=(WHEN=(31,1,CH,NE,C' '),
         BUILD=(%00,C' ',%03)),
      IFTHEN=(WHEN=(21,1,CH,NE,C' '),
         BUILD=(%00,C' ',%02)),
      IFTHEN=(WHEN=(11,1,CH,NE,C' '),
         BUILD=(%00,C' ',%01))
 OPTION COPY
 END

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

Active User


Joined: 03 Nov 2005
Posts: 271
Location: Mumbai

PostPosted: Thu Feb 01, 2018 3:48 pm    Post subject: Reply to: Copying only first and last word from a record
Reply with quote

Thanks for the reply guys.

I will try this. Only issue I didn't highlight in original post is my input words can be of different length.

But I will check with these solutions. it should work
Back to top
View user's profile Send private message
sergeyken

Active User


Joined: 29 Apr 2008
Posts: 261
Location: Maryland

PostPosted: Fri Feb 02, 2018 3:22 am    Post subject: Re: Reply to: Copying only first and last word from a record
Reply with quote

chandan.inst wrote:
Only issue I didn't highlight in original post is my input words can be of different length.

PARSE= will handle different length. Furthermore, STARTAFT=BLANKS,ENDBEFR=BLANKS will take care of any number of separating blanks.

You may need to set FIXLEN= to the maximum possible word length.

In the output record, you can use parameters JFY= and/or SQZ= to truncate unneeded blanks in output record.
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 -> SYNCSORT 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 select record x+7 or x+2 based... JoAnn Kulcyk SYNCSORT 6 Tue Jan 16, 2018 10:49 pm
No new posts ISSUE IN copying Sequential file reco... thesumitk JCL & VSAM 2 Wed Dec 13, 2017 3:07 pm
No new posts query to fetch record which has only ... maxsubrat DB2 12 Mon Dec 11, 2017 5:03 pm
No new posts Extract record for change in combinat... Trinadh DFSORT/ICETOOL 6 Thu Nov 23, 2017 3:32 pm
No new posts Extract Record using range of Data scorp_rahul23 DFSORT/ICETOOL 3 Wed Nov 15, 2017 11:54 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us