Convert saplogon.ini to SAP Java PlatinGUI connections

I like to use my native Mac OSX system and the Java PlatinGUI for working and developing with SAP whenever I can. Of course, I know that the native Windows GUI is way more advanced (because better taken care of by SAP), but I hate to boot my Windows VM every time I want to do something SAP-related. Since I work for multiple clients having multiple SAP installations (ERP, CRM, Solution Manager, …), I want to have my SAP connections in synch. For my Windows systems – yes, I do have a few of them – I share the saplogon.ini via Dropbox. However, that doesn’t help me having the same connection entries in my Mac Java SAPGUI (PlatinGUI).

Hence, I wrote a tiny (and not very fancy) Python script to convert the saplogon.ini entries to the connection strings used in the Java SAPGUI’s connections file (which on Mac OSX can be found in the user’s Application Library folder). It doesn’t do much and it is not very robust against invalid input, but I would like to share it here, so anybody can use it for their own purposes. If you have an advice on how to improve the script radically or on how to support more input information, please let me know.

#!/usr/bin/env python

import sys, os

try:
    fname = sys.argv[1]
    fh = open(fname, 'r')
except:
    print sys.argv[0], ' <path/saplogon.ini>'
    sys.exit(-1)

data = fh.readlines()
fh.close()

# initialize entry data base (100 records)
entries = []
for i in range(100):
    entry = {'description': '', 'server': '', 'router': '', 'database': ''}
    entries.append(entry)

for line in data:
    data = line.strip()
    if data != '':    # ignore empty lines
        if data.startswith('[') and data.endswith(']'):
            key = data.lower()[1 : len(data) - 1]
        else:
            parts = data.split('=')
            item = parts[0]
            value = parts[1]
            try:
                nr = int(item[4 : ])
                entries[nr][key] = value
            except ValueError:
                pass

# now print connection strings for Java GUI
for e in entries:
    if e['description'] != '':
        comp = '/' if e['router'] != '' else ''
        connStr = e['description'] + ':conn=' + \
            e['router'] + comp + \
            '/H/' + e['server'] + \
            '/S/32' + e['database'] + '&expert=true&wan=true'
        connStr.replace("/H//H/", "/H/")
        print connStr
Advertisements

8 thoughts on “Convert saplogon.ini to SAP Java PlatinGUI connections

  1. hi, thx for your share. I’m sorry but i found difficulty how to do this code or how to run your cmd version whish had you been shared in SAP Family. I’m new in SAP for Java. can you give me any hint or how-to-do with this SAP GUI for Java Configuration Generator Scripts? Thank you for your time.

  2. Hi, thanks for your writing. This almost help me out, but I’m still have no idea how I can implement this code in Mac OSX to converting my connection in saplogon.ini? Can you give a hint how to run this script? Thanks a lot. 😀

  3. Hello Kris, thanks for your feedback and sorry for not replying sooner.

    Just copy the Python source code into a new file and save it as whatever_name_you_like.py
    Then open a Terminal and run:
    python whatever_name_you_like.py path/to/your/saplogon.ini

    Please let me know if you need further information, eg. on where to find the files.

    Michael

  4. Thanks a lot! I’m sorry about those double posting up there, I thought it’s because my computer was error. Can I ask one another question?Are this conversions are limited up to 100 records?? Am I supposed to split my connections for 100 lines?? Oh, sorry. another question. did you the one who put this code into SAP GUI Family? because I downloaded the zip files for conversion from that site.

    Thank you Michael for your advises.

  5. Hi Michael, I did converting the connections. The problems now is how to adding the conversion files to the configurations in SAP Logon in Mac. I already copied all setting from the conversions, into text file setting.txt inside the Library>Preferences>SAP folders, but nothing changed in my SAP Logon. Is there any advice for my problem? 😀

    • Hi Michael, I’ve got a syntax error when running the code: Non-ASCII character ‘\xc2’ on line 2, but no encoding declared. Any ideas where’s the problem?

      • Hello Åke,
        Thanks for your comment. Are you sure, you only copied the source code from above? The error looks like there is a (unknown) special character in your script.
        Michael

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s