Newsletters   Subscriptions  Forums  Store   Career  Media Kit  About Us  Contact  Search   Home 
fhg
Volume 5, Number 4 -- January 26, 2005

Another Reason to Use P-Fields

Hey, Ted:


Within a subfile, I am using an indicator to highlight a field if the value of that field is invalid. Is there a way, when I read a subfile record, to analyze the attributes of the field to see if the indicator was switched on or off when the subfile record was written? My problem is that the display attribute is losing its original setting.

--Alan


I don't know of a way to determine the original setting. I have included hidden one-byte fields in a subfile to store the settings of indicators so I could reset the indicators before updating the subfile record. You have put your finger on a good reason to use p-fields instead of indicators to control display file attributes.

Here's a display file, SFL223D, which uses indicator 71 to display a negative balance amount in reverse image.

 A                                      DSPSIZ(24 80 *DS3)
 A          R SFL01                     SFL
 A            LINENBR01      3  0O  9  2EDTCDE(4)
 A            NAME01        20   O    +2
 A            BALANCE01      9  2O    +2EDTCDE(J)
 A  71                                  DSPATR(RI)
 A          R CTL01                     SFLCTL(SFL01)
 A                                      CA03(03)
 A                                      SFLDSP
 A                                      SFLDSPCTL
 A                                      SFLSIZ(11)
 A                                      SFLPAG(10)

Here's a short program, SFL223R, which loads some records into the subfile and updates one of them. The first time the subfile is displayed, Don's and Lou's records show a balance in reverse image. When Don's name is changed to Bubba, the reverse image attribute disappears.

 H dftactgrp(*no) actgrp(*caller)
 H option(*srcstmt: *nodebugio)

 Fsfl223d   cf   e             workstn
 F                                     sfile(sfl01:rrn)

 D rrn             s              3  0

 D Load            pr
 D  Name                         20    value
 D  Balance                       9p 2 value
 D  RecNbr                        3p 0

 D ChangeName      pr
 D  RecNbr                        3p 0 value
 D  NewName                      20    value

  /free
      Load('Bob': 200: RRN);
      Load('Don': -35: RRN);
      Load('Jim': 25.95: RRN);
      Load('Lew': 180: RRN);
      Load('Lou': -99999: RRN);
      Load('Sue': 500: RRN);
      Load('Tom': 1750: RRN);
      exfmt ctl01;
      ChangeName(2: 'Bubba');
      exfmt ctl01;
      *inlr = *on;
  /end-free

 P Load            b
 D                 pi
 D  Name                         20    value
 D  Balance                       9p 2 value
 D  RecNbr                        3p 0
  /free
    RecNbr += 1;
    LineNbr01 = RecNbr;
    Name01 = Name;
    Balance01 = Balance;
    *in71 = (Balance01 < *zero);
    write sfl01;
  /end-free
 P                 e

 P ChangeName      b
 D                 pi
 D  RecNbr                        3p 0 value
 D  NewName                      20    value
  /free
    chain RecNbr sfl01;
    if %found();
       Name01 = NewName;
       update sfl01;
    endif;
  /end-free
 P                 e

Here's the same display file, but the setting of the balance field is now controlled by p-field BALATTR01, which is written to the subfile record. The display attributes of the balance field are no longer dependent on the setting of an indicator.

 A                                      DSPSIZ(24 80 *DS3)
 A          R SFL01                     SFL
 A            LINENBR01      3  0O  9  2EDTCDE(4)
 A            NAME01        20   O    +2
 A            BALANCE01      9  2O    +2EDTCDE(J)
 A                                      DSPATR(&BALATTR01)
 A            BALATTR01      1A  P
 A          R CTL01                     SFLCTL(SFL01)
 A                                      CA03(03)
 A                                      SFLDSP
 A                                      SFLDSPCTL
 A                                      SFLSIZ(11)
 A                                      SFLPAG(10)

Here's the revised RPG code. When Don's name is changed to Bubba, the balance of -35 continues to be displayed in reverse image.

 H dftactgrp(*no) actgrp(*caller)
 H option(*srcstmt: *nodebugio)

 Fsfl224d   cf   e             workstn
 F                                     sfile(sfl01:rrn)

 D rrn             s              3  0
 D Normal          c                   x'20'
 D Reverse         c                   x'21'

 D Load            pr
 D  Name                         20    value
 D  Balance                       9p 2 value
 D  RecNbr                        3p 0
 D ChangeName      pr
 D  RecNbr                        3p 0 value
 D  NewName                      20    value

  /free
      Load('Bob': 200: RRN);
      Load('Don': -35: RRN);
      Load('Jim': 25.95: RRN);
      Load('Lew': 180: RRN);
      Load('Lou': -99999: RRN);
      Load('Sue': 500: RRN);
      Load('Tom': 1750: RRN);
      exfmt ctl01;
      ChangeName(2: 'Bubba');
      exfmt ctl01;
      *inlr = *on;
  /end-free

 P Load            b
 D                 pi
 D  Name                         20    value
 D  Balance                       9p 2 value
 D  RecNbr                        3p 0
  /free
    RecNbr += 1;
    LineNbr01 = RecNbr;
    Name01 = Name;
    Balance01 = Balance;
    if (Balance01 >= *zero);
       BalAttr01 = Normal;
    else;
       BalAttr01 = Reverse;
    endif;
    write sfl01;
  /end-free
 P                 e

 P ChangeName      b
 D                 pi
 D  RecNbr                        3p 0 value
 D  NewName                      20    value
  /free
    chain RecNbr sfl01;
    if %found();
       Name01 = NewName;
       update sfl01;
    endif;
  /end-free
 P                 e

To learn more about p-fields, see the article "Anatomy of a P-Field."

--Ted


Click here to contact Ted Holt by e-mail.

Sponsored By
PATRICK TOWNSEND & ASSOCIATES

Deploy. Run. Manage. Succeed.

Alliance AES/400
Database Field Encryption

· Encrypt credit card, social security, pin numbers and other sensitive data.
· Easy to use with RPG or COBOL - sample code included.
· Get compliant - SOX, Privacy notification, GLBA, Etc.
· Free 30-day trial. Fully functional software - Not a demo.

DB2 field encryption with Alliance AES: Encrypt and decrypt individual fields in AS/400 DB2 database files. Alliance APIs can be used in RPG and Cobol applications including older OPM applications. Alliance AES encryption for DB2 fields integrates with Alliance key management for the secure storage of AES keys.

DB2 file encryption with Alliance AES: Encrypt any DB2 database file with Alliance AES/400. You can specify that the data be converted to ASCII or retained in the original EBCDIC character set. You can also specify that the pass phrase should be converted to ASCII for decryption on an ASCII system such as Microsoft Windows. Alliance DB2 file encryption integrates with Alliance AES key management.

IFS file encryption with Alliance AES: You can encrypt and decrypt IFS (Integrated File System) files with Alliance AES encryption commands. Once encrypted files can be decrypted on an AS/400 or Windows PC or Server platform. You can also use the free Alliance Windows AES encryption application to encrypt files on a Windows platform for decryption on the AS/400. IFS file encryption integrates with Alliance AES key management for secure key storage.

AES self-decrypting archives: Alliance AES/400 can encrypt files into a self-decrypting archive. A self-decrypting archive is a Windows executable program. You can run the self-decrypting archive, enter a pass phrase, and decrypt and extract the file. If run from a command line you can pass the program parameters for the decryption. This is helpful if you are automating the decryption process. If you run the self-decrypting archive program without parameters it presents a Windows GUI dialog for pass phrase and other decryption information.

Report distribution with AES encryption: When Alliance AES encryption is used with the Alliance FTP Manager application you can automatically distribute reports in encrypted or self-decrypting archive format. Reports can be sent from one or more output queues, and reports can be selectively routed from the output queue.

AES key management: Alliance AES/400 provides a complete key management facility to help you securely store keys and pass phrases. All application program interfaces and commands allow the use of a named AES key. The Alliance AES key manager automatically backs up the key store when keys are added or changed.

Windows encryption application: Alliance AES encryption includes a Windows application that you can freely distribute to provide encryption and decryption services. Files encrypted on a Windows platform with the Alliance application can be decrypted on the AS/400. Files encrypted on the AS/400 can be decrypted on the Windows platform.

Sample code: The Alliance AES/400 product includes sample RPG and ILE-RPG source code that demonstrate how to use the encryption APIs. There are also sample CL programs that show how to use the Alliance commands to encrypt and decrypt files, and create self-decrypting archives.

More information:
Patrick Townsend & Associates, Inc.
7700 Earling Street NE
Olympia, WA 98506
Voice: (360) 357-8971
Fax: (360) 357-9047
Email: Info@patownsend.com
Web: www.patownsend.com

Click here for 30 day trial


Technical Editors: Howard Arner, Joe Hertvik, Ted Holt,
Shannon O'Donnell, Kevin Vandever
Managing Editor: Shannon Pastore
Contributing Technical Editors: Joel Cochran, Wayne O. Evans, Raymond Everhart,
Bruce Guetzkow, Marc Logemann, David Morris
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message.


THIS ISSUE
SPONSORED BY:

Advanced Systems Concepts
Patrick Townsend & Associates
Guild Companies


BACK ISSUES

TABLE OF
CONTENTS
An Introduction to WDSc Table Views

Another Reason to Use P-Fields

The Save-Restore Commands


The Four Hundred
Oracle Lays Out Plans to Fuse Its Three ERP Suites

ERP Vendors Target PeopleSoft, JDE Bases

IBM Ends 2004 with Most Profitable Quarter in Its History

Four Hundred Stuff
2005: A SOX Auditor's Odyssey

iSeries Plays a Central Role in MoMA's Expansion

CXL Debuts iSeries Security Reporting Tool

Four Hundred Monitor


Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.
Guild Companies, Inc. (formerly Midrange Server), 50 Park Terrace East, Suite 8F, New York, NY 10034
Privacy Statement