Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

The Motivation for Automating SAP Login

 

Many of us would be working on several SAP systems on any day. If you're tired of entering the username and password in every SAP system you enter, this document will help you by automating the entrance to SAP landscapes by skipping the logon screen using a simple GuiXT script. GuiXt is based on a simple scripting language.

From version 4.x GuiXT is included with SapGui free of charge. For earlier versions we would have to procure it from Synactive.

Steps to be followed-

  1. Activate GuiXT by navigating to Customize Local Layout () and selecting Activate GuiXT.

    2.   Navigate to C Drive and create a folder and name it – GuiXT

    3.   Create a subfolder and name it – Scripts

    4.   Now create a report program with code-

*External files        : None
*SAP Release          : SAP ECC 6.0
*DESCRIPTION: Program to download Logon script for auto-sign in

REPORT  ZAJ_GUIXT no STANDARD PAGE HEADING.
*------------------------------------------------------------------------------*
* DATA TYPE DECLARATION
*------------------------------------------------------------------------------*

data: BEGIN OF it_tab OCCURS 0,
       line_text type string,
      END OF it_tab.
data: filenam type string.
*------------------------------------------------------------------------------*
* SELECTION
*------------------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-002.
SELECTION-SCREEN COMMENT /1(79) text-001.
parameters: p_file type string default 'c:\guixt\scripts' .
parameters:p_sid(3) type c DEFAULT 'RET',
           p_clnt(3) type c DEFAULT '112',
           p_unam(8) type c default '123456',
           p_pwd type maktx default 'xxxxxx'. " Case Sensitive
SELECTION-SCREEN END OF BLOCK b1.

CONCATENATE 'if V[_database=' p_sid ']' INTO it_tab-line_text.
append it_tab.

CONCATENATE 'Set F[RSYST-MANDT]   "' p_clnt '"' into it_tab-line_text.
append it_tab.

CONCATENATE 'Set F[RSYST-BNAME]   "' p_unam '"' into it_tab-line_text.
append it_tab.

CONCATENATE 'Set F[RSYST-BCODE]   "' p_pwd '"' into it_tab-line_text.
append it_tab.

it_tab-line_text = 'Set F[RSYST-LANGU]   "en"'.
append it_tab.

it_tab-line_text = 'Enter'.
append it_tab.

it_tab-line_text = 'EndIf'.
append it_tab.

CONCATENATE p_file '\Logon.txt' INTO filenam.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
*   BIN_FILESIZE                    =
    FILENAME                        = filenam
   FILETYPE                        = 'ASC'
   APPEND                          = 'X'
*   WRITE_FIELD_SEPARATOR           = ' '
 TABLES
    DATA_TAB                        = it_tab
 EXCEPTIONS
   FILE_WRITE_ERROR                = 1
   NO_BATCH                        = 2
   GUI_REFUSE_FILETRANSFER         = 3
   INVALID_TYPE                    = 4
   NO_AUTHORITY                    = 5
   UNKNOWN_ERROR                   = 6
   HEADER_NOT_ALLOWED              = 7
   SEPARATOR_NOT_ALLOWED           = 8
   FILESIZE_NOT_ALLOWED            = 9
   HEADER_TOO_LONG                 = 10
   DP_ERROR_CREATE                 = 11
   DP_ERROR_SEND                   = 12
   DP_ERROR_WRITE                  = 13
   UNKNOWN_DP_ERROR                = 14
   ACCESS_DENIED                   = 15
   DP_OUT_OF_MEMORY                = 16
   DISK_FULL                       = 17
   DP_TIMEOUT                      = 18
   FILE_NOT_FOUND                  = 19
   DATAPROVIDER_EXCEPTION          = 20
   CONTROL_FLUSH_ERROR             = 21
   OTHERS                          = 22
          .
IF SY-SUBRC eq 0.
  message s057(zmsg) WITH filenam.
  else.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. 
 

5. Execute the code to generate the Logon script.

Note: If your Login script was generated successfully, you should get this message-

Note: You need to do this 'One-Time' task to set the Profile in GuiXT-

6.  Launch GuiXT using the command- 'GUIXT.EXE VISIBLE' as shown-

7. Navigate to Profiles Screen and Provide the path as shown-

8. Your Screen should like below. If not, make necessary changes. The
    highlighted  areas are important. Finally Click on OK.

9.  When you have verified/ changed the GuiXT Profile settings, click OK. In the  
    following pop-up, select Yes. Upon clicking Yes, the window will be closed.

Now its time to test it!

Launch your Landscape to see it open!

Note: Execute the report program to 'Add' multiple instances of the Landscape.

If you think this is cumbersome, you may change the Path (here- c:\guixt\scripts) to your shared drive and later change the GuiXT Profile accordingly.

30 Comments