sweetie
2nd April 2002, 18:01
Hi,
How can i create a report that writes records with fixed lenght.
The reportgen. cuttes the blancs at the end of a line.
I must create lines with 128 char lenght. (at the 129 a car. return)
shah_bs
3rd April 2002, 07:27
If you have position 128 as 'spare', fill it with some special character (example # or ~) in the report layout. That will give you a fixed length output.
Alternatively, put the special character in position 129, and then once the file is created, you can cut off that position.
sweetie
3rd April 2002, 10:08
thanks for your quick answer.
As it is a file for a bank i can not put something i want in the 128 position.
Using your second solution demands a different treatment on an nt and a unix machine. I suppose that you want to cut the 129 position with a unix or nt/W2000 script/command.
evesely
3rd April 2002, 16:58
Have you though of using the seq.* commands to write a text file instead of using a report? You can then write out as many characters per line as you want. That is how we have done things like this in the past.
sweetie
3rd April 2002, 18:23
Hi,
yes i know how to write a seq file.
But it is a session in baan tfcmg4260s000 which permits to work with 2 reports where 1 is a file (electronic banking).
So than you lose all the functionality of the report.
NPRao
3rd April 2002, 20:39
Hi Sweetie,
Did you consider the option of using the fixed variables
Fixed variables
A string variable can be declared as fixed so that its current length always equals the maximum length. For example:
STRING name(10) FIXED
name = "andrew" | the string is always filled up with spaces
The keyword FIXED is applicable to one-dimensional strings only. Multi-dimensional string arrays are always fixed and do not need to be declared with the keyword FIXED.
evesely
3rd April 2002, 23:47
In a test I ran, the report compiler automatically inserted a strip$() in an assignment, effectively negating my attempt to use a fixed length string.
sweetie
4th April 2002, 10:16
ed is wright.
:)
~Vamsi
4th April 2002, 22:46
How about reading the output of the report generated and writing it back with fixed width? Use seq.* functions for this to keep it o/s independant.
NPRao
4th April 2002, 22:51
If the report is not too complex and is just printing some lines of text, info, or values,
you might consider to use the spool functions
~Vamsi
5th April 2002, 00:34
How about creating a new device?
Device: ASCIF128
Description: Rewrite ASCII File - Page width 128
Device Type: Rewrite file
4GL Program: otccomconv
Argument: ASCII
Path: Fileout
<yes>: Change Output file allowed
Page Length: 55
Create a 3GL script "tccomconv" with the following code in it:
long ret | general return variable
long fp1 | file pointer for input file
long fp2 | file pointer for output file
string tmp.file(1024) | input file - created by Baan
string line.i(128) fixed | variable to hold a line of data
function main()
{
tmp.file = creat.tmp.file$(bse.tmp.dir$())
wait.and.activate("ttstpconv", argv$(1), tmp.file, argv$(3), argv$(4))
fp1 = seq.open(tmp.file, "r")
fp2 = seq.open(argv$(2), "w")
while not seq.gets(line.i, 128, fp1)
|That line.i is set to fixed should do the trick.
ret = seq.puts(line.i, fp2)
endwhile
ret = seq.close(fp1)
ret = seq.close(fp2)
ret = seq.unlink(tmp.file)
}
Add some error handling to this code before using it. Should you choose to use this route, would appreciate your final code for out Code & Utilities forum.
sweetie
5th April 2002, 12:48
Hi Vamsi,
the idea of reading again the reportfile and writing it with seq of fixed length 128 seems a very good idea.
I will give it a try.
Keep you informed:cool: