
We have a requirement where we need to create a text file in BC Cloud.
Using stream functions for the same.
The separator in this file is not a tab.
This file has a defined length for each value and if something is not satisfying is less in length then it remains blank and if more than length then it truncates.
How to achieve this in code.
Example:
Sales Line info with Item no and name and amount .two lines I will explain
ITEM0001fruit 200.76
ITEM0001basket200.76
so
outstrea.write(no+description)+tab+outstream.write(amount);
here TAB will shift the amount to right but here this is not the case
so first place value is fixed to 20:
so if 16 is the length of both(no+description) those 16 places should be occupied by value and the rest will remain blank and if satisfies length like in line 2 or more then it gets truncated to 20only. so no shift in the amount place holder.
No change in amount position ,it will start at 21 position only as an example
so how to achieve this if length keeps on varying how to add those many of spaces to keep length fixed.
Sample like
20 dot places
....................amount
value exist
ITEM01fruit........amount
so all 20 Is occupied then only other value starts
Hello,
In BC cloud, you can't use Write function. you need to use WriteText to create text file. for fixed spacing, you can use PADSTR. below is an example.