DELPHI 调用SAP—RFC 示例

2024-04-21 15:18
文章标签 调用 示例 delphi rfc sap

本文主要是介绍DELPHI 调用SAP—RFC 示例,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

DELPHI 调用SAP—RFC 示例


Logon to the R3-system with the componente TSAPLogOnControl


In this example the form TForm1 contains the following components:

Component Function
SAPLogOnControl1 SAP ActiveX-Component to logon to the system
Button1 Button to start the procedure

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;
  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 *)
  Connection:= SAPLogOnControl1.NewConnection;

  (* start LogOn *)
  if Connection.LogOn(0,false) = true then

  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.


top of page

Example 2:

Logon to the R3-system with the Component TSAPLogOnControl and SilentLogOn


In this example the form TForm1 contains the following components:

Component Function
SAPLogOnControl1 SAP ActiveX-Component to logon to the system
Button1 Button to cut the connection

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.


top of page



Example 3:
Read all costcenters with the function RFC_READ_TABLE

In this example the form TForm1 contains the following components:

Component function
SAPFunctions1 SAP ActiveX-component to connect RFC/BAPI
Grid

这篇关于DELPHI 调用SAP—RFC 示例的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/923392

相关文章

C++20管道运算符的实现示例

《C++20管道运算符的实现示例》本文简要介绍C++20管道运算符的使用与实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧... 目录标准库的管道运算符使用自己实现类似的管道运算符我们不打算介绍太多,因为它实际属于c++20最为重要的

Java中调用数据库存储过程的示例代码

《Java中调用数据库存储过程的示例代码》本文介绍Java通过JDBC调用数据库存储过程的方法,涵盖参数类型、执行步骤及数据库差异,需注意异常处理与资源管理,以优化性能并实现复杂业务逻辑,感兴趣的朋友... 目录一、存储过程概述二、Java调用存储过程的基本javascript步骤三、Java调用存储过程示

ModelMapper基本使用和常见场景示例详解

《ModelMapper基本使用和常见场景示例详解》ModelMapper是Java对象映射库,支持自动映射、自定义规则、集合转换及高级配置(如匹配策略、转换器),可集成SpringBoot,减少样板... 目录1. 添加依赖2. 基本用法示例:简单对象映射3. 自定义映射规则4. 集合映射5. 高级配置匹

C++11作用域枚举(Scoped Enums)的实现示例

《C++11作用域枚举(ScopedEnums)的实现示例》枚举类型是一种非常实用的工具,C++11标准引入了作用域枚举,也称为强类型枚举,本文主要介绍了C++11作用域枚举(ScopedEnums... 目录一、引言二、传统枚举类型的局限性2.1 命名空间污染2.2 整型提升问题2.3 类型转换问题三、C

Python中Tensorflow无法调用GPU问题的解决方法

《Python中Tensorflow无法调用GPU问题的解决方法》文章详解如何解决TensorFlow在Windows无法识别GPU的问题,需降级至2.10版本,安装匹配CUDA11.2和cuDNN... 当用以下代码查看GPU数量时,gpuspython返回的是一个空列表,说明tensorflow没有找到

Java实现自定义table宽高的示例代码

《Java实现自定义table宽高的示例代码》在桌面应用、管理系统乃至报表工具中,表格(JTable)作为最常用的数据展示组件,不仅承载对数据的增删改查,还需要配合布局与视觉需求,而JavaSwing... 目录一、项目背景详细介绍二、项目需求详细介绍三、相关技术详细介绍四、实现思路详细介绍五、完整实现代码

python如何调用java的jar包

《python如何调用java的jar包》这篇文章主要为大家详细介绍了python如何调用java的jar包,文中的示例代码简洁易懂,具有一定的借鉴价值,有需要的小伙伴可以参考一下... 目录一、安装包二、使用步骤三、代码演示四、自己写一个jar包五、打包步骤六、方法补充一、安装包pip3 install

C++ 检测文件大小和文件传输的方法示例详解

《C++检测文件大小和文件传输的方法示例详解》文章介绍了在C/C++中获取文件大小的三种方法,推荐使用stat()函数,并详细说明了如何设计一次性发送压缩包的结构体及传输流程,包含CRC校验和自动解... 目录检测文件的大小✅ 方法一:使用 stat() 函数(推荐)✅ 用法示例:✅ 方法二:使用 fsee

mysql查询使用_rowid虚拟列的示例

《mysql查询使用_rowid虚拟列的示例》MySQL中,_rowid是InnoDB虚拟列,用于无主键表的行ID查询,若存在主键或唯一列,则指向其,否则使用隐藏ID(不稳定),推荐使用ROW_NUM... 目录1. 基本查询(适用于没有主键的表)2. 检查表是否支持 _rowid3. 注意事项4. 最佳实

HTML中meta标签的常见使用案例(示例详解)

《HTML中meta标签的常见使用案例(示例详解)》HTMLmeta标签用于提供文档元数据,涵盖字符编码、SEO优化、社交媒体集成、移动设备适配、浏览器控制及安全隐私设置,优化页面显示与搜索引擎索引... 目录html中meta标签的常见使用案例一、基础功能二、搜索引擎优化(seo)三、社交媒体集成四、移动