Page 2 of 3

Re: csv 2 fixed with non consistant amount fileds

PostPosted: Wed Oct 12, 2011 11:36 pm
by AKDEARAGON
I found my problem. This site has been great help glad I found it. :D


But could you explain a little more of what I'm using in the following area:
BUILD=(1:%00,7:%01,27:%02,29:%03,79:%04,85:%05,95:%06,
110:%07,145:%08,180:%09,215:%10,223:%11,253:%12,258:%13,
268:%14,269:%15,270:%16,272:%17,274:%18,275:%19,276:%20,
286:%21,296:%22,298:%23,308:%24,310:%25,311:%26,313:%27,
315:%28,316:%29,322:%30,328:%31,329:%32,330:%33,331:%34,
332:%35,333:%36,334:%37,335:%38,336:%39,337:%40,338:%41,
339:%42,340:%43,341:%44,351:%45,352:%46,353:%47,357:%48,
358:%49,359:%50,363:%51,367:%52,371:%53,372:%54,373:%55,
374:%56,375:%57,410:%58,411:%59)),
IFTHEN=(WHEN=INIT,
PARSE=(%60=(ABSPOS=316,ENDBEFR=C'.',ENDBEFR=C' ',FIXLEN=3),
%61=(FIXLEN=2),
%62=(ABSPOS=322,ENDBEFR=C'.',ENDBEFR=C' ',FIXLEN=3),
%63=(FIXLEN=2)),
OVERLAY=(316:%60,JFY=(SHIFT=RIGHT),C'.',%61,TRAN=ALTSEQ,
322:%62,JFY=(SHIFT=RIGHT),C'.',%63,TRAN=ALTSEQ))


The second ifthen that assigns %60 because I assume that %59 was last used from standard input, and ABSPOS=316 is absolute possition of the field I am using. I am getting 1st 3 postions up to the decimal if there is one or a ' ' showing end, then assigning %61 to last 2 char if there is value after decimal right. but then the overlay i'm little shake on when you use the tran=altseq that I really don't understand, but it works

Re: csv 2 fixed with non consistant amount fileds

PostPosted: Wed Oct 12, 2011 11:57 pm
by Frank Yaeger
then the overlay i'm little shake on when you use the tran=altseq that I really don't understand, but it works


Again, break it down to understand it.

After:

OVERLAY=(316:%60,JFY=(SHIFT=RIGHT),C'.',%61,

we would have values like:

155.04
143. 
  2. 
154.84
166. 
  1.6
  1.06


The TRAN=ALTSEQ uses the ALTSEQ table (X'40' -> X'F0') to change the first and/or second blank after the decimal point to a zero.

Re: csv 2 fixed with non consistant amount fileds

PostPosted: Thu Oct 13, 2011 12:04 am
by AKDEARAGON
Thanks the light bulb has gone on!

New questions: if i have several fields in a row that I need to use this statement JFY=(SHIFT=RIGHT,LEAD=C'0') is there an easy way to group them save lines of code or just list out each field at a time? example:
BUILD=(1:%00,JFY=(SHIFT=RIGHT,LEAD=C'0'),
7:%01,27:%02,JFY=(SHIFT=RIGHT,LEAD=C'0'),
29:%03,79:%04,JFY=(SHIFT=RIGHT,LEAD=C'0'),
85:%05,JFY=(SHIFT=RIGHT,LEAD=C'0'),
95:%06,JFY=(SHIFT=RIGHT,LEAD=C'0'),

second question I have dates that appear as follows:
10/11/2011
5/15/2011
12/5/2011

I need them to end up as follows:
20111011
20110515
20111205

Re: csv 2 fixed with non consistant amount fileds

PostPosted: Thu Oct 13, 2011 1:10 am
by Frank Yaeger
If you need LEAD=C'0' for each individual field, you must specify them individually. If you grouped them together as one field, LEAD=C'0' would only apply to the one field, not the individual fields. Of course, I don't know why you are using LEAD=C'0' so I can't comment on whether you need it or not.

You can use a DFSORT job like the following to do your date conversion:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
10/11/2011
5/15/2011
12/5/2011
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  OPTION COPY
  INREC PARSE=(%01=(ENDBEFR=C'/',FIXLEN=2),
               %02=(ENDBEFR=C'/',FIXLEN=2),
               %03=(FIXLEN=4)),
    BUILD=(%03,%01,UFF,EDIT=(TT),%02,UFF,EDIT=(TT))
/*

Re: csv 2 fixed with non consistant amount fileds

PostPosted: Thu Oct 13, 2011 1:24 am
by AKDEARAGON
Thanks for your help

All this is to get to the mainframe for processing.

Re: csv 2 fixed with non consistant amount fileds

PostPosted: Thu Oct 13, 2011 9:27 am
by dick scherrer
Hello,

All this is to get to the mainframe for processing.
How are these records to be used that requires this :?

If you explain howt these records are input, someone may have a suggestion as to how you can use the records directly.

Re: csv 2 fixed with non consistant amount fileds

PostPosted: Thu Oct 13, 2011 10:14 pm
by AKDEARAGON
This all goes to mainframe. The dates are compared for oldest or evaluated if greater than # of days. so need yyyymmdd include all zeroes. The numeric fields are evaluated for having numeric if then do something. if a numeric field has spaces before the number then to the mainframe it isn't numeric. if a field is 2 bytes long and it only has a blank then a 1 then it's not evaluated corectly but if it has 01 we are good to go.

Re: csv 2 fixed with non consistant amount fileds

PostPosted: Thu Oct 13, 2011 10:23 pm
by dick scherrer
Hello,

This all goes to mainframe
Does not answer my questoin.

The posted sort and whatever runs after is of course on the mainframe.

What program/utility reads the data after the sort (or without the sort if possible)?

Re: csv 2 fixed with non consistant amount fileds

PostPosted: Thu Oct 13, 2011 10:50 pm
by AKDEARAGON
Sorry, this all is used by cobol program and Easytrieve programs. I had coded a lengthy cobol job to parse it out and make each field usable going forward but now that I've done that I have gotten like 10 other request to do same sort of thing with other files of different lengths and values. I was trying to work this out thinking with dfsort it is faster to make changes and layout what file needs to be to the mainframe than coding new cobol job each time. It is clean and much faster.
%22=(ENDBEFR=C'/',FIXLEN=02),
%23=(ENDBEFR=C'/',FIXLEN=02),
%24=(ENDBEFR=X'05',FIXLEN=04),
%25=(ENDBEFR=C'/',FIXLEN=02),
%26=(ENDBEFR=C'/',FIXLEN=02),
%27=(ENDBEFR=X'05',FIXLEN=04),
I have new question testing my data.
if in the Parse area I have coded the date field to be 3 seperate fields example
and it is emediately followed by another date field but when i get to the build the first date field is empty I am not getting the expected results because I'm looking for c'/' it find the next delimiter of x'05' how can I build a blank or zero filed field for 1st date and then process the 2nd date?

Re: csv 2 fixed with non consistant amount fileds

PostPosted: Thu Oct 13, 2011 11:06 pm
by skolusu
Use the UFF on the year field like shown below

//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                     
10/11/2011                                                         
5/15/2011                                                           
12/5/2011                                                           
                                                                   
NOVALUE                                                             
BLAHBLAH                                                           
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                     
  OPTION COPY                                                       
  INREC PARSE=(%01=(ENDBEFR=C'/',FIXLEN=02),                       
               %02=(ENDBEFR=C'/',FIXLEN=02),                       
               %03=(ENDBEFR=X'05',FIXLEN=04)),                     
    BUILD=(%03,UFF,EDIT=(TTTT),%01,UFF,EDIT=(TT),%02,UFF,EDIT=(TT))
//*


this produces
20111011
20110515
20111205
00000000
00000000
00000000