How to insert a row into a flat file

selinta

selinta

Member
Hello!
Please, help me!
How can I insert a row to the begin (not to the end) of an existing flat file? Or modify an existing row?


---------------------------
Thank you!
 
There are many flat file functions /APIs available in JDE tools thru which you can perform any of the above operations. For inseting row in begin you might have to use a temporary file and then recreate the exiting file with new line and copy back the temp file.

Chan
 
Hello!
Please, help me!
How can I insert a row to the begin (not to the end) of an existing flat file? Or modify an existing row?


---------------------------
Thank you!

What version of E1? What platform are you on (Windows,Linux,ISeries)?

BSFN? APP? UBE?
 
Thank you for your replies!

nkuebelbeck, I'm working with JDE OneWorld, B7333, the platform is Windows, UBE.

peterbruce, I'm looking for BSFN that can insert line to the middle or to the beginning of an existing file. I had found B34A1010, with it I can create flat file and write lines with append mode. But I can't understand how can I insert something not to the end of file. I may be blunt, but I can't find how to do it nor on JDEList neither somewhere else :(

[email protected], thank you, but how can I using this can insert something exactly to the top of file? Can you explain it for me some more detail?


Chan Rana, oh, I use it now :) Can you give me a hint whether can I append whole file to file with my line or I have to copy it line by line?

Regards
 
Hi Selinta,

You're a very old release of One World there so I am not sure if what I'm about to say can be done.

There are BSFNs to read through a text file, line by line (B76B0220 Fetch Next Line from Flat File). It has a file line pointer that enables us to read lines of a text file. So you'll need this one.

Then in the same BSFN there is another module (Append Line to Flat File)

I guess with a bit of manipulation you could read from one file and then insert into a new file at the point you want????

Have a look at these:
B4700230
B76B0220
B34A1010

Then if you get no joy, search this table in JDE, F9862 for the words 'Flat' or 'File' or 'Text' etc.

You maybe lucky in that you can add at a point of your choice, but I think they only add at the end. Unless you recreate the file in the order you want, as mentioned above.

If you can't add a line mid way, this would work:

Another way could be for you to actually use a JDE work file TBLE with a LNID type value. Use the read BSFN above to read the existing file and store the text into your new TBLE file.
Make sure an alias is long enough to store your text.
Use LNID as you can have the gaps you may need. So 1.000 2.000 (we can insert 1.001 1.002 etc)

You can read through and point to whatever record you want at will.

When you're finished, sequence by LNID and move that database table to a new file
 
Thank you very much)

johndanter , I had done it with B76B0220 Fetch Next Line from Flat File and B34A1010 Append Line to Flat File! Thank you again)
 
You should be able to create a BSFN to do that. I would create a new file, add your row, copy the file and then delete it
Hope this helps
Thanks
 
Selinta,

to be blunt :D, this is not a JDE issue. A flat file is a flat (sequential) file. It is NOT a random access/insert/update file. Flat file operations are very basic - Open, Close, Read Next, Append (write at end of file).
Other than some oddballs out there that definition holds true for almost all systems out there.

As Chan Rana described if you need to perform any I-O operation other than APPEND you will need to READ in the contents of the original file and WRITE (APPEND) to a new file - modifying the data as needed. Alternatively OS Shells (Windows Command Shell, Unix Shells, etc) provide means of concatenating files together - follow this http://stackoverflow.com/questions/2477271/concatenate-text-files-with-windows-command-line-dropping-leading-lines to get a clue on how to do it.
 
Back
Top