Question

I'm developing RPG program on the IBM developing software

what happen is that I'm creating a display file with input field

I'm trying to accomplish one task.

If they already input all the field and the other record is display I want to protect the filed that they just input the value until they press enter

but I'm confuse how can I use the DSPATR(PR) to protect the field

Was it helpful?

Solution 2

I found answer for my question.

To do this just go to properties on the screen designer > right click to properties and find keyword protect and this will protect the whole screen for the field that they enter until enter is pressed to unprotect.

It's also can be done by adding DSPATR(PR) with indicator and add this to RPG to turn on the indicator for the required field.

OTHER TIPS

On the green-screen the RPG program only knows about what is on the screen when you hit <enter> on your screen. It sounds like you want to protect a field after the user has entered data into the field. I don't think that is possible unless each field has the CHECK(ER) on each field. That would get annoying depending on the program function. Hands-down entry people prefer to just keep typing and they have memorized exactly how many tabs and spaces they need to key to enter the data.

For study purpouse you can set display attributes since your RPG "backend" code, for example in your case the hexadecimal code value for protect (read only) filed is 'A0', take a look of the code:

In DDSSRC:

.....AAN01N02N03T.Nombre++++RLon++TPdBLínPosFunciones+++++++++++++++++++++++++++
 A* First declare the variable 
 A                REV1           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(&REV1)

In RPGSRC, just set or clear when you need it:

CL0N01Factor1+++++++Operac&ExtFactor2+++++++Resultado+++++Lon++D+MaMeIg....Comentarios+++++++++
C* 
C* Set the hex value in the QDDSSRC variable
C                       EVAL      REV2 = x'A0'
C*
C* Clear the variable
C                   CLEAR                   REV1              1

There are too many hexa codes for many purpouses, just need to look around the www :).

A SEL 1A B 11 2
A 99 DSPATR(PC)

A 99 DSPATR(RI)

When you display a field on the green screen, you EXFMT generally for I/O. Here, I would clear the SEL field first then EXFMT the record format from the display(DDS) file. Once the user presses ENTER, I "turn on" the indicator 99. I would then EXFMT again to display the screen. In the example if *IN99 was *ON, the cursor would Position To the SEL field AND Reverse Image it. You can do the same with protect DSPATR(PR). In your code, you'd "set off" the indicator, display the screen. User hits ENTER you "turn on" the indicator and repop the screen.

In RPG, you can use MOVE *ON *IN99.

or you can use SETON ........99.

or MOVE '1' *IN99.

In CLP, you can CHGVAR VAR(&IN99) VALUE('1')

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top