Thursday, January 11, 2024

Set screen field attribute using P Field


DSPATR(&program-to-system-field)

The program-to-system-field parameter is required and specifies that the named field must be defined in the record format, alphanumeric (A in position 35), length of one, and usage P (P in position 38). The program uses this P-field to set the display attribute for the field this DSPATR keyword applies to.The name P-field is used for multiple fields with the record being defined. One DSPATR P-field is allowed per field. The P-field contains the display attribute and identifies whether the field should be protected.

Valid P-field values

The DSPATR P-field does not support the following display attributes:

  • MDT - Set changed data tag when displayed
  • OID   - Operator identification
  • PC     - Position cursor
  • SP      - Select by light pen

Valid P-field values (nonprotect)

Hex

Limited color

Full color

20

Normal

Green

21

Reverse image

Green, reverse image

22

High intensity

White

23

High intensity, reverse image

White, reverse image

24

Underscore

Green, underscore

25

Underscore, reverse image

Green, underscore, reverse image

26

Underscore, high intensity

White, underscore

27

Nondisplay

Nondisplay

28

Blink

Red

29

Blink, reverse image

Red, reverse image

2A

Blink, high intensity

Red, high intensity

2B

Blink, high intensity, reverse image

Red, high intensity, reverse image

2C

Blink, underscore

Red, underscore

2D

Blink, underscore, reverse image

Red, underscore, reverse image

2E

Blink, underscore, high intensity

Red, underscore, blink

2F

Nondisplay

Nondisplay

30

Column separator

Turquoise, column separator

31

Reverse image, column separator

Turquoise, column separator, reverse image

32

High intensity, column separator

Yellow, column separator

33

High intensity, reverse image, column separator

White, reverse image, column separator

34

Underscore, column separator

Turquoise, underscore, column separator

35

Underscore, reverse image, column separator

Turquoise, underscore, reverse image, column separator

36

Underscore, high intensity, column separator

Yellow, underscore, column separator

37

Nondisplay

Nondisplay

38

Blink, column separator

Pink

39

Blink, reverse image, column separator

Pink, reverse image

3A

Blink, high intensity, column separator

Blue

3B

Blink, high intensity, reverse image, column separator

Blue, reverse image

3C

Blink, underscore, column separator

Pink, underscore

3D

Blink, underscore, reverse image, column separator

Pink, underscore, reverse image

3E

Blink, underscore, high intensity, column separator

Blue, underscore

3F

Nondisplay

Nondisplay    


Valid P-field values (protect)

Hex

Limited color

Full color

A0

Normal

Green

A1

Reverse image

Green, reverse image

A2

High intensity

White

A3

High intensity, reverse image

White, reverse image

A4

Underscore

Green, underscore

A5

Underscore, reverse image

Green, underscore, reverse image

A6

Underscore, high intensity

White, underscore

A7

Nondisplay

Nondisplay

A8

Blink

Red

A9

Blink, reverse image

Red, reverse image

AA

Blink, high intensity

Red, high intensity

AB

Blink, high intensity, reverse image

Red, high intensity, reverse image

AC

Blink, underscore

Red, underscore

AD

Blink, underscore, reverse image

Red, underscore, reverse image

AE

Blink, underscore, high intensity

Red, underscore, blink

AF

Nondisplay

Nondisplay

B0

Column separator

Turquoise, column separator

B1

Reverse image, column separator

Turquoise, column separator, reverse image

B2

High intensity, column separator

Yellow, column separator

B3

High intensity, reverse image, column separator

White, reverse image, column separator

B4

Underscore, column separator

Turquoise, underscore, column separator

B5

Underscore, reverse image, column separator

Turquoise, underscore, reverse image, column separator

B6

Underscore, high intensity, column separator

Yellow, underscore, column separator

B7

Nondisplay

Nondisplay

B8

Blink, column separator

Pink

B9

Blink, reverse image, column separator

Pink, reverse image

BA

Blink, high intensity, column separator

Blue

BB

Blink, high intensity, reverse image, column separator

Blue, reverse image

BC

Blink, underscore, column separator

Pink, underscore

BD

Blink, underscore, reverse image, column separator

Pink, underscore, reverse image

BE

Blink, underscore, high intensity, column separator

Blue, underscore

BF

Nondisplay

Nondisplay


In DDSSRC:
A* First declare the variable 
 A                PFLD1           1A  P
 A*
 A* then, after the display field in function limit you assign it
 A*
 A                FIELD01       14Y 2B 17 42EDTCDE(1)    
 A                                          DSPATR(&PFLD1)

In RPGSRC, just set or clear when you need it:
C* 
C* Set the hex value in the QDDSSRC variable
C                       EVAL      PFLD1 = x'A0'
C*
C* Clear the variable
C                   CLEAR                   PFLD1              1

The following example shows how to specify the DSPATR keyword with P-field usage:
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
     A          R RECORD                   
     A            FLD1           5A     2  6DSPATR(&PFLD1)
     A            FLD2           5A     2  6DSPATR(&PFLD2)
     A            PFLD1          1A  P
     A            PFLD2          1A  P
     A

There is another technique which might interest you, and that is the DDS keyword DSPATR() used with a program to system field.  Instead of communicating with the display file via indicators, you can set the attributes .

Sample source code:

A                                      CF03(03 'Exit')
A*
A          R DSPFR                     TEXT('Display file examples')
A                                      BLINK
A*
A                                  9  2'Some input'
A                                      DSPATR(HI UL)
A            FLDA          10   B 10  2TEXT('Generic input/output')
A                                      DSPATR(&FLDAATR)
A            FLDB          20   B 11  2TEXT('Generic input/output')
A                                      DSPATR(&FLDBATR)
A            FLDAATR        1   P
A            FLDBATR        1   P

*****************************************************
H debug option(*srcstmt: *nodebugio)
H actgrp('QILE') dftactgrp(*no)
 * dbgview(*list)

 * Show use of program to system attribute field

fdspfatr   cf   e             workstn

 * work variables
d atr             s                   like(fldaatr)

 * field attribute bit patterns
d NO              s              1a   inz(x'00')
no attrs
d RI              s              1a   inz(x'01')
reverse
d HI              s              1a   inz(x'02')
highlight
d UL              s              1a   inz(x'04')
underline
d ND              s              1a   inz(x'07')
non display
d BL              s              1a   inz(x'08')
blink
d NP              s              1a   inz(x'20')
non protect
d CS              s              1a   inz(x'30')
column sep
d PR              s              1a   inz(x'80')
protect

d setAtr          pr                  like(atr)
d  inpFld                       50    const

c                   dow       *in03 = *off
c                   exfmt     dspfr
c   03              leave
c                   exsr      process
c                   enddo

c                   eval      *inLR = *On

 * ===========================================================
c     process   begsr

 * Top field to specify the colour of the bottom field, vice versa
c                   eval      FLDAATR = setAtr(FLDB)
c                   eval      FLDBATR = setAtr(FLDA)
c                   endsr

 * ===========================================================
p setAtr          b
d setAtr          pi                  like(atr)
d  inpFld                       50    const

d Wrk_fld         s                   like(atr)

 * reset all attributes
c                   eval      Wrk_fld         = NP

c                   select
c                   when      inpFld = 'RI'
c                   biton     RI            Wrk_fld         
c                   when      inpFld = 'HI'
c                   biton     HI            Wrk_fld         
c                   when      inpFld = 'UL'
c                   biton     UL            Wrk_fld         
c                   when      inpFld = 'BL'
c                   biton     BL            Wrk_fld         
c                   when      inpFld = 'CS'
c                   biton     CS            Wrk_fld         
c                   endsl

c                   return    Wrk_fld         

 p                 e

Friday, August 27, 2021

INFDS (File Information Data Structure)


FILE INFORMATION DATA STRUCTURE (INFDS)
* -------------------------------------------------------------------
 * FILE INFORMATION DATA STRUCTURE
 * -------------------------------------------------------------------
 * The INFDS contains the following feedback information:
 * File Feedback (length is 80)
 * Open Feedback (length is 160)
 * Input/Output Feedback (length is 126)
 * Device Specific Feedback (length is variable)
 * Get Attributes Feedback (length is variable)
 * -------------------------------------------------------------------
 * Standard RPG feedback area 1-80
 * -------------------------------
 D INFDS ds
 D File *FILE
 * * File name
 D OpenInd 9 9
 * * File open?
 D EOFInd 10 10
 * * File at eof?
 D FileStatus *STATUS
 * * Status code
 D OpCode *OPCODE
 * * Last opcode
 D Routinr *ROUTINE
 * * RPG Routine
 D ListNum 30 37
 * * Listing line
 D SpclStat 38 42S 0
 * * SPECIAL status
 D RecordFmt *RECORD
 * * Record name
 D MsgID 46 52
 * * Error MSGID
 * ----------------------------------------------------------------
 * The next 4 fields are available after POST
 D Screen_P *SIZE
 * * Screen size
 D NLSIn_P *INP
 * * NLS Input?
 D NLSOut_P *OUT
 * * NLS Output?
 D NLSMode_P *MODE
 * * NLS Mode?
 * ----------------------------------------------------------------
 * Open feedback area 81-240
 * NOTE that getting data beyond column 80 is expensive
 * in terms of program opens...
 D ODP_TYPE 81 82
 * * ODP Type
 D FILE_NAME 83 92
 * * File name
 D LIBRARY 93 102
 * * Library name
 D SPOOL_FILE 103 112
 * * Spool file name
 D SPOOL_LIB 113 122
ΓΒ©copyright 2
 * * Spool file lib
 D SPOOL_NUM 123 124I 0
 * * Spool file num
 D RCD_LEN 125 126I 0
 * * Max record len
 D KEY_LEN 127 128I 0
 * * Max key len
 D MEMBER 129 138
 * * Member name
 D TYPE 147 148I 0
 * * File type
 D ROWS 152 153I 0
 * * Num PRT/DSP rows
 D COLUMNS 154 155I 0
 * * Num PRT/DSP cols
 D NUM_RCDS 156 159I 0
 * * Num of records
 D ACC_TYPE 160 161
 * * Access type
 D DUP_KEY 162 162
 * * Duplicate key?
 D SRC_FILE 163 163
 * * Source file?
 D VOL_OFF 184 185I 0
 * * Vol label offs
 D BLK_RCDS 186 187I 0
 * * Max rcds in bl
 D OVERFLOW 188 189I 0
 * * Overflow line
 D BLK_INCR 190 191I 0
 * * Blk increment
 D FLAGS1 196 196
 * * Misc flags
 D REQUESTER 197 206
 * * Requester name
 D OPEN_COUNT 207 208I 0
 * * Open count
 D BASED_MBRS 211 212I 0
 * * Num based mbrs
 D FLAGS2 213 213
 * * Misc flags
 D OPEN_ID 214 215
 * * Open identifie
 D RCDFMT_LEN 216 217I 0
 * * Max rcd fmt le
 D CCSID 218 219I 0
 * * Database CCSID
 D FLAGS3 220 220
 * * Misc flags
 D NUM_DEVS 227 228I 0
 * * Num devs defin
 * ----------------------------------------------------------------
 * I/O feedback area 241-366
 * * 241-242 not used
 D WRITE_CNT 243 246I 0
 * * Write count
 D READ_CNT 247 250I 0
 * * Read count
 D WRTRD_CNT 251 254I 0
 * * Write/read count
 D OTHER_CNT 255 258I 0
 * * Other I/O count
 D OPERATION 260 260
 * * Cuurent operatio
 D IO_RCD_FMT 261 270
 * * Rcd format name
 D DEV_CLASS 271 272
 * * Device class
 D IO_PGM_DEV 273 282
 * * Pgm device name
ΓΒ©copyright 3
 D IO_RCD_LEN 283 286I 0
 * * Rcd len of I/O
 * ----------------------------------------------------------------
 * POST area 241-nnn
 * Display
 D PGM_DEV_P 241 250
 * * Program device
 D DEV_DSC_P 251 260
 * * Dev description
 D USER_ID_P 261 270
 * * User ID
 D DEV_CLASS_P 271 271
 * * Device class
 D DEV_TYPE_P 272 277
 * * Device type
 D REQ_DEV_P 278 278
 * * Requester?
 D ACQ_STAT_P 279 279
 * * Acquire status
 D INV_STAT_P 280 280
 * * Invite status
 D DATA_AVAIL_P 281 281
 * * Data available
 D NUM_ROWS_P 282 283I 0
 * * Number of rows
 D NUM_COLS_P 284 285I 0
 * * Number of cols
 D BLINK_P 286 286
 * * Allow blink?
 D LINE_STAT_P 287 287
 * * Online/offline?
 D DSP_LOC_P 288 288
 * * Display location
 D DSP_TYPE_P 289 289
 * * Display type
 D KBD_TYPE_P 290 290
 * * Keyboard type
 D CTL_INFO_P 342 342
 * * Controller info
 D COLOR_DSP_P 343 343
 * * Color capable?
 D GRID_DSP_P 344 344
 * * Grid line dsp?
 * ----------------------------------------------------------------
 * The following fields apply to ISDN.
 D ISDN_LEN_P 385 386I 0
 * * Rmt number len
 D ISDN_TYPE_P 387 388
 * * Rmt number type
 D ISDN_PLAN_P 389 390
 * * Rmt number plan
 D ISDN_NUM_P 391 430
 * * Rmt number
 D ISDN_SLEN_P 435 436I 0
 * * Rmt sub-address
 D ISDN_STYPE_P 437 438
 * * Rmt sub-address
 D ISDN_SNUM_P 439 478
 * * Rmt sub-address
 D ISDN_CON_P 480 480
 * * Connection
 D ISDN_RLEN_P 481 482I 0
 * * Rmt address len
 D ISDN_RNUM_P 483 514
 * * Rmt address
 D ISDN_ELEN_P 519 520
 * * Extension len
 D ISDN_ETYPE_P 521 521
 * * Extension type
ΓΒ©copyright 4
 D ISDN_ENUM_P 522 561
 * * Extension num
 D ISDN_XTYPE_P 566 566
 * * X.25 call type
 * ----------------------------------------------------------------
 * ICF
 D PGM_DEV_P 241 250
 * * Program device
 D DEV_DSC_P 251 260
 * * Dev description
 D USER_ID_P 261 270
 * * User ID
 D DEV_CLASS_P 271 271
 * * Device class
 D DEV_TYPE_P 272 272
 * * Device type
 D REQ_DEV_P 278 278
 * * Requester?
 D ACQ_STAT_P 279 279
 * * Acquire status
 D INV_STAT_P 280 280
 * * Invite status
 D DATA_AVAIL_P 281 281
 * * Data available
 D SES_STAT_P 291 291
 * * Session status
 D SYNC_LVL_P 292 292
 * * Synch level
 D CONV_TYPE_P 293 293
 * * Conversation typ
 D RMT_LOC_P 294 301
 * * Remote location
 D LCL_LU_P 302 309
 * * Local LU name
 D LCL_NETID_P 310 317
 * * Local net ID
 D RMT_LU_P 318 325
 * * Remote LU
 D RMT_NETID_P 326 333
 * * Remote net ID
 D APPC_MODE_P 334 341
 * * APPC Mode
 D LU6_STATE_P 345 345
 * * LU6 conv state
 D LU6_COR_P 346 353
 * * LU6 conv
 * * correlator
 * ----------------------------------------------------------------
 * The following fields apply to ISDN.
 D ISDN_LEN 385 386I 0
 * * Rmt number len
 D ISDN_TYPE 387 388
 * * Rmt number type
 D ISDN_PLAN 389 390
 * * Rmt number plan
 D ISDN_NUM 391 430
 * * Rmt number
 D ISDN_SLEN 435 436I 0
 * * sub-addr len
 D ISDN_STYPE 437 438
 * * sub-addr type
 D ISDN_SNUM 439 478
 * * Rmt sub-address
 D ISDN_CON 480 480
 * * Connection
 D ISDN_RLEN 481 482I 0
 * * Rmt address len
 D ISDN_RNUM 483 514
 * * Rmt address
ΓΒ©copyright 5
 D ISDN_ELEN 519 520
 * * Extension len
 D ISDN_ETYPE 521 521
 * * Extension type
 D ISDN_ENUM 522 561
 * * Extension num
 D ISDN_XTYPE 566 566
 * * X.25 call type
 * ----------------------------------------------------------------
 * The following information available only when program started
 * result of a received program start req. (P_ stands for protected)
 D TRAN_PGM 567 630
 * * Trans pgm name
 D P_LUWIDLN 631 631
 * * LUWID fld len
 D P_LUNAMELN 632 632
 * * LU-NAME len
 D P_LUNAME 633 649
 * * LU-NAME
 D P_LUWIDIN 650 655
 * * LUWID instance
 D P_LUWIDSEQ 656 657I 0
 * * LUWID seq num
 * ----------------------------------------------------------------
 * Below info is available only when a protected conversation
 * is started on a remote system. (U_ stands for unprotected)
 D U_LUWIDLN 658 658
 * * LUWID fld len
 D U_LUNAMELN 659 659
 * * LU-NAME len
 D U_LUNAME 660 676
 * * LU-NAME
 D U_LUWIDIN 677 682
 * * LUWID instance
 D U_LUWIDSEQ 683 684I 0
 * * LUWID seq num
 * ----------------------------------------------------------------
 * Device independent area 367-nnn
 * NOTE that this area is shared with the POST feedback area above!
 * ----------------------------------------------------------------
 * Printer
 D CUR_LINE 367 368I 0
 * * Current line num
 D CUR_PAGE 369 372I 0
 * * Current page cnt
 D PRT_MAJOR 401 402
 * * Major ret code
 D PRT_MINOR 403 404
 * * Minor ret code
 * ----------------------------------------------------------------
 * Disk
 D FDBK_SIZE 367 370I 0
 * * Size of DB fdbk
 D JOIN_BITS 371 374I 0
 * * JFILE bits
 D LOCK_RCDS 377 378I 0
 * * Nbr locked rcds
 D POS_BITS 385 385
 * * File pos bits
 D DLT_BITS 384 384
 * * Rcd deleted bits
 D NUM_KEYS 387 388I 0
 * * Num keys (bin)
 D KEY_LEN 393 394I 0
 * * Key length
 D MBR_NUM 395 396I 0
ΓΒ©copyright 6
 * * Member number
 D DB_RRN 397 400I 0
 * * Relative-rcd-num
 D KEY 401 2400
 * * Key value (max
 * * size 2000)
 * ----------------------------------------------------------------
 * ICF
 D ICF_AID 369 369
 * * AID byte
 D ICF_LEN 372 375I 0
 * * Actual data len
 D ICF_MAJOR 401 402
 * * Major ret code
 D ICF_MINOR 403 404
 * * Minor ret code
 D SNA_SENSE 405 412
 * * SNA sense rc
 D SAFE_IND 413 413
 * * Safe indicator
 D RQSWRT 415 415
 * * Request write
 D RMT_FMT 416 425
 * * Remote rcd fmt
 D ICF_MODE 430 437
 * * Mode name
 * ----------------------------------------------------------------
 * Display
 D DSP_FLAG1 367 368
 * * Display flags
 D DSP_AID 369 369
 * * AID byte
 D CURSOR 370 371
 * * Cursor location
 D DATA_LEN 372 375I 0
 * * Actual data len
 D SF_RRN 376 377I 0
 * * Subfile rrn
 D MIN_RRN 378 379I 0
 * * Subfile min rrn
 D NUM_RCDS 380 381I 0
 * * Subfile num rcds
 D ACT_CURS 382 383
 * * Active window
 * * cursor location
 D DSP_MAJOR 401 402
 * * Major ret code
 D DSP_MINOR 403 404
 * * Minor ret code
ΓΒ©copyright 7
PROGRAM STATUS DATA STRUCTURE (PSDS)
* -------------------------------------------------------------
 * Program Status Data Structure -- PSDS
* -------------------------------------------------------------
 D SDS
 D PROC_NAME *PROC
 * Procedure name
 D PGM_STATUS *STATUS
 * Status code
 D PRV_STATUS 16 20S 0
 * Previous status
 D LINE_NUM 21 28
 * Src list line nu
 D ROUTINE *ROUTINE
 * Routine name
 D PARMS *PARMS
 * Num passed parms
 D EXCP_TYPE 40 42
 * Exception type
 D EXCP_NUM 43 46
 * Exception number
 D PGM_LIB 81 90
 * Program library
 D EXCP_DATA 91 170
 * Exception data
 D EXCP_ID 171 174
 * Exception Id
 D DATE 191 198
 * Date (DATE fmt)
 D YEAR 199 200S 0
 * Year (YEAR fmt)
 D LAST_FILE 201 208
 * Last file used
 D FILE_INFO 209 243
 * File error info
 D JOB_NAME 244 253
 * Job name
 D USER 254 263
 * User name
 D JOB_NUM 264 269S 0
 * Job number
 D JOB_DATE 270 275S 0
 * Date (UDATE fmt)
 D RUN_DATE 276 281S 0
 * Run date (UDATE)
 D RUN_TIME 282 287S 0
 * Run time (UDATE)
 D CRT_DATE 288 293
 * Create date
 D CRT_TIME 294 299
 * Create time
 D CPL_LEVEL 300 303
 * Compiler level
 D SRC_FILE 304 313
 * Source file
 D SRC_LIB 314 323
 * Source file lib
 D SRC_MBR 324 333
 * Source file mbr
 D PROC_PGM 334 343
 * Pgm Proc is in
 D PROC_MOD 344 353
 * Mod Proc is in
 D CURR_USER 358 367
 * Mod Proc is in
 * -------------------------------------------------------------
ΓΒ©copyright 8
 * Values of PGM_STATUS (*STATUS) -- if %Status = 00100 ...
 * -------------------------------------------------------------
 * Normal Codes
 *
 * Code Condition
 * 00000 No exception/error occurred
 * 00001 Called program returned with the LR indicator on.
 * Exception/Error Codes
 * Code Condition
 * 00100 Value out of range for string operation
 * 00101 Negative square root
 * 00102 Divide by zero
 * 00103 An intermediate result is not large enough to
 * contain the result.
 * 00104 Float underflow. An intermediate value is too
 * small to be contained in the intermediate
 * result field
 * 00112 Invalid Date, Time or Timestamp value.
 * 00113 Date overflow or underflow. (For example, when
 * the result of a Date calculation
 * results in a number greater than HIVAL or less
 * than LOVAL.)
 * 00114 Date mapping errors, where a Date is mapped from a 4
 * character year to a 2 character year and the date range
 * is not 1940-2039.
 * 00120 Table or array out of sequence.
 * 00121 Array index not valid
 * 00122 OCCUR outside of range
 * 00123 Reset attempted during initialization step of program
 * 00202 Called program or procedure failed; halt indicator
 * (H1 through H9) not on
 * 00211 Error calling program or procedure
 * 00222 Pointer or parameter error
 * 00231 Called program or procedure returned with halt
 * indicator on
 * 00232 Halt indicator on in this program
 * 00233 Halt indicator on when RETURN operation run
 * 00299 RPG IV formatted dump failed
 * 00333 Error on DSPLY operation
 * 00401 Data area specified on IN/OUT not found
 * 00402 PDA not valid for non-prestart job
 * 00411 Data area type or length does not match
 * 00412 Data area not locked for output
 * 00413 Error on IN/OUT operation
 * 00414 User not authorized to use data area
 * 00415 User not authorized to change data area
 * 00421 Error on UNLOCK operation
 * 00425 Length requested for storage allocation is out of range
 * 00426 Error encountered during storage management operation
 * 00431 Data area previously locked by another program
 * 00432 Data area locked by program in the same process
 * 00450 Character field not entirely enclosed by shift-out
 * and shift-in characters
 * 00501 Failure to retrieve sort sequence.
 * 00502 Failure to convert sort sequence.
 * 00802 Commitment control not active.
 * 00803 Rollback operation failed.
 * 00804 Error occurred on COMMIT operation
 * 00805 Error occurred on ROLBK operation
 * 00907 Decimal data error (digit or sign not valid)
 * 00970 The level number of the compiler used to generate
 * the program does not agree with the level number
 * of the RPG IV run-time subroutines
 * 09998 Internal failure in ILE RPG/400 compiler or in
 * run-time subroutines

 * 09999 Program exception in system routine.