CBL_MANAGED_SESSION_GET_USERDATA

Restriction: This routine is not supported when CHARSET"EBCDIC" is in effect.
Retrieves user data saved in the current RunUnit.

Syntax:

call "CBL_MANAGED_SESSION_GET_USERDATA" using by value user-dataname
                                        returning user-data.

Parameters:

user-dataname
picture clause: string
user-data
picture clause: object

On entry:

user-dataname
The name of the user data either set via the CBL_MANAGED_SESSION_SET_USERDATA library routine, or the RunUnit::SetUserData method.

On exit:

user-data
The user data saved in the current RunUnit.

Example:

The following example demonstrates the use of CBL_MANAGED_SESSION_GET_USERDATA and CBL_MANAGED_SESSION_SET_USERDATA from within a RunUnit.

The COBOL program that utilizes the library routines:

program-id. "GetUserDataExample".
procedure division.
*> retrieves a user data object called message from the
*> current rununit
declare msg as string
call "CBL_MANAGED_SESSION_GET_USERDATA" using
                                         by value "message"
                                         returning msg
end-call.

*> creates a new user data object that contains the
*> original object   "OK"
set msg to msg & " - OK"
call "CBL_MANAGED_SESSION_SET_USERDATA" using
                                          by value "reply"
                                          by value msg
end-call.
goback.

And the C# program that calls the COBOL program from within a RunUnit:

using System;
using MicroFocus.COBOL.RuntimeServices;
    
class MainClass {
       public static void Main(string[] args) {
           RunUnit ru = new RunUnit();
           try
           {
           ru.SetUserData("message","PASS: CBL_MANAGED_SESSION_GET_USER_DATA");
           ru.Call("GetUserDataExample");
           Console.WriteLine(ru.GetUserData("reply"));
           }
           finally
           {
           ru.StopRun();
           }
       }
}