Bapi/RFC with Delphi (Series 5) -- use tsapfunctions and tsaplogoncontrol (No Logon dialog box Delphi source code)

Source: Internet
Author: User

1. Create a new form and add the following controls on the form


Component Function
Sapfunctions1 SAP ActiveX-component to connect RFC/bapi
Saplogoncontrol1 SAP ActiveX-component to logon to the system
Grid Stringgrid to show the data's in the form
Button1 Button to start the procedure

2. The source code is as follows (use the rfc_read_table function to read the cost center)
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 );
VaR TXT: string;
R: integer;

Begin
Connection: = saplogoncontrol1.newconnection;
Connection. User: = ansiuppercase (edit1.text );
Connection. System: = 'kids ';
Connection. Client: = '000000 ';
Connection. applicationserver: = 'sapides ';
Connection. systemnumber: = '00 ';
Connection. Password: = edit2.text;
Connection. Language: = 'de ';

If connection. Logon (0, true) = true then
(* Parameter "true" = silentlogon *)

Begin

(* Assign the existing connection to *)
(* Component sapfunctions1 *)
Sapfunctions1.connection: = connection;

Funct: = sapfunctions1.add ('rfc _ read_table ');
Funct. Exports ('query _ table'). Value: = 'cskt ';
If not funct. Call then
Showmessage (funct. Exception)
Else begin
Table: = funct. Tables. Item ('data ');
Grid. rowcount: = table. rowcount + 1;
Grid. cells [0, 0]: = 'client ';
Grid. cells [1, 0]: = 'costcent-No ';
Grid. cells [2, 0]: = 'costcent-Des .';
For R: = 1 to grid. rowcount-1 do begin
TXT: = table. Value (R, 1 );
Grid. cells [0, R]: = copy (txt, 0, 3 );
Grid. cells [1, R]: = copy (txt, 9, 10 );
Grid. cells [2, R]: = copy (txt, 27,20 );
End;
Grid. Visible: = true;
End;
End;
End;
End.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.