Dates. Robelle Suprtool 5.7
ಜಾಹಿರಾತು
ಜಾಹಿರಾತು
156 • Suprtool 5.7 for MPE
In this example, Address is a repeated field (2X20). We wish to extract the data as it exists in the input record rather than forcing it to a constant value.
>ext account {extract key value}
>ext address {take both of the repeated fields}
In the next example, we assume that the Balance field is a repeated field (12J2). We wish to make each of the 12 repeated fields in the output record equal to 100:
>extract name
>extract balance=100
If we only wanted to extract the sixth field of BALANCE and set it to 100 we would do the following:
>extract name
>extract balance(6)=100
Character Constants
Use the ^-character to specify any ASCII character. The number (the actual ASCII value), or letter (^A means control A), must follow immediately after the ^-character.
Suprtool treats character constants as strings. When you extract the constant to a field longer than one byte, Suprtool pads it with spaces.
>define field,1,1 {byte field}
>ext field = ^0 {binary zero}
>ext field = ^G {Control-G (bell)}
>ext field = ^27 {escape}
>ext field = ^252 {Roman-8 box}
>ext field = ^186 {Euro currency symbol €}
You can also extract the constant directly without referring to a defined field. This always produces a one-byte constant with no blank padding.
>ext ^0 {binary zero}
>ext ^13,^10 {Carriage Return, Line Feed}
>ext ^M,^J {CR, LF again}
>ext ^27,"&dB" {escape sequence}
Dates
Extracting Today's Date
To extract today's date, use the following:
>item field,date,ccyymmdd {identify date format of field}
>extract field=$today {today's date}
>extract field=$today(-1) {yesterday's date}
>extract field=$today(+1) {tomorrow's date}
Use the Item command to qualify the field as a date. Suprtool uses the date format to determine the output format of the date. The $today function accepts one optional argument which is the number of days before or after today. The maximum number of days in either direction is 9999.
Oracle dates include both the date and the time. If you extract an Oracle date using
$today, the time is always 00:00 (i.e., midnight).
Extracting Relative Dates
The Extract command provides the same relative date features as the If command
(see "Date Selection" on page 198 for a complete description of the options of
Suprtool Commands
Suprtool Commands
$date). You must first use the Item command to identify the field name as a date.
Suprtool uses the field type and length along with the date format to determine the output format of the date. Note that the three parts of $DATE are always specified in
(year/month/day) order, regardless of the date format of the field.
>item field,date,mmddyy
>extract field=$date(*/*/*) {today's date}
>extract field=$date(*/*-1/01) {start of last month}
>extract field=$date(*/*-1/last) {end of last month}
Oracle dates include both the date and the time. If you extract an Oracle date using
$date, the time is always 00:00 (i.e., midnight).
$Stddate
Similar to the If command, the Extract command is also capable of utilizing the
$stddate function. This will allow for conversion of any of the supported Suprtool date formats to be converted to a date in the ccyymmdd date format in a double integer container.
For example,
>get sales-detail
>def new-ship-date,1,4,double
>item ship-date,date,mmddyyyy
>ext order-no / sales-amount
>ext new-ship-date = $stddate(ship-date)
>out salesinfo,link
>xeq
Invalid Dates
Because the $stddate must have a valid date in order to properly convert the date to the ccyymmdd format, a value of 0 will be returned for any invalid dates. An invalid date is any number of a particular date format whose date equivalent cannot be found on the calendar.
This means that if you attempt to extract use the $stddate function against a value that is not a valid date then the extracted value will be 0.
$Days
As with the $stddate function, the $days function is also available to the Extract command. You can convert any supported date to a Julian Day number in the following manner:
>in ordfile
>def ship-days,1,4,double
>def order-days,1,4,double
>def delay,1,4,double
>ext order-no
>ext ship-days=$days(ship-date)
>ext order-days=$days(order-date)
>ext delay=$days(ship-date)-$days(order-date)
>out neword,link
>xeq
IN=15, OUT=15. CPU-Sec=1. Wall-Sec=1.
Invalid Dates
If an invalid date is encountered, the extracted value will be zero. Therefore in the example above, if the order has not yet been shipped (ship-date does not contain a valid date) the resulting delay value will be negative.
Suprtool 5.7 for MPE• 157
ಡೌನ್ಲೋಡ್ ಮಾಡಿ
ಜಾಹಿರಾತು