Hi All,

Context: I'm looking at integrating our stock-counting system
(Microsoft Access/VBA) more closely with Axapta using the
AxaptaCOMConnector. The intention is to automate the transfer of
results from the stock-counting system into an Axapta table called
SynStockTake. This will remove much user intervention to export/import
several batches of data.

Setup: I have created an Axapta class called SynStkTkRemote with a
method called countLinesAdd intended to be called from Access which
will add a record into the Axapta table. To create the standard COM I
created a new configuration called 'Connector' with the appropriate
application, database and company (DataAreaID) setup. I have tested
the AxaptaCOMConnector with the Axapta Class using VB6 and Microsoft
Access and VBA - and on the surface seems fine. The VB program creates
the COM Objects, Logs onto Axapta, executes Axapta methods, Logs Off
Axapta, and finally the objects are destroyed.

Problem: When the VB program launches, the button clicked to execute
the CountLinesAdd method works fine ONLY the first time it is used -
i.e. the records are added to SynStockTake as expected into the
correct company (SYN). There-after the class uses the 'DAT' company
instead - i.e. countLinesAdd() adds records to, and getCheckQty()
queries the 'DAT' dataAreaID. The only way to make sure the correct
company is used again is to completely close the program and re-run it
- which will not be feasible in a live environment. The class works
fine everytime within Axapta itself.

Attempted Solutions:

      1) I've tried to force the Axapta Class to use the 'SYN' company
by adding ChangeCompany('SYN') and SynStockTake.company('SYN') with no
sucess.
      2) It crossed my mind the AxaptaCOMConnector might be picking up
the Company from the 'Original (installed configuration)' Axapta
configuration so I amended the registry settings accordingly and
re-registered the COM Components, again with no sucess.
      3) In the AxaptaCOMConnector.Axapta class, the logon() method
includes a parameter to specify the configuration used - this makes no
difference.



Axapta Version: Navision Axapta 3.0 Build #1951.210/514-90 SP2/OP023-19
User Operating System: WinXP
AxaptaCOMConnector version: 1.2

I've googled this problem with no result. Has anybody else experienced
this? I would be extremely grateful for any help/suggestions.

Axapta Class:

Code:
public class SynStkTkRemote
{
    SynStockTake            SynStockTake;
}

Static void Main(Args    _args)
{

}

void new()
{
    ;
    ChangeCompany('SYN')
    SynStockTake.company('SYN');
}


private void setCompany()
{
    ;
    ChangeCompany('SYN')
    SynStockTake.company('SYN');
}

public int countLinesAdd(ItemID _ItemID, WMSLocationID _WMSLocationID,
           WMSPalletID _WMSPalletID, InventQty _QtyCounted,
SynStkCntType _RecordType)
{
    ;
    this.setCompany();

    ttsbegin;
    SynStockTake.clear();
    SynStockTake.initValue();
    SynStockTake.ItemId        = _ItemID;
    SynStockTake.WMSLocationId = _WMSLocationID;
    SynStockTake.WMSPalletID   = _WMSPalletID;
    SynStockTake.QtyCounted    = _QtyCounted;
    SynStockTake.RecordType    = _RecordType;
    SynStockTake.insert();
    ttscommit;

    return 1; // to develop: return 0 if insert failed.

}

public real getCheckQty()
{
    real         checkQty;
    ;

    this.setCompany();

    SynStockTake.company('SYN');
    checkQty = (Select Sum(QtyCounted) From SynStockTake).QtyCounted;

    return checkQty;
}



VB6/VBA Code:

Code:
Private Sub cmdAddRecord_Click()

    Dim Axapta As AxaptaCOMConnector.Axapta
    Dim axStk As AxaptaCOMConnector.IAxaptaObject
      
    Set Axapta = New AxaptaCOMConnector.Axapta
  
    Axapta.Logon
  
    Set axStk = Axapta.CreateObject("SynStkTkRemote")
  
    MsgBox axStk.Call("countLinesAdd", Me.txtItemID.Text,
Me.txtLocation.Text, Me.txtStillage.Text, CInt(Me.txtQtyCounted), 1)

    Axapta.Logoff

    Set axStk = Nothing
    Set Axapta = Nothing
  
End Sub

Private Sub cmdCheckQty_Click()

    Dim Axapta As AxaptaCOMConnector.Axapta
    Dim axStk As AxaptaCOMConnector.IAxaptaObject
      
    Set Axapta = New AxaptaCOMConnector.Axapta
  
    Axapta.Logon , , , "Connector"
  
    Set axStk = Axapta.CreateObject("SynStkTkRemote")
  
    MsgBox axStk.Call("getCheckQty")
  
    Axapta.Logoff

    Set axStk = Nothing
    Set Axapta = Nothing
  
End Sub








SPONSORED LINKS
Computer part Programming languages Microsoft axapta
Support exchange


YAHOO! GROUPS LINKS




Reply via email to