SET219G

LANSA

SET219G
* =======================================================
* Process ........: SET_219
* Function .......: SET219G
* Created on .....: 7th November, 2001
* Description ....: Caller example -> Execute OS/400 Cmd
* Version.........: 1
*
* Full Description:
*
* This function is a simple example of how SET219Y can
* be used to manage calls to functions on remote systems.
*
* In this case SET219G requests that you input an OS/400
* operating system command. It then calls SET219H on the
* specified remote server to execute the command.
*
* =======================================================
* ============== D E F I N I T I O N S ================
* =======================================================
Function Options(*LIGHTUSAGE *DIRECT)
Define Field(#SERVERURL) Reffld(#S_219HOST)
Define Field(#COMMAND) Type(*CHAR) Length(256) Label('OS/400 Command')
* =======================================================
* ================ M A I N L O G I C ===============
* =======================================================
Execute Subroutine(DOCOMMANDS)
Execute Subroutine(CLOSE)
Exchange Fields(#SERVERURL)
Menu
* =======================================================
* ======= U N I Q U E S U B R O U T I N E S ========
* =======================================================
Subroutine Name(DOCOMMANDS)
*
* Default the server value
*
If_Null Field(#SERVERURL)
Use Builtin(TCONCAT) With_Args(*S_HOSTURL ':' *S_HOSTPORT) To_Get(#SERVERURL)
Endif
*
* Loop until terminated by menu/cancel key
*
Begin_Loop
*
* Ask for the server URL name and the command
*
Request Fields(#SERVERURL #COMMAND) Identify(*LABEL) Exit_Key(*NO) Menu_Key(*YES *RETURN) Prompt_Key(*NO) Cursor_Loc(*atfield #command)
*
* If a command was not specified issue a
* message ... otherwise execute the command
*
If_Null Field(#COMMAND)
Message Msgtxt('Input the OS/400 command to be executed then press enter')
Else
*
* Else pass the command to SET219H and execute it
*
*
* Clear any existing argument details
*
Execute Subroutine(CLEAR_ARGS)
*
* Set up the command to be passed to SET219H
*
Execute Subroutine(SET_ALPHA) With_Parms(COMMAND *BLANKS 1 #COMMAND)
*
* Call SET219H on the remote server system
*
Execute Subroutine(CALL) With_Parms(SET219H #SERVERURL)
Endif
*
* Loop around to show the resulting message and get
* the next command to be executed
*
End_Loop
*
Endroutine
*
* =======================================================
* ======== C O M M O N S U B R O U T I N E S =========
* =======================================================
* This set of subroutines are simple interfaces to RDML
* function SET219Y. They can be copied from this function
* and used in other similar functions unchanged.
* =======================================================
*
* -------------------------------------------------------
* Use CLEAR_Args to clear the current set of values
* -------------------------------------------------------
Subroutine Name(CLEAR_ARGS)
Execute Subroutine(CALL_219Y) With_Parms(CLEAR)
Endroutine
* -------------------------------------------------------
* Use SET_ALPHA to pass an alphanumeric value
* -------------------------------------------------------
Subroutine Name(SET_ALPHA) Parms((#S_219NAM1 *RECEIVED) (#S_219NAM2 *RECEIVED) (#S_219NAMI *RECEIVED) (#S_219AVAL *RECEIVED))
Execute Subroutine(CALL_219Y) With_Parms(SETALP)
Endroutine
* -------------------------------------------------------
* Use CALL to call a function
* -------------------------------------------------------
Subroutine Name(CALL) Parms((#S_219FUNC *RECEIVED) (#S_219HOST *RECEIVED))
Define Field(#W_219HOST) Reffld(#S_219HOST)
Use Builtin(UPPERCASE) With_Args(#S_219HOST) To_Get(#W_219HOST)
If Cond('#W_219HOST = LOCAL')
Call Process(*DIRECT) Function(#S_219FUNC) Exit_Used(*NEXT) Menu_Used(*NEXT) If_Error(*NEXT)
Else
Execute Subroutine(CALL_219Y) With_Parms(CLIENTCALL)
Endif
Endroutine
* -------------------------------------------------------
* Use CLOSE to close down SET219Y
* -------------------------------------------------------
Subroutine Name(CLOSE)
Execute Subroutine(CALL_219Y) With_Parms(CLOSE)
Endroutine
* -------------------------------------------------------
* CALL_219Y is used to consolidate calls to SET219Y
* -------------------------------------------------------
Subroutine Name(CALL_219Y) Parms((#S_219OPER *RECEIVED))
Exchange Fields(#S_219OPER #S_219NAM1 #S_219NAM2 #S_219NAMI #S_219AVAL #S_219NVAL #S_219HOST #S_219FUNC)
Call Process(*DIRECT) Function(SET219Y)
Endroutine