180 likes | 334 Views
ED. ED. Instruction type: SS1 Explicit Coding: D1(L1,B1),D2(B2) Example ED 3(4,5),8(7) Example ED X(8),Y Use: Converts packed fields to an edited character format (printable). Target Field.
E N D
ED • Instruction type: SS1 • Explicit Coding: D1(L1,B1),D2(B2) • Example ED 3(4,5),8(7) • Example ED X(8),Y • Use: Converts packed fields to an edited character format (printable)
Target Field • The target field must contain edit characters that describe how the packed field will be edited • X’40’ Blank • X’20’ Digit Selector • X’21’ Digit Selector and Significance Starter • X’4B’ Decimal Point • X’6B’ Comma • X’60’ Negative Sign
Edit Process 1) Build an edit word • Move the edit word to the output area • Ed-it the packed field into the output area Example: EDWD DC X’40202020212060’ AMTPK DC PL3’-12345’ AMTOUT DS CL7 … MVC AMTOUT,EDWD ED AMOUNT,AMTPK
What happens? ED X,Y Y 12 34 5D X 40 20 20 20 21 20 60 Before After X 40 F1 F2 F3 F4 F5 60
What happens? ED X,Y Y 12 34 5C X 40 20 20 20 21 20 60 Before After X 40 F1 F2 F3 F4 F5 40
What happens? ED X,Y Y 00 04 5D X 40 20 21 20 20 20 60 Before After X 40 40 40 F0 F4 F5 60
Making it work • Start the edit word with a fill character • Count the number of digits in the packed field. Example XPK DS PL4 • No of digits = (2 x 4) – 1 = 7 digits • The number of 20’s and 21’s in the edit word must match this number • It can also contain other edit symbols • The output field size must match the edit word field size
Building the Edit Word XPK DS PL4 EDWD DC ???
Building the Edit Word Start with the fill character XPK DS PL4 EDWD DC X’40’
Building the Edit Word Count the digits XPK DS PL4 (4 x 2) – 1 = 7 EDWD DC X’40’
Building the Edit Word Add correct number of 20’s and a 21 XPK DS PL4 (4 x 2) – 1 = 7 EDWD DC X’4020202020202120’
Building the Edit Word Add other edit characters as needed XPK DS PL4 (4 x 2) – 1 = 7 EDWD DC X’40204B2020204B20212060’
Building the Edit Word Count characters in the edit word XPK DS PL4 (4 x 2) – 1 = 7 EDWD DC X’40204B2020204B20212060’ | 11 |
Building the Edit Word Output field must match edit word XPK DS PL4 (4 x 2) – 1 = 7 EDWD DC X’40204B2020204B20212060’ | 11 | XOUT DS XL11
Finishing the job • Move the edit word to the output area MVC XOUT,EDWD • Edit the packed field into the output area ED XOUT,XPK
Common Errors • The packed field doesn’t match the edit word field (the number of 20s and 21s must match the number of digits in the packed field) • The edit word size must match the output field size
Try it in VisibleZ • Try the following programs: • ed.obj • ed1.obj • ed2.obj • ed3.obj • ed4.obj