1.連線
sapconnection :=
SAPLogonControl1 .NewConnection ;
sapconnection.User :=
AnsiUpperCase(‘userid‘);
sapconnection.system := ‘TES’
;// server 簡稱 ‘TES’;
sapconnection.client :=
‘105’ ;// client id ‘105’;
sapconnection.applicationserver := ‘192.168.1.27’ ;//ip;
sapconnection.systemnumber:= ’00’ ;
//’00’;
sapconnection.password := ‘passwd‘ ;
sapconnection.language := ‘zf’ ;// ‘ZH’;
sapconnection.CodePage := ‘8300’;
2. CALL RFC
SAPFunctions1.RemoveAll;
funct :=SAPFunctions1.add(‘Z_PP_PROD’); // function 名稱
funct.EXports(‘I_WERKS’).VALUE:= ‘1000’; // 輸入的參數
funct.EXports(‘I_PRODNO’).VALUE:= ‘4500000001’; // 輸入的參數2
funct.EXports(‘I_PRODITM’).VALUE:= ‘00010’;
IF
NOT funct.CALL THEN
ShowMessage(‘呼叫error’)
ELSE BEGIN
try
table :=funct.imports.Item(‘E_ZPPS009’); //連結成功 返回的 Table
except
ShowMessage(‘error’)
end;
// 可直接使用 TABLE 的值
StringGrid1 .Cells [1,1]:=
TABLE.Value(‘WERKS’) ;
StringGrid1 .Cells [2,1]:=
TABLE.Value(‘PRODNO’);
StringGrid1 .Cells [3,1]:=
TABLE.Value(‘PRODITM’);
StringGrid1 .Cells [4,1]:=
TABLE.Value(‘LIFNR’);
StringGrid1 .Cells [5,1]:=
TABLE.Value(‘NAME1’);
StringGrid1 .Cells [6,1]:=
TABLE.Value(‘MATNR’);