EDPX RDML

FUNCTION OPTIONS(*DIRECT *WEBEVENT)
GROUP_BY NAME(#PRMTBLGRP) FIELDS(#MPRMCTG #MPRMCOD #MPRMDSC)
DEF_LIST NAME(#ARRAY_LST) FIELDS(#Z_DATA) COUNTER(#Z_COUNT) TYPE(*WORKING) ENTRYS(500)
DEF_LIST NAME(#X1BL01LST) FIELDS(#X1ALPLONG) ENTRYS(1000)

DEFINE FIELD(#ZZCOUNT) TYPE(*DEC) LENGTH(2) DECIMALS(2)
DEFINE FIELD(#ZZCOUNTC) TYPE(*CHAR) LENGTH(2)

DEFINE FIELD(#ZFNAMEMMM) TYPE(*CHAR) LENGTH(25)
DEFINE FIELD(#ZLNAMEMMM) TYPE(*CHAR) LENGTH(25)
DEFINE FIELD(#ZSSNUMMMM) TYPE(*CHAR) LENGTH(25)

* =======================================================
* Moving Respective HTML Pages to Components
* =======================================================

CHANGE FIELD(#DCTONLCMP) TO(*NULL)
CHANGE FIELD(#DCTHEDCMP) TO(PAG_RPARRHED)
CHANGE FIELD(#DCTHDRCMP) TO(*NULL)
CHANGE FIELD(#DCTLFTCMP) TO(*NULL)
CHANGE FIELD(#DCTPAGCMP) TO(PAG_RPARRAY)
* =======================================================
* Process according to Button clicked
* =======================================================

CASE OF_FIELD(#STDRENTRY)
WHEN VALUE_IS(‘*EQ N’)
* do logic here to validate if you want to
REQUEST FIELDS(#ZFNAMEMMM #ZLNAMEMMM) EXIT_KEY(*NO) MENU_KEY(*NO)
WHEN VALUE_IS(‘*EQ *BLANKS’)
CHANGE FIELD(#MPRMCTG) TO(PENDC)
CHANGE FIELD(#MPRMCOD) TO(”’RPARRAY1”’)
CLR_LIST NAMED(#ARRAY_LST)
CLR_LIST NAMED(#X1BL01LST)

SELECT FIELDS(#PRMTBLGRP) FROM_FILE(M@PRMTBL) WITH_KEY(#MPRMCTG #MPRMCOD) GENERIC(*YES)
EXECUTE SUBROUTINE(LISTENTRY) WITH_PARMS(#MPRMDSC)
ENDSELECT

* Build List for Javascript Array
CHANGE FIELD(#ZZCOUNT) TO(0)
SELECTLIST NAMED(#ARRAY_LST)
CHANGE FIELD(#X1ALPLONG) TO(#Z_DATA)
ADD_ENTRY TO_LIST(#X1BL01LST)
ENDSELECT
OTHERWISE
MESSAGE MSGTXT(‘STDRENTRY not Programmed for’)
ENDCASE

REQUEST FIELDS((#STDNEXT *HIDE) (#STDRENTRY *HIDE)) EXIT_KEY(*NO) MENU_KEY(*NO) PROMPT_KEY(*NO)
REQUEST BROWSELIST(#X1BL01LST) EXIT_KEY(*NO) MENU_KEY(*NO)

* =======================================================
* Subroutine ….: LISTENTRY
* Description….: Add Entries to List
* =======================================================
SUBROUTINE NAME(LISTENTRY) PARMS(#Z_DATA)
IF_NULL FIELD(#Z_DATA)
ELSE
ADD_ENTRY TO_LIST(#ARRAY_LST)
ENDIF
ENDROUTINE

EDPX PAGE COMPONENT

<script language=”javascript”>
var arrEDPX=new Array();    //* Array of Field Validation requests

//* Populate/Override above fields by Loading Global Script Data Defined in the Function RDML
//###############################
//### BEGIN RDML Provided Data  ###
//###############################
<RDML MERGE=”&BLX1BL01LST”>
//###############################
//### END   RDML Provided Data  ###
//###############################
</script>

<style type=”text/css”>
<!–
 A {color:blue;text-decoration:none;font:x-small arial;}
–>
</style>

<table cellpadding=”0″ cellspacing=”0″ border=”0″ align=”center” >

 <tr align=”center”>
              <TR><TD VALIGN=”TOP” COLSPAN=”2″><RDML COMPONENT=”&FLD_DCTLFTCMP”></TD>
     <td align=”center” width=”725″ height=”100%” valign=”top” bgcolor=”white”>
                          <TABLE width=725>
                               <tr><td>
                        <br><center><FONT Color=”#8C2532″ Face=”ARIAL” Size=”5″><b>Loading a javascript array</FONT></b></center>
              </td></tr>
             <tr><td>
<!– ############################################ –>
<!– ### !@BEGIN   RDML MERGE=”&MESSAGES” ### –>
<!– ############################################ –>
<RDML MERGE=”&MESSAGES”>
<!– ############################################ –>
<!– ### !@END      RDML MERGE=”&MESSAGES” ### –>
<!– ############################################ –>
<br>

<TABLE ALIGN=”CENTER”>
<TR>
    <TD>First Name</TD>
    <TD><INPUT TYPE=”TEXT” NAME=”AZFNAMEMMM”  TITLE=”First Name” ID=”FNAME” EDPX=”RXQA2Z004010REQ” onfocus =”focusWork(this,event)” onblur=”focusWork(this,event)”></TD>
</TR>
<TR>
    <TD>Last Name</TD>
    <TD><INPUT TYPE=”TEXT” NAME=”AZLNAMEMMM” TITLE=”Last Name” ID=”LNAME” EDPX=”REQa2z” onfocus =”focusWork(this,event)” onblur=”focusWork(this,event)””></TD>
</TR>

<TR>
    <TD><INPUT TYPE=”SUBMIT” VALUE=”Submit Form” ID=”BUTTON2″ onClick=”return validateForm();”></TD>
   <TD><INPUT TYPE=”RESET” VALUE=”Reset”></TD>
</TR>
</TABLE>
<!– Job# <RDML MERGE=”*JOBNBR”> –>
</tr></td>
</TABLE>

EDPX HED COMPONENT

<!– ############################################## –>
<!– ### !@BEGIN Page Component PAG_HED     ### –>
<!– ############################################## –>
<script type=”text/JavaScript”>
<!–

//* This is an attempt to eventually pull out the file level
//* validations from the LANSA repository to be applied on client side

function validateForm()
{
var myattr=new Array();
bldAttrArray(myattr);
if(chkreqelements(myattr,’form’))
 {mapValuesBack();return(true);} else {return(false);}
if(customValidations) {return(true);} else {return(false);}
}
function validateField(vfieldobj)
{
var myfieldobj=vfieldobj;
var myfieldattr=new Array();
bldFieldAttrArray(myfieldobj,myfieldattr);
if(!chkreqelements(myfieldattr,’field’)) ErrField(myfieldobj);
}

function bldAttrArray(bldattrarr)
{
var attstr=”what is in new array\n\n”;
var attnodeName=””;
var attnodeValue=””;
var k=0;
    for(i=0;i<document.LANSA.elements.length;i++)
    {
        for(j=0;j<document.LANSA.elements[i].attributes.length;j++)
          {
        attnodeName=document.LANSA.elements[i].attributes[j].nodeName.toUpperCase();
        if(attnodeName==”EDPX”)
        {
        attnodeValue=document.LANSA.elements[i].attributes[j].nodeValue;
        attnodeValue=attnodeValue.toUpperCase();
        k=bldattrarr.length;
        bldattrarr[ k ]=document.LANSA.elements[i].id+”:”+attnodeValue;
        attstr += bldattrarr[ k ]+”  “;
        attstr += “\n”;
        }
        }
    }
    //* remove comment bellow to see all EDPX elements in form
    //*alert( attstr );
 }

function bldFieldAttrArray(fieldobj,fieldattarr)
{
var fieldattobj=fieldobj;
var fieldattstr=”what is in field array\n\n”;
var fieldattnodeName=””;
var fieldattnodeValue=””;
var k=0;
        for(j=0;j<fieldattobj.attributes.length;j++)
          {
                fieldattnodeName=fieldattobj.attributes[j].nodeName.toUpperCase();
                if(fieldattnodeName==”EDPX”)
                {
                        fieldattnodeValue=fieldattobj.attributes[j].nodeValue;
                        fieldattnodeValue=fieldattnodeValue.toUpperCase();
                        k=fieldattarr.length;
                        fieldattarr[ k ]=fieldattobj.id+”:”+fieldattnodeValue;
                        fieldattstr += fieldattarr[ k ]+”  “;
                }
          }
     fieldattstr += “\n”;
    //* remove comment bellow to see all EDPX elements in form
    //* alert(fieldattstr);
 }
function chkreqelements(attarr,atttyp)
{
var cremsg=”The Following errors have been found: “;
//* For LANSA users Messages can be put in a browse list *NOBICP then do a merge list here
var crems00=”is required and must be entered”
var crems01=”has bad address “;
var crems02=”has invalid characters a-z A-Z “;
var crems03=”has invalid characters a-z A-Z 0-9 “;
var crems04=”is not a number “;
var crems05=”can not be a number “;
var crems06=”is invalid date “;
var crems07=”is not an acceptable range for Date of Birth “;
var crems08=”is invalid format ###-##-#### “;
var crems09=” “;
var crems10=” “;
var crems11=” “;
var crems12=” “;
var crems13=” “;
var crems14=” “;
var crems15=” “;
var crems99=”ERROR COUNT ->  “;
var creid=””;
var creval=””;
var crestr=””;
var dotdot=0;
var creobj=””;
var crereq=””;
var cretyp=””;
var cretxt=””;
var errcnt=0;
var cretmp=””;
cremsg += “\n\n”;

  for(i=0;i<attarr.length;i++)
    {
      crestr=attarr[i];
      dotdot=crestr.indexOf(“:”);
      creid=crestr.substr(0,dotdot);
      creval=crestr.substr(dotdot+1,crestr.length-1);
      crereq=creval.match(“REQ”);
      creobj=document.getElementById(creid);
      creobj.value=trimTrailingBlanks(creobj.value);
      credesc=creobj.name;

      if(creobj.title) {credesc=creobj.title;}
      if(creobj.value.length == 0)
          {
                 //* Format of message here
                 cretmp=credesc+” as NULL => ”
                 if(creval.match(“REQ”)) {errcnt=errcnt+1;cremsg +=cretmp+crems00+”\n”;}

          }
          else
            {
                 //* Format of message here
                 cretmp=credesc+” as “+creobj.value+”  => ”

                 //* Add new validation checks here
                 if(creval.match(“EML”)) {if(!emailValidator(creobj)){errcnt=errcnt+1;cremsg +=cretmp+crems01+”\n”;}}
                 if(creval.match(“A2Z”)) {if(!isAlpha(creobj)){errcnt=errcnt+1;cremsg +=cretmp+crems02+”\n”;}}
                 if(creval.match(“A29″)) {if(!isAlphanumeric(creobj)){errcnt=errcnt+1;cremsg +=cretmp+crems03+”\n”;}}
                 if(creval.match(“NUM”)) {if(!isNumeric(creobj)){errcnt=errcnt+1;cremsg +=cretmp+crems04+”\n”;}}
                 if(creval.match(“NAN”)) {if(isNumeric(creobj)){errcnt=errcnt+1;cremsg +=cretmp+crems05+”\n”;}}
                 if(creval.match(“DTE”)) {if(!dmyValidator(creobj)){errcnt=errcnt+1;cremsg +=cretmp+crems06+”\n”;continue}}
                 if(creval.match(“DOB”)) {if(!dmyValidator(creobj)){errcnt=errcnt+1;cremsg +=cretmp+crems07+”\n”;}}
                 if(creval.match(“SSN”)) {if(!isSSN(creobj)){errcnt=errcnt+1;cremsg +=cretmp+crems08+”\n”;}}
                 if(creval.match(“ZIP”)) {if(!isZipcodeUSA(creobj)){errcnt=errcnt+1;cremsg +=cretmp+crems09+”\n”;}}
                 if(creval.match(“ZZZ”)) {if(!dummyValidator(creobj)){errcnt=errcnt+1;cremsg +=cretmp+crems10+”\n”;}}
                 if(creval.match(“ZZZ”)) {if(!dummyValidator(creobj)){errcnt=errcnt+1;cremsg +=cretmp+crems11+”\n”;}}
                 if(creval.match(“ZZZ”)) {if(!dummyValidator(creobj)){errcnt=errcnt+1;cremsg +=cretmp+crems12+”\n”;}}
                 if(creval.match(“ZZZ”)) {if(!dummyValidator(creobj)){errcnt=errcnt+1;cremsg +=cretmp+crems13+”\n”;}}
                 if(creval.match(“ZZZ”)) {if(!dummyValidator(creobj)){errcnt=errcnt+1;cremsg +=cretmp+crems14+”\n”;}}
                 if(creval.match(“ZZZ”)) {if(!dummyValidator(creobj)){errcnt=errcnt+1;cremsg +=cretmp+crems15+”\n”;}}

               }

      }
 if(errcnt!= 0)
    {
     if(errcnt!=1) cremsg+=”\n”+crems99+errcnt;
     if(atttyp==’form’) alert( cremsg );
     return(false);
    }
  else
    {return(true);}
 }

function trimTrailingBlanks(TrimtrailingblanksValue)
{trim=TrimtrailingblanksValue;
 if (trim.length==0) return trim;
 for (var i=trim.length-1;i>=0;i–) if (trim.substring(i,i+1) !=’ ‘) {i++;break;}
 if (i<0) i=0;
 trim=trim.substring(0,i);
 return trim;
}
//* ==============================================
//* Validation functions — Add new functions here
//* ==============================================

function isNumeric(elem){
        var numericExpression = /^[0-9]+$/;
        if(elem.value.match(numericExpression)){
                return true;
        }else{ return false;}
}

// If the element’s string matches the regular expression it is all letters
function isAlpha(elem){
        var alphaExp = /^[a-zA-Z]+$/;
        if(elem.value.match(alphaExp)){
                return true;
        }else{ return false;}
}

// If the element’s string matches the regular expression it is numbers and letters
function isAlphanumeric(elem){
        var alphaExp = /^[0-9a-zA-Z]+$/;
        if(elem.value.match(alphaExp)){
                return true;
        }else{ return false;}
}

function lengthRestriction(elem, min, max){
        var uInput = elem.value;
        if(uInput.length >= min && uInput.length <= max){
                return true;
        }else{ return false;}
}

function emailValidator(elem){
        var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
        if(elem.value.match(emailExp)){
                return true;
        }else{ return false;}
}

function dummyValidator(elem){
        if(elem==elem){
                return true;
        }else{ return false;}
}

function ssnValidation(elem) {
    var ssn = elem.value;
    var matchArr = ssn.match();
    var numDashes = ssn.split(‘-‘).length – 1;
    if (matchArr == null || numDashes == 1 || (parseInt(matchArr[1],10)==0)) {return false;}   else {  return true;}}
function isSSN(elem){
        var numericExpression = /^(\d{3})-?\d{2}-?\d{4}$/;
        if(elem.value.match(numericExpression)){
                return true;
        }else{ return false;}
}
function isZipcodeUSA(elem)
{
  var iszip = elem.value;
  var numDashes = elem.value.split(‘-‘).length – 1;
  var islength = elem.value.length;
     if (islength == 5)
       {
         if(isNumeric(elem))
           {
             return true;
             } else { return false;}
       }
}

//#######################################
//### Highlight/Unhighlight Focused Input Fields
//#######################################
function focusWork(focusworkThis,focusworkEvent)
{var Event=focusworkEvent;
 var This=focusworkThis;
 if (Event.type==’focus’) This.style.backgroundColor=’Yellow’;
 if (Event.type==’blur’)
     { This.style.backgroundColor=’White’;
       validateField(This);}
}
//#######################################
//### Error Notify Red Background Fields
//#######################################
function ErrField(errfieldThis)
{ var This=errfieldThis;
  This.style.backgroundColor=’Pink’;
 }

function isCustom()
{
//* Put your custom specific validations here (false=fail)
if(‘a’ == ‘a’) {return(true);}
       else {return false;}
}

function switchInputType(SwitchinputtypeBase,SwitchinputtypeObjectID)
{
 var objectSW=document.getElementById(SwitchinputtypeObjectID);
 var baseSW=SwitchinputtypeBase;
   baseSW.value=objectSW.value;
 var masag=’Value is/’+baseSW.value;
 alert(masag);
 debugAlert(baseSW);
}

function mapValuesBack()
{
  //switchInputType(document.LANSA.AZFNAMEMMM,’FNAME’);
  //switchInputType(document.LANSA.AZLNAMEMMM,’LNAME’);
  document.LANSA.ASTDRENTRY.value=’N’;
  HandleEvent(‘<RDML MERGE=”*PROCESS”>’,'<RDML MERGE=”*FUNCTION”>’);
}

//#####################################################
//### Alert to Show Object Properties
//#####################################################
function debugAlert(AlertObject)
{ var i = 0 ; a = “”;
// list all window properties in a variable
for ( property in AlertObject )
{a += ( i ) + ” ” + property + “…”;
i ++;
if(i % 5 == 0) a += “\n”;
}
// display the window properties list
alert( a );
}

//–>
</script>
<!– ############################################## –>
<!– ### !@END    Page Component PAG_HED      ### –>
<!– ############################################## –>

SQL STUFF I FORGET

String Functions

Function Description CHAR(N) Returns the the string representation of the
number N.
CHAR_LENGTH(S) Returns the length of a string.
CONCAT(S1, S2) Concatenates S1 with S2.
SUBSTR(S, I, L) Returns a substring of S, starting at index I of lenght L.
LOWER(S) Returns the lowercase representation of S.
UPPER(S) Returns the uppercase representation of S.
TRIM(S) Removes spaces from the beggining and and of S.
RTRIM(S)
LTRIM(S)
Removes spaces at the begging (right) or end (left) of S.

Date and Time Functions

Function Description CURDATE()
CURTIME()
Returns the system’s current date/time.
DATE(D)
DATE(T)
Converts a string representation of a date/time into into a
date/time value.
DAY(D) Returns the day(1-31) from the date D.
WEEK(D) Returns the week (1-54) from the date D.
MONTH(D) Returns the month (1-12) from the date D.
YEAR(D) Returns the year from the date D.
DAYOFWEEK(D) Returns the week day (1-7) from the date D where 1 is Sunday.
DAYOFWEEK_ISO(D) Returns the week day (1-7) from the date D where 1 is Monday.
DAYOFYEAR(D) Returns the number of the day, in a year (1-366).
HOUR(T) Returns the hour (0-24) from the time T.
MINUTE(T) Returns the minute from the time T.
SECOND(T) Returns the second from the time T.
MICROSECOND(T) Returns the microsecond from the time