Baanboard.com

Baanboard.com (http://www.baanboard.com/baanboard/index.php)
-   Nederlandstalig forum (http://www.baanboard.com/baanboard/forumdisplay.php?f=67)
-   -   switch.to.company werkt niet (http://www.baanboard.com/baanboard/showthread.php?t=66386)

Rickman 16th May 2014 13:46

switch.to.company werkt niet
 
1 Attachment(s)
Ik gebruik in een reportscript de functie 'switch.to.company'.
Kort na deze functie volgt een update in tccom010 maar ondanks dat er geen error ontstaat bij bovengenoemde functie, wordt de update in hetzelfde (verkeerde) bedrijf gedaan. Kortom, er wordt niet van bedrijf gewisseld.

Zou iemand mij kunnen vertellen waar het precies fout gaat?

Met vriendelijke groet,

Jan

bhushanchanda 16th May 2014 13:57

Use this:-

Code:

db.set.to.default(ttccom010)

switch.to.company(target_comp)
db.set.retry.point()

select tccom010.*
from  tccom010 for update
as set with 1 rows
selectdo
....
...
...
db.update()
endselect

commit.transaction()


OR

Code:



db.set.retry.point()
db.set.to.default(ttccom010)
select tccom010.*
from  tccom010 for update
where tccom010._compnr = :target_comp
as set with 1 rows
selectdo
....
...
...
db.update()
endselect

commit.transaction()


Rickman 20th May 2014 15:03

It is not working
 
1 Attachment(s)
No matter which way I try, it is not working.

Maybe i't will be more clear if I attach the whole script.

The script is creating debtors, based on records in pampa003
The value of pampa002.ctpc of the first record is "015", so according the case statement the target_comp = 212. The first record is processed the way it should be (a debtor is created in company 212). The second record has a pampa002.ctpc value of "016", the target_comp is set to 118. But during the update in table tccom010 (after function 'switch.to.├žompany'
the record is inserted in company 212 instead of company 118.

That's the problem. :confused:

bhushanchanda 20th May 2014 15:22

Hi,

Check whether field pampa002.ctpc is added in Report Input Fields. Also check all other fields which you are using in your report script.

vamsi_gujjula 20th May 2014 17:35

i would recommend .. to debug the report script

Moreover i would prefer using compnr.check with if else

if compnr.check (target.comp) then
.... do xyz
else
error while switching
endif

JaapJD 20th May 2014 20:06

Ensure that the package combinations of 118 and 212 are equal to your current package combination. Probably 212 is, but 118 is not. If you check the return value of switch.to.company, you will see it failing.
Note that you can use different package combinations, but the data model (tables, domains, CDF, timestamps, MLE) need to be the same.


All times are GMT +2. The time now is 03:54.


vB.Sponsors
©2001-2017 - Baanboard.com - Baanforums.com