Importing a Custom Flat File without using Table Conversions

pfaloney

Well Known Member
I am working on enhancing the SCP Inbound Processor to process a custom file of 4 fields after the rest of the inbound process is complete. I have added the code and all of the information is there but am not able to either open or read the flat file.

Using table conversions is not an option due to the names of the files changing based on the Import Version.

Note: I am currently running it locally on my Thick Client

The code (only the open and fetch lines) is attached
 

Attachments

  • 185144-A490E.txt
    977 bytes · Views: 107
Your main problem is that B34A1010 only has file write operations. When you open a file using its Open function your choices are open for Append (Create new file or write to end of existing file) or Open Output (create or replace file). Only write operations to a file are supported in either mode.

FetchNextLineFromFlatFile (B76B0220) should work for you, but you need to let the routine pass the idFilePtr back to your code. For this argument change the arrows so they point both ways. I haven't used this routine before but a quick glance showed that it will open the file as needed without a specific open function.

Regards,
 
Question: Do I even need "Open Flat File"? I am asking since there is another Business Function (I believe B44H9908) with the same name.
 
Not to encourage the TC, but...
... Remember, you can always rename your Flat-File to something familiar, then call the TC to eat it...

(db)
 
Dan:

Unfortunately. We tie everything together via the F34A11 table since our install of Advanced Planning and Production Scheduling is increasing. So far, only 1 country needs this additional functionality (it will be 3 different files coming in at the same time) but I have a feeling that more installs will need something like this in the future. I would have to start duplicating TC's if I went that route.

Also, our drop zones may be becoming more dynamic in the near future since we may be retiring the current server.
 
+1

I am attaching some code I've done in the past using that BSFN.
You loop through the inbound file until ERRC trips and break the inbound text up into fields.
So you need the delimiter to break them out.
 
[ QUOTE ]
+1

I am attaching some code I've done in the past using that BSFN.
You loop through the inbound file until ERRC trips and break the inbound text up into fields.
So you need the delimiter to break them out.

[/ QUOTE ]

Maybe it my computer and that it is only 8 AM here, but I do not see a attachment.
 
Hmm??
smile.gif


Try now
 

Attachments

  • 185165-Flat File upload.txt
    36.4 KB · Views: 209
[ QUOTE ]
Hmm??
smile.gif


Try now

[/ QUOTE ]
Other than initializing idGENLNG to "", my code essentially matched.

I am getting an error code of 2 and a Message of 3003

My filepath/name is \\xxxcoapDEV03\FLATFLTEST\701_WO_Import_JDE_Strands.txt

I have tries it that way and with a e$\ after the server name with the same error.

Note: JDE is on a AS400 even though I am running this locally
 
If you are trying to import and parse a comma delimited (or other delimiter) file take a look at post #183138 (and associate thread).
 
[ QUOTE ]
If you are trying to import and parse a comma delimited (or other delimiter) file take a look at post #183138 (and associate thread).

[/ QUOTE ]
It is a text file with a delimiter of a comma. However, each line is only 37 characters. I will do the parsing when each line is read.
 
Size wasn't the issue. Parsing is. To properly parse a correctly formatted CSV file is a little more complex than it may first appear...

"Joan ""the bone"", Anne",Jet,"9th, at Terrace plc",Desert City,CO,00123


Joan "the bone", Anne
Jet
9th, at Terrace plc
Desert City
CO
00123
 
You say you are running locally on your dev machine.
Can you paste "\\xxxcoapDEV03\FLATFLTEST\701_WO_Import_JDE_Strands.txt" into Windows Explorer and access / open the file with notepad?
 
[ QUOTE ]
You say you are running locally on your dev machine.
Can you paste "\\xxxcoapDEV03\FLATFLTEST\701_WO_Import_JDE_Strands.txt" into Windows Explorer and access / open the file with notepad?

[/ QUOTE ]
You just gave me an idea but I will have to check with out CNC tomorrow
 
The only BSFN you need is
Fetch Next Line from Flat File in a loop until ERRC trips out

As others have said, try the files address on your PC.
Are you mapped to the drive where you try to find the file even?

Test it on your C:/ for now to see if it works
 
Issue finally resolved. Drop zone access issue. Now all I have to do is figure out how to clear the file after processing.
 
This is great code, thank you for posting. I am using it to build an upload for some vouchers. I have a question for you as I am experiencing a problem with the last field in my flat file. It is the amount of the voucher, and I am trying to convert it to a math numeric. The only way my program will recognize the value is if I add an extra comma at the end of the line.Whats strange tho, if I capture the value in a string variable it works. Just wondering if you came across anything like this in regards to the last value of the line being an amount. I have tried to add code to add a column but that didn't work either. Thanks
 
If you look at the value in debug, you will see an extra space after the field value. This is a EOL, CR, and/or LF. Use the Strip BSFN to remove the hex characters.
 
For anyone's interest. If you have the same issue as me, it was due to a carriage return causing my code to not convert to a number....Remove Carriage Return and all is good again...
 
Back
Top