Page 1 of 1

Creating a Pipe Delimited File

PostPosted: Mon Jan 30, 2012 5:55 pm
by riverspree
Currently I am working on setting up a pipe delimited download file. The file will then be used by a reporting application at my company and stored in SQL. The application will identify the pipes then separate and move the data to the tables. However I’m still pretty new to a lot of this and am having a little bit of a challenge setting this one up. So to the interwebs I have gone!

(I hope this makes sense as I am still learning some of the terminology/process flows – I further realize this may kind of be “well duh” information, but again I’m new to a lot of this.)

My question is how would I set it up so that the data is delimited after the file containg the data is read? Would I modify the copybook so that when the data is read and moved into that CPY the delimitation is set up there? Or would the delimitation occur during the perform/move process in the source/program code – or other? Sorry if this is vague, I was unsure how to word.

If you need anymore information or better clarification on something please let me know. I realize I may have something worded incorrectly/vaguely because of a lack of student experience. Just let me know and I’ll do my best to provide it.

*Information has been modified to show and example of my data layout but not actual values to protect company rights/privacy*

Copybook
01 STR-ORACLE-DETAIL-RECORD.
03 STR-RECORD-TYPE PIC X(1).
88 STR-DETAIL-RECORD VALUE '1'.
03 STR-DATA-TYPE PIC X(1).
03 STR-PRE-SUBSTITUTION-DATA.
05 STR-DATA1 PIC X(1).
05 STR-DATA2 PIC X(4).
05 STR-DATA3 PIC X(5).
05 STR-DATA4 PIC X(3).
05 STR-DATA5 PIC X(3).
05 STR-DATA6 PIC X.
05 STR-DATA7 PIC X(3).
05 STR-DATA8 PIC X.
05 STR-DATA9 PIC 9(3).
05 STR-DATA10 PIC 9(3).
05 STR-DATA11 PIC +9(11)V9(2).
05 STR-DATA12 PIC +9(11)V9(2).
05 STR-DATA13 PIC +9(11)V9(2).
05 FILLER PIC X(15).
03 STR-PRE-SUBSTITION-DATA.
05 STR-QUARTER-DIV PIC X(1).
05 STR-PST-DIV PIC +9(11)V9(2).
ETC….

Source
PERFORM L100-READ-DETAIL-FILE.

IF WS-END-OF-DETAIL-FILE
GO TO A200-EXIT.

MOVE SPACES TO STR-ORACLE-DETAIL-RECORD.
MOVE SEC-RECORD-TYPE TO STR-RECORD-TYPE
MOVE SEC-DATA-TYPE TO STR-DATA-TYPE
MOVE SEC-VALUE1 TO STR-DATA2
MOVE SEC-VALUE2 TO STR-DATA3
MOVE SEC-VALUE3 TO STR-DATA4
MOVE SEC-VALUE4 TO STR-DATA5
MOVE SEC-VALUE5 TO STR-DATA6
ETC…Continues…PERFORM L200-WRITE-ORACLE-DETAIL.

Example of data to be read: (Current Detail File)

1P1010020000010074A001Q010295L0A6…… +414+0000000003892 +00 ….. Continues >>>>>

Each record continues as a massively long row (periods are not part of data, just used to show further data sample.

Any assitance you may be able to provide is greatly appriciated. Thanks in advance.

Re: Creating a Pipe Delimited File

PostPosted: Mon Jan 30, 2012 6:20 pm
by BillyBoyo
If you define your output record in working-storage, which has between each elementary field,

level-number (05, 07, 10, whatever you need) FILLER PIC X VALUE "|".


Then you code MOVE statements for all your input fields, to your output in W-S. Then you can WRITE the record from W-S.

This sort of thing is good practice for getting the editor to come to your aid. If you invest some time in research, even just using PF1, you can change all the lines in a copy of your input copybook to:

MOVE INPUT-ABC-NAME-1
MOVE INPUT-ABC-NAME-2
MOVE INPUT-ABC-NAME-3
etc

And a copy of your output copybook to:
                             TO OUTPUT-ABC-NAME-1
                             TO OUTPUT-ABC-NAME-2
                             TO OUTPUT-ABC-NAME-3
                             etc


And then do a huge block move (MM/MM) to a huge block overlay (OO/OO).

Re: Creating a Pipe Delimited File

PostPosted: Mon Jan 30, 2012 9:37 pm
by riverspree
Thank you very much for the assist. While I had a suspision that was it, I honestly did not think it could be a such a simple solution. Much appriciated. Now I'm off to conquer the JCL end of things!

Re: Creating a Pipe Delimited File

PostPosted: Mon Jan 30, 2012 9:57 pm
by enrico-sorichetti
why write a program and not use for example Your sort
see here for examples
http://www.ibm.com/support/docview.wss? ... g3T7000094
( how to deal with CSV records )

Re: Creating a Pipe Delimited File

PostPosted: Mon Jan 30, 2012 10:27 pm
by BillyBoyo
riverspree wrote:Thank you very much for the assist. While I had a suspision that was it, I honestly did not think it could be a such a simple solution. Much appriciated. Now I'm off to conquer the JCL end of things!


No problem. Glad you're not moaning about how much work today :-) Have a quick look at enrico's suggestion as well.

Re: Creating a Pipe Delimited File

PostPosted: Tue Jan 31, 2012 12:29 am
by riverspree
Thank you for the addtional information enrico.

I did end up having to move the copybook to the WS and do a write from becauase the pipes were getting commented out, but I am happy to say the file is delimited and importing perfectly into excel & Oracle. Thanks again!

Re: Creating a Pipe Delimited File

PostPosted: Tue Jan 31, 2012 12:43 am
by BillyBoyo
Swift work. By "commented out" you mean "treated as comments in file and linkage sections" sort of thing, I guess.

If your Cobol program is doing nothing but putting the pipes in, it might be worth looking at the sort solution.

Your records are big. To use the sort you'd not want to drive yourself nuts to try to get the starts/lengths all right by hand. So use the rexx from the paper enrico refers to to generate Symbols, for use on the SYMNAMES DD. This allows you "names" in the sort which are the same as your Cobol program.

  OPTION COPY
  INREC BUILD=(REC-NAME1,PIPE,
               REC-NAME2,PIPE,
               ...
               REC-NAMEn)


Then, along with the generated symbols, include this in the data for the SYMNAMES DD.
PIPE,C'¦'