Bapi/RFC with Delphi (Series 3) -- use tsaplogoncontrol (login to the Delphi source code of SAP without a dialog box)

Source: Internet
Author: User

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


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

2,Source codeAs follows:
 

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: = 'kids ';
Connection. Client: = '000000 ';
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.

 

 
Wdtfuncs SAP data type not supportederror on line: Set I _tabname = func. Exports ("tabname ")

Here is my VB code:

Option explicitpublic functions as sapfunctionsocx. sapfunctionsprivate logoncontrol as saplogonctrl. saplogoncontrolprivate r3connection as saplogonctrl. connectionprivate tablefactory as saptablefactorydim func as sapfunctionsocx. functionpublic I _tabname as sapfunctionsocx. parameterpublic I _field as sapfunctionsocx. parameterpublic I _langu as sapfunctionsocx. parameterpublic strlabel as sapfunctionsocx. parameter 'public tentries as saptablefactoryctrl. tablepublic sub main () dim IX as integer dim retcm as Boolean dim silentlogon as Boolean set logoncontrol = Createobject ("sap. logoncontrol.1 ") set functions = Createobject (" sap. functions ") set tablefactory = Createobject (" sap. tablefactory.1 ") set r3connection = logoncontrol. newconnection r3connection. client = "000" r3connection. applicationserver = "a1kgnb09" r3connection. language = "de" r3connection. user = "bcuser" r3connection. password = "minisap" r3connection. system = "A1 sap 620 09" r3connection. systemid = "000" r3connection. systemnumber = "00" r3connection. usesaplogonini = false silentlogon = false retcm = r3connection. logon (0, silentlogon) If retcm <> true then msgbox "Logon Failed": Exit sub functions. connection = r3connection set func = functions. add ("ddif_fieldlabel_get") set I _tabname = func. exports ("tabname") set I _field = func. exports ("fieldname") set I _langu = func. exports ("Langu") set strlabel = func. imports ("label") I _tabname.value = "usr02" I _field.value = "bname" I _assist.value = "de" func. call msgbox strlabel 'debug. print enumber_of_entries 'For IX = 1 to tentries. rowcount 'debug. print tentries (IX, 1) 'Next r3connection. logoffend sub

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.