How can I open and read information line by line from a flat file?

Ignacio Rafael

Member
Hi everybody, I've asked for a proccess to import data from a flat file to various JD Edwards tables
confused.gif
.

I know the existence of a kind of UBE called "Table Conversion", but I don't know how to use it. I've searched for a easier way and I've found out the "B76B220 - Fetch Next Line from Flat File" business function, but I don't know how to call it too.

Could someone show me the way to use both methods?. I'm more interested in the business function, I guest that the flat file should be open before and close after I've read all flat files, but I don't know which business function should I use and how to call them as the "B76B220 - Fetch Next Line from Flat File".

Thanks very much for your help!
smirk.gif
.
 
Hi Ignacio,

You need to use anotoher BSFN Open Flat File to get the file pointer first before you use this BSFN. Here's an example of how to use it:
Open Flat File
RV Error Code <- cErrorCode
RV Error Message <- szErrorMessageId
<Zero> -> cAppendMode
VA rpt_mnFilePointer_GENLNG <- idFilePtr
VA rpt_szPathAndFile_EFRM -> szFilePath

Fetch Next Line from Flat File
VA rpt_szPathAndFile_PTH -> szFlatFileName
VA rpt_mnFilePointer_GENLNG -> idFilePtr
VA rpt_szFlatFileRecord_APTA <- szFlatFileRecord
VA rpt_mnRecordLength_RCLN <- mnRecordLength
RV Error Code <- cErrorCode
RV Error Message <- szErrorMessageID

Also, this topic has been disucssed before many times. Search for "flat file", I am sure you'll find many topics related to your requirements.

Cheers,

Lynnol
 
Hi, Ignacio!

This has been covered many times in the past.
Please go to the search option and type "Fetch Next Line from Flat File", remember to set the search range for some years (put 10 and you'll get most of them
wink.gif
), there are many posts with detailed instructions.

Best regards!
 
I suggest you look into Cross Reference for an application using B76B0220 and find out how it is used, by yourself!
If it is too much (and we're so close to Christmas time) here's a hint:
Driver - DO_SECTION <~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
..........
0003 While rpt_mnFilePointer_GENLNG [GENLNG] != <Zero>
0004 Fetch Next Line from Flat File [FetchNextLineFromFlatFile,B76B0220,D76B0220B,CLOC]
DS szFlatFileName [D76B0220B,PTH] <- rpt_szPathAndFile_EFRM [EFRM]
DS idFilePtr [D76B0220B,GENLNG] <-> rpt_mnFilePointer_GENLNG [GENLNG]
DS szFlatFileRecord [D76B0220B,APTA] -> rpt_szFlatFileRecord_FFRC [FFRC]
DS mnRecordLength [D76B0220B,RECL] <- rpt_mnRecordLength_RCLN [RCLN]
0005 rpt_mnRecordCounter1_CNR1 [CNR1] = [VA rpt_mnRecordCounter1_CNR1]+1
0006 Do Custom Section(RS My Text File Upload)
0007 EndWhile
......
Note I separated the flat file reading and the record processing (uploading it into a Z table) in two sections.
No Open/Close required (as you are only READING the flat file).
 
Thanks a lot... but here\'s a little problem.

My project manager has told me that the flat file is going to be a .CSV file finally. Each column is going to be separated by some character, and I've realized that it means, columns with diferente legnht in each row. So it is to be necessary to make a table conversion.

He told me that it should be an automatic proccess, it cannot be a simple interactive application with the import option in grid. It should read the flat file from a network location without the user interaction, like an UBE.

Last week I was trying to develop one with the report assistant, but I couldn't make it run, always return me a strange error when de UBE run.

Does it exist any alternative way?. Where can I find a table conversion tutorial?
confused.gif
.

Thanks a lot again!.
 
Back
Top