mgakhar
10th January 2007, 19:35
Hi,
We have a requirement where we have to read a file and upload data from the file into Baan tables. So on the first form, the user enters the file name and path etc and then hits continue. On hitting continue, the control shifts to the 2nd form and here we display the contents of the file.
Lets assume that the file just contains list of items.

Here is my code written for this -

i = 1

while seq.eof(fp) = 0
seq.gets(item, 2048, fp)
do.occ(i, set.items, item)
i = i + 1
endwhile

function set.items(domain tcitem i.item)
{
item.del = i.item
update.occ()
}

The 2nd form has just 1 field (multiocc) - item.del. The problem is that the 2nd form displays the last item in the file for all occurrences.

What am I doing wrong? Please help.

Please note that we do not want to use exchange schemes for this requirement.

Thanks
MG.

mark_h
10th January 2007, 19:44
I would keep it simple and create a table for form 2. Load the new table from the file (you could even keep the table generic for multiple uses). Use the new table as the maintable and make it a multi-occurence the session.

mgakhar
10th January 2007, 20:51
Well if creating a table is the only to accomplish this then we'll probably drop the requirement. Reason being that eventually we'll create more such Upload sessions and it doesnt make sense to create as many tables in Baan just for purpose of displaying the records. It is a good feature to have but not a critical one.

Im hoping there is another way of getting this to work ...

thanks,
MG.

mark_h
10th January 2007, 23:30
Nope - I was talking about 1 table to be used for all the upload sessions. It could have field names like key1, fld1, fld2, etc.. Then each upload session would put something different in each field. All you would have to do on form 2 is put meaningful labels and adjust the length for that data that is being displayed. So for this session the keyfield could contain the input item, fld1 could have description, etc. All you have to do is put a little thought into the field sizes of this generic all purpose table. Maybe something to track when they have been processed or maybe userid. Something so multiple users can run it at once.

What I usually do is give the users an option to validate the data. It runs a report showing what would be input from the file and what errors might exist. So for a bom load session when they click validate I might take the items for the BOM and bounce them against the item master to make sure the item actually exists. I find doing these checks before calling something like a function server actually makes things cleaner - my opinion only.

zacharyg
11th January 2007, 23:25
Perhaps you should consider using an exchange script to import the file. If your main requirement ist to import the data without a fancy UI, this could be a good alternative.

You could have the import operational in less time as it takes to develop a session for this task. The exchange schemes also provides error handling in the form of rejecting a record and providing the error code of the error.