SET219C

LANSA

SET219C
* =======================================================
* Process ........: SET_219
* Function .......: SET219C
* Created on .....: 7th November, 2001
* Description ....: Caller example -> Display Employee
* 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 SET219C requests that you input an
* employee number. It then calls SET219D on the specified
* remote server to fetch the employee details and return
* them. The results are then displayed to the user.
*
* =======================================================
* ============== D E F I N I T I O N S ================
* =======================================================
Function Options(*LIGHTUSAGE *DIRECT)
Define Field(#SERVERURL) Reffld(#S_219HOST)
Def_List Name(#SKILLS) Fields(#SKILDESC #GRADEDES)
Define Field(#SKILTOTAL) Reffld(#STD_NUM)
Def_Cond Name(*OKAY) Cond('#IO$STS = OK')
* =======================================================
* ================ M A I N L O G I C ===============
* =======================================================
Execute Subroutine(EMPLOYEES)
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(EMPLOYEES)
*
* 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 an employee number and server URL
*
Request Fields(#SERVERURL #EMPNO) Identify(*LABEL) Exit_Key(*NO) Menu_Key(*YES *RETURN) Prompt_Key(*NO) Cursor_Loc(*Atfield #Empno)
*
* Clear any existing argument details
*
Execute Subroutine(CLEAR_ARGS)
*
* Set up the employee enumber to be passed to SET219D
*
Execute Subroutine(SET_ALPHA) With_Parms(EMPNO *BLANKS 1 #EMPNO)
*
* Call SET219D on the remote server system
*
Execute Subroutine(CALL) With_Parms(SET219D #SERVERURL)
*
* Get the status returned by SET219D
*
Execute Subroutine(GET_ALPHA) With_Parms(STATUS *BLANKS 1 #IO$STS)
*
* If the employee details were found extract and
* display them .... including a list of skills
*
If Cond(*OKAY)
*
* Get the basic employee details that were returned
*
Execute Subroutine(GET_ALPHA) With_Parms(SURNAME *BLANKS 1 #SURNAME)
Execute Subroutine(GET_ALPHA) With_Parms(GIVENAME *BLANKS 1 #GIVENAME)
Execute Subroutine(GET_ALPHA) With_Parms(DEPTDESC *BLANKS 1 #DEPTDESC)
Execute Subroutine(GET_ALPHA) With_Parms(SECDESC *BLANKS 1 #SECDESC)
Execute Subroutine(GET_NUMBER) With_Parms(SALARY *BLANKS 1 #SALARY)
Execute Subroutine(GET_NUMBER) With_Parms(POSTCODE *BLANKS 1 #POSTCODE)
*
* Put the returned skills into the #SKILLS browse list
*
Clr_List Named(#SKILLS)
Execute Subroutine(GET_NUMBER) With_Parms(SKILTOTAL *BLANKS 1 #SKILTOTAL)
Begin_Loop Using(#STD_NUM) To(#SKILTOTAL)
Execute Subroutine(GET_ALPHA) With_Parms(SKILLIST SKILDESC #STD_NUM #SKILDESC)
Execute Subroutine(GET_ALPHA) With_Parms(SKILLIST GRADEDES #STD_NUM #GRADEDES)
Add_Entry To_List(#SKILLS)
End_Loop
*
* Display the basic details and skills browse list
*
Display Fields(#EMPNO #SURNAME #GIVENAME #DEPTDESC #SECDESC #SALARY #POSTCODE) Identify(*DESC) Browselist(#SKILLS) Exit_Key(*NO) Menu_Key(*YES *RETURN) Prompt_Key(*NO)
*
Endif
*
* Loop around and get the next employee number
*
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 GET_ALPHA to return an alphanumeric value
* -------------------------------------------------------
Subroutine Name(GET_ALPHA) Parms((#S_219NAM1 *RECEIVED) (#S_219NAM2 *RECEIVED) (#S_219NAMI *RECEIVED) #S_219AVAL)
Execute Subroutine(CALL_219Y) With_Parms(GETALP)
Endroutine
* -------------------------------------------------------
* Use GET_NUMBER to return an alphanumeric value
* -------------------------------------------------------
Subroutine Name(GET_NUMBER) Parms((#S_219NAM1 *RECEIVED) (#S_219NAM2 *RECEIVED) (#S_219NAMI *RECEIVED) #S_219NVAL)
Execute Subroutine(CALL_219Y) With_Parms(GETNUM)
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