BAPI / RFC with Delphi(系列之三)--TSAPLogonControl使用(无对话框的登录sap的delphi源代码)...

1、新建一个Form,并在form上添加下列控件

ComponentFunction
SAPLogOnControl1SAP ActiveX-Component to logon to the system
Button1Button to start the procedure

2、源代码如下
 

unit s_logon;

interface

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

type
  TForm1 = class(TForm)
  SAPLogonControl1: TSAPLogonControl;
  Panel1: TPanel;
  Edit1: TEdit;
  Edit2: TEdit;
  Label1: TLabel;
  Label2: TLabel;
  StaticText1: TStaticText;
  Button1: TButton;
  procedure SAPLogonControl1Click(Sender: TObject);
  procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;

var
Form1: TForm1;
Connection :variant;

implementation

{$R *.DFM}

procedure TForm1.SAPLogonControl1Click(Sender: TObject);
begin

  (* define connection and it's parameters *)
  Connection := SAPLogoncontrol1.newConnection;

  (* In some GUI-versions the username *)
  (* must be written in uppercase !!!  *)
 
Connection.User := AnsiUpperCase(Edit1.text);

  Connection.System            := 'IDS';
  Connection.Client            := '800';
  Connection.ApplicationServer := 'SAPIDES';
  Connection.SystemNumber      := '00';
  Connection.Password          := Edit2.text;
  Connection.Language          := 'DE' ;
  SAPLogonControl1.Enabled     := false;

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

  begin
    ShowMessage('Logon O.K.');
    Button1.Enabled:= true;
  end
  else
  begin
    ShowMessage('Error on logon :-(((');
    SAPLogonControl1.Enabled:=true;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin

  (* cut connection *)
  Connection.LogOff;

  ShowMessage('System LogOff...');
  SAPLogonControl1.Enabled:=true;
  Button1.Enabled :=false;
end;
end.

 



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值