We now want to use the techniques presented so far to implement an advanced example: a "SAP Personal Desktop" that allows the user to re-arrange the SAP function two-dimensionally to suit personal needs and preferences.

 

Our "Personal Desktop" is initially shown with the standard layout:

WIth the pushbuttons on the left the user can save the personalized layout and henceforth choose between the two (standard or personalized).

The example shown is already of practical use, but you could even add business objects such as customers, orders, etc to the Personal Desktop, and start the desired transaction when the user clicks on the object. To do this you would create a GuiXT button "Add to Personal Desktop" in several SAP transactions so that the user can add the object (e.g. an order number) to the desktop with a simple button click.
 

For the realization of our example we will need:

  • a list of the transactions and InputScripts that we want to offer to the user, together with suitable icons

  • the necessary GuiXT scripts and VBScript functions

For this tutorial we have chosen several transactions and one InputScript that invokes a list of promotions. The icons are freeware images found on  internet  (each 32x32 Pixel, .gif format; the formats .jpg or .ico are possible as well):

                

The desktop functions are described in two text files "menu\icons.txt" and "menu\items.E.txt" where E is the language key.  We store both files in the script directory.

Format:

"icons.txt": Starts with an icon id, then the file name, either as the absolute file path or relative to the GuiXT script directory. The delimiter character is the semicolon.

"items.E.txt": Starts with a transaction code and optionally an InputScript call, then the item label and the icon id.

For our example we use the following files:

// icons for SAP Personal Desktop
cust1;menu\icons\customer.gif
cust2;menu\icons\customer_change.gif
cust3;menu\icons\customer_display.gif
order1;menu\icons\order.gif
order2;menu\icons\order_change.gif
order3;menu\icons\order_display.gif
room;menu\icons\room.gif
prom1;menu\icons\promotions.gif
 


// Items for SAP Personal Desktop English version
XD01; Create customer; cust1
XD02; Change customer; cust2
XD03; Display customer; cust3

VA01; Create order; order1
VA02; Change order; order2
VA03; Display order; order3

// Promotions
SA38,process=promotions.txt; Promotions list; prom1


// Rooms and Meetings
PP30; Room reservation; room
 

The two-dimensional layout is also stored in a text file. It is not necessary to create this file manually since we can save the layout as a personal layout and then copy it as standard layout.

All files including the icon files can be stored in SAP Web Repository.

Our "SAP Personal Desktop" will replace the SAP standard navigation tree. As a further enhancement we could offer a button that allows the user to switch between the standard SAP navigation tree and the personal desktop.

In the GuiXT Script we again use the ListView control from "Microsoft Common Controls"; all the elements contained in the script are explained in the preceding tutorials. With &%[USERPROFILE] we address the user profile folder for storing the personal layout. Depending on the Windows version this can be (for example) C:\Documents and Settings\{username} or C:\Users\{username}.

GuiXT script:

Title "SAP Personal Desktop"

// delete SAP standard menu
del
X[IMAGE_CONTAINER]

// special functions
Pushbutton (1,0) "@2L\QSave as personal layout@" process="menu_save_layout.txt"
Pushbutton
(3,0) "@9T\QStandard Layout@" process="menu_standard_layout.txt"
Pushbutton
(5,0) "@42\QRestore personal layout@" process="menu_personal_layout.txt"

Control (0,6) (50,300) progid="Comctl.ListViewCtrl" name="menu_control" initflag="menu_init"

// initialize if necessary
if V[menu_init=X]
 
  // copy standard menu files to long texts
 
CopyText fromFile="menu\icons.txt" toText="menu_icons"
 
CopyText fromFile="menu\items.&V[_language].txt" toText="menu_items"
 
  // create menu
 
CallVbs menu_init &V[menu_control]

  // set personal or standard layout
 
CopyText fromFile="&%[USERPROFILE]\sap_personal_desktop_layout.txt" toText="menu_layout"
 
 
if not Q[ok]
   
CopyText fromFile="menu\layout.txt" toText="menu_layout"
 
endif

 
CallVBS set_menu_layout &V[menu_control]

endif

 

We create the Personal Desktop based on the GuiXT long text variables "menu" and "menu_layout", where "menu_layout" contains the coordinates of each item. This file is automatically generated when the user presses the "Save as personal layout" button. If it is empty, a linear layout is used by the ListView control. For our standard layout example, the file looks as follows (the list view control uses "twips", not "pixels"):

XD01;4366;2037
XD02;4313;4948
XD03;4233;7964
VA01;6112;2037
VA02;6033;4921
VA03;5953;7964
SA38,process=promotions.txt;9340;1984
PP30;9181;5054

In VBScript we create all items with their symbols. We then define the event handling (double click) for the control. The function "set_menu_layout"  moves each element to the specified position:

' ---------------------------------------------
'       SAP Personal Desktop                   '
'                                              ' 
' --------------------------------------------- 

Sub menu_init(mv)
    
   
    ' for VbsEdit only to use context sensitive help 
    IfIsEmpty(mv) Then
        Set mv = CreateObject("ComCtl.ListViewCtrl")
    EndIf
    
    
    mv.View = 0    ' 0 = lvwIcon = icons (MS docu)  
    
    
    ' no label editing
    mv.LabelEdit = 1  ' manual
    
    ' font
    mv.Font.Name = "Arial"
    mv.Font.Size = 10
    
    ' color
    mv.BackColor = RGB(255,255,255)   
    mv.ForeColor = RGB(50,60,90) 
    
    
    ' Icons
    Dim imgList
    Set imgList = 
guixt.CreateObject("ComCtl.ImageListCtrl")
    
    
    imgList.ListImages.Clear()
    imgList.ImageHeight = 32
    imgList.ImageWidth = 32
    imgList.MaskColor = RGB(255,255,255)
    
    
    ' parameters in menu line
    Dim params
    
    
    ' read menu
    Dim icons
    icons = Split(guixt.GetText("menu_icons"), vbCrLf)
    
    
    ' create icons
    ForEach line In icons
        
        IfNot line = ""AndNotMid(Trim(line),1,2) = "//"Then
            
            
            params = Split(Trim(line), ";")
            
            
            Dim imagepath
            imagepath = guixt.FilePath(Trim(params(1)))
            
            Call imgList.ListImages.Add(1, Trim(params(0)), LoadPicture(imagepath)) 
            
            
            
            
        EndIf  
    Next
    
    
    Set mv.Icons = imgList 
    
    
    ' read menu items
    Dim items
    items = Split(guixt.GetText("menu_items"), vbCrLf)
    
    
    
    Dim itm
    
    ' create items
    ForEach line In items
        
        IfNot line = ""AndNotMid(Trim(line),1,2) = "//"Then
            
            params = Split(Trim(line), ";")
            
            
            ' create new list view item
            Set itm = mv.ListItems.Add()
            
            itm.Tag =   Trim(params(0))
            itm.Text =  Trim(params(1))
            
            IfNot params(2) = ""Then
                itm.Icon =  Trim(params(2))
            EndIf  
            
        EndIf  
    Next
    
    
    ' handle  events
    Set e = New menu_events
    Set e.mv = mv
    Call guixt.SetEventHandler(mv, e)      
    
EndSub

Class menu_events
    
    Dim mv
    
    ' double click    
    Function OnDblClick
        
        If mv.selectedItem IsNothingThen
            ExitFunction
        EndIf
        
        guixt.input("OK:" & mv.selectedItem.Tag)
        
    EndFunction
    
    
EndClass

Sub get_menu_layout(mv)
    
    Dim s()
    Dim n
    n = 0
    
    ForEach itm In mv.listitems
        ReDimPreserve s(n) 
        
        s(n) = itm.Tag & ";" & itm.Top & ";" & itm.Left
        
        n = n + 1
        
        
    Next
    
    
    Call guixt.settext("menu_layout",Join(s,vbCrLf))
    
EndSub  


Sub set_menu_layout(mv)
    
    Dim s
    s = Split(guixt.gettext("menu_layout"), vbCrLf)
    
    
    ' create dictionary object
    Set pos = CreateObject("Scripting.Dictionary")
    
    
    ForEach line In s
        params = Split(Trim(line), ";")
        Call pos.Add(params(0), params(1) & ";" & params(2))
    Next
    
    
    ForEach itm In mv.listitems
        
        Dim p
        p = pos.Item(itm.Tag)
        
        IfNot p = ""Then
            Dim p2
            p2 = Split(p, ";")
            
            itm.Top  = p2(0)
            itm.Left = p2(1)
        EndIf  
        
        
    Next
    
    
EndSub  

The InputScripts that save the layout and load the standard and personal layout are simple:

// InputScript menu_save_layout.txt
Set
text[menu_layout] ""
CallVBS get_menu_layout &V[menu_control]
CopyText
fromText="menu_layout" toFile="&%[USERPROFILE]\sapmenu_layout.txt"
Return
"S: Menu layout saved" -statusline

 

// InputScript menu_personal_layout.txt
CopyText fromFile="&%[USERPROFILE]\sapmenu_layout.txt" toText="menu_layout"
CallVBS set_menu_layout &V[menu_control]

 

// InputScript menu_standard_layout.txt
CopyText fromFile="menu\standard_layout.txt" toText="menu_layout"
CallVBS set_menu_layout &V[menu_control]

 

And here, finally, is the InputScript that we use to display the "Promotions" list:

// InputScript promotions.txt
Screen SAPMS38M.0101
 
Set F[Programm] "RV15C003"
 
Enter "/8"

// List Promotions
Screen RV15C003.1000
 
Enter "/8"