14 About PDL Statements and Syntax

This chapter contains these topics:

A Data Item Formula consists of Program Design Language (PDL) statements. PDL statements form the following types of operations.

You must use specific syntax when you work with PDL statements.

14.1 About PDL Statements

A PDL statement combines one or more of the following elements:

  • Keywords

  • Variables

  • Database Files

  • Operators

  • Constants

  • Punctuation

14.1.1 Keywords

Keywords are the vocabulary of PDL. They identify the type of operation the statement performs.

14.1.2 Variables

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.

14.1.3 Database Files

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.

14.1.4 Operators

You define the valid assignment and arithmetic operators.

14.1.5 Constants

You specify alpha constants by enclosing them in single quotes. You specify numeric constants without quotes.

Examples:

vc0001 := 'Proof Mode';

$#am1 := 0;

PDL does NOT recognize the RPG constants such as *BLANK or *ZERO.

14.1.6 Punctuation

The basic PDL punctuation is a semi-colon (;), which you must use to separate PDL statements.

14.2 About Blocks of Statements

14.2.1 Keywords and Syntax

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


14.2.2 Rules

  • 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

14.3 About Comments

14.3.1 Keywords and Syntax

Syntax Explanation
\ (backslash) Initiates and terminates a comment.

The syntax is: \ text \

You must enclose all comments within a pair of backslashes.


14.3.2 Rules

Comment lines must not exceed 50 characters.

For example: Initial Comment

\ Compute extended amount. \

Begin

$#xtp := q2xqt * q2uncs;

End

For example: Embedded Comment

Begin

$#am1 := 0; \ Order Total \

$#xtp := 0; \ Extended Amount \

End

14.4 About Assignments

14.4.1 Operator and Syntax

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


14.4.2 Rules

You can use standard notation using parentheses for arithmetic operations.

For example:

in98 := '0';

vdremk := 'NOT DEFINED';

sftrdj := $$edt;

$#am1 := $#am1 + (qzqty * qzcst);

$#wrk := 100;

abalph := vd#fnm |> vd#lnm;

$cc := SST (qxxcc,3,10)

14.5 About Database Operations

14.5.1 Keywords and Syntax

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;


14.5.2 Rules

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

14.6 About Program Calls

14.6.1 Keywords and Syntax

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;


14.6.2 Rules

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

14.7 About Loops

14.7.1 Keywords and Syntax

Keywords Syntax
Until Provides for loop processing where the system evaluates a condition at the bottom of the loop.
  • Translates to DOU in the RPG code.

The syntax is: UNTIL (condition) DO (Statement)

While Provides for loop processing where the system evaluates a condition at the top of the loop.
  • Translates to DOW in the RPG code.

The syntax is: WHILE (condition) DO (Statement)

Do An integral part of the loop statement.

14.7.2 Rules

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

14.8 About Conditions

14.8.1 Keywords and Syntax

Keywords Explanation
If Provides for conditional processing.
  • § The condition is two expressions that you separate by a relationship.

  • § The data types of the expressions have to match. For example, alpha to alpha, numeric to numeric.

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)

14.8.2 Symbols

Symbols Explanation
= Equal
¼ Not Equal
> Greater Than
< Less Than
>= Greater Than or Equal To
<= Less Than or Equal To

14.8.3 Rules

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

14.9 About Miscellaneous Keywords and Syntax

14.9.1 Keywords and Syntax

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;


14.9.2 Rules for Include

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

Description of Figure 14-1 follows
Description of "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

Description of Figure 14-2 follows
Description of "Figure 14-2 Data Item Formula Revisions (Include Module) screen"

14.9.3 Rules for Return

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