RDML for SET209W

LANSA

RDML for SET209W
* =======================================================
* Process ........: SET_209
* Function .......: SET209A
* Created on .....: 15/02/00 at 14:43:32
* Description ....: Function Skeleton
* Version.........: 1
*
* Full Description:
*
* this Lansa for the Web function is a user interface
* used to input information to send an email. The email
* is actually sent in SET209E
*
* Service used: SMTPCLIENT
*
* Disclaimer: The following material is supplied as an
* example only. No warranty is expressed or implied.
*
* =======================================================
* Function control options
Function Options(*DIRECT *WEBEVENT)
*
* Group and field definitions
* =======================================================
* These fields are only used for the text area in the
* web page.
Define Field(#S_209TX01) Reffld(#S_209TX)
Define Field(#S_209TX02) Reffld(#S_209TX)
Define Field(#S_209TX03) Reffld(#S_209TX)
Define Field(#S_209TX04) Reffld(#S_209TX)
Define Field(#S_209TX05) Reffld(#S_209TX)
Define Field(#S_209TX06) Reffld(#S_209TX)
Define Field(#S_209TX07) Reffld(#S_209TX)
Define Field(#S_209TX08) Reffld(#S_209TX)
Define Field(#S_209TX09) Reffld(#S_209TX)
Define Field(#S_209TX10) Reffld(#S_209TX)
*
* Maximum number of characters that can be typed in the
* TA. It will be equal to the number of lines
* times the length of the field.
Define Field(#MAXCHAR) Type(*DEC) Length(005) Decimals(0)
Define Field(#TXTLENGTH) Type(*DEC) Length(003) Decimals(0) Default(75)
Define Field(#NUM_LINES) Type(*DEC) Length(005) Decimals(0) Default(11)
*
* =======================================================
*
Define Field(#W_JSMSTS) Reffld(#S_JSMSTS)
* Fields exchanged with SET209E
Group_By Name(#EMAIL_DTA) Fields(#S_209FROM #W_JSMSTS #ATT_COUNT #S_209SUBJ #S_209SERV #S_209USER #S_209PSWD)
*
Define Field(#MSGDTA) Type(*CHAR) Length(132)
* Array of the text area portions
Def_Array Name(#TXT) Indexes(#II) Of_Fields(#S_209TX #S_209TX01 #S_209TX02 #S_209TX03 #S_209TX04 #S_209TX05 #S_209TX06 #S_209TX07 #S_209TX08 #S_209TX09 #S_209TX10)
Group_By Name(#PANELDATA) Fields((#S_CLICKED *HIDDEN) (#S_209DESC *NOID) #S_209FROM #S_209SUBJ #S_209TX (#MAXCHAR *HIDDEN) #S_209SERV #S_209USER #S_209PSWD (#S_209SMTP *HIDDEN) #S_209SNDE)
*
* Field and condition to validate for errors
Define Field(#VAL_ERROR) Reffld(#STD_NUM) Default(0)
Def_Cond Name(*VALIDATED) Cond('#VAL_ERROR = 0')
*
* Field to evalutate what button was clicked. In this
* case there is only one.
Define Field(#S_CLICKED) Type(*CHAR) Length(030) Default('FORM.INITIALIZE')
* Entry counter for recipients browselist #S_209RCPS
Define Field(#RCP_COUNT) Reffld(#LISTCOUNT)
* Entry counter for attachment working list #WLST_ATT
* and condition to evaluate wether any attachments files
* were specified
Define Field(#ATT_COUNT) Reffld(#LISTCOUNT)
*
* Recipients browselist and corresponding working list
Def_List Name(#S_209RCPS) Fields((#S_209RECP *OUTPUT))
Def_List Name(#WLST_RCPS) Fields(#S_209RECP) Counter(#RCP_COUNT) Type(*WORKING)
*
* Attachments browselist and corresponding working list
Def_List Name(#S_209ATT) Fields((#S_209ATTS *OUTPUT))
Def_List Name(#WLST_ATT) Fields(#S_209ATTS) Counter(#ATT_COUNT) Type(*WORKING)
*
* Working list of email text
Def_List Name(#EMAIL_TXT) Fields(#S_209TEXT) Type(*WORKING)
* Mainline
*
Case Of_Field(#S_CLICKED)
* first time
When Value_Is('= FORM.INITIALIZE')
Inz_List Named(#S_209RCPS) Num_Entrys(0000003) With_Mode(*ADD)
Inz_List Named(#S_209ATT) Num_Entrys(0000003) With_Mode(*ADD)
Change Field(#MAXCHAR) To('#TXTLENGTH * #NUM_LINES')
Otherwise
* Subsequent times, validate entry fields and if ok send
* the email
Execute Subroutine(VALIDATE)
*
If Cond(*VALIDATED)
* Open the Java service manager. The open and close of
* JSM are handled by the function SETJSMO across all
* examples.
Execute Subroutine(OP_CL_JSM) With_Parms(OPEN)
* Call SET209E to send the email
Execute Subroutine(SEND_EMAIL)
*
If Cond('#w_jsmsts *ne OK')
Message Msgtxt('Email not sent, see following messages')
Else
Message Msgtxt('Email successfully sent')
Endif
* Close the Java service manager
Execute Subroutine(OP_CL_JSM) With_Parms(CLOSE)
Endif
Endcase
*
Request Fields(#PANELDATA) Identify(*NOID) Browselist(#S_209RCPS) Exit_Key(*NO) Menu_Key(*NO) Prompt_Key(*NO)
*
* This display is never executed. However, it is required
* to generate the html for the browselist. To make the
* browselist appear on the page, you must edit the HTML
* and manually add this line. This line was generated for
* second page for this function as SET209W002:
* <RDML MERGE="&BLS_209ATT ">
Display Browselist(#S_209ATT) Exit_Key(*NO) Menu_Key(*NO) Prompt_Key(*NO)
*
Subroutine Name(VALIDATE)
* Verfify the required fields have been entered, if not
* set the error in the condition flag
Def_Cond Name(*VAL_ERROR) Cond('(#s_209serv = *blanks) or (#s_209from = *blanks) or (#rcp_count = *zeros)')
Clr_List Named(#WLST_RCPS)
* Add recipients from browselist to working list
Selectlist Named(#S_209RCPS)
Continue If('#S_209RECP *EQ *BLANKS')
Add_Entry To_List(#WLST_RCPS)
Endselect
*
If Cond(*VAL_ERROR)
Message Msgtxt('One or more required entries left blank.')
Change Field(#VAL_ERROR) To(1)
Else
Change Field(#VAL_ERROR) To(*DEFAULT)
Execute Subroutine(ADD_ATTS)
Endif
Endroutine
*
Subroutine Name(SEND_EMAIL)
Exchange Fields(#EMAIL_DTA)
Call Process(*DIRECT) Function(SET209E) Exit_Used(*NEXT) Menu_Used(*NEXT) Pass_Lst(#WLST_RCPS #WLST_ATT #EMAIL_TXT)
*
Endroutine
*
Subroutine Name(ADD_ATTS)
Clr_List Named(#WLST_ATT)
* Add attachments
Selectlist Named(#S_209ATT) Get_Entrys(*NOTNULL)
Add_Entry To_List(#WLST_ATT)
Endselect
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
*
* 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. Will CLOSE JSM and then Abort.') To_Get(#MSGDTA)
Message Msgid(DCM9899) Msgf(DC@M01) Msgdta(#MSGDTA)
*
Endif
*
Endroutine
*