Article
A Forum reader recently asked:
"I have a problem with the SAP script for NSL 6.01. The script does not always recognize the main SAP logon window and therefore is not filling the username and password fields. This happens about 80% of the time when I open the SAP GUI."
And here's the response from Michael Kimble ...
Solution
Here is the SAP script that I have been using. It works with SAP 6.20 and 6.40.
#================================================================================
# Set Password Policy to SAPPwdPolicy
# Uncomment these next two lines to use the password policies
# NOTE: you have to create a password policy to match the specified
name
#================================================================================
#RestrictVariable $Password SAPPwdPolicy
#RestrictVariable ?NewPassword SAPPwdPolicy
# Reset Error Code Variable
Set ?ErrorMsg "<NOTSET>"
#================================================
# System Selection Box
# Detects what the user selected from the menu
#================================================
Dialog
Class "Sapgui 620"
EndDialog
#=========================================================================
# Read the title and set it
# Allows one script for multiple backend systems
# LoginWatch.exe can be used to determine RegSplit syntax for your
site
#=========================================================================
ReadText #0 ?Title
If ?Title Eq "<NOTSET>"
EndScript
Else
RegSplit "Sapgui 620 \[/M/(.*)/S/(.*)/G/(.*) 3\]" ?Title
?SAPMessageServer ?SAPSystemID ?SAPSystem
# StrCat ?PlatformName "SAP - " ?SAPSystem
StrCat ?PlatformName "SAP - " ?SAPMessageServer
Set ?SAPSystem ?PlatformName
EndScript
EndIf
#================================================
# System Selection Box for v6.4
# Detects what the user selected from the menu
#================================================
Dialog
Class "Sapgui 640"
EndDialog
#=========================================================================
# Read the title and set it
# Allows one script for multiple backend systems
# LoginWatch.exe can be used to determine RegSplit syntax for your
site
#=========================================================================
ReadText #0 ?Title
If ?Title Eq "<NOTSET>"
EndScript
Else
# RegSplit "Sapgui 640 (.*)/S/(.*) 3" ?Title ?SAPHost ?SAPSID
RegSplit "Sapgui 640 \[/M/(.*)/S/(.*) 3" ?Title ?SAPHost ?SAPSID
# StrCat ?SAPSystem "SAP - " ?SAPHost ":" ?SAPSID
StrCat ?SAPSystem "SAP - " ?SAPHost
EndScript
EndIf
#=========================================
# Login Dialog Box when Title is SAP
#=========================================
Dialog
Title "SAP"
Ctrl #100
Ctrl #400
Ctrl #59393
EndDialog
# SetPlat allows multiple usernames and passwords to operate
seamlessly
SetPlat ?SAPSystem
# Handles Logon (If a User has no credentials saved, prompt the user
for them)
Call Logon
#============================================================================================================
# Repeat loop to handle events that occur after a logon attempt e.g.
error handling
# Delay is required on logon to allow the application to generate any
errors before the script continues...
#============================================================================================================
Delay 1000
Repeat
# Read the error message and set it as a variable
ReadText #59393 ?ErrorMsg
# If the user must enter a new password, break this repeat loop (and
start the change password)
If ?ErrorMsg Eq "Please enter new password"
Break
EndIf
# If SAP starts, there are no errors so break this repeat loop
If ?ErrorMsg Eq " Loading data..."
Break
EndIf
# Check to see if User Is Locked
If ?ErrorMsg Eq "User is locked. Please notify the person
responsible"
MessageBox "Your SAP account has been locked. Please contact
the Helpdesk."
KillApp "SAPLOGON.EXE"
Set ?ErrorMsg "<NOTSET>"
EndScript
EndIf
# If there are no errors, break this repeat loop
If ?ErrorMsg Eq "<NOTSET>"
Break
EndIf
# Then check that all required fields are complete. This error should
never occur.
If ?ErrorMsg Eq "Make an entry in all required fields"
OnException EnterVariablesCancelled Call EnterVariablesCancel
DisplayVariables "Please enter your SAP login details, please
put an entry in all fields."
# Before we put the correct Username in, make sure that the field is
clear
Repeat 12
Type "\d"
EndRepeat
Call Logon
EndIf
# Also check for password reset by help desk or incorrect details on
first screen
If ?ErrorMsg Eq "Name or password is incorrect. Please re-enter"
OnException EnterVariablesCancelled Call EnterVariablesCancel
DisplayVariables "The Username and/or password is incorrect.
Please verify your details and try again."
# Before we put the correct Username in, make sure that the field is
clear
Repeat 12
Type "\d"
EndRepeat
Call Logon
EndIf
Delay 100
EndRepeat
#==========================================================================================
# Change Password Detected
# Parent is used because the window we wish to set focus on is behind
the active window
#==========================================================================================
Dialog
Title "SAP R/3"
Class #32770
Parent
Title "SAP R/3"
Class "SAP_FRONTEND_SESSION"
EndParent
EndDialog
# SetPlat is used to point to where the Username and Password are
stored (not against FRONT.EXE)
SetPlat ?SAPSystem
#===================================================================================
# System requests new password, prompt the user for it and set it when
correct.
#===================================================================================
Set ?OriginalPassword $Password
ChangePassword ?NewPassword "Your password has expired. Please
enter a new password."
Type ?NewPassword
Delay 100
Type "\T"
Type ?NewPassword
Delay 100
Type "\N"
Set $Password ?NewPassword
#================================================================================
# Change password rejected by SAP. Clear the message and prompt user
to retry.
#================================================================================
Dialog
Title "Error"
Class #32770
Parent
Title "SAP R/3"
Class #32770
EndParent
EndDialog
SetPlat ?SAPSystem
Type "\N" -Raw
Set $Password ?OriginalPassword
Type "\N" -Raw
MessageBox "Your password was NOT changed! The application must
close and you must start it again."
KillApp "SAPLOGON.EXE"
#=============================
# Login Dialog Box
#=============================
Dialog
Title "SAP R/3"
Ctrl #100
Ctrl #400
Ctrl #59393
EndDialog
# SetPlat allows multiple usernames and passwords to operate
seamlessly
SetPlat ?SAPSystem
# Handles Logon (If a User has no credentials saved, prompt the user
for them)
Call Logon
#============================================================================================================
# Repeat loop to handle events that occur after a logon attempt e.g.
error handling
# Delay is required on logon to allow the application to generate any
errors before the script continues...
#============================================================================================================
Delay 1000
Repeat
# Read the error message and set it as a variable
ReadText #59393 ?ErrorMsg
# If the user must enter a new password, break this repeat loop (and
start the change password)
If ?ErrorMsg Eq "Please enter new password"
Break
EndIf
# If SAP starts, there are no errors so break this repeat loop
If ?ErrorMsg Eq " Loading data..."
Break
EndIf
# Check to see if User Is Locked
If ?ErrorMsg Eq "User is locked. Please notify the person
responsible"
MessageBox "Your SAP account has been locked. Please contact
the Helpdesk."
KillApp "SAPLOGON.EXE"
Set ?ErrorMsg "<NOTSET>"
EndScript
EndIf
# If there are no errors, break this repeat loop
If ?ErrorMsg Eq "<NOTSET>"
Break
EndIf
# Then check that all required fields are complete. This error should
never occur.
If ?ErrorMsg Eq "Make an entry in all required fields"
OnException EnterVariablesCancelled Call EnterVariablesCancel
DisplayVariables "Please enter your SAP login details, please
put an entry in all fields."
# Before we put the correct Username in, make sure that the field is
clear
Repeat 12
Type "\d"
EndRepeat
Call Logon
EndIf
# Also check for password reset by help desk or incorrect details on
first screen
If ?ErrorMsg Eq "Name or password is incorrect. Please re-enter"
OnException EnterVariablesCancelled Call EnterVariablesCancel
DisplayVariables "The Username and/or password is incorrect.
Please verify your details and try again."
# Before we put the correct Username in, make sure that the field is
clear
Repeat 12
Type "\d"
EndRepeat
Call Logon
EndIf
Delay 100
EndRepeat
# Sub Routine Called for Logon
Sub Logon
SetPrompt "Username:"
Type $Username
Type "\T"
SetPrompt "Password:"
Type $Password
Type "\N"
Delay 2000
Set ?ErrorMsg "<NOTSET>"
EndSub
# Sub Routine Called if user cancels correcting credentials
Sub EnterVariablesCancel
Type \Alt+\|115
EndScript
EndSub
SetPrompt "Please enter your credentials to logon to SAP."
Environment
- SAP GUI ver: 6.20 and 6.40
- NSL verison: 6.01.05 installed in eDirectory LDAP mode (without
SecretStore) - Windows XP SP2, Windows 2000 SP3 and Windows 2000 SP4
Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (so don't even think of calling Support if you try something and it blows up).
It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.
Related Articles
User Comments
- Be the first to comment! To leave a comment you need to Login or Register
- 3835 reads


0