Page 1 of 1

reading flat file and populating data area

PostPosted: Fri Feb 08, 2013 1:00 am
by indra_nsec
Hi,

I am trying to read a flat file which has been formed from a csv file and populate a data area

eq,

csv file as below

abc,1.2,rr,,7.89,qqq

flat file is formed as

abc00001.2rr00007.8qqq

now i need above data to filled in data area

as fields like A(3),N(3.3),A(2),N(4.2),A(3)

is it possible anyway?

Re: reading flat file and populating data area

PostPosted: Mon Feb 11, 2013 9:55 pm
by RGZbrog
For Natural under Windows or Unix it's a simple matter of reading the CSV directly. On the mainframe the CSV must be converted to a flat file, as you have done, but the format could be simplified to make your job much easier, because the record definition must match the data byte for byte.

If you changed the record format to abc001200rr000780qqq you would have the simplest solution.
DEFINE DATA LOCAL
1 #IN
  2 #A1 (A3)
  2 #N1 (N3.3)
  2 #A2 (A2)
  2 #N2 (N4.2)
  2 #A3 (A3)
END-DEFINE
*
READ WORK 1 #IN
  DISPLAY #A1 #N1 #A2 #N2 #A3
END-WORK
END
In the data, note the implied decimal points and the number of digits before and after the decimal.

Because the record includes the decimal point and fewer decimal positions
DEFINE DATA LOCAL
1 #IN
  2 #A1 (A3)
  2 #N1 (A7)
  2 #A2 (A2)
  2 #N2 (A7)
  2 #A3 (A3)
1 #OUT
  2 #N3 (N5.1)
  2 #N4 (N5.1)
  2 #N5 (N3.3)
  2 #N6 (N4.2)
END-DEFINE
*
READ WORK 1 #IN
  MOVE EDITED #N1 TO #N3 (EM=99999.9)
  MOVE EDITED #N2 TO #N4 (EM=99999.9)
  MOVE        #N3 TO #N5
  MOVE        #N4 TO #N6
  DISPLAY #A1 #N1 #N3 #N5 #A2 #N2 #N4 #N6 #A3
END-WORK
END
You need to remove the decimal (MOVE EDITED) and then convert to the proper number of digits (MOVE/ASSIGN).

Re: reading flat file and populating data area

PostPosted: Wed Feb 13, 2013 12:06 am
by indra_nsec
Hi,

Thanks for the answer.
Infact thats what I also decided to do later on ........

Re: reading flat file and populating data area

PostPosted: Mon Sep 15, 2014 10:27 am
by boby125
Text removed as it was copied from RGZbrog's reply, above.

Re: reading flat file and populating data area

PostPosted: Mon Sep 15, 2014 11:15 am
by enrico-sorichetti
On the mainframe the CSV must be converted to a flat file, as you have done, but the format could be simplified to make your job much easier, because the record definition must match the data byte for byte.


On the mainframe the CSV must be converted to a flat file, as you have done, but the format could be simplified to make your job much easier, because the record definition must match the data byte for byte.


any reason to clone a previous reply ???