inalfa01
8th November 2005, 15:01
What was the exact procedure to copy a company to a new number?
Especially the repairing of the company number in th new company...
I believe there are no sesisons for this repairing in 2.2d...

Viplov
10th November 2005, 13:45
You can create a new company and then create a sequential dump of the another company which you want to copy.

inalfa01
14th November 2005, 14:14
But how to convert the company number in the new company in 2.2d?

dave_23
14th November 2005, 19:21
Does triton of the tfgld9001 - 9004 sessions? that is how you would
change the company number if the data.

Dave

norwim
15th November 2005, 09:55
Hi there,

lets assume you have sequential dumps of all tables in directory "/dump".
These seq. dumps have seperator "|".
Lets further assume your companynumber is "123".

change to directory /dump

Create the following file (in directory /dump) "awkcomchk":

#----------start of file awkcomchk
BEGIN{FS="|"}
{if (NR==1) for (i=1;i<=NF;i++) x[i]=1}
{for (i in x) if ($i!="123") delete x[i]}
{ok=asort(x,y); if (ok==0) exit}
END{for (i in x) these=these " " i;
if (these!="") print FILENAME" Companynumber in: " these}
#----------End of file



Now check all sequential dump files there using:
for i in *
do
awk -f awkcomchk $i
done

This will give you a list of all files which have the string "123" in each field x.

To change these via awk ist a lot simpler than the above script :-)


hth

Norbert

norwim
15th November 2005, 10:39
Hi there,

with the above assumptions (old company number= "123", new shall be "321")
#----start of awkconvcomp
BEGIN{FS="|"}
{if (NR==1) for (i=1;i<=NF;i++) x[i]=1}
{for (i in x) if ($i!="123") delete x[i]}
{ok=asort(x,y); if (ok==0) exit}
END{for (i in x) these=these " " i;
if (these!="")
{print "mv "FILENAME" orig/"FILENAME >> "convert.sh";
print "BEGIN{FS=\"|\";OFS=\"|\"}" > "awk"FILENAME;
for (i in x) print "{$"i"=\"321\"}" > "awk"FILENAME;
print "{print $0}" > "awk"FILENAME;
print "awk -f awk"FILENAME " orig/"FILENAME " > "FILENAME
>> "convert.sh"}}
#----end of file awkconvcomp
The above script will create a script "convert.sh" plus all awk-scripts needed to change 123 into 321.

requirements:

complete sequential dump in directory /dump ... all files have seperator "|"
you created a directory /dump/orig
you pasted the awkscript above into /dump/awkconvcomp

go to directory /dump

for i in *
do
awk -f awkconvcomp $i
done
..
then
sh convert.sh

Tested. Note that if your bdbpost creates two leading lines, then you may need to insert
{if (NR==1) {next;next}} as line 3 in the above awk-script
Of course you should check the result, if you have a corrupted record with no company number in it, then the table won't be converted .... but I thought it to be funny to have a solution independent of Baan Version :-)

hth

Norbert