• Introducing Dark Mode! Switch by clicking on the lightbulb icon next to Search or by clicking on Default style at the bottom left of the page!

Fetch Next Line From Flat File(B76B0220) Clears the file

coolkl

Active Member
Hello All,

I am developing a UBE to read a CSV file from a folder. Currently testing on my local machine. When I am testing, Open File BSFN works and it returns the file pointer (value = 1 in most cases). But then
when Fetch Next Line From Flat File(B76B0220) is executed it does not retrieve any record. All the file in the folder which is read gets cleared. Any idea where I am missing the point ?

My sample code is below and Error debug log for BSFN is attached

Open Flat File
"1" -> BF cSuppressErrorMessage
VA rpt_szErrorCode_ERRC <- BF cErrorCode
VA rpt_szErrorMessage_DTAI <- BF szErrorMessageId
<Zero> -> BF cAppendMode
VA rpt_szFilePointer_GENLNG <- BF idFilePtr
VA rpt_szCC_COBRAURL -> BF szFilePath


Fetch Next Line from Flat File
VA rpt_szFileName_PTH -> BF szFlatFileName
VA rpt_szFilePointer_GENLNG -> BF idFilePtr
VA rpt_szFlatFileRecord_DS200 <- BF szFlatFileRecord
VA rpt_mnRecordLength_RECL <- BF mnRecordLength
"1" -> BF cSuppressErrorMessage
VA rpt_szErrorCode_ERRC <- BF cErrorCode
VA rpt_szErrorMessage_DTAI <- BF szErrorMessageID
 

Attachments

lmujica

Active Member
Hello coolkl,

You don't have to use "Open Flat File", "Fetch Next Line from Flat File" opens the flat file for you. I suggest you to try these:

1. Delete "Open Flat File".
2. Asign full path and flat file name to "BF szFlatFileName". Actually you just asign "Test2.txt" instead of, ie., "c:\Test2.txt".
3. Change "BF idFilePtr" from input (->) to input/output (<-->).
4. Change "BF mnRecordLength" from output (<-) to input (->) and asign a value less than 1501.

Hope it helps and keep me updated. BR,


Luis.
 

craig_welton

Legendary Poster
I am at a 9.0 site right now, so could be different on 9.2 but ...

Try passing the # of characters you are trying to read in BF mnRecordLength. In the example, you are receiving it. Make it the size of rpt_szFlatFileRecord_DS200.

I don't understand about the folder being cleared. There is nothing in this function that would do that.

Craig
 

Larry_Jones

Legendary Poster
One of your Issues is that Open Flat File is for the purpose of opening a file for OUTPUT only. If you pass the Append flag = 1 then it opens an existing file in WRITE APPEND mode, otherwise it Creates (deleting any pre-existing file) a new file.
 

coolkl

Active Member
Hello coolkl,

You don't have to use "Open Flat File", "Fetch Next Line from Flat File" opens the flat file for you. I suggest you to try these:

1. Delete "Open Flat File".
2. Asign full path and flat file name to "BF szFlatFileName". Actually you just asign "Test2.txt" instead of, ie., "c:\Test2.txt".
3. Change "BF idFilePtr" from input (->) to input/output (<-->).
4. Change "BF mnRecordLength" from output (<-) to input (->) and asign a value less than 1501.

Hope it helps and keep me updated. BR,


Luis.
Thanks your step wise description nailed it. It worked. Thanks very much, saved my day and ton of effort
 

coolkl

Active Member
I am at a 9.0 site right now, so could be different on 9.2 but ...

Try passing the # of characters you are trying to read in BF mnRecordLength. In the example, you are receiving it. Make it the size of rpt_szFlatFileRecord_DS200.

I don't understand about the folder being cleared. There is nothing in this function that would do that.

Craig
Thanks for your help.
 
Top