Read Flat file into F0911Z1

jimjung27

Active Member
I have a need to read a flat file into a JDE Table (F0911Z1) and need the ability to choose different locations by UBE version in the Processing Options. I am trying to use B76B0220 but can't get it to work. I think I'm close. Anyone see something wrong?

Here's my code:

PO szPathFilenameExtension = ltrim(rtrim([PO szPathFilenameExtension],' '),' ' )
VA rpt_FilePointer_GENLNG = 0
//
Open Flat File
VA rpt_ErrorCode_ERRC <- cErrorCode
VA rpt_ErrMsgID_DTAI <- szErrorMessageId
"1" -> cAppendMode
VA rpt_FilePointer_GENLNG <- idFilePtr
PO szPathFilenameExtension -> szFilePath
Fetch Next Line from Flat File
PO szPathFilenameExtension -> szFlatFileName
VA rpt_FilePointer_GENLNG <> idFilePtr
VA rpt_Text2000_DESCR <- szFlatFileRecord
"2000" -> mnRecordLength
VA rpt_ErrorCode_ERRC <- cErrorCode
VA rpt_ErrMsgID_DTAI <- szErrorMessageID
While VA rpt_FilePointer_GENLNG is not equal to "0"
Fetch Next Line from Flat File
PO szPathFilenameExtension -> szFlatFileName
VA rpt_FilePointer_GENLNG <> idFilePtr
VA rpt_Text2000_DESCR <- szFlatFileRecord
"2000" -> mnRecordLength
VA rpt_ErrorCode_ERRC <- cErrorCode
VA rpt_ErrMsgID_DTAI <- szErrorMessageID
End While
//
Close Flat File
VA rpt_ErrorCode_ERRC <- cErrorCode
VA rpt_ErrMsgID_DTAI <- szErrorMessageId
VA rpt_FilePointer_GENLNG -> idFilePtr
 
Can you describe in more detail what you mean by "...but can't get it to work"?

I don't see where you're performing an insert to your z-file
Does the 'Open' file call work?
Have you stepped through the ER code in debug? If so, what is happening?
 
Hello jimjung27,

I think you don't have to use "Open Flat File" and "Close Flat File" because "Fetch Next Line from Flat File" open the file when idFilePtr is 0 (zero) and this BSFN close the file when it reaches EOF.
Also I can see that the maximun lenght string is 1500 (you're using 2000).

Regards,



Luis.
 
Hi,

First off you don't need to use OpenFlatFile as this is for opening a flat file for output. Set the File pointer to zero and pass it into FetchNextLineFromFlatFile which will open the file for input and return the correct pointer.

the last problem you have is that your while loop is on GENLNG_FilePointer which will always be greater than zero if the file was opened correctly, you should code as follows:-

FetchNextLineFromFlatFile

While VA rpt_ErrorCode_ERRC = '0'
<process record>
FetchNextLineFromFlatFile
EndWhile

CloseFlatFile

The parameters into the BSFN's look correct so if you have the correct permissions to the path/file this should work OK.

Softtop
 
You don't have to use the open flat file and close flat file functions here. Delete those lines and it should work.

rgds,
Walter.
 
Thanks to all for the advice. I have new faith and will try again and let you know !
 
Just ran it in debug without Open/Close file and length of 1500 char and it worked !!!!! Very happy about this. Thank you so much !!!!!
 
Back
Top