1 / 16

RPG IV

RPG IV. Defining Data with Definition Specifications - Chapter 3. Objectives :. Define work fields, data structures and other data items Set the initial value for data items Distinguish among program variables, literals and constants. Definition Specifcations.

sheila
Download Presentation

RPG IV

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. RPG IV Defining Data with Definition Specifications - Chapter 3

  2. Objectives: • Define work fields, data structures and other data items • Set the initial value for data items • Distinguish among program variables, literals and constants

  3. Definition Specifcations • Define all fields in your program • Specify name, length, and type • Input Specifications define fields from database • Definition Specifications define work fields or stand-alone fields

  4. Numeric Literal • The literal may include a decimal point and/or sign. • The sign must be the left most character of the literal. • The literal may include digits 0 thru 9. • The literal should never contain commas, dollar signs, or percent signs. • The literal must not be enclosed in apostrophes.

  5. Character Literals • To indicate that a value is a character literal simply enclose it with apostrophes.

  6. Figurative Constants • *BLANK(S) - fills a character field with blanks • *HIVAL - fills a character with X’FFFF… (all bits on), fills a numeric field with all 9s and + sign • *LOVAL - fills a character with x’000…(all bits off), fills a numeric field with all 9s and - sign • *ZERO(S) - fills a numeric field with zeros • *ALL - causes a string to be repeated in a field • *OFF - character value of ‘0’ • *ON - character value of ‘1’ • *NULL- used with pointers

  7. Assigning Initial Values to Data • Specify the value using the INZ keyword in the fields definition • The value is indicated using a numeric or character literal or a figurative constant

  8. Zoned Decimal and Packed Decimal • Zoned decimal requires a full byte of storage • Packed-decimal use a compressed storage format • Integers and binary numbers require even less memory than the decimal data types do

  9. Date, Time and Timestamp • Timestamp is a combination of date and time • Define a standalone field, put a D (for dates), T (for times) and Z (for timestamp) in column 40

  10. Indicator Data Type • Refered to in other languages as Boolean data type • Code N in column 40 • You can initialize to *ON or *OFF

  11. Defining Constants • A named constant differs from a standalone in two respects: • Its value never changes during processing • It is defined with no specified length • Code the letter C, for constant, in column 24 • Enter the value in the Keywords area

  12. Defining Data Structures • Subdivide fields into subfields • Change field data types • Data structure has two parts, the data structure header and the definition for the subfields • DS coded in 24-25 on D spec signals the beginning of a data structure • Enter name of data structure in 7-21

  13. Defining Data-Structure Subfields • Absolute notation, uses From and To to indicate the beginning and ending postions of the subfield • Length notation, leaves From blank and enters the subfield length in the To positions • Length notation is prefered

  14. Overlapping Subfields • Locations of subfields can overlap • Absolute notation clearly indicates the overlap with the From and To • Length notation uses the keyword OVERLAY

  15. Points to Remember • RPG IV requires you to define all fields your programs will use • Input fields are defined using Input Specifications and standalone fields are defined using Definition Specifications • You can use the keyword INZ to assign a value to a field

  16. Points to Remember (cont) • Figurative constants are built-in literals with specified values. • Definition Specifications are used to define named constants as well as standalone fields • RPG IV supports many data types; character, numeric, date, and boolean • Data structures let you subdivide fields into subfields and redefine fields

More Related