如何用dephi连接SAP调用RFC?
具体要怎么调用?
是否要用到什么SDK?

解决方案 »

  1.   

    汗foxyy8888和vividw~~~~~
    RFC,都木有听说过?严重怀疑你俩是不是多年的网虫~~
      

  2.   

    先要安裝2個控件,RFCGFunctions & RFCLoginControlunit logon1;interfaceusesWindows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,ExtCtrls, OleCtrls, StdCtrls, SAPFunctionsOCX_TLB, Grids;type
    TForm1 = class(TForm)
      SAPFunctions1: TSAPFunctions;
      Button1: TButton;
      Grid: TStringGrid;
      procedure Button1Click(Sender: TObject);
    private
    { Private-Deklarationen }
    public
    { Public-Deklarationen }
    end;var
    Form1 : TForm1 ;
    Table,Funct : VARIANT ;implementation
    {$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
    var txt : string  ;
        r   : integer ;
    begin  (* define function *)
      Funct := SAPFunctions1.add('RFC_READ_TABLE');  (* tell the function what table should be read *)
      Funct.exports('QUERY_TABLE').value := 'CSKT';  (* call the function *)
      if not Funct.call then    (* on error show message *)
        showMessage(Funct.exception)  else begin    (* select table with the data's *)
        Table := Funct.tables.item('DATA');    (* addjust the StringGrid *)
        grid.rowCount := Table.rowcount + 1;
        grid.cells[0,0] := 'Client';
        grid.cells[1,0] := 'Kostenstelle';
        grid.cells[2,0] := 'Bezeichnung';
        for r := 1 to grid.rowCount -1 do begin      (* select first dataset *)
          txt := Table.value(r,1);      (* Because the RCF-function returns only one    *)
          (* string whitch contains all data's, the       *) 
          (* string must be cut to different parts        *)
          grid.cells[0,r] := copy(txt,0,3);   (* Client                *)
          grid.cells[1,r] := copy(txt,9,10);  (* CostCent-number     *)
          grid.cells[2,r] := copy(txt,27,20); (* CostCent-description*)
        end;
        grid.visible := True;
      end;
    end;
    end.