Difference between revisions of "Format Zip Code"
From MidrangeWiki
DaveLClarkI (talk | contribs) |
DaveLClarkI (talk | contribs) (→Summary) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[[Category:Sample Code]] | [[Category:Sample Code]] | ||
[[Category:Service Procedures]] | [[Category:Service Procedures]] | ||
+ | __FORCETOC__ | ||
== Summary == | == Summary == | ||
The following are the RPG/LE fully free-form definitions and instructions needed for using the {{AN}} service procedure. This service procedure simply allows the caller to (re)format a USA zip code. | The following are the RPG/LE fully free-form definitions and instructions needed for using the {{AN}} service procedure. This service procedure simply allows the caller to (re)format a USA zip code. | ||
− | == Service | + | By [[User:DaveLClarkI|Dave Clark]] |
+ | |||
+ | == Service Prototype == | ||
+ | Place the following in a separate copybook for inclusion in both the caller and the service program source members. | ||
<pre> | <pre> | ||
**free | **free | ||
Line 14: | Line 18: | ||
ZipValue varchar(10) const; | ZipValue varchar(10) const; | ||
end-pr; | end-pr; | ||
+ | </pre> | ||
+ | |||
+ | == Service Procedure == | ||
+ | Place the following in a service program source member. | ||
+ | <pre> | ||
+ | **free | ||
+ | ctl-opt NoMain AlwNull(*UsrCtl) Debug Option(*SrcStmt:*NoDebugIo) | ||
+ | DatFmt(*ISO) TimFmt(*ISO); | ||
//============================================================================== | //============================================================================== |
Latest revision as of 15:57, 17 December 2018
Summary
The following are the RPG/LE fully free-form definitions and instructions needed for using the Format Zip Code service procedure. This service procedure simply allows the caller to (re)format a USA zip code.
By Dave Clark
Service Prototype
Place the following in a separate copybook for inclusion in both the caller and the service program source members.
**free //============================================================================== // Format USA zip code or foreign postal code for output. //============================================================================== dcl-pr GenUtl_FormatZipCode varchar(10); ZipValue varchar(10) const; end-pr;
Service Procedure
Place the following in a service program source member.
**free ctl-opt NoMain AlwNull(*UsrCtl) Debug Option(*SrcStmt:*NoDebugIo) DatFmt(*ISO) TimFmt(*ISO); //============================================================================== // Format USA zip code or foreign postal code for output. //============================================================================== dcl-proc GenUtl_FormatZipCode export; dcl-pi *n varchar(10); ZipValue varchar(10) const; end-pi; dcl-s ZipCode like(ZipValue); ZipCode = GenUtl_StripFormatting(%trim(ZipValue): ' +-.'); if %len(ZipCode) = *zero // if blank or not GenUtl_isDigits(ZipCode); // or not all digits return ZipCode; // return as-is (alpha postal code?) endif; if %len(ZipCode) <= 5; // no zip+4 present? return %editc(%int(ZipCode):'X'); // return 5-digit zip code endif; return %trim(%editw(%int(ZipCode):'0 - ')); // return formatted zip+4 end-proc;
References
- GenUtl_isDigits service procedure
- GenUtl_StripFormatting service procedure