// ---------------------------------------------------------------------- // Form View - XXXXXXX // Description - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Authorship - Created by XXXXXXXX on MM-DD-YYYY // ---------------------------------------------------------------------- H BNDDIR('LRNGSRV') DFTACTGRP(*no) ACTGRP(*caller) // Display and other file declarations FSearchSel CF E WORKSTN D* The name of the program that a touch/select request is delegated to. D* Typically that program displasy some details of the item that was selected. D PRIMARY_DETAIL_PROGRAM... D C 'DETAILER1' // Locally scoped variable declarations (identifiable by names like Local.xxxxx) D Local DS Qualified D IsNewForm N Inz(True) D TempIndex 10I00 Inz(0) D OddColumn N Inz(True) // The refine option variables are mapped to the refine fields in the Popover // In a real user scenario you would have options like Open Orders,Types,Date Ranges,etc // These are values you are using to refine of filter your searches D Refine DS Qualified D Option1 N Inz(False) D Option2 10A Inz(' ') D Option3 10A Inz(' ') D Option4 10A Inz('ONE') D RefineEnabled N Inz(True) False = Disabled * Information used to produce the example 5 columns in the RESULTS table * Change the column values are required to match your fields D Results DS Qualified D RowLimit 10I00 Inz(5) D RowTotal 10I00 Inz(0) D Id 50A varying Inz('') D Col1Value 50A varying Inz('') D Col2Value 50A varying Inz('') D Col3Value 50A varying Inz('') D Col4Value 50A varying Inz('') D Col5Value 50A varying Inz('') D Col6Value 50A varying Inz('') D Col7Value 50A varying Inz('') D Col8Value 50A varying Inz('') D Col9Value 50A varying Inz('') // Standard includes for LRNG APIs, etc /INCLUDE LRNGSOURCE,LRNGCOMMON // Your projects standard include and standard parameter definitions /INCLUDE QRPGLESRC,STDINCLUDE /INCLUDE QRPGLESRC,STDPARAM // Switch to free format coding style /free // ------------------------------------------------------------ // Main : Loop until this program should not handle the request // ------------------------------------------------------------ Exsr Initialize; CheckAppAvailability(RequestACTION:RequestPROGRAM:SavedSTATE); DoW (RequestPROGRAM = ProgramINFO.Name); // Handle the user's requested action Exsr HandleRequestedAction; // If this is still the handler program If (RequestPROGRAM = ProgramINFO.Name); // Display the appropriate form view Exsr DisplayFormView; // Check ongoing availability CheckAppAvailability(RequestACTION:RequestPROGRAM:SavedSTATE); Endif; Enddo; // Return control back to the driver to invoke the next program Exsr Terminate; *InLR = True; Return; // ---------------------------------------------------------- // Initialize : Perform program initialization logic // ---------------------------------------------------------- Begsr Initialize; // Initialize the search field from the current (ie: last used) value. SearchVal = LRNG_GetPropAsStr(LAST_SEARCHED_XXXXX); // Set the indicator to show/hide the Refine button EndSr; // ---------------------------------------------------------- // Terminate : Perform program termination logic // ---------------------------------------------------------- Begsr Terminate; // Remember the current search value in case we come back later LRNG_AssignStrToProp(SearchVal : LAST_SEARCHED_XXXXX); EndSr; // ---------------------------------------------------------- // HandleRequestedAction : Handle the user's requested action // ---------------------------------------------------------- Begsr HandleRequestedAction; // Handle the user's requested action Select; // Search button touched When (RequestACTION = 'SEARCHREQUESTED'); Exsr Handle_SEARCHREQUESTED; // Entry in the RESULT table touched When (RequestACTION = 'RESULTSELECTED'); Exsr Handle_RESULTSELECTED; // Refine button touched When (RequestACTION = 'REFINEREQUESTED'); Exsr Handle_REFINEREQUESTED; // Refine button touched When (RequestACTION = 'APPLYREFINEMENT'); Exsr Handle_APPLYCLICK; // Default behaviour Other; Exsr Handle_DEFAULT; EndSl; Endsr; // ------------------------------------------- // Handle_DEFAULT : Handle the DEFAULT request // ------------------------------------------- Begsr Handle_DEFAULT; Endsr; // ------------------------------------------------------------- // Handle_SEARCHREQUESTED : The user touched the "Search" button // ------------------------------------------------------------- Begsr Handle_SEARCHREQUESTED; // Set the initial search result and limit counters Results.RowTotal = 0; Results.RowLimit = 100; // Limit to 100 // If no search string was specified show a pop over message if (SEARCHVAL = ' '); ShowPopOverMessage('SEARCHVAL':'Please specify a search':'I'); // Otherwise generate 30 'sample' tables item rows else; Local.OddColumn = False; // Generate 30 sample dummy data rows. Replace this logic // with your own 'real' search logic, probably over a data base // table. Your would aso be looking at search refinement details // to limit what was found For Local.TempIndex = 1 to 30; Local.OddColumn = NOT(Local.OddColumn); // Put dummy data into all 9 results columns and also // into the hidden ID field used by Handle_RESULTSELECTED Results.ID = 'Thing-' + %char(Local.TempIndex); Results.Col1Value = Results.ID; Results.Col2Value = 'BBBBBBBBBB'; Results.Col3Value = 'CCCCCCCCC'; Results.Col4Value = 'DDDDDDDDDDDDDDDDDDDD'; Results.Col5Value = 'EEEEEEEEEEEEEEEEEEEEEEEEE'; Results.Col6Value = '99999.99'; Results.Col7Value = '99999.99'; Results.Col8Value = 'GGGGGGGGGGGGGG'; Results.Col9Value = 'HHHHHHHHHHHHHHHHHHH'; // Add this result to the RESULTS table Exsr AddRESULTSTableRow; Endfor; // Show a pop over message if too many results were found if (Results.RowTotal >= Results.RowLimit); ShowPopOverMessage( 'SEARCHVAL' : 'Search was stopped at ' + %char(Results.RowLimit) + ' rows' : 'I'); endif; endif; Endsr; // ------------------------------------------------------------- // Handle_REFINEREQUESTED : The user touched the "Refine" button // ------------------------------------------------------------- Begsr Handle_REFINEREQUESTED; // Restore the values kept in the local Refine variables into // the visible PopOver fields LRNG_Using('/Form.Fields.REFINEBUT'); LRNG_SetProperty('ShowPopOver' : 'True'); LRNG_SetProperty('PopOver.Fields.Refine1.Value' : Refine.Option1); LRNG_SetProperty('PopOver.Fields.Refine2.Value' : Refine.Option2); LRNG_SetProperty('PopOver.Fields.Refine3.Value' : Refine.Option3); LRNG_SetProperty('PopOver.Fields.Refine4.Value' : Refine.Option4); LRNG_EndUsing(); Local.IsNewForm = False; Endsr; // ------------------------------------------------- // Handle_APPLYCLICK : Handle the APPLYCLICK request // ------------------------------------------------- Begsr Handle_APPLYCLICK; // Save the PopOver field values in the local Refine variables. LRNG_Using('/Form.Fields.REFINEBUT.PopOver.Fields'); Refine.Option1 = LRNG_GetPropAsStr('Refine1.Value'); Refine.Option2 = LRNG_GetPropAsStr('Refine2.Value'); Refine.Option3 = LRNG_GetPropAsStr('Refine3.Value'); Refine.Option4 = LRNG_GetPropAsStr('Refine4.Value'); LRNG_EndUsing(); // Execute the search (again) Exsr Handle_SEARCHREQUESTED; Endsr; // ---------------------------------------------------- // Handle_RESULTSELECTED : Handle action RESULTSELECTED // ---------------------------------------------------- Begsr Handle_RESULTSELECTED; // Get the Row ID of the RESULTS table entry that was touched LRNG_Using('/Form.Fields.RESULTFORM.Fields.RESULTS'); Results.ID = LRNG_GetPropAsStr('CurrentRowID'); // Put the ID value into the state data key 1 so that DETAILER1 // (say) knows which data item it should display details about. // ie: This is how the "key" of the order, product,invoice, etc // is passed across to DETAILER1/2/3/4 like programs. LRNG_AssignStrToProp(Results.ID : CURRENT_ID1_XXXXX); // Switch/transfer/delegate the display of the selected // row to the program named in PRIMARY_DETAIL_PROGRAM // so it can display some details abotu this item RequestPROGRAM = PRIMARY_DETAIL_PROGRAM; RequestACTION = 'DEFAULT'; Endsr; // ---------------------------------------------------------------- // AddRESULTSTableRow : Add a row to the result table named RESULTS // ---------------------------------------------------------------- Begsr AddRESULTSTableRow; // Only add if the RESULTS table is not full if ( Results.RowTotal < Results.RowLimit); // Increment the result table row counter Results.RowTotal += 1; // Put the data into the correct table row LRNG_Using('/Form.Fields.RESULTFORM.Fields.RESULTS.Row' : Idx(Results.RowTotal) ); // Theme.Enabled is declared in STDINCLUDE to enable/disable // alternate row colors. // In the same Theme DS are specified the alternating colors If (Theme.Enabled); If (Local.OddColumn); LRNG_AssignStrToProp(Theme.OddRowColor : 'BackColor'); Else; LRNG_AssignStrToProp(Theme.EvenRowColor : 'BackColor'); Endif; ENDIF; // Put the data into COL1, COL2 and COL3 LRNG_AssignStrToProp(Results.Col1Value : 'COL1.Value'); LRNG_AssignStrToProp(Results.Col2Value : 'COL2.Value'); LRNG_AssignStrToProp(Results.Col3Value : 'COL3.Value'); LRNG_AssignStrToProp(Results.Col4Value : 'COL4.Value'); LRNG_AssignStrToProp(Results.Col5Value : 'COL5.Value'); LRNG_AssignStrToProp(Results.Col6Value : 'COL6.Value'); LRNG_AssignStrToProp(Results.Col7Value : 'COL7.Value'); LRNG_AssignStrToProp(Results.Col8Value : 'COL8.Value'); LRNG_AssignStrToProp(Results.Col9Value : 'COL9.Value'); // Add the hidden ID value used to identify the selected row content when touched LRNG_AssignStrToProp(Results.ID : 'ID'); endif; Endsr; // ------------------------------------------------------------------- // Set_REFINEMSG : Show field REFINEMSG with a filter summary // ------------------------------------------------------------------- Begsr Set_REFINEMSG; // This code builds a message to show the search has been refined RefineMsg = ''; if (Refine.RefineEnabled); if (Refine.Option1); RefineMsg = %trim(RefineMsg) + 'Ref1=Checked'; Else; RefineMsg = %trim(RefineMsg) + 'Ref1=UnChecked'; Endif; RefineMsg = %trim(RefineMsg) + ', Ref2=' + Refine.Option2; RefineMsg = %trim(RefineMsg) + ', Ref3=' + Refine.Option3; RefineMsg = %trim(RefineMsg) + ', Ref4=' + Refine.Option4; Endif; Endsr; // ------------------------------------------ // DisplayFormView : Display this form view(s) // ------------------------------------------- Begsr DisplayFormView; //Build the REFINEMSG to be displayed Exsr Set_REFINEMSG; // Write out and read back this handler's form view (screen layout). If (Not Local.IsNewForm); LRNG_SetSendChangesOnly(); Endif; LRNG_Send(); // Condition what appears on the screen *IN01 = (Results.RowTotal > 0); *IN02 = Refine.RefineEnabled; EXFMT FormView; LRNG_Receive(); // Get the next requested action to take and the program to handle it LRNG_GetRequestedAction(RequestPROGRAM:RequestACTION); Local.IsNewForm = True; // By default assume new form displayed Endsr; /end-free