reading flat file and populating data area



Software AG's platform-independent programming language with full support for open-source and Internet applications

reading flat file and populating data area

Postby indra_nsec » Fri Feb 08, 2013 1:00 am

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?
indra_nsec
 
Posts: 4
Joined: Sat Mar 10, 2012 1:09 pm
Has thanked: 0 time
Been thanked: 0 time

Re: reading flat file and populating data area

Postby RGZbrog » Mon Feb 11, 2013 9:55 pm

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).
User avatar
RGZbrog
 
Posts: 101
Joined: Mon Nov 23, 2009 1:34 pm
Location: California, USA
Has thanked: 0 time
Been thanked: 0 time

Re: reading flat file and populating data area

Postby indra_nsec » Wed Feb 13, 2013 12:06 am

Hi,

Thanks for the answer.
Infact thats what I also decided to do later on ........
indra_nsec
 
Posts: 4
Joined: Sat Mar 10, 2012 1:09 pm
Has thanked: 0 time
Been thanked: 0 time

Re: reading flat file and populating data area

Postby boby125 » Mon Sep 15, 2014 10:27 am

Text removed as it was copied from RGZbrog's reply, above.
We offer up to date pass4sure.co.uk exam practice questions with self paced test engine to help you pass UNC Greensboro exam and complete your ccent course & CISCO
boby125
 
Posts: 1
Joined: Mon Sep 15, 2014 10:24 am
Has thanked: 0 time
Been thanked: 0 time

Re: reading flat file and populating data area

Postby enrico-sorichetti » Mon Sep 15, 2014 11:15 am

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 ???
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 165 times


Return to Natural

 


  • Related topics
    Replies
    Views
    Last post