PDF='MAIN' { ATTRIBUTES='*' { LIBLOBJ='*OBJLIB'; ROWCOLOR1='altcol1'; ROWCOLOR2='altcol2'; USEACTGROUP='1'; PLATFORM='rpgfree.txt'; ATTACHED='0'; PROJECT='36'; OBJECTNAME='WKORDVLD'; OBJLIBRARY='XL_WEBEXMP'; TITLE='Work order validation'; SOURCEFILE='QRPGLESRC'; SOURCELIBR='XL_WEBEXMP'; WEBPATH='http://esdi.excelsystems.com/wsexmp/'; SET='46'; VERSION='4.00'; CRTBNUM='Revision 2105'; CRTTEMPLT='C:\\Program Files\\ESDI\\WebSmart\\Temp\\Page at a Time Maint.tpl'; SAVBNUM='Revision 2105'; REPSYSTEM='ESDI520'; REPTYPE='1'; LASTLOC='4'; VHTML='N'; LASTSAVE='1/22/2008 10:45:48'; } FILES='*' { FILE='MU_ORDHF' { LIBRARY='XL_WEBDEMO'; RCDFORMAT='RORDERH '; LEVELID='1071025172820'; RFLEVELID='4E69C242A36A9'; EXTDS='0'; } FILE='MU_CUSTF' { LIBRARY='XL_WEBDEMO'; RCDFORMAT='R_CUSTF '; LEVELID='1070921111624'; RFLEVELID='403ABD661EC5A'; EXTDS='0'; } } PANELS='*' { PANEL='ListHeader' { DESC='Main List Header'; DETAILS=' Work order validation

Work order validation

Description:   This Example demonstrates some field validation techniques

Order Number:
'; } PANEL='ListDetails' { DESC='Page header'; DETAILS=' '; ITERATIONS='10'; } PANEL='ListFooter' { DESC='Page footer'; DETAILS='
Action Order Number Purchase Order / Description Customer Name Order Date Order Status Order Total
Display Edit
'; } PANEL='PageFooter' { DESC='Page Footer'; DETAILS='
  1. Instructions are coming soon.


  2.     
        
       
        

Program Definition:   wrkordvld.pdw

Rate This Example

Did this knowledge base article help you to achieve your goal?  Yes  No  Don\'t Know

Enter additional comments below.   If you want to hear back from us, include your contact information.

'; } PANEL='addlink' { DESC='Add Record'; DETAILS='Add Record '; } PANEL='RcdDisplay' { DESC='Display an individual record'; DETAILS=' Work order validation

Work order validation

Description:   This Example demonstrates some field validation techniques

Order Number:
Purchase Order / Description:
Customer Number:
Order Date:
Order Status:
Order Total:
Tax Percentage:
Warehouse Location:
Ship to Location:
Ship Date:
Invoice Number:
  1. Example step.


  2. Replace:
                          sample replaced text
                          
    with the following:
                          sample replacing text
                          

Program Definition:   wrkordvld.pdw

Rate This Example

Did this knowledge base article help you to achieve your goal?  Yes  No  Don\'t Know

Enter additional comments below.   If you want to hear back from us, include your contact information.

'; } PANEL='DelChoice' { DESC='Confirm a delete'; DETAILS='

Are you SURE you want to delete this record?

Yes    No '; } PANEL='RtnToList' { DESC='Return to List'; DETAILS='
'; } PANEL='ListPrev' { DESC='Link to previous page'; DETAILS='
Previous '; } PANEL='ListNext' { DESC='Link to next page'; DETAILS='
Next '; } PANEL='RcdManage' { DESC='Add or Change An Individual Record'; DETAILS=' Work order validation

Work order validation

Description:   This Example demonstrates some field validation techniques





Order Number:
Purchase Order / Description:
Customer Number:(valid: 1, 3 or 5)(invalid: 99) ">
Order Date: YYYYMMDD "
Order Status:
Order Total: ">
Tax Percentage: ">
Warehouse Location:
Ship to Location: ">
Ship Date: ">
Invoice Number: ">
  1. Example step.


  2. Replace:
                          sample replaced text
                          
    with the following:
                          sample replacing text
                          

Program Definition:   wrkordvld.pdw

Rate This Example

Did this knowledge base article help you to achieve your goal?  Yes  No  Don\'t Know

Enter additional comments below.   If you want to hear back from us, include your contact information.

'; } } PREVIEWS='*' { DEFAULT='Main List'; PREVIEW='Main List' { SEG='ListHeader'; SEG='ListDetails' { REPEAT='10'; } SEG='ListFooter'; SEG='ListPrev'; SEG='ListNext'; SEG='PageFooter'; SEG='addlink'; } PREVIEW='Display' { SEG='RcdDisplay'; } PREVIEW='Manage' { SEG='RcdManage'; } } ACTIONS='func Main() { // Program Name: WKORDVLD // Program Title: Work order validation // Created by: SPOT // Template family: Idaho // Template name: Page at a time maintenance // Purpose: Maintain a database file. Supports options for add, change, delete and display. // Program Modifications: // Determine which library list will be used setlibl("*OBJLIB"); // Open all files openfile("*ALL"); //declare fields for rating the page crtfld(RPNUM, 5, "N", 0, "Number"); crtfld(RPTYPE, 1, "A", 0, "Page Type"); crtfld(RPSOPR, 1, "A", 0, "Solve Problem?"); crtfld(RPCOMM, 4000, "A", 0, "Comment"); //This workfield is needed to return to examples list crtfld(wsnum, 5, "N", 0, "Example number from exlist app"); crtfld(rtncod, 1, "A", 0, "valid smurf return code"); crtfld(errorCSS, 200, "A", 0, "css for error"); crtfld(errorImg, 100, "A", 0, "error image"); wsnum = getparm("wsnum"); skipsmurfchk(); // Instead do our own check rtncod = isvalidsmurf(); if(rtncod == "1") { gensmurfid("*IFNONE", "*DAY",1, "*YES", "*YES", "*YES"); //set cookie params for use in ws example rate this page feature setsmurf("wsnumb", wsnum); } else { wsnum = getsmurf("wsnumb"); } // append to URLs to make them unique crtfld(rnd,6,"A",0); rnd = numtoalpha(pgmf_curtime); // Starting and ending relative record numbers are used to control Next/Previous page of records crtfld(StartRRN, 9,"N",0,"Starting RRN"); crtfld(EndRRN, 9,"N",0,"Ending RRN"); // Record counter to determine how many records have been output to the list crtfld(rcdcnt, 5,"N",0,"Number of records written to list "); // Page size determines the maximum number of records (rows) contained in the list crtfld(listsize, 5,"N",0,"Page size of list-max records"); // Generic relative rcd number work field crtfld(rrn, 9, "N", 0, "Relative Record Number"); // get the saved relative record number to position the list crtfld(SavedRrn, 9, "A", 0, "Saved rrn"); crtfld(flag2,1, "N"); flag2 = 0; // Set maximum list size to 20 for this program listsize=20; crtklist(PfKlist, OHORD); crtklist(MU_CUSTF.defaultlink, OHCUST); // Get rrn from URL to determine if a starting value was specified StartRRN = getparm("rrn"); // Tasks to control record list (default task is to display the list) runtask("DEFAULT", displist); runtask("prev", prev); // Task for the record display option runtask("disp", disprcd); // Tasks controlling record deletion runtask("delconf", delconf); runtask("del", deletercd); // Tasks controlling record management runtask("beginmanage", beginmanage); runtask("endmanage", endmanage); } func displist() { /* if(flag2 == 0) { beginmanage(); } else { */ OHORD = getparm("OHORD"); // Output header wrtseg(ListHeader); rcdcnt=0; // if we have a starting rrn, use that as the // starting point, else use keys if (StartRRN > 0) { MU_ORDHF.rrn = StartRRN; getrcd(MU_ORDHF, "*RRN", "*NO"); } posrcd(MU_ORDHF,PfKlist); getnxtrcd(MU_ORDHF); // if the key entered is past the end of the file then display the last record in the file if (MU_ORDHF.status <> RecordRetrieved) { posrcd(MU_ORDHF,"*LAST"); getnxtrcd(MU_ORDHF); } while ((MU_ORDHF.status == RecordRetrieved) and (rcdcnt < listsize)) { // assign the relative record number for use in page rrn = MU_ORDHF.rrn; // If it\'s the first time through, output the list header if (rcdcnt == 0) { // Save key value of last first record in list StartRRN = MU_ORDHF.rrn; } // output the list detail wrtseg(ListDetails, TRUE); // Save rrn value of last record in list EndRRN = MU_ORDHF.rrn; // get the next record rcdcnt = rcdcnt + 1; getnxtrcd(MU_ORDHF); } // close off the table wrtseg(ListFooter); // write the PREV link if necessary MU_ORDHF.rrn = StartRRN; getrcd(MU_ORDHF, "*RRN", "*NO"); posrcd(MU_ORDHF, pfklist); getprvrcd(MU_ORDHF); if (MU_ORDHF.status == RecordRetrieved) { wrtseg(ListPrev); } // write the Add Link wrtseg(AddLink); // write the NEXT link if necessary if (rcdcnt == listsize) { MU_ORDHF.rrn = EndRRN; getrcd(MU_ORDHF, "*RRN", "*NO"); posrcd(MU_ORDHF, pfklist,"*GT"); getnxtrcd(MU_ORDHF); if (MU_ORDHF.status == RecordRetrieved) { EndRRN = MU_ORDHF.rrn; wrtseg(ListNext); } } // close the page wrtseg(PageFooter); //} } // If TASK=PREV position file pointer at 1st record of previous list and read previous until // BOF or list size is reached. Then using save new starting key values and load list func prev() { MU_ORDHF.rrn = StartRRN; getrcd(MU_ORDHF, "*RRN", "*NO"); posrcd(MU_ORDHF,PfKlist); getprvrcd(MU_ORDHF); rcdcnt = 1; while ((MU_ORDHF.status == RecordRetrieved) and (rcdcnt < listsize)) { rcdcnt = rcdcnt + 1; getprvrcd(MU_ORDHF); } // Save key values as current list start location and display new list StartRRN = MU_ORDHF.rrn; displist(); } // Display details for selected record: func disprcd() { // get the relative record number parm rrn = getparm("rrn", "*MAND"); // get saved relative record number parm SavedRrn = getparm("FirstRowRRN"); // get the record from the file MU_ORDHF.rrn = rrn; getrcd(MU_ORDHF, "*RRN"); wrtseg(RcdDisplay, TRUE); } func delconf() { // get the relative record number parm rrn = getparm("rrn", "*MAND"); // get saved relative record number parm SavedRrn = getparm("FirstRowRRN"); // get the record from the file MU_ORDHF.rrn = rrn; getrcd(MU_ORDHF, "*RRN"); wrtseg(RcdDisplay, TRUE); } func deletercd() { // get the relative record number parm rrn = getparm("rrn", "*MAND"); // get saved relative record number parm SavedRrn = getparm("FirstRowRRN"); // get the record from the file MU_ORDHF.rrn = rrn; getrcd(MU_ORDHF, "*RRN"); // if the record to be deleted is the first record in the list, retrieve the previous // record and use that as the first record when the list is redisplayed if (rrn == alphatonum(savedrrn)) { // position by key posrcd(MU_ORDHF, pfklist); getprvrcd(MU_ORDHF); // set the list starting point savedrrn = numtoalpha(MU_ORDHF.rrn); // re-retrieve the record to be deleted MU_ORDHF.rrn = rrn; getrcd(MU_ORDHF, "*RRN"); } dltrcd(MU_ORDHF); // redirect back to the mainlist redirect("?rrn=" + SavedRrn); } // Present panel to prepare to Add or Change new record: func beginmanage() { flag2 = 1; // get the relative record number parm rrn = getparm("rrn", "*OPT"); /* if(rrn == 0) { rrn = 1; } */ // get saved relative record number parm SavedRrn = getparm("FirstRowRRN"); // get the record from the file MU_ORDHF.rrn = rrn; getrcd(MU_ORDHF, "*RRN"); // output the segment wrtseg(RcdManage); } // Accept user input and pass to add or change record. func endmanage() { // create a field to capture the requested action crtfld(mode, 15,"A",0,"add or change?"); mode = getparm("mode"); // get saved relative record number parm SavedRrn = getparm("FirstRowRRN"); if(mode == "Add") { // get the parms getparmset(OHORD, OHDESC, OHCUST, OHORDT, OHSTAT, OHOTOT, OHTAX, OHWHSE, OHCUSH, OHSHPDT, OHINV); // do any validation // write the record wrtrcd(MU_ORDHF); } if(mode == "Change") { // get the relative record number parm rrn = getparm("rrn", "*MAND"); // get the record from the file MU_ORDHF.rrn = rrn; getrcd(MU_ORDHF, "*RRN"); // get the parms getparmset(OHDESC, OHCUST, OHORDT, OHSTAT, OHOTOT, OHTAX, OHWHSE, OHCUSH, OHSHPDT, OHINV); //perform validation here vld(); if (vldflag == "1") { errorCSS = "#error{ width:100%; border-style: solid; border-width: thin; border-color: #999999; background-color: #cccccc; }"; errorImg = ""; wrtseg(RcdManage); } else { errorImg = ""; errorCSS = ""; updrcd(MU_ORDHF); // redirect back to the mainlist redirect("?rrn=" + SavedRrn, "*SAME", "rand"); } } } func vld() { crtfld(vldflag, 1, "A", 0, "Is Valid Data Flag"); crtfld(rtncode, 1, "A", 0, "Return Code"); crtfld(errdate, 50, "A", 0, "Date Error Field"); crtfld(errdesc, 50, "A", 0, "error field for blank description"); crtfld(errcust, 50, "A", 0, "err field for customer"); //date must be YYYYMMDD rtncode = datevldn(OHORDT , "*YMD8"); if (rtncode == "1"){ errdate = "Must enter valid date YYYYMMDD or YYYY/MM/DD"; vldflag = "1"; } //Description can\'t be blank if (OHDESC == ""){ errdesc = "Description cannot be blank"; vldflag = "1"; } //Only allow customers who exist posrcd(MU_CUSTF); if (MU_CUSTF.status == RecordNotFound){ errcust = "Customer does not exist."; vldflag = "1"; } } '; }