FUNCTION YRFCTEST.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(IV_RESULT) TYPE BOOLEAN
*"----------------------------------------------------------------------
DATA:
ls_rfcresult TYPE YRFCRESULT
.
LS_RFCRESULT-TIMESTAMP = SY-DATUM && SY-UZEIT.
LS_RFCRESULT-BUILD_RESULT = IV_RESULT.
INSERT YRFCRESULT FROM ls_rfcresult.
ENDFUNCTION.
#-Begin-----------------------------------------------------------------
#-Sub Load-NCo--------------------------------------------------------
Function Load-NCo {
[String]$ScriptDir = "C:\NCo"
If ([Environment]::Is64BitProcess) {
[String]$Path = $ScriptDir + "\x64\"
} Else {
[String]$Path = $ScriptDir + "\x86\"
}
[String]$File = $Path + "sapnco.dll"; Add-Type -Path $File
$File = $Path + "sapnco_utils.dll"; Add-Type -Path $File
}
#-Function Get-Destination--------------------------------------------
Function Get-Destination {
#-Verbindungsparamter-----------------------------------------------
$cfgParams = `
New-Object SAP.Middleware.Connector.RfcConfigParameters
$cfgParams.Add($cfgParams::Name, "TEST")
$cfgParams.Add($cfgParams::AppServerHost, "localhost")
$cfgParams.Add($cfgParams::SystemNumber, "00")
$cfgParams.Add($cfgParams::Client, "000")
$cfgParams.Add($cfgParams::User, "BCUSER")
$cfgParams.Add($cfgParams::Password, "minisap")
Return [SAP.Middleware.Connector.RfcDestinationManager]::GetDestination($cfgParams)
}
#-Sub Invoke-SAPFunctionModule----------------------------------------
Function Invoke-SAPFunctionModule {
$destination = Get-Destination
#-Metadaten---------------------------------------------------------
$rfcFunction = `
$destination.Repository.CreateFunction("YRFCTEST")
#-Importparameter setzen--------------------------------------------
$rfcFunction.SetValue("IV_RESULT", "X")
#-Funktionsbaustein aufrufen----------------------------------------
$rfcFunction.Invoke($destination)
}
#-Sub Main------------------------------------------------------------
Function Main () {
Load-NCo
Invoke-SAPFunctionModule
}
#-Main----------------------------------------------------------------
Main
#-Error routine-------------------------------------------------------
Trap {
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") > $Null
[Void] [System.Windows.Forms.MessageBox]::Show( `
$_.Exception.GetType().FullName + `
[System.Environment]::NewLine + `
"Error at line " + $_.InvocationInfo.ScriptLineNumber + `
" in " + $_.InvocationInfo.ScriptName + `
[System.Environment]::NewLine + [System.Environment]::NewLine + `
$_.Exception.Message, "An Error Occurred", 0)
Exit
}
#-End-------------------------------------------------------------------
#-Begin-----------------------------------------------------------------
#-Sub Main--------------------------------------------------------------
Function Main() {
$URI = "http://localhost:8090";
$User = "BCUSER";
$Password = "minisap";
$Headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]";
$Bytes = [System.Text.Encoding]::UTF8.GetBytes("$($User):$Password");
$Base64 = [System.Convert]::ToBase64String($Bytes);
$Headers.Add("Authorization","Basic $Base64");
[xml]$Crumbs = Invoke-WebRequest "$URI/crumbIssuer/api/xml" `
-Method Get -Headers $Headers;
$Headers.Add($Crumbs.defaultCrumbIssuer.crumbRequestField, `
$Crumbs.defaultCrumbIssuer.crumb);
$Headers.Add("Accept", "application/xml");
$Result = Invoke-WebRequest -Uri "$URI/job/Test/build" `
-Method Post -Headers $Headers;
}
#-Main------------------------------------------------------------------
Main
#-Error Routine---------------------------------------------------------
Trap {
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") > $Null
[Void] [System.Windows.Forms.MessageBox]::Show( `
$_.Exception.GetType().FullName + `
[System.Environment]::NewLine + `
"Error at line " + $_.InvocationInfo.ScriptLineNumber + `
" in " + $_.InvocationInfo.ScriptName + `
[System.Environment]::NewLine + [System.Environment]::NewLine + `
$_.Exception.Message, "An Error Occurred", 0)
Exit
}
#-End-------------------------------------------------------------------
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
3 | |
3 | |
3 | |
2 | |
2 | |
2 | |
2 | |
2 | |
1 |