Open Flat File in read mode

Imrankhan

Active Member
Hi,

I need to open a flat file and read it and display it in a report. Please let me know how to use "Open Flat File" and "Fetch Next Line from Flat File". Thanks.

Sheik
 
Sheik,

I have not used the BSFN to do this before what I have done in the past is create a table and then have the flat file converted using TC and write the report over the temp/work table/file.

Angelis
 
Hi Sheik,

Here is the way to use the BSFN's to read the flat file

1) Use "Open Flat File" once to open your flat file

2) Then use "Fetch Next Line from Flat File" to read every record from the flat file. Here is the way to use the BSFN

0001 VA dd_PTH = "file location path dependent on the platform type"
0002 VA dd_RECL = "maximum length of data"
0003 VA dd_GENLNG = 0
0004 Fetch Next Line from Flat File
VA dd_PTH -> szFlatFileName
VA dd_GENLNG <> idFilePtr
VA dd_APTA <- szFlatFileRecord
VA dd_RECL -> mnRecordLength
0005 While VA sec_dd_GENLNG is not equal to "0"
0006 Fetch Next Line from Flat File
VA dd_PTH -> szFlatFileName
VA dd_GENLNG <> idFilePtr
VA dd_APTA <- szFlatFileRecord
VA dd_RECL -> mnRecordLength
0007 End While

NOTE: The maximum value of mnRecordLength is 1500.

3) At the end close the flat file after all records read

Hope this helps!!

For more info : Refer to solution ID: 201015306
 
Masters,

I have a problem very closely related so I am adding it here.

I am using the FetchNextLineFromFlatFile function successfully when run on a fat client and going to a c:\ or d:\ directory. However, when running it on the AS400 we are unable to see the flat file. I don't know ANYTHING about AS400s, so is there a way I can figure out what the directory should be called?

Here's what I DO know. The server (from Work with Servers) is 'MSDAS5'. I created a TC that works - when it runs on fat client it runs from c:\B7\DV7333\Import\EPHSCON.csv. When the TC runs from AS400 we drop the .csv and ftp the file to TSTDATMOP/EPHSCON.

Can anybody help?

Ben again,
B7333 (Xe) running on HTML
 
Your AS400 cannot see the windows network directories. You can talk to
your AS400 system administrator to discuss what libraries on the AS400
you can use to drop files.



This issue has been discussed repeatedly on the list. If you do some
searching, you can find a lot of information about how to deal with
table conversions on the AS400.



Ellen Deak

Senior Systems Developer

Cooper Standard Automotive

JDE EnterpriseOne (OneWorld XE Update 7 SP23_M1), AS400 DB2 V5R3M0,
Citrix Clients
 
Re: RE: Open Flat File in read mode

Thanks for trying Ellen, but - No I can't talk to my System Administrator, and this isn't about TCs.

I think I will open up a new post to clarify.

Ben again,
 
RE: RE: Open Flat File in read mode

It doesn't matter whether it's a TC or if you're trying to use or the
file i/o business functions. If the file path doesn't exist on the
iSeries (which a wintel file path won't) you won't be able to read/write
to it when the UBE executes on the Enterprise Server.



There are lots of posts on how to work around this.



Ellen Deak

Senior Systems Developer

Cooper Standard Automotive

JDE EnterpriseOne (OneWorld XE Update 7 SP23_M1), AS400 DB2 V5R3M0,
Citrix Clients
 
The while loops until the "VA sec_dd_GENLNG" is not equal to 0. After you read all the lines, you lose the file id.
How can I close the file without "VA sec_dd_GENLNG" ?
Thanks.
Z
 
We do a lot of interfaces using flat files on IFS (integrated file share on I series ) . For this we ask our system admin to create a folder share and allow csv .txt as valid file types and have encoding set to UTF8 . You can also have in jde for inbound files P93081 to set encoding . We have template UBE for inbound interfaces where we provide the path , then create path for IFS . Pls note windows path are like C:\XXX\YYY while on IFS the paths are /PY910/XXX/YYY , the direction of slash is the other side . Then we copy to import if we are using TC because TC cannot have dynamic path and so we let is read from import of the path code . If you use business function B34A1010 for open , write , close . Use B76B0220 and then get the entire record tuple . The use function like Parse delimited string to separate out data values from the record , validate and enter into staging and whatever after that .. Hope this guides a little
 
The while loops until the "VA sec_dd_GENLNG" is not equal to 0. After you read all the lines, you lose the file id.
How can I close the file without "VA sec_dd_GENLNG" ?
Thanks.
Z

You can use your if condition to see the APA record and see if it not blank or null and then go from there . Pls note any time you use generic pointer we should always use Memory , Free PTR to DSTR which actually makes the pointer variable memory to Null else you will have memory leaks the more this interface runs . Hope this helps
 
You can use your if condition to see the APA record and see if it not blank or null and then go from there . Pls note any time you use generic pointer we should always use Memory , Free PTR to DSTR which actually makes the pointer variable memory to Null else you will have memory leaks the more this interface runs . Hope this helps

in the while loop Fetch change
VA dd_GENLNG <> idFilePtr
TO
VA dd_GENLNG > idFilePtr
 
Back
Top