@Echo off
REM #Doc: In this script you define customer SAPSiteId settings
REM       This script is used by JobMgr JobScripts parameters
REM       for getting SAPSiteId specific environment
REM       for getting NX specific environment

REM #toDo: please setup Customer TcPrompt settings

REM #New: 04.12.2017 /J.Fes first version



 if "%~1" neq "" set SAPSiteId=%~1
 set SAPPromptCmd=
 set SAPPromptCmdOpt=

 set JobMgr_SAPPromptGet_ResCode=-1
 set JobMgr_SAPPromptGet_ResMsg=Unkown

 Call Echo "----------------------------------------------------------------------------"
 Call Echo "Info: Executing SAPPrompt_Custom.cmd [%SAPSiteId%/%SAPPrompt_Custom_Opt%]"


REM -- #Optional # Conncet Network drives !! -----------------------------------
REM Disk Connect [default=OFF]
set JobMgr_use_DiskConnect=OFF

if "%JobMgr_use_DiskConnect%" neq "ON" goto :Next
  set PLMShare_DiskConnectInfo=S: \\MyServer\ugsshare
  call ConnectNetUnc.cmd "PLMShare" S: \\MySerrver\PLMShare . . PLMshare_DiskConnectStatus
  Echo Connect Disk:%PLMShare_DiskConnectInfo% Status:%PLMshare_DiskConnectStatus%
  if /I not "%PLMshare_DiskConnectStatus%" equ "OK" goto :PLMShare_DiskConnectErr
:Next

REM -- get SAP-prompt ----------------------------------------------------------
set JobMgr_SAPPromptGet_ResCode=0
set JobMgr_SAPPromptGet_ResMsg=OK


REM -- #Doc: Example:  Generic: fuer TC10
if /i "%SAPSiteId%" neq "SAPQSystem" goto :Next
 rem SET SAP_DATA=\\SRV_XXX\PLMShare\SAPdata\windows
 set SAPPromptCmd=%SAP_DATA%\SAP_profilevars.bat
 set SAPPromptCmdOpt=
:Next


REM -- #Doc: Example: addPLM - tc83
if /i "%SAPSiteId%" neq "SAPPSystem" goto :Next
  REM -- #DOC: add settings for SAP Site
   set SAPPromptCmd=
   set SAPPromptCmdOpt=
:Next



REM -- #Doc: Setup custom  SAPPrompt_Custom_Opt
if "%SAPPrompt_Custom_Opt%" neq "NX???" goto :Next
 rem -- #DOC: do setup something depending on this settings
:Next



REM -- #Doc: check start TcPrompt

 if "%SAPPromptCmd%" equ "" goto :SAPPromptCmdNotRequired
 if exist "%SAPPromptCmd%" goto :SAPPromptCmdFoundYES
 goto :SAPPromptCmdFoundNO

:SAPPromptCmdFoundNO
 rem -- #Doc: ERR Custom TC-Prompt not found
 call ErrorHandel "S" "TcPrompt:fnf" "[Missing:%SAPPromptCmd%]"
 goto :End

:PLMShare_DiskConnectErr
 rem -- #Doc: ERR PLMShare
 call ErrorHandel "S" "PLMShare:ERR" "[%PLMShare_DiskConnectInfo% Status:%PLMshare_DiskConnectStatus%]"
 goto :End

:SAPPromptCmdFoundYES
 rem -- #Doc: OK Now execute get Custom TC-Prompt
 call "%SAPPromptCmd%" %SAPPromptCmdOpt%
 goto :Next

:SAPPromptCmdNotRequired
 goto :Next

:Next
 REM -- am Ende "\"  abschneiden
 if not defined UGII_BASE_DIR goto :next
  if "%UGII_BASE_DIR:~-1%" equ "\" set UGII_BASE_DIR=%UGII_BASE_DIR:~0,-1%
 :next

 if not defined UGII_ROOT_DIR goto :next
  if "%UGII_ROOT_DIR:~-1%" equ "\" set UGII_ROOT_DIR=%UGII_ROOT_DIR:~0,-1%
 :next

:Next

 rem #New: 30.05.2014 TC_SHARED_MEMORY_DIR
 if not defined TC_SHARED_MEMORY_DIR_Disable set TC_SHARED_MEMORY_DIR_Disable=true
 if /i "%TC_SHARED_MEMORY_DIR_Disable%" neq "true" goto :TC_SHARED_MEMORY_DIR_Enable



:Next

 Call Echo "----------------------------------------------------------------------------"
 Call Echo "SAPSide.........................: %SAPSiteId%"


 if not defined UGII_BASE_DIR goto :Next
 if not exist "%UGII_BASE_DIR%\nxbin" goto :Next
 REM -- #New: 30.01.2017/J.Fes add tp path .\nxbin since NX11
 set UGII_NXBIN_DIR=%UGII_BASE_DIR%\nxbin
 Call PathEnvAddPath.cmd "%UGII_NXBIN_DIR%"
:Next

 if not defined UGII_ROOT_DIR goto :Next
 Call PathEnvAddPath.cmd "%UGII_ROOT_DIR%"
:Next

 if not defined UGII_BASE_DIR goto :Next
 Call PathEnvAddPath.cmd "%UGII_BASE_DIR%"
:Next

 call Echo "JobMgr_SAPPromptGet_ResCode.....: %JobMgr_SAPPromptGet_ResCode%"
 call Echo "JobMgr_SAPPromptGet_ResMsg......: %JobMgr_SAPPromptGet_ResMsg%"

 goto :end
:end

if /i "%JobMgr_Debug%" neq "ON" goto :JumbOverDebug
 call Echo "---------------------------------------------------------------------------"
 call Echo "#Debug..........................: %~0"
 call Echo "#JobMgr_SAPPromptGet_ResCode....: %JobMgr_SAPPromptGet_ResCode%"
 call Echo "#JobMgr_SAPPromptGet_ResMsg.....: %JobMgr_SAPPromptGet_ResMsg%"
 pause
 Echo "-- TC --------------------------------------------------------------------"
 set TC
 Echo "-- UG --------------------------------------------------------------------"
 set UG
 pause
:JumbOverDebug
