This chapter contains these topics:
A Data Item Formula consists of Program Design Language (PDL) statements. PDL statements form the following types of operations.
Blocks of statements
Comments
Assignments
Database operations
Program calls
Loops
Conditions
Miscellaneous keywords and syntax
You must use specific syntax when you work with PDL statements.
A PDL statement combines one or more of the following elements:
Keywords
Variables
Database Files
Operators
Constants
Punctuation
Keywords are the vocabulary of PDL. They identify the type of operation the statement performs.
The following are valid variable names in PDL statements:
Database field names
Examples: ABAN8, MCDL01
Screen and report field names
Examples: VDDOCO, SFTRDJ, VC0001, RR#CLS
Data Dictionary
You can use Data Dictionary fields in PDL. The system uses the data type and size as they are defined in the Data Dictionary.
Indicators
You can use indicators by using the names IN01 to IN99. You can also use INLR. You can use both of these in PDL assignment statements to set on or off, and in conditional expressions to test for on or off.
Example:
in98 := '0'
If in98 = '0' Then
Note: In PDL, the system does not use * with indicators. That is, you specify indicator 01 as in01 and not *in01.
Program Workfields
Any name that PDL recognizes as a variable, but is not a database field name, Data Dictionary field, screen or report field, or indicator, the system considers as a program work field. PDL will prompt you to define its data type.
Examples: $#am1, $#xtp, $po1
Be aware that if you did not yet generate the source code, PDL is not able to search the source code to find a definition.
You must first define a database file name in the File Specifications before you can use it in one of the database I/O statements. PDL does not add file names to the specifications.
Keywords | Explanation |
---|---|
Begin | Initiates a block of statements.
The syntax is: Begin |
End | Terminates a block of statements initiated by the Begin statement.
The syntax is: End |
You must enter all Data Item Formulas within a Begin...End block. A comment statement may precede the Begin statement. For example:
\ Use system date as default. \
Begin
If vdtrdj = ' ' Then
vdtrdj := $$edt;
End
You must separate all statements within a Begin...End block by a semicolon. For example:
\ Load A/B name to vc0 field. \
Begin
aban8 := q3an8;
chain f0101la;
If in98 = '0' Then
vc0003 := abalph;
End
You can nest Begin...End up to a maximum of 50 levels. For example:
\ Computer counter. \
Begin
If zaclst = '900' Then
Begin
rr#nin := ' 1';
$#nin := 1;
End;
If zaclst < '900' Then
Begin
rr#nin := ' 0';
$#nin := 0;
End
End
Operators | Explanation |
---|---|
:= | The assignment operator. The system assigns the first variable the value of the variable or expression following the operator.
The syntax is: variable := expression; |
+ | Add |
- | Subtract |
* | Multiply |
/ | Divide |
|| | Concatenate |
|> | Blank and Concatenate |
|< | Truncate and Concatenate |
SST | Substring
The syntax is: variable := SST (field,n1,n2) n1 = start position n2 = length of string |
Keywords | Explanation |
---|---|
Chain | Provides for random data base processing.
The syntax is: CHAIN file; |
Delete | Provides the ability to delete the current data base record.
The syntax is: DELETE file; |
Poseq | Provides for the positioning of a pointer to a specific data base record that is equal to or greater than the key value you specify.
The syntax is: POSEQ file; |
Posgt | Provides for the positioning of a pointer to a specific data base record that is greater than the key value that you specify.
The syntax is: POSGT file; |
Read | Provides for sequential data base processing by reading the next record in the file you designate.
The syntax is: READ file; |
Readc | Provides for processing of workstation files to obtain the next record change in a subfile.
They syntax is: READC file; |
Reade | Provides for sequential data base processing by reading the next record in the file with a key equal to the one you specify.
The syntax is: READE file; |
Readp | Provides for sequential data base processing by reading the record previous to the record read in the file you designate.
They syntax is: READP file; |
Update | Provides the ability to update the current data base record.
The syntax is: UPDATE file; |
Write | Provides the ability to add a new data base records.
The syntax is: WRITE file; |
You must first define the file in the program using the File Specifications before you enter it in the statement.
The Chain, Poseq, Posgt, and Reade statements use the default KLIST name that the system generates for the file you specify.
You should assign a value to each field of the KLIST prior to entering the statement.
Specify indicator 98 in the statements to signify that the system did not retrieve a record for the program.
Specify indicator 99 in the statements to signify that a database operation error took place.
\ Load A/B name to vc0 field. \
Begin
aban8 := q3an8;
chain f0101la;
If in98 = '0' Then
vc0003 := abalph;
End
Keywords | Explanation |
---|---|
Call | Allows you to execute another program.
The syntax is: CALL variable; |
Parm | Allows you to deliver parameters to a program that the program call statement executes.
The syntax is: PARM variable; |
Neither the Call statement nor the Parm statement allows the use of constants.
Prior to the Call statement you must enter an assignment statement to load a variable with the name of the program to launch, and load one or more variables with the values of the parameters.
The Parm statements must immediately follow the Call statement.
For example:
Begin
##pid := 'P1540 ';
##vers := 'ZJDE001';
##doco := nrdoco;
Call ##pid;
Parm ##pid;
Parm ##vers;
Parm ##doco;
End
Keywords | Syntax |
---|---|
Until | Provides for loop processing where the system evaluates a condition at the bottom of the loop.
The syntax is: UNTIL (condition) DO (Statement) |
While | Provides for loop processing where the system evaluates a condition at the top of the loop.
The syntax is: WHILE (condition) DO (Statement) |
Do | An integral part of the loop statement. |
The Do keyword is an integral part of the loop statement.
The statement following Do can be a single statement, or a block of statements within a Begin...End block.
The action is simply two expressions that you separate.
For example:
Begin
While in98 = '0' Do
Begin
$#xtp := q2xqt * q2uncs;
$#am1 := $#am1 + $#xtp;
reade f59422;
End
End
Keywords | Explanation |
---|---|
If | Provides for conditional processing.
|
Then | Specifies the starting point for all actions the system takes when the condition of the If statement is met. |
Else | Enter these statements following the If and Then statements. The system executes these statements when the condition of the If statement is not met. |
The Then keyword is an integral part of the If statement.
The statement following the Then keyword can be a Begin/End block to allow for a block of statements when the condition is met.
The Else statement can follow the statements you enter with If (condition) and Then (statement).
The syntax is: IF (condition) THEN (statement) ELSE (statement)
Symbols | Explanation |
---|---|
= | Equal |
¼ | Not Equal |
> | Greater Than |
< | Less Than |
>= | Greater Than or Equal To |
<= | Less Than or Equal To |
You do not have to enter the semicolon (;) to end the statement following the Else, or the Then when there is no Else.
For example, a simple If...Then statement:
Begin
If sftrdj = ' ' Then
sftrdj := $$edt
End
For example, an If...Then...Else statement
Begin
If in98 = '0' Then
vc0003 := abalph
Else
vc0003 := 'NOT DEFINED'
End
If you nest Begin/End blocks between the Then and Else statements, you should use the semicolon after each individual statement but not following the End.
For example, an If...Then with a Begin...End statement
Begin
If zaclst = '999' Then
Begin
rr#nin := '1';
$#nim := 1;
End
End
For example, an If...Then...Else with Begin...End statement
Begin
If zaclst = '900' Then
Begin
rr#nin := '0';
$#nin := 0;
End;
Else
If zaclst < '900' Then
Begin
rr#nin := '<0';
$#nin := 1-;
End;
Else
Begin
rr#nin := '>0';
$#nin := 1;
End
End
Keywords | Explanation |
---|---|
Include | Provides the ability to include other PDL modules in the User Calculation.
The syntax is: INCLUDE (module name) |
Return | Provides for user specification of the Source of Data alone or as the result of a series of procedures.
The syntax is: RETURN variable; |
You can keep PDL modules in the form of a copy book by designating *FORMULA in the Program ID field and *LIBRARY in the File ID field on the Data Item Formula Revisions screen.
Figure 14-1 Data Item Formula Revisions screen
The include module should have a unique name, for example @CONCAT.
It is JD Edwards World naming convention to begin module names with the @ symbol.
The keyword include causes the Program Generator to automatically generate the appropriate code for the include module. This prevents the need to reenter user calculations that are necessary in numerous programs.
Following is an example of an include module and the include statement that calls the module.
Figure 14-2 Data Item Formula Revisions (Include Module) screen
Specifying the Return keyword is the same as entering *PROC in the Read From field in the Detail Programming Facility.
The system omits all standard processing for this data field. In other words, by specifying the Return keyword, the system uses the code the PDL generates instead of any standard logic.
For example:
begin
$#b1 := 0;
$#b1 := q2xqt * q2uncs;
return $#b1
end