RDML for SET217S

LANSA

RDML for SET217S
* =======================================================
* Process ........: SET_217
* Function .......: SET217S
* Created on .....: 19/10/01 at 11:41:13
* Description ....: Function Skeleton
* Version.........: 1
*
* This function is the web service that RECEIEVEs the
* order numbers entered in either SET215G or SET215W. It
* then SENDs back the order information Shipment Date,
* Order Status and Cost.
*
* Service used: HTTPCLIENT
*
* For the RECEIVE command.
* HANDLER: inbound xml (IXML).
* XSL: set217_orderstatus_request_in
*
* For the SEND command.
* HANDLER: inbound xml (IXML).
* XSL: set217_orderstatus_response_out
*
* Disclaimer: The following material is supplied as an
* example only. No warranty is expressed or implied.
*
* ======================================================*
Function Options(*DIRECT)
*
Define Field(#KEYWORD) Reffld(#STD_TEXT)
Define Field(#KEYW_VAL1) Reffld(#STD_TEXTL)
Define Field(#KEYW_VAL2) Reffld(#STD_TEXTL)
*
* Incoming list of order numbers
Def_List Name(#IN_LIST) Fields(#S_214ORDN) Type(*WORKING)
* Outgoing list of with the order status and errors
Def_List Name(#OUT_LIST) Fields(#S_214ORDN #S_214STAT #S_214COST #S_214SDAT #S_214IOST #S_214ERRO) Counter(#LISTCOUNT) Type(*WORKING)
Def_List Name(#ERR_LIST) Fields(#S_214ERRO) Type(*WORKING)
*
Define Field(#MSGDTA) Type(*CHAR) Length(132)
* Group of fields to FETCH from the order header file
* S214ORDH
Group_By Name(#ORDER_REQ) Fields(#S_214COST #S_214SDAT #S_214STAT)
Change Field(#S_JSMSTS #S_JSMMSG) To(*BLANKS)
*
* Open the Java service manager
Use Builtin(JSM_OPEN) To_Get(#S_JSMSTS #S_JSMMSG)
Execute Subroutine(CHECK_STS)
*
* Load HTTPCLIENT service
Execute Subroutine(START_CMD) With_Parms('SERVICE_LOAD')
Execute Subroutine(KEYWRD) With_Parms('SERVICE' 'HTTPCLIENT' *BLANKS)
Use Builtin(JSM_COMMAND) With_Args(#S_JSMCMD) To_Get(#S_JSMSTS #S_JSMMSG)
Execute Subroutine(CHECK_STS)
*
* Build the RECEIVE command
*
* HANDLER(IXML) refers to the inbound xml handler
* Refer to the HTTPService.properties file that in the
* Properties directory of your JSM installation (for
* example /jsm/instance/properties/).
*
* XSL(set217_orderstatus_request_in) is a reference to
* the style sheet used to transform the XML going out.
* set217_orderstatus_request_in is a symbolic name.
* The JSM will look up the symbolic name in the
* HTTPCLIENT services' properties file and convert it to
* a real value. In this case the real value is
* set217_orderstatus_request_inbound.xsl
*
* SERVICE_LIST has the field names that define he
* working list #IN_LIST. This is the Order number.
Execute Subroutine(START_CMD) With_Parms('RECEIVE')
Execute Subroutine(KEYWRD) With_Parms('HANDLER' 'IXML' *BLANKS)
Execute Subroutine(KEYWRD) With_Parms('XSL' 'SET217_ORDERSTATUS_REQUEST_IN' *BLANKS)
Execute Subroutine(KEYWRD) With_Parms('SERVICE_LIST' 'S_214ORDN' *BLANKS)
* Receive order numbers
Use Builtin(JSM_COMMAND) With_Args(#S_JSMCMD) To_Get(#S_JSMSTS #S_JSMMSG #IN_LIST)
Execute Subroutine(CHECK_STS)
*
Define Field(#WK_COUNT) Reffld(#LISTCOUNT) Default(*zero)
Change Field(#WK_COUNT) To(*DEFAULT)
*
* Select orders. For each one of them, fetch the order
* header file and then, if OK, select detail records to
* calculate the total cost of the order.
* If an error occurs, set the value of the error field.
* Regardless, add a record to the outgoing working list
* Also, regardless, add a Fragment of the outgoing
* information. A Fragment is a piece of repeating
* information that was specified when creating the
* transformation style sheet using the Wizard.
* When a FATAL error occurs (IO$STS=ER), stop
* processing the orders.
*
Selectlist Named(#IN_LIST)
Change Field(#WK_COUNT) To('#wk_count + 1')
Clr_List Named(#OUT_LIST)
Fetch Fields(#ORDER_REQ) From_File(S214ORDH) With_Key(#S_214ORDN) Io_Error(*NEXT) Val_Error(*NEXT) Issue_Msg(*YES)
Change Field(#S_214IOST) To(#IO$STS)
If_Status Is(*OKAY)
Execute Subroutine(CALC_COST)
Else
Execute Subroutine(SET_ERROR)
Endif
Add_Entry To_List(#OUT_LIST)
Execute Subroutine(ADD_FRAGM)
Leave If('#S_214IOST = ER')
Endselect
*
* Build the SEND command
*
* HANDLER(IXML) refers to the outbound xml handler
* Refer to the HTTPService.properties file that in the
* Properties directory of your JSM installation (for
* example /jsm/instance/properties/).
*
* XSL(set217_orderstatus_response_out) is a reference to
* the style sheet used to transform the XML going out.
* set217_orderstatus_response_out is a symbolic name.
* The JSM will look up the symbolic name in the
* HTTPCLIENT services' properties file and convert it to
* a real value. In this case the real value is
* set217_orderstatus_response_outbound.xsl
*
Execute Subroutine(START_CMD) With_Parms('SEND')
Execute Subroutine(KEYWRD) With_Parms('HANDLER' 'IXML' *BLANKS)
Execute Subroutine(KEYWRD) With_Parms('XSL' 'set217_orderstatus_response_out' *BLANKS)
*
* SEND order status information. It will be RECEIVEd by
* the function SET215R
Use Builtin(JSM_COMMAND) With_Args(#S_JSMCMD) To_Get(#S_JSMSTS #S_JSMMSG)
Execute Subroutine(CHECK_STS)
*
* Close this JSM session
Use Builtin(JSM_CLOSE) To_Get(#S_JSMSTS #S_JSMMSG)
Execute Subroutine(CHECK_STS)
*
Return
*
* SUBROUTINES
*
Subroutine Name(ADD_FRAGM)
Case Of_Field(#WK_COUNT)
* Add the first fragment. The difference between adding
* the first fragment and subsequent ones is the syntax.
* Subsequent fragments require the keyword OUTPUT with
* value *ADD
When Value_Is('= 1')
Execute Subroutine(START_CMD) With_Parms('SEND')
Execute Subroutine(KEYWRD) With_Parms('HANDLER' 'IXML' *BLANKS)
Execute Subroutine(KEYWRD) With_Parms('XSL' 'set217_orderstatus_fragment' *BLANKS)
Execute Subroutine(KEYWRD) With_Parms('SERVICE_LIST' 'S_214ORDN,S_214STAT,S_214COST,S_214SDAT,' 'S_214IOST,S_214ERRO')
Execute Subroutine(KEYWRD) With_Parms('FRAGMENT' 'ORDERDETAIL' *BLANKS)
Use Builtin(JSM_COMMAND) With_Args(#S_JSMCMD) To_Get(#S_JSMSTS #S_JSMMSG #OUT_LIST)
Execute Subroutine(KEYWRD) With_Parms('OUTPUT' '*ADD' *BLANKS)
Otherwise
Use Builtin(JSM_COMMAND) With_Args(#S_JSMCMD) To_Get(#S_JSMSTS #S_JSMMSG #OUT_LIST)
Endcase
*
Execute Subroutine(CHECK_STS)
Endroutine
*
Subroutine Name(START_CMD) Parms((#STD_TEXTS *RECEIVED))
Change Field(#S_JSMCMD) To(#STD_TEXTS)
Endroutine
*
Subroutine Name(KEYWRD) Parms(#KEYWORD #KEYW_VAL1 #KEYW_VAL2)
Use Builtin(BCONCAT) With_Args(#S_JSMCMD #KEYWORD) To_Get(#S_JSMCMD)
Use Builtin(TCONCAT) With_Args(#S_JSMCMD '(' #KEYW_VAL1 #KEYW_VAL2 ')') To_Get(#S_JSMCMD)
Endroutine
*
Subroutine Name(SET_ERROR)
Define Field(#CHAR_ORDN) Type(*CHAR) Length(7)
If_Status Is(*ERROR)
Change Field(#S_214ERRO) To('''Fatal Application error in FETCH in file S214ORDH. Verify that S214ORDH exists and is operational. Processing will terminate.''')
Else
Use Builtin(NUMERIC_STRING) With_Args(#S_214ORDN) To_Get(#CHAR_ORDN)
If_Status Is(*NORECORD)
Use Builtin(BCONCAT) With_Args('Order Number' #CHAR_ORDN 'not found.') To_Get(#S_214ERRO)
Else
Use Builtin(BCONCAT) With_Args('FETCH operation in file S214ORDN' 'with Order Number' #CHAR_ORDN 'was unsuccessful') To_Get(#S_214ERRO)
Endif
Endif
Add_Entry To_List(#OUT_LIST)
Use Builtin(BCONCAT) With_Args('The return code was' #S_214IOST) To_Get(#S_214ERRO)
Change Field(#ORDER_REQ) To(*NULL)
Endroutine
*
Subroutine Name(CALC_COST)
Change Field(#S_214COST) To(*ZEROS)
Select Fields(#S_214QTY) From_File(S214ORDD) With_Key(#S_214ORDN) Io_Error(*NEXT) Val_Error(*NEXT)
Change Field(#S_214COST) To('#s_214cost + (#S_214QTY * 2)')
Endselect
Change Field(#S_214ERRO) To(*BLANKS)
Endroutine
* Check the status of the JSM command issued
Subroutine Name(CHECK_STS)
*
If Cond('#S_jsmsts *NE OK')
*
Use Builtin(BCONCAT) With_Args('Error Status Code: ' #S_JSMSTS) To_Get(#MSGDTA)
Message Msgid(DCM9899) Msgf(DC@M01) Msgdta(#MSGDTA)
Use Builtin(BCONCAT) With_Args('Error Message: ' #S_JSMMSG) To_Get(#MSGDTA)
Message Msgid(DCM9899) Msgf(DC@M01) Msgdta(#MSGDTA)
Use Builtin(BCONCAT) With_Args(*FUNCTION 'ended in error. Review previous messages.') To_Get(#MSGDTA)
Use Builtin(JSM_CLOSE) To_Get(#S_JSMSTS #S_JSMMSG)
Endif
*
Endroutine
*