有一个数据传输的组件,在Delphi中调用SAP的function。
长期以来有个问题一直让我很困惑:在某些机器上运行的很好,但我自己的机器上却运行不了:
错误提示有几种:
1、明明是正确的密码,连接控件却总提示用户名和密码错误。
2、提示没有授权
3、提示saplogon.ini中找不到xxx.xxx.xxx.xxx(appserver IP)
用了N种方法重写都没有解决,最后偶然试了一下把密码大写,居然通过!!!
真该死,SAP的登录密码居然一定要转为大写!!!但我估计是在某些版本的gui组件中用小写也能通过,只是我的GUI版本太高,所以无法成功登录。
示例代码如下:
(* 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.');
end
else
begin
ShowMessage('Error on logon :-(((');
SAPLogonControl1.Enabled:=true;
end;