SET215W

LANSA

SET215W
* =======================================================
* Process ........: SET_215
* Function .......: set215W
* Created on .....: 19/10/01 at 11:41:13
* Description ....: Function Skeleton
* Version.........: 1
*
* This Lansa for the Web function requests up to 5
* Order Numbers.
* The selected orders are exchanged with SET215R
* together with a working list where potential errors
* would be returned.
* In this case, unlike in example 214/216, there are two
* working lists involved. A working list of orders, each
* of them having more than one error, hence the error
* working list.
*
* A host selection is required. The selected host is the
* the host where the status of the order is looked up.
* If you select the lansa host, a dummy cgi program
* will send back a response with order details status.
*
* Refer to SET215R and SET217S for details on how to use
* JSM to do two way XML transactions.
*
* Disclaimer: The following material is supplied as an
* example only. No warranty is expressed or implied.
*
* ======================================================*
Function Options(*DIRECT *WEBEVENT)
*
Define Field(#WK_ORDN) Reffld(#S_214ORDN)
*
* Lansa host name and port
Define Field(#LANSAHOST) Reffld(#S_214HOST) Input_Atr(LC) Default('LANSADEMO.COM')
*
Define Field(#S_CLICKED) Type(*CHAR) Length(030) Default('FORM.INITIALIZE')
*
* Conditions to verify whether #OUT_LIST has records
Def_Cond Name(*NO_ORDERS) Cond('#LISTCOUNT *LE 0')
* Conditions to verify the chosen transaction service
Def_Cond Name(*LANSAHOST) Cond('(#S_214HOST = *BLANKS) OR (#S_214HOST = LANSADEMO.COM)')
*
* Working list with order numbers going out.
Def_List Name(#OUT_LIST) Fields(#S_214ORDN) Counter(#LISTCOUNT) Type(*WORKING)
*
* Working list with order status details coming back in
Def_List Name(#IN_LIST) Fields(#S_214ORDN #S_214STAT #S_214COST #S_214SDAT #S_214IOST #S_214ERRO) Type(*WORKING)
*
* Order status fields to display
Define Field(#ORD_COUNT) Reffld(#LISTCOUNT)
Def_List Name(#S_215ORDD) Fields((#S_214ORDN *INPUT) #S_214COST #S_214SDAT #S_214STAT) Counter(#ORD_COUNT)
*
Define Field(#SELE_ORDS) Type(*CHAR) Length(004) Default(ORDS)
Def_Cond Name(*DSP_ORDS) Cond('#SELE_ORDS = ORDS')
* Browselist to input order number(s)
Def_List Name(#S_215ORDS) Fields(#S_214ORDN)
*
* Group of fields to exchange with host related
* information
Group_By Name(#OUT_DATA) Fields(#S_214HOST #S_214URI)
*
* Group with screen fileds.
Group_By Name(#PANELDATA) Fields((#S_215DESC *NOID) (#SELE_ORDS *HIDDEN) (#S_CLICKED *HIDDEN) (#S_215STSR *NOID) #S_214HOST)
*
Group_By Name(#ORDERDATA) Fields((#S_215DESC *NOID) (#SELE_ORDS *HIDDEN) (#S_CLICKED *HIDDEN) (#S_215STSR *NOID) #S_214HOST)
*
Case Of_Field(#S_CLICKED)
When Value_Is('= FORM.INITIALIZE')
* first time, initialize browselist with 5 entries.
* Set S_214host to the host of the transaction server
Execute Subroutine(SET_HOST)
Inz_List Named(#S_215ORDS) Num_Entrys(0000005) With_Mode(*ADD)
Otherwise
Use Builtin(CLR_MESSAGES) With_Args(Y)
* the first time, S_214ORDS which is the browselist with
* order numbers only. Subsequent times, S_214ORDD is
* shown, so the order numbers must be selected from that
* one
If Cond(*DSP_ORDS)
Execute Subroutine(SEL_ORDS)
Change Field(#SELE_ORDS) To(*BLANKS)
Else
Execute Subroutine(SEL_ORDD)
Endif
* If no order number was typed in, display request screen
If Cond(*NO_ORDERS)
Message Msgtxt('No Order Numbers entered')
Else
* Call SETJSMO to open JSM
Execute Subroutine(OP_CL_JSM) With_Parms(OPEN)
* Set S_214host to the host of the transaction server
Execute Subroutine(SET_URI)
* Call service in specified Transaction server
Execute Subroutine(SND_STSREQ)
* Get Order details and/or errors
Execute Subroutine(GET_STSREQ)
* Close JSM
Execute Subroutine(OP_CL_JSM) With_Parms(CLOSE)
Endif
*
Endcase
*
* Request the browselist of order numbers and the
* selection of the host where the service runs.
* and product quantities
Request Fields(#PANELDATA) Browselist(#S_215ORDS) Exit_Key(*NO) Menu_Key(*NO) Prompt_Key(*NO)
Request Fields(#ORDERDATA) Browselist(#S_215ORDD) Exit_Key(*NO) Menu_Key(*NO) Prompt_Key(*NO)
*
Subroutine Name(SEL_ORDS)
Clr_List Named(#OUT_LIST)
* Select the entries of the input browselist and add them
* to the exchange working list
Selectlist Named(#S_215ORDS)
Continue If('#S_214ORDN *LE 0')
Add_Entry To_List(#OUT_LIST)
Endselect
Endroutine
*
Subroutine Name(SEL_ORDD)
Clr_List Named(#OUT_LIST)
* Select the entries of the input browselist and add them
* to the exchange working list
Selectlist Named(#S_215ORDD)
Continue If('#S_214ORDN *LE 0')
Add_Entry To_List(#OUT_LIST)
Endselect
Endroutine
*
Subroutine Name(SET_URI)
* Set the exchanged fields with the host value and the
* URI (Uniform Resource I). The URI value is a symbolic
* name resolved in file DC@W29 to a process and function
* name and partition identifier for the service to run.
If Cond(*LANSAHOST)
Change Field(#S_214HOST) To(#LANSAHOST)
Change Field(#S_214URI) To(SET215SRV)
Else
Change Field(#S_214URI) To(SET217_ORDERSTATUS_SERVICE)
Endif
*
Change Field(#S_214ERRO) To(*BLANKS)
Endroutine
*
Subroutine Name(SET_HOST)
* Change the host field to the value of the SET system
* variable S_HOSTURL. This variable is used across the
* SET collection to hold the value of the host location.
* Depending on whether you have executed other SET
* examples, this variable might or might not have a value
* If it has a value, concatenate it with the host port
* value held in a system variable with the same
* functionality as S_HOSTURL
Change Field(#S_214HOST) To(*S_HOSTURL)
If Cond('#S_214HOST *NE *BLANKS')
Use Builtin(TCONCAT) With_Args(#S_214HOST ':' *S_HOSTPORT) To_Get(#S_214HOST)
Else
Change Field(#S_214HOST) To('nnn.nnn.nnn.nnn:xx')
Endif
Endroutine
*
Subroutine Name(SND_STSREQ)
*
Clr_List Named(#IN_LIST)
Exchange Fields(#OUT_DATA)
Call Process(*DIRECT) Function(SET215R) Exit_Used(*NEXT) Menu_Used(*NEXT) Pass_Lst(#OUT_LIST #IN_LIST)
*
Endroutine
*
Subroutine Name(GET_STSREQ)
* Verify if any errors occurred
Clr_List Named(#S_215ORDD)
Change Field(#WK_ORDN) To(*ZEROS)
Selectlist Named(#IN_LIST)
*
Begincheck
Valuecheck Field(#S_214IOST) With_List('OK') Msgid(DCM9899) Msgdta(#S_214ERRO)
Endcheck If_Error(*NEXT)
*
* There will be as many entries in the error working list
* as errors, for one order. Only add one entry per order
* number to display
If Cond('#WK_ORDN *NE #S_214ORDN')
Add_Entry To_List(#S_215ORDD)
Change Field(#WK_ORDN) To(#S_214ORDN)
Endif
*
Endselect
*
Dowhile Cond('#ORD_COUNT < 5')
Change Field(#S_215ORDD) To(*NULL)
Add_Entry To_List(#S_215ORDD)
Endwhile
Endroutine
*
Subroutine Name(OP_CL_JSM) Parms((#W_ACTION *RECEIVED))
Define Field(#W_ACTION) Type(*CHAR) Length(005)
Group_By Name(#S_EXCHFLD) Fields(#S_JSMSTS #S_JSMMSG #W_ACTION)
Exchange Fields(#S_EXCHFLD)
Call Process(*DIRECT) Function(SETJSMO) Exit_Used(*NEXT) Menu_Used(*NEXT)
Endroutine
*