Require at least one parameter. Fix some issues with "Return selected customer"
This commit is contained in:
@@ -34,8 +34,6 @@
|
|||||||
//==============================================================
|
//==============================================================
|
||||||
// Compilation
|
// Compilation
|
||||||
// Use CRTSQLRPGI command.
|
// Use CRTSQLRPGI command.
|
||||||
// Note that /INCLUDEs expects to find code in DEMO library,
|
|
||||||
// not the default of QRPGLESRC. Change as needed.
|
|
||||||
//=============================================================
|
//=============================================================
|
||||||
// 12/2023 Convert to totally **FREE
|
// 12/2023 Convert to totally **FREE
|
||||||
// 02/2024 Change CUSTID to character for alpha-numeric keys
|
// 02/2024 Change CUSTID to character for alpha-numeric keys
|
||||||
|
|||||||
@@ -64,6 +64,9 @@
|
|||||||
//============================================================
|
//============================================================
|
||||||
// 12/2023 Converted to totally **FREE
|
// 12/2023 Converted to totally **FREE
|
||||||
// Changed to use SQLPROBLEM service pgm
|
// Changed to use SQLPROBLEM service pgm
|
||||||
|
// 01/2025 Require at least one parameter.
|
||||||
|
// Remove commented SQLPROBLEM code.
|
||||||
|
// Fix some issues with "Return selected customer"
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
ctl-opt dftactgrp(*no) actgrp(*caller) option(*nodebugio: *srcstmt)
|
ctl-opt dftactgrp(*no) actgrp(*caller) option(*nodebugio: *srcstmt)
|
||||||
@@ -222,9 +225,17 @@ for fetch only
|
|||||||
//=============================================================
|
//=============================================================
|
||||||
// === Program Starts Here ====================================
|
// === Program Starts Here ====================================
|
||||||
//=============================================================
|
//=============================================================
|
||||||
|
// Check at least one parameter. Calling from the command line
|
||||||
|
// without a parm caused confusion for newer developers.
|
||||||
|
// In a production environment, this would be called from a
|
||||||
|
// tested menu or some program that enforced security.
|
||||||
|
if %parms() = 0;
|
||||||
|
snd-msg *DIAG (%trim(PgmName) + ': There must be at least one parameter');
|
||||||
|
snd-msg *ESCAPE 'See previous diagnostic (*DIAG) message ';
|
||||||
|
endif;
|
||||||
|
|
||||||
// === Set up for the first screen IO =========================
|
// === Set up for the first screen IO =========================
|
||||||
Init();
|
Init(pParmType : pCustID);
|
||||||
BldFkeyText();
|
BldFkeyText();
|
||||||
SflClear();
|
SflClear();
|
||||||
|
|
||||||
@@ -266,6 +277,9 @@ dou COWSCOMEHOME;
|
|||||||
else;
|
else;
|
||||||
ProcessOption();
|
ProcessOption();
|
||||||
endif;
|
endif;
|
||||||
|
if Quit_Pgm = *on;
|
||||||
|
leave;
|
||||||
|
endif;
|
||||||
iter;
|
iter;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
@@ -331,7 +345,7 @@ Dcl-Proc ScreenIO;
|
|||||||
write MSGCTL;
|
write MSGCTL;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
End-Proc;
|
End-Proc ScreenIO;
|
||||||
|
|
||||||
//=== ProcessFunctionKey ======================================
|
//=== ProcessFunctionKey ======================================
|
||||||
// Process whatever keyboard entry was made.
|
// Process whatever keyboard entry was made.
|
||||||
@@ -403,7 +417,7 @@ Dcl-Proc ProcessFunctionKey;
|
|||||||
SflMsgSnt= SndSflMsg('DEM0003');
|
SflMsgSnt= SndSflMsg('DEM0003');
|
||||||
endsl;
|
endsl;
|
||||||
|
|
||||||
End-Proc;
|
End-Proc ProcessFunctionKey;
|
||||||
|
|
||||||
//=== ProcessOption ===========================================
|
//=== ProcessOption ===========================================
|
||||||
// Did user enter one or more options? Loop through the
|
// Did user enter one or more options? Loop through the
|
||||||
@@ -427,6 +441,7 @@ Dcl-Proc ProcessOption;
|
|||||||
// Return customer number to caller
|
// Return customer number to caller
|
||||||
pCustID = SF_CUST_H;
|
pCustID = SF_CUST_H;
|
||||||
CloseDownPgm();
|
CloseDownPgm();
|
||||||
|
Quit_Pgm = *on;
|
||||||
return;
|
return;
|
||||||
//--- 2 = Edit with external program -----------------
|
//--- 2 = Edit with external program -----------------
|
||||||
when SF_OPT = '2' and Maint_OK = *on;
|
when SF_OPT = '2' and Maint_OK = *on;
|
||||||
@@ -497,7 +512,7 @@ Dcl-Proc ProcessOption;
|
|||||||
) + 1;
|
) + 1;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
End-Proc;
|
End-Proc ProcessOption;
|
||||||
|
|
||||||
//=== SflFirstPage ============================================
|
//=== SflFirstPage ============================================
|
||||||
// Processes the Search fields in the Sub file control, then
|
// Processes the Search fields in the Sub file control, then
|
||||||
@@ -527,7 +542,7 @@ Dcl-Proc SflFirstPage;
|
|||||||
endif;
|
endif;
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
End-Proc;
|
End-Proc SflFirstPage;
|
||||||
|
|
||||||
//=== SflFillPage =============================================
|
//=== SflFillPage =============================================
|
||||||
// Adds a page worth of records to the subfile.
|
// Adds a page worth of records to the subfile.
|
||||||
@@ -582,7 +597,7 @@ Dcl-Proc SflFillPage;
|
|||||||
endIf;
|
endIf;
|
||||||
endfor;
|
endfor;
|
||||||
endsl;
|
endsl;
|
||||||
End-Proc;
|
End-Proc SflFillPage;
|
||||||
|
|
||||||
|
|
||||||
//=== Update Subfile Recd =====================================
|
//=== Update Subfile Recd =====================================
|
||||||
@@ -594,7 +609,7 @@ Dcl-Proc UpdSflRecd;
|
|||||||
update SFL;
|
update SFL;
|
||||||
sfInAct = *off;
|
sfInAct = *off;
|
||||||
write DUMMY; // Supposed to help restore SFL display
|
write DUMMY; // Supposed to help restore SFL display
|
||||||
End-Proc;
|
End-Proc UpdSflRecd;
|
||||||
|
|
||||||
//=== ProcessSearchCriteria ====================================
|
//=== ProcessSearchCriteria ====================================
|
||||||
// Examine the data entered in the search fields and build an
|
// Examine the data entered in the search fields and build an
|
||||||
@@ -647,7 +662,7 @@ Dcl-Proc ProcessSearchCriteria;
|
|||||||
endif;
|
endif;
|
||||||
CursorOpen = *on;
|
CursorOpen = *on;
|
||||||
endif;
|
endif;
|
||||||
End-Proc;
|
End-Proc ProcessSearchCriteria ;
|
||||||
|
|
||||||
//=== SetCursorPostion ========================================
|
//=== SetCursorPostion ========================================
|
||||||
// If Invalid Option, position screen cursor on first error,
|
// If Invalid Option, position screen cursor on first error,
|
||||||
@@ -656,7 +671,7 @@ Dcl-Proc SetCursorPosition;
|
|||||||
if OptError = *off;
|
if OptError = *off;
|
||||||
SC_CSR_RCD=SflRRN;
|
SC_CSR_RCD=SflRRN;
|
||||||
endif;
|
endif;
|
||||||
End-Proc;
|
End-Proc SetCursorPosition;
|
||||||
|
|
||||||
//=== BldFKeyText =============================================
|
//=== BldFKeyText =============================================
|
||||||
// Build the Function key text for the bottom of the screen.
|
// Build the Function key text for the bottom of the screen.
|
||||||
@@ -684,7 +699,7 @@ Dcl-Proc BldFkeyText;
|
|||||||
endif;
|
endif;
|
||||||
SFT_KEYS = CatB(SFT_KEYS : F9Text);
|
SFT_KEYS = CatB(SFT_KEYS : F9Text);
|
||||||
SFT_KEYS = CatB(SFT_KEYS : F12TEXT);
|
SFT_KEYS = CatB(SFT_KEYS : F12TEXT);
|
||||||
End-Proc;
|
End-Proc BldFkeyText ;
|
||||||
|
|
||||||
//=== CloseDownPgm ============================================
|
//=== CloseDownPgm ============================================
|
||||||
// Things to do before we issue a return to the caller
|
// Things to do before we issue a return to the caller
|
||||||
@@ -692,12 +707,17 @@ Dcl-Proc CloseDownPgm;
|
|||||||
CloseCursor();
|
CloseCursor();
|
||||||
close PMTCUSTD;
|
close PMTCUSTD;
|
||||||
CustDsp(); // Close Window display file.
|
CustDsp(); // Close Window display file.
|
||||||
End-Proc;
|
End-Proc CloseDownPgm;
|
||||||
|
|
||||||
//=== Init ====================================================
|
//=== Init ====================================================
|
||||||
// Must be executed each time program is entered, because F12
|
// Must be executed each time program is entered, because F12
|
||||||
// and Enter key leave with LR off.
|
// and Enter key leave with LR off.
|
||||||
Dcl-Proc Init;
|
Dcl-Proc Init;
|
||||||
|
dcl-pi *n;
|
||||||
|
pParmType char(1);
|
||||||
|
pCustID like(CUSTID);
|
||||||
|
end-pi;
|
||||||
|
|
||||||
//=== Options Text ========================================
|
//=== Options Text ========================================
|
||||||
dcl-c OPT1TEXT '1=Select';
|
dcl-c OPT1TEXT '1=Select';
|
||||||
dcl-c OPT2TEXT '2=Edit';
|
dcl-c OPT2TEXT '2=Edit';
|
||||||
@@ -744,7 +764,7 @@ Dcl-Proc Init;
|
|||||||
SH_FUNCT = CenterStr(HdrMaint);
|
SH_FUNCT = CenterStr(HdrMaint);
|
||||||
endif;
|
endif;
|
||||||
SC_OPTIONS = CatB(SC_OPTIONS : OPT5TEXT);
|
SC_OPTIONS = CatB(SC_OPTIONS : OPT5TEXT);
|
||||||
End-Proc;
|
End-Proc Init;
|
||||||
|
|
||||||
//=============================================================
|
//=============================================================
|
||||||
// === S u b P r o c e d u r e s ============================
|
// === S u b P r o c e d u r e s ============================
|
||||||
@@ -765,34 +785,14 @@ dcl-proc CatB;
|
|||||||
else;
|
else;
|
||||||
return %trimr(ToStr) + ' ' + AddStr;
|
return %trimr(ToStr) + ' ' + AddStr;
|
||||||
endif;
|
endif;
|
||||||
end-proc;
|
end-proc CatB;
|
||||||
|
|
||||||
// //=== SQLProblem ==============================================
|
|
||||||
// // For those "Never should happen" SQL errors.
|
|
||||||
// // Issues DUMP(A) to dump memory, then ends program by
|
|
||||||
// // sending an *ESCAPE message of the supplied debugging text.
|
|
||||||
// dcl-proc SQLProblem;
|
|
||||||
// dcl-pi SQLProblem;
|
|
||||||
// piSQLDebug varchar(1024) value;
|
|
||||||
// end-pi;
|
|
||||||
|
|
||||||
// //--- Local Variables ----------------------------------------
|
|
||||||
// dcl-s wkSQLDebug varchar(1024);
|
|
||||||
|
|
||||||
// wkSQLDebug = 'SQLSTT ' + SQLSTT
|
|
||||||
// + ' << Unexpected SQL Return Code: '
|
|
||||||
// + piSQLDebug;
|
|
||||||
// dump(a);
|
|
||||||
// SndEscMsg(wkSQLDebug);
|
|
||||||
// return;
|
|
||||||
// end-proc;
|
|
||||||
|
|
||||||
//=== FetchNextData ===========================================
|
//=== FetchNextData ===========================================
|
||||||
// Fetch the next row from the cursor
|
// Fetch the next row from the cursor
|
||||||
// Returns: End of data Indicator:
|
// Returns: End of data Indicator:
|
||||||
// *ON No more data, nothing returned
|
// *ON No more data, nothing returned
|
||||||
// *OFF Data returned
|
// *OFF Data returned
|
||||||
//------------------------------------------------------------
|
//------------------------------------------------------------
|
||||||
dcl-proc FetchNextData;
|
dcl-proc FetchNextData;
|
||||||
dcl-pi FetchNextData ind;
|
dcl-pi FetchNextData ind;
|
||||||
TheRecd likeds(CustMast);
|
TheRecd likeds(CustMast);
|
||||||
@@ -819,7 +819,7 @@ dcl-proc FetchNextData;
|
|||||||
|
|
||||||
RETURN wkEof;
|
RETURN wkEof;
|
||||||
|
|
||||||
end-proc;
|
end-proc FetchNextData;
|
||||||
|
|
||||||
//=== ReadByKey ===============================================
|
//=== ReadByKey ===============================================
|
||||||
// Read the record by key into the specified data record
|
// Read the record by key into the specified data record
|
||||||
@@ -846,7 +846,7 @@ dcl-proc ReadByKey;
|
|||||||
from CUSTMAST
|
from CUSTMAST
|
||||||
where CUSTID = :TheKey
|
where CUSTID = :TheKey
|
||||||
;
|
;
|
||||||
end-proc;
|
end-proc ReadByKey;
|
||||||
|
|
||||||
//=== BuildSFLRecd ============================================
|
//=== BuildSFLRecd ============================================
|
||||||
// Builds a SFL record from the specified data record
|
// Builds a SFL record from the specified data record
|
||||||
@@ -868,7 +868,7 @@ dcl-proc BuildSflRecd;
|
|||||||
endif;
|
endif;
|
||||||
// Save Active status in case we update subfile
|
// Save Active status in case we update subfile
|
||||||
SF_ACT_H = CustRecd.ACTIVE;
|
SF_ACT_H = CustRecd.ACTIVE;
|
||||||
end-proc;
|
end-proc BuildSflRecd;
|
||||||
|
|
||||||
//=== CloseCursor =============================================
|
//=== CloseCursor =============================================
|
||||||
// Closes the SQL Cursor if open
|
// Closes the SQL Cursor if open
|
||||||
@@ -883,7 +883,7 @@ dcl-proc CloseCursor;
|
|||||||
CursorOpen = *off;
|
CursorOpen = *off;
|
||||||
endif;
|
endif;
|
||||||
RETURN;
|
RETURN;
|
||||||
end-proc;
|
end-proc CloseCursor;
|
||||||
|
|
||||||
//=== SndSflMsg ===============================================
|
//=== SndSflMsg ===============================================
|
||||||
// Send a message to the Error Subfile
|
// Send a message to the Error Subfile
|
||||||
@@ -925,7 +925,7 @@ dcl-proc SndSflMsg;
|
|||||||
retField = *on;
|
retField = *on;
|
||||||
RETURN retField;
|
RETURN retField;
|
||||||
|
|
||||||
end-proc;
|
end-proc SndSflMsg;
|
||||||
|
|
||||||
//=== SflClear ================================================
|
//=== SflClear ================================================
|
||||||
// Clears the Subfile
|
// Clears the Subfile
|
||||||
@@ -937,4 +937,4 @@ dcl-proc SflClear;
|
|||||||
write SFLCTL;
|
write SFLCTL;
|
||||||
scSflClr = *OFF;
|
scSflClr = *OFF;
|
||||||
return;
|
return;
|
||||||
end-proc;
|
end-proc SflClear;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
PGM
|
PGM
|
||||||
/* Create UTIL_BND binding directory in *CURLIB */
|
/* Create SRV_BASE36 binding directory in *CURLIB */
|
||||||
/* Change next statement if needed */
|
/* Change next statement if needed */
|
||||||
CRTBNDDIR BNDDIR(*CURLIB/SRV_BASE36) TEXT('BASE36 ADD +
|
CRTBNDDIR BNDDIR(*CURLIB/SRV_BASE36) TEXT('BASE36 ADD +
|
||||||
Service PGMs')
|
Service PGMs')
|
||||||
|
|||||||
Reference in New Issue
Block a user