-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
1/42
Unit 4. Manipulating Data in Calculations
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
2/42
CopyrightIBM
Corp.1996,2000
4-2
Unit Objectives - Data Manipulation
After completing this unit, you should be able to:
code calculation specifications using free form operation codes, andexpressions for:
assignment of numeric, character, and logical values arithmetic operations logical operations string handling operations
Code Built In Functions in expressionsOL864000
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
3/42
CopyrightIBMCorp.1996,2000
4-3
Types of Expressions
Assignment / Data conversion
Arithmetic
Logical
StringOL864005
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
4/42
CopyrightIBMCorp.1996,2000
4-4
Assignment Opcodes
Eval
Assignment via simple expression Result = Expression Supports all Data Types
Data types must be compatible Left justified with character operands
EvalR - same as Eval but:
Character only
Right justified
Move
Right justified
MoveL
Left justified
MoveA
For arraysOL864105
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
5/42
CopyrightIBMCorp.1996,2000
4-5
Numeric Assignment
Assign Value
CL0N01Factor1+++++++Opcode(E)+Extended-factor2++++++++++++++++++++++++++C Eval NumericVar = 567**
C Eval Num2 = 0 - Num2
Clear Numeric to Zero
CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq**
C Eval NumericVar = 0C Eval NumericVar = *Zeros
OL864110
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
6/42
CopyrightIBMCorp.1996,2000
4-6
Assignment of Character Variable
Assign Value to Character Variable
CL0N01Factor1+++++++Opcode(E)+Extended-factor2++++++++++++++++++++++++++C Eval CharVar = A_StringC EvalR CharVar = A_String
CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEqC MoveL (P) A_String CharVarC Move (P) A_String CharVar
Assign Blanks to Character Variable
CL0N01Factor1+++++++Opcode(E)+Extended-factor2++++++++++++++++++++++++++C Eval CharVar = C Eval CharVar = *BlanksC EvalR CharVar = *Blanks
**CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++C MoveL *Blanks CharVarC Move *Blanks CharVar
OL864115
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
7/42
Move
Character to Character
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++CommentsD Char3 S 3 Inz( NOP )D Char6 S 6 Inz( ABCDEF )CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq**
C Move Char3 Char6** Char6 = ABCNOP
Numeric to Character
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++CommentsD Num3 S 3 0 Inz(123-)D Char6 S 6 Inz( ABCDEF )
CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq**C Move Num3 Char6** Char6 = ABC12L
Character to Numeric
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++Comments
D Char3 S 3 Inz( NOP )D Num5 S 5 0 Inz(12345)CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq**C Move Char3 Num5** Num5 = 12567-
OL864120
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
8/42
MoveL
Numeric to Character
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++CommentsD Num3 S 3 0 Inz(123-)D Char6 S 6 Inz( ABCDEF )CL0N01Factor1+++++++Opcode++++Factor2+++++++Result++++++++Len++D+HiLoEq
**C MoveL Num3 Char6** Char6 = 12LDEF
Character to Numeric (Long)
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++CommentsD Char3 S 3 Inz( NOP )
D Num5 S 5 0 Inz(12345)CL0N01Factor1+++++++Opcode++++Factor2+++++++Result++++++++Len++D+HiLoEq**C MoveL Char3 Num5** Num5 = 56745
Character to Numeric (Short)
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++CommentsD Char3 S 3 Inz( NOP )D Num2 S 2 0 Inz(12)CL0N01Factor1+++++++Opcode++++Factor2+++++++Result++++++++Len++D+HiLoEqC MoveL Char3 Num2** Num2 = 56-
OL864125
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
9/42
CopyrightIBM
Corp.1996,2000
4-9
Rules of Move
Move/MoveL/MoveA controlled by length of shorter field length
Data conversion is automatic
Result field cleared first by P extender
Decimal Alignment not performedOL864130
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
10/42
CopyrightIBMC
orp.1996,2000
4-10
OL864200
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
11/42
CopyrightIBMC
orp.1996,2000
4-11
Arithmetic Opcodes
Legacy OpCodes:
ADD SUB MULT DIV MVR XFOOT SQRT Z-ADD Z-SUB
Best coded using EVALs and BIFsOL864205
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
12/42
CopyrightIBMC
orp.1996,2000
4-12
Addition and Subtraction
CL0N01Factor1+++++++Opcode(E)+Extended-factor2++++++++++++++++++++++++++C Eval YTDPay = YTDPay + GrsPay**
C Eval NetPay = Netpay - Taxes**
C Eval NumericVar = Var1 - Var2 + 3 + Const1
OL864210
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
13/42
CopyrightIBMC
orp.1996,2000
4-13
Multiplication
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++CommentsD Result1 S 5P 1D Result2 S 5P 1D Result3 S 5P 2
**CL0N01Factor1+++++++Opcode(E)+Extended-factor2++++++++++++++++++++++++C Eval Result1 = 123.456 * 10** Result1 = 1234.5 - truncated
C Eval (H) Result2 = 123.456 * 10
** Result2 = 1234.6 - roundedC 123.456 Eval (H) Result3= 10 * 123.466** Result3 = 234.56 - numeric overflow
OL864215
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
14/42
CopyrightIBMC
orp.1996,2000
4-14
Numeric Overflow
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++CommentsD NumericVar S 7P 2D Fld1 S 3 0 INZ(993)D Fld2 S 3 0 INZ(50)
D Fld3 S 4 1D Fld4 S 5 1**
CL0N01Factor1+++++++Opcode(E)+Extended-factor2++++++++++++++++++++++++C Eval Fld3 = Fld1 + Fld2
C Eval Fld4 = Fld1 * Fld2
What will be the values of Fld3 and Fld4?
What will happen when these statements are executed?OL864220
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
15/42
CopyrightIBMC
orp.1996,2000
4-15
Division and Remainders
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++CommentsD NumericVar S 5P 0D Remainder S 5P 0D Months S 3 0 INZ(54)D Years S 3 0 INZ
D RemMon S 2 0 INZCL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq***************************************************************C Eval NumericVar = 200 / 3**** NumericVar = 66
***************************************************************
C Eval (H) NumericVar = 200 / 3**** NumericVar = 67
***************************************************************C Eval NumericVar = %div(200:3)C Eval Remainder = %rem(200:3)** NumericVar = 66
** Remainder = 2***************************************************************C Eval Years = Months / 12C Eval RemMon = %rem(Months : 12)** Years = 4** PartMon = 6
OL864225
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
16/42
CopyrightIBMC
orp.1996,2000
4-16
Exponentiation
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++++D CubeRoot S 5 3D Cubed S 5 3**
D Number S 4S 0 Inz(144)D SqRoot S 2S 0**
CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEqC Eval (H) Cubed = 3**3
C Eval CubeRoot = Cubed**(1/3)** CubeRoot = 2.99
C Eval (H) CubeRoot = Cubed**(1/3)** CubeRoot = 3
C Eval SqRoot = Number**.5
** SqRoot = 12
OL864230
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
17/42
CopyrightIBMC
orp.1996,2000
4-17
OL86410L
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
18/42
CopyrightIBMC
orp.1996,2000
4-18
Comparison Operations
x = y Equality
x y Not equal
x > y Greater Than
x >= y Greater Than or Equal
x < y Less Than
x
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
19/42
CopyrightIBMC
orp.1996,2000
4-19
Class Exercise
CL0N01Factor1+++++++Opcode(E)+Extended-factor2++++++++++++++++++++++++++
** 1C Eval *In99 = *ON
** 2
C Eval *In99 = (X > Y)** 3C Eval *In99 = (X > Y) AND (Z 0)
** 4C Eval *In99 = ((X > Y) AND (Z 0)) OR *In23
** 5C Eval *In99 = (X > Y) OR NOT *in23
What is the meaning of each expression?OL864310
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
20/42
Setting Indicators
CN0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEqC Eval *In99 = *ONC Eval *In(99) = *ON
CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEqC Move *ON *In99**
**C MoveA 101 *In(97)**C Eval *In97 = *OnC Eval *In98 = *offC Eval *In(99) = *ON
OL864315
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
21/42
CopyrightIBMCorp.1996,2000
4-21
If / Else / EndIf
CL0N01Factor1+++++++Opcode(E)+Extended-factor2++++++++++++++++++++++++++C If Fld1 = Fld2C Eval *In99 = *ONC ElseC Eval FldTot = FldTot + Fld1C Endif
C Eval *In99 = (Fld1 = Fld2)
C If NOT *In99C Eval Fldtot = Fldtot + Fld1
C Endif**C If *In10
: : :C If NOT *In10
OL864320
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
22/42
CopyrightIBMCorp.1996,2000
4-22
IF Expressions
CL0N01Factor1+++++++Opcode(E)+Extended-factor2++++++++++++++++++++++++++C If *in99CC Else
C | If (X < Y)C |C | ElseC | | If (X > Y) AND (Z 0)C | |C | | Else
C | | | If ((X = Y) AND (Z < 0))C | | | OR *in23C | | |
C | | | EndIfC | | EndIfC | EndIfC EndIf
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
23/42
CopyrightIBMCorp.1996,2000
4-23
Ol864325
OL864400
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
24/42
CopyrightIBMCorp.1996,2000
4-24
String Handling BIFs
BIF Purpose
%CHAR Convert to character
%EDITC Edit numeric using edit code
%EDITW Edit numeric using edit word
%REPLACE Replaces all or part of character string
%SCAN Matches search argument against character string
%SUBST Extracts substring from a character string
%TRIM Removes left and right blanks from a string
%TRIML Removes left blanks from a string
%TRIMR Removes right blanks from a string OL864405
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
25/42
CopyrightIBMCorp.1996,2000
4-25
Concatenation
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++D FirstName S 6 INZ( John )D LastName S 6 INZ( Smith )D FullName S 15 INZ
CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEqC Eval FullName = FirstName + LastName** FullName = John Smith
C Eval FullName = FirstName + + LastName** FullName = John Smith
C Eval FullName = FirstName + + LastName** FullName = John Smith
OL864410
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
26/42
Remove Blanks - %TRIM
%TRIM(string) %TRIML(string) %TRIMR(string)
%TRIM strips leading and trailing blanks from character or graphic fields
%TRIML strips leading blanks only
%TRIMR strips trailing blanks only
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++CommentsD AString S 17 Inz( This is it )D Another S 12 InzD YetAnoter S 20 InzD BigOne S 26 InzD OneMore S 10 InzCL0N01Factor1+++++++Opcode(E)+Extended-factor2++++++++++++++++++++++++++
C Eval Another = %TRIML(AString)** Another = This is it C Eval YetAnother = %TRIMR(AString) + ? ? ** YetAnother = This is it?? C Eval OneMore = %TRIM(AString)** OneMore = This is itC Eval BigOne = %TRIMR(AString) + %TRIML(AString)** BigOne = This is itThis is it
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++D FirstName S 6 INZ( John )D LastName S 6 INZ( Smith )D FullName S 15 INZCL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEqC Eval FullName = %trimr(LastName)C + , C + %trimr(FirstName)
** FullName = Smith, John
OL864415
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
27/42
CopyrightIBMCo
rp.1996,2000
4-27
Determine the Length of a String - %Len
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++CommentsD Length S 2 0 InzD String S 25 Inz( Learning Services )
CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEqC Eval Length = %Len(String)** Length = 25
C Eval Length = %Len(%TrimR(String))** Length = 17
OL864420
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
28/42
CopyrightIBMCo
rp.1996,2000
4-28
Scan for Character String - %Scan (1/2)
%SCAN(search argument : source string {: start})
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++CommentsD Position S 2 0 Inz
D String1 S 7 Inz( ABCDEFG )D String2 S 2 Inz( RS )D String3 S 5 Inz( TUVXY )D String4 S 25 Inz( Learn )CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq
**C Eval Position = %scan( CD : String1)** Position = 3
C Eval Position = %scan(String2 : String3 : 3)** Position = 0
C If %scan(%trim(String4) : String3)**
OL864425
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
29/42
CopyrightIBMCo
rp.1996,2000
4-29
Scan for Character String - %Scan (2/2)
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++CommentsD Source S 15A Inz( Dr. Doolittle )D Pos S 5 0 InzCL0N01Factor1+++++++Opcode(E)+Extended-factor2++++++++++++++++++++++++++
C Eval pos = %scan( oo : source)** 1 Pos = 6C Eval pos = %scan( D : source : 2)** 2 Pos = 5
C Eval pos = %scan( abc : source)** 3 Pos = 0
C Eval pos = %scan( Dr. : source : 2)** 4 Pos = 0
OL864430
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
30/42
CopyrightIBMCo
rp.1996,2000
4-30
Extract Substring - %Subst
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++CommentsD Comment S 16 INZ( It s a great day )D NameField S 20 INZ( John Smith )D FirstName S 10 INZ
D ReverseNm S 20 INZD BlankPos S 2 0 INZCL0N01Factor1+++++++Opcode(E)+Extended-factor2++++++++++++++++++++++++++C Eval %SUBST(Comment:8:5) = lousy** The field Comment = It s a lousy day
C Eval BlankPos = %scan( : NameField)C Eval FirstName = %SUBST(NameField : 1 :C BlankPos -1)** FirstName = John
C Eval ReverseNm = %TrimR(%Subst(NameField :C BlankPos + 1))
C + , C + %Subst(NameField : 1 :C BlankPos - 1)** ReverseNm = Smith, John
OL864435
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
31/42
Convert to Character - %Char
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++CommentsD PostalCode S 5 0 Inz(30101)D PostExtend S 4 0 Inz(3490)D FullPostCode S 10 Inz**CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEqC Eval FullPostCode = %char(PostalCode)
C +
C + %char(PostExtend)
OL864440
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
32/42
Edit with %EditC / %EditW
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++CommentsD AvlCost S 7 2 Inz(12500.00)D AvlPrice S 9 2 Inz(250000.00)D EditAmount S 50D EditWd C , , **Dollars& &Cents**CL0N01Factor1+++++++Opcode(E)+Extended-factor2++++++++++++++++++++++++++
C Eval EditAmount =Inventory cost is
C + %editc(AvlCost : K : *cursym)** EditAmount = Inventory cost is $12,500.00**C Eval EditAmount = Inventory price is C + %editw(AvlPrice : EditWd)** EditAmount = Inventory price is **250,000*Dollars 00 Cents
OL864445
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
33/42
CopyrightIBMCo
rp.1996,2000
4-33
Convert String - XLATE
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++CommentsD Phone S 8 Inz(974 8088 )D PhoneNbr S Like(Phone)**
D Upper C IVXLD Lower C ivxl**
D Atable S 6 Inz( RPG iv )D Btable S Like(Atable)*************************************************************CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++C : - Xlate Phone PhoneNbr** PhoneNbr = 974-8088
C Lower:Upper Xlate Atable Btable** Btable = RPG IV
OL864450
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
34/42
Replace String of Characters -
%Replace
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++CommentsD Greetings S 50 Inz( We wish you, &C, +D a Happy Birthday! )D FullName S 30 Inz( Mr. Smith )D Position S 2 0CL0N01Factor1+++++++Opcode(E)+Extended-factor2+++++++++++++++++++++++++C Eval Position = %scan (&C : Greetings)
C If Position > 0C Eval Greetings = %replace(%trim(FullName) :C Greetings : Position : 2)C EndIf** Greetings = We wish you, Mr. Smith, a Happy Birthday!
OL864455
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
35/42
CopyrightIBMCo
rp.1996,2000
4-35
OL864505
P d R l U i P th
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
36/42
CopyrightIBMCo
rp.1996,2000
4-36
Precedence Rules - Using Parentheses
( ) are highest in precedence; use them to:
Break up complex expressions Ensure accurate results
CL0N01Factor1+++++++Opcode(E)+Extended-factor2++++++++++++++++++++++++++** Actual Unit Price = ItemPrice - ItemDscnt** Calculate total price of items ordered (OrdQty)**
C Eval Total = OrdQty * ItemPrice - ItemDscnt
** Above calculation is not correct. Should be written:**C Eval Total = OrdQty * (ItemPrice - ItemDscnt)
CL0N01Factor1+++++++Opcode(E)+Extended-factor2++++++++++++++++++++++++++** Correct but ambiguous:C If *IN03 OR Count > Max AND *IN99** Better:
C If *IN03 OR (Count > Max AND *IN99)
OL864510
Precision Expressions
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
37/42
CopyrightIBMCo
rp.1996,2000
4-37
Precision - Expressions
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++CommentsD MarkUpPct1 S 5P 2D MarkUpPct2 S Like(MarkUpPct1)
D List S 11P 2 Inz(4.0)D Cost S Like(List)D Inz(3.0)CL0N01Factor1+++++++Opcode(E)+Extended-factor2++++++++++++++++++++++++++C Eval MarkUpPct1 = (List - Cost) / (Cost / 100)** MarkUpPct1 = 33.00
C Eval MarkUpPct2 = (List - Cost) / (Cost / 100.00** MarkUpPct2 = 33.30
Expected value of mark up Percentage is 33.33OL864515
Specifying Precision Rules
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
38/42
CopyrightIBMCo
rp.1996,2000
4-38
Specifying Precision Rules
Resulting Decimal Positions:
*RESDECPOS on H-spec applies to ALL Evals R-extender without *RESDECPOS applies to single Eval
Maximum Digits:
*MAXDIGITS on H-spec (default) applies to ALL Evals
M-extender to apply max. digits rules to single Eval
H ExprOpts(*RESDECPOS)
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++Comments**D PackedN1 s 13p 2D PackedN2 s 13p 2D PackedN3 s 13p 2**
CL0N01Factor1+++++++Opcode(E)+Extended-factor2++++++++++++++++++++++++++
** Accuracy is maintained to TWO decimal placesC Eval PackedN1 = PackedN1 * PackedN2 * PackedN3** Accuracy is maintained to THREE decimal places** because of rounding
C Eval (h) PackedN1 = PackedN1 * PackedN2 * PackedN3
Ol864520
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
39/42
Precision Using %FLOAT
Dname+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++CommentsD Three_00 S 5P 2 Inz(3)D Two_00 S 5P 2 Inz(2)D One S 1P 0 Inz(1)**D Ans1 S 5P 2D Ans2 S 5P 2D Ans3 S 5P 2CL0N01Factor1+++++++Opcode(E)+Extended-factor2++++++++++++++++++++++++++C Eval Ans1 = (Two_00 / (Three_00 / One))** Ans1 is 0.00C Eval (R) Ans2 = (Two_00 / (Three_00 / One))** Ans2 is 0.66C Eval Ans3 = %Float(Two_00 / (Three_00 / One))** Ans3 is 0.66
OL864525
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
40/42
%DEC / %DECH / %DECPOS BIFs
D Three_00 S 5P 2 Inz(3)D Two_00 S 5P 2 Inz(2)D One S 1P 0 Inz(1)**D Ans1 S Like(Three_00)D Ans2 S Like(Three_00)D Ans3 S Like(Three_00)D Pos1 S 3P 0D Pos2 S Like(Pos1)**CL0N01Factor1+++++++Opcode(E)+Extended-factor2++++++++++++++++++++++++++C Eval Ans1 = (Two_00 / (Three_00 / One)) ++++* |______________|* (30,27)* |________________________|* (30,0)
C Eval Pos1 = %Decpos(Two_00 / (Three_00/One))** Ans1 is 0.00 Pos1 is 0C Eval Ans2 = (Two_00 / %Dec(Three_00/One:5:2))C Eval Pos2 = %Decpos(Two_00 /C %Dec(Three_00/One:5:2))** Ans2 is 0.66 Pos2 is 25C Eval Ans3 = %DecH(Two_00 / (Three_00/One):5:2)** Ans3 is 0.67
OL864530
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
41/42
CopyrightIBMCorp.1996,2000
4-41
OL86420L
Unit Summary
-
7/29/2019 IBM AS400 RPG IV Training Course(Course Code OL86)--5
42/42
CopyrightIBMCorp.1996,2000
4-42
Unit Summary
Having completed this unit, you should be able to:
code calculation specifications using free form operation codes, andexpressions for:
assignment of numeric, character, and logical values arithmetic operations logical operations string handling operations
Code Built In Functions in expressionsOL864ZZZ