Handling of timestamps in RPGLE: Difference between revisions

From Try-AS/400
Jump to navigation Jump to search
(New)
 
(Temp Link)
Tag: New redirect
 
Line 1: Line 1:
Because date and time values have been bolted-on to RPG later, their '''handling of timestamps in RPGLE''' is somewhat tedious.
#REDIRECT [[Using timestamps in RPG]]
 
To make it work properly, we need three (!) variables:
* CHANGED is the database field, type timestamp. Incompatible with the timestamp type within RPG, so we need another variable…
* STAMP is the variable for dealing with timestamps within RPG.
* STAMP$ is a string variable derived from the DSPF for showing a nicely formatted timestamp. This isn't meant to be edited, so fields must be flagged O!
 
----
 
;PF
      A            CHANGED        Z
 
;DSPF
      A            STAMP$        19A  O ...
 
;RPGLE
      D*
      D* For saving/handling timetamp data.
      DSTAMP            S              Z
      D*
 
For every time we write, or update a record:
      C* Get current timestamp.
      C                  TIME                    STAMP
      C                  MOVEL    STAMP        CHANGED
 
For every instance before displaying the STAMP$ field:
      C* Get timestamp, and produce nice version thereof.
      C                  MOVEL    CHANGED      STAMP$
      C    '.':':'      XLATE    STAMP$        STAMP$
      C    '-':' '      XLATE    STAMP$:11    STAMP$
 
== See also ==
* [https://ibmdocs.pocnet.net/SC41-5712-01.pdf SC41-5712-01], AS/400e DDS Reference
* [https://ibmdocs.pocnet.net/SC09-2508-02.pdf SC09-2508-02], AS/400e ILE RPG for AS/400 Reference
 
[[Category: Programming]]

Latest revision as of 23:28, 23 February 2023