별도 class로 만들어서 관리하고 있으나, 최소 로직으로만 간단하게 적어보았습니다.
const
RESULT_CODE = 1;
RESULT_MESSAGE = 2;
var
I: Integer;
oLogon: TSAPLogonControl;
oSAPFunction: TSAPFunctions;
varConnection: Variant;
varFunction: Variant;
varTable: Variant;
varReturn: Variant;
begin
oLogon := TSAPLogonControl.Create(nil);
oSAPFunction := TSAPFunctions.Create(nil);
varConnection := oLogon.NewConnection;
varConnection.ApplicationServer := '';
varConnection.User := '';
varConnection.Password := '';
varConnection.Client := '';
varConnection.System := '';
varConnection.SystemNumber := '';
varConnection.Language := '';
varConnection.CODEPAGE := '';
oLogon.Enabled := False;
if varConnection.LogOn(0, True) = True then begin
oSAPFunction.Connection := varConnection;
varFunction := oSAPFunction.Add('FunctionName');
varFunction.exports('InputParam').value := 'Value';
if varFunction.call then begin
varReturn := varFunction.Imports.item('OutputParam');
ShowMessage(varReturn.value(RESULT_CODE));
ShowMessage(varReturn.value(RESULT_MESSAGE));
varTable := varFunction.Tables.Item('TableName');
for I := 1 to varTable.RowCount do
ShowMessage(varTable.value(I, 'ColumnName'));
end;
end;
varConnection.LogOff;
end;
반응형