RDML for SET216S

LANSA

RDML for SET216S
* =======================================================
* Process ........: SET_216
* Function .......: SET216S
* Created on .....: 19/10/01 at 11:41:13
* Description ....: Function Skeleton
* Version.........: 1
*
* Full Description:
*
* This function is the web service that RECEIEVEs the
* order details entered in either SET214G or SET214W. It
* then SENDs back the order information Shipment Date,
* Order Status, Order Number and Cost.
*
* Service used: HTTPCLIENT
*
* For the RECEIVE command.
* HANDLER: inbound xml (IXML).
* XSL: set216_order_request_in
*
* For the SEND command.
* HANDLER: inbound xml (IXML).
* XSL: set216_order_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)
*
* Working list coming in with details to create the
* order detail record(s)
*
Def_List Name(#IN_LIST) Fields(#S_214PROD #S_214QTY) Type(*WORKING)
* Outoing working list with validation errors that might
* occur when creating the order.
Def_List Name(#OUTERRLST) Fields(#S_214ERRO) Type(*WORKING)
*
* Group of fields to insert
*
Group_By Name(#INS_ORDER) Fields(#S_214ORDN #S_214CUST #S_214PROD #S_214QTY #S_214BADD #S_214SDAT #S_214SADD #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 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(set216_order_request_in) is a reference to
* the style sheet used to transform the XML going out.
* set216_order_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
* set216_order_request_inbound.xsl
*
* SERVICE_LIST has the field names that define he
* working list #IN_LIST. These are the product and
* and the quantity.
Execute Subroutine(START_CMD) With_Parms('RECEIVE')
Execute Subroutine(KEYWRD) With_Parms('HANDLER' 'IXML' *BLANKS)
Execute Subroutine(KEYWRD) With_Parms('XSL' 'set216_order_request_in' *BLANKS)
Execute Subroutine(KEYWRD) With_Parms('SERVICE_LIST' 'S_214PROD,S_214QTY' *BLANKS)
*
* Receive working list with product and quantity
* information required to create the order detail records
Use Builtin(JSM_COMMAND) With_Args(#S_JSMCMD) To_Get(#S_JSMSTS #S_JSMMSG #IN_LIST)
Execute Subroutine(CHECK_STS)
*
* Calculate the Shipment date as current date + 10 days
Use Builtin(FINDDATE) With_Args(#MMDDYYYY 10 L L) To_Get(#S_214SDAT #S_RETCDA1)
*
* Use autonum system variable to get next order number
Change Field(#S_214ORDN) To(*AUTONUM07S_214ORDN)
*
* Change order status
Change Field(#S_214STAT) To(LOGGED)
*
* Clear messages from the message queue
Use Builtin(CLR_MESSAGES)
*
* Insert order header record
Insert Fields(#INS_ORDER) To_File(S214ORDH) Io_Error(*NEXT) Val_Error(*NEXT)
*
* Check status. If the record was inserted without errors
* select the records from the incoming product and
* quantity working list, do a dummy cost calculation and
* insert detail record(s).
If_Status Is(*OKAY)
Change Field(#STD_NUM #S_214COST) To(*ZEROS)
Selectlist Named(#IN_LIST)
Continue If('#S_214QTY = 0')
Change Field(#STD_NUM) To('#S_214QTY * 2')
Change Field(#S_214COST) To('#STD_NUM + #S_214COST')
Insert Fields(#INS_ORDER) To_File(S214ORDD) Io_Error(*NEXT) Val_Error(*NEXT)
Leave If('#IO$STS *NE OK')
Endselect
Endif
*
* If validation errors occured, get the messages from the
* message queue and add them to the outgoing error
* working list
*
If_Status Is_Not(*OKAY)
Change Field(#S_RETCDA2) To(OK)
Use Builtin(GET_MESSAGE) With_Args(Y) To_Get(#S_RETCDA2 #S_214ERRO)
Dowhile Cond('#S_RETCDA2 = OK')
Add_Entry To_List(#OUTERRLST)
Use Builtin(GET_MESSAGE) With_Args(Y) To_Get(#S_RETCDA2 #S_214ERRO)
Endwhile
Endif
*
* Build the SEND command
*
* HANDLER(OXML) 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(set216_order_request_in) is a reference to
* the style sheet used to transform the XML going out.
* set216_order_reponse_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
* set216_order_reponse_outbound.xsl
*
* SERVICE_LIST has the names of the fields that define
* the working list #OUTERRLST. The working list name is
* specified as the third return value in the JSM command
* Built In function.
Execute Subroutine(START_CMD) With_Parms('SEND')
Execute Subroutine(KEYWRD) With_Parms('HANDLER' 'IXML' *BLANKS)
Execute Subroutine(KEYWRD) With_Parms('XSL' 'set216_order_response_out' *BLANKS)
Execute Subroutine(KEYWRD) With_Parms('SERVICE_LIST' 'S_214ERRO' *BLANKS)
*
* SEND a response with either the successfully created
* order information or the validation errors.
Use Builtin(JSM_COMMAND) With_Args(#S_JSMCMD) To_Get(#S_JSMSTS #S_JSMMSG #OUTERRLST)
Execute Subroutine(CHECK_STS)
*
* Close the Java service manager
Use Builtin(JSM_CLOSE) To_Get(#S_JSMSTS #S_JSMMSG)
Execute Subroutine(CHECK_STS)
*
Return
*
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
*
* Check the status of the JSM command issued
Subroutine Name(CHECK_STS)
*
Define Field(#MSGDTA) Type(*CHAR) Length(132)
*
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)
Message Msgid(DCM9899) Msgf(DC@M01) Msgdta(#MSGDTA)
Use Builtin(JSM_CLOSE) To_Get(#S_JSMSTS #S_JSMMSG)
Abort Msgid(DCM9899) Msgf(DC@M01) Msgdta(#MSGDTA)
Endif
*
Endroutine