IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Copy semicolon delimited data


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Thu Jul 05, 2007 2:46 am
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 Developer


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

PostPosted: Thu Jul 05, 2007 8:37 pm
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:

Use [URL] BBCode for External Links

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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to save SYSLOG as text data via P... All Other Mainframe Topics 4
No new posts Store the data for fixed length COBOL Programming 1
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts VB to VB copy - Full length reached SYNCSORT 8
No new posts SCOPE PENDING option -check data DB2 2
Search our Forums:

Back to Top