cancel
Showing results for 
Search instead for 
Did you mean: 

RFC call from Delphi (Bad Variant Type error)

Former Member
0 Kudos

Well, I'm trying to call an RFC function from Delphi via ActiveX objects..

I have Codegear 2009 installed and it works without any problem..

But on another system with Delphi7 installed when I ran same code it gives "Bad Variant Type" error when assigning SapLogonControl's connection object to SapFunction's connection parameter... Both computers have same SAP installation. And on both systems ActiveX objects imported correctly on Delphi.

Here is the code:


unit logon1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, OleCtrls, StdCtrls, SAPFunctionsOCX_TLB,
Grids, SAPLogonCtrl_TLB;

type
  TForm1 = class(TForm)
  SAPFunctions1: TSAPFunctions;
  Button2: TButton;
  Grid: TStringGrid;
  Edit1: TEdit;
  Edit2: TEdit;
  Label1: TLabel;
  Label2: TLabel;
  SAPLogonControl1: TSAPLogonControl;
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;

var
Form1 : TForm1 ;
Table, Funct, Connection : VARIANT ;

implementation

{$R *.DFM}


procedure TForm1.Button2Click(Sender: TObject);

begin
  Connection                  := SAPLogoncontrol1.newConnection;
  Connection.User             := 'testuser';
  Connection.System           := 'CRD';
  Connection.Client           := '300';
  Connection.ApplicationServer:= '10.1.1.10';
  Connection.SystemNumber     := '00';
  Connection.Password         := 'testpass';
  Connection.Language         := 'EN' ;

  if Connection.LogOn(0,true) = true then
  (* parameter "true" = SilentLogOn *)

  begin

    (* assign the existing connection to the *)
    (* component SAPFunctions1                *)
    SAPFunctions1.Connection := Connection; // It gives error on this line...


    Funct := SAPFunctions1.add('ZGIS_TEST_FUNC');
    .
    .
    .
  end;
end;

end.

As I said while Codegear 2009 runs this code without any problem, Delphi 7 crashes on that assignment.. Also I tried outside Delphi, and the file compiled with Codegear works on both systems while the file compiled with Delphi 7 again crashes on buth systems...

Is there a problem with Delphi 7? Should I use at least Delphi 8 or something for compiling?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Hakan,

I have got exactly the same problem. Did you manage to solve it?

Regards,

Pat.

Former Member
0 Kudos

Hi Hakan,

You must use Non-Unicode RFC library for Delphi 7.0.

( Bende Delphi 7.0 kullaniyorum. Ayni hatayi aldim. Unicode library kullanmistim. Kaldirip Non-Unicode olani kullandim. Su an hata yok. RFC cagirabiliyorum. )

Mustafa Yalcin

Former Member
0 Kudos

hi,Excuse me about bad variant type solved?