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

coolkl

Well Known 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

  • 123.JPG
    123.JPG
    60.9 KB · Views: 61
Hi, use only Fetch Next Line from Flat File, it works fine without Open Flat File.
 
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.
 
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
 
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.
 
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
 
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.
 
Back
Top