IBM Support

JR64814: IBM RPA - FOCUS WINDOW COMMAND DOESN'T OPEN SAP APPLICATION

Subscribe to this APAR

By subscribing, you receive periodic emails alerting you to the status of the APAR, along with a link to the fix after it becomes available. You can track this item individually or track all items by product.

Notify me when this APAR changes.

Notify me when an APAR for this component changes.

Direct link to fix

 

APAR status

  • Closed as program error.

Error description

  • Focus Window command finds the SAP application, set the focus on
    it but doesn't bring it to foreground.
    

Local fix

  • As a workaround, the following Power Shell script can be used
    inside IBM RPA to bring the application to foreground, since
    it's already focused by the Focus Window command:
    Add-Type -Language CSharp -TypeDefinition @"
       using System;
       using System.Collections.Generic;
       using System.Runtime.InteropServices;
       using System.Text;
       public static class FocusWindowHelpers
       {
           [DllImport("user32.dll")]
           [return: MarshalAs(UnmanagedType.Bool)]
           private static extern bool SetForegroundWindow(IntPtr
    hWnd);
    
    
           [DllImport("user32.dll")]
           [return: MarshalAs(UnmanagedType.Bool)]
           private static extern bool ShowWindow(IntPtr hWnd, int
    nCmdShow);
    
    
           [DllImport("user32.Dll")]
           private static extern bool EnumChildWindows(IntPtr
    hParent, EnumWindowsDelegate lpfn, IntPtr lParam);
    
    
           [DllImport("user32.dll")]
           private static extern int GetWindowText(IntPtr hWnd,
    StringBuilder lpWindowText, int nMaxCount);
           private delegate bool EnumWindowsDelegate(IntPtr hWnd,
    int lParam);
           public static void BringToFront(IntPtr handle, bool
    isMDI)
           {
                   if (isMDI)
                   {
                           ShowWindow(handle, 3);
                           ShowWindow(handle, 9);
                   }
                   else
                   {
                           ShowWindow(handle, 5);
                   }
    
    
                   SetForegroundWindow(handle);
           }
           public static List<KeyValuePair<string, IntPtr>>
    GetAllExistingWindows(int handle)
           {
               var windows = new List<KeyValuePair<string,
    IntPtr>>();
               EnumChildWindows((IntPtr)handle, (h, _) =>
               {
                   var title = new StringBuilder(256);
                   var titleLength = GetWindowText(h, title, 512);
                   if (titleLength > 0)
                       windows.Add(new KeyValuePair<string,
    IntPtr>(title.ToString(), h));
                   return true;
               }, IntPtr.Zero);
               return windows;
           }
       }
    "@
    
    function Find-WindowHandle {
           param(
                   [String] $title,
    
    
                   [Int] $mainWindowHandle
           )
           $MatchingWindows =
    [FocusWindowHelpers]::GetAllExistingWindows($mainWindowHandle) |
    ? { $_.Key -match $title }
    
    
           if (-not $MatchingWindows) {
                   return [IntPtr]::Zero
           }
           return $MatchingWindows[0].Value
    }
    
    function Focus-Window {
           param(
                   [Parameter(Mandatory = $True, ValueFromPipeline =
    $True)]
                   [String] $MainWindowTitle,
    
    
                   [Parameter(ValueFromPipeline = $True)]
                   [String] $ChildWindowTitle
           )
    
    
           $MainWindowHandle = Find-WindowHandle "$MainWindowTitle"
    0
           [FocusWindowHelpers]::BringToFront($MainWindowHandle, 0)
    
    
           if ($ChildWindowTitle) {
                   $ChildWindowHandle = Find-WindowHandle
    "$ChildWindowTitle" $MainWindowHandle
    
    [FocusWindowHelpers]::BringToFront($ChildWindowHandle, 1)
           }
    }
    
    Focus-Window "${mainWindow}" "${childWindow}"
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED:                                              *
    * Users automating SAP applications                            *
    ****************************************************************
    * PROBLEM DESCRIPTION:                                         *
    * No further information                                       *
    ****************************************************************
    * RECOMMENDATION:                                              *
    * Update to 21.0.1 IF007 or 21.0.2 IF005                       *
    ****************************************************************
    

Problem conclusion

  • First fixed in 21.0.1 IF007 and 21.0.2 IF005
    

Temporary fix

Comments

APAR Information

  • APAR number

    JR64814

  • Reported component name

    RPA

  • Reported component ID

    5737N5100

  • Reported release

    L00

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2022-04-07

  • Closed date

    2022-06-16

  • Last modified date

    2022-06-16

  • APAR is sysrouted FROM one or more of the following:

  • APAR is sysrouted TO one or more of the following:

Fix information

  • Fixed component name

    RPA

  • Fixed component ID

    5737N5100

Applicable component levels

[{"Line of Business":{"code":"LOB45","label":"Automation"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSC50T","label":"IBM Robotic Process Automation"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"L00"}]

Document Information

Modified date:
17 June 2022