2021.10.14 - [Delphi/꿀팁] - SAP RFC 가져오기 - 1
const
  RESULT_CODE = 1;
  RESULT_MESSAGE = 2;
var
  oLogon: TSAPLogonControl;
  oSAPFunction: TSAPFunctions;
  
  varFunction: Variant;
  varReturn: Variant;
  varItem: Variant;
  varItemsRow: Variant;
begin
  oLogon := TSAPLogonControl.Create(nil);
  oSAPFunction := TSAPFunctions.Create(nil);
  varConnection := RFC.Logon.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('InputParam1').value := 'Value';
    varFunction.exports('InputParam2').value := 'Value';
    
    varItem := varFunction.Tables.Item('TableName');
    
    varItemsRow := varItem.Rows.Add;
    varItemsRow.Value[rcdMapRule.targetcolumnname] := 'Value';
    
    if varFunction.call then begin
      varReturn := varFunction.Imports.item('OutputParam');
      ShowMessage(VarToStr(varReturn.Value(RESULT_CODE)));
      ShowMessage(VarToStr(varReturn.Value(RESULT_MESSAGE)));
    end;
  end;
  
  varConnection.LogOff;
end;
반응형