HP RPG/XL Programmer's Guide (30318-90001)

8-: 1
Chapter 8 Communicating with MPE and Other RPG Programs
RPG has certain unique language features that make it easy to communicate
with other RPG programs. It also contains features that give RPG
programs access to certain operating system areas and routines. Overall,
these features extend the functionality of RPG and allow you to gain more
control over the execution of application programs.
Some of the most common ways to use the operating system and to
communicate with other RPG programs are described in this chapter. Where
appropriate, you are directed to operating system and RPG manuals for
additional information.
Using the System Date and Time
There are two ways to retrieve the current date in an RPG program.
You can use the UDATE special field in Calculation and Output
Specifications. UDATE is automatically initialized to the current date
when a program begins execution (the date is not reinitialized when
programs continue execution past midnight).
If you want to retrieve the date as well as the current time, use the
TIME (or TIME2) Calculation Specification operation. Since TIME is
executed dynamically, the date and time are always current. You may want
to use TIME, for example, to stamp transaction records before they are
written to tape. TIME gets the time and, optionally, the date and stores
them in the Result Field in the format: hhmmssmmddyy (or hhmmssddmmyy in
Foreign format). For example, the date 10/29/86 and time 3:13:25 is
returned as 031325102986. TIME2 returns the date and time in a
40-character formatted string. The format for this string is shown below
along with an example of a date and time that might be returned:
day, mon dd, year, hh:mm xM JULIAN:nnn
WED, OCT 29, 1986, 3:13 AM JULIAN:304
You can specify which parts of the date and time to retrieve, if you
wish, by entering their positions in the Factor2 and Result Fields.
Figure 8-1 shows how to use the TIME2 operation to stamp output records
with the most current date and time. Only the current time and the day
of the month are used in this example.