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
 
Copy semicolon delimited data

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
puzzled_elton

New User


Joined: 09 May 2005
Posts: 7

PostPosted: Thu Jul 05, 2007 2:25 am    Post subject: Copy semicolon delimited data
Reply with quote

I have my data in a semicolon-delimited format. I have to write this data in to some other file with out semicolons.

But there is a chance of not having data in some fields. In that case a semicolon will be placed in that field. for example

INPUTFILE: 123;231;1;abvc;;;32;


if you see in the above example
123 should go to field1 of output file
231 should to to field2 of ouput file
1 should go to field3 of ouput file
abvc should go to field4 of output file
space should go to field5 of output file
sapce should go to field6 of output file
32 should go to field7 of output file

finally my output file should look like

OUTPUT FILE:field1field2field3field4field5filed6filed7

OUTPUT FILE: 1232311abvc 32
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Jul 05, 2007 2:46 am    Post subject:
Reply with quote

Hello,

If you switch to cobol, you can do this with a very simple program that reads your delimited input and UNSTRINGs it into a fixed record format (i.e. copybook), then writes the fixed length records.

The unstring will also accomodate fields of inconsistent lengths.

Let me know if you want this topic moved to cobol.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Jul 05, 2007 8:37 pm    Post subject:
Reply with quote

Here's a DFSORT job that will do what you asked for using DFSORT's PARSE and SQZ functions. The tricky part here is preserving a blank for each ;; value while not adding other blanks for the variable length values. You'll need z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006) in order to use DFSORT's PARSE and SQZ functions. If you don't have the April, 2006 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:

www.ibm.com/servers/storage/support/software/sort/mvs/peug/

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
123;231;1;abvc;;;32;
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
* Extract each field between the semicolons as a
* 10-character right-justified value.
  INREC IFTHEN=(WHEN=INIT,
    PARSE=(%01=(ENDBEFR=C';',FIXLEN=10),
           %02=(ENDBEFR=C';',FIXLEN=10),
           %03=(ENDBEFR=C';',FIXLEN=10),
           %04=(ENDBEFR=C';',FIXLEN=10),
           %05=(ENDBEFR=C';',FIXLEN=10),
           %06=(ENDBEFR=C';',FIXLEN=10),
           %07=(ENDBEFR=C';',FIXLEN=10)),
* Build a record with the extracted fields.
    BUILD=(1:%01,11:%02,21:%03,31:%04,41:%05,51:%06,61:%07)),
* Replace each blank extracted field with a X'FF' character so
* we can preserve the blank fields.
   IFTHEN=(WHEN=(1,1,CH,EQ,C' '),OVERLAY=(1:X'FF'),HIT=NEXT),
   IFTHEN=(WHEN=(11,1,CH,EQ,C' '),OVERLAY=(11:X'FF'),HIT=NEXT),
   IFTHEN=(WHEN=(21,1,CH,EQ,C' '),OVERLAY=(21:X'FF'),HIT=NEXT),
   IFTHEN=(WHEN=(31,1,CH,EQ,C' '),OVERLAY=(31:X'FF'),HIT=NEXT),
   IFTHEN=(WHEN=(41,1,CH,EQ,C' '),OVERLAY=(41:X'FF'),HIT=NEXT),
   IFTHEN=(WHEN=(51,1,CH,EQ,C' '),OVERLAY=(51:X'FF'),HIT=NEXT),
   IFTHEN=(WHEN=(61,1,CH,EQ,C' '),OVERLAY=(61:X'FF'))
* Squeeze out the blanks - keep the X'FF' characters.
  OUTREC IFTHEN=(WHEN=INIT,BUILD=(1,70,SQZ=(SHIFT=LEFT))),
* Replace each X'FF' character with a blank.
    IFTHEN=(WHEN=INIT,BUILD=(1,70,TRAN=ALTSEQ))
  ALTSEQ CODE=(FF40)
/*
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Extract record for change in combinat... Trinadh DFSORT/ICETOOL 5 Thu Nov 23, 2017 3:32 pm
No new posts Fetching data from JHS as per the cur... arunsoods All Other Mainframe Topics 4 Wed Nov 22, 2017 1:54 pm
No new posts Compare and COPY using DFSORT pshongal DFSORT/ICETOOL 3 Fri Nov 17, 2017 9:49 am
No new posts Extract Record using range of Data scorp_rahul23 DFSORT/ICETOOL 3 Wed Nov 15, 2017 11:54 pm
No new posts Updating data from one file to other!!! Vignesh Sid SYNCSORT 1 Mon Nov 06, 2017 2:42 pm

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