To display the second screen:
WRITE SFLCTLFMT (with both indicators for SFL and SFLCTL set on)
EXFMT WINDOWFMT (assuming the OVERLAY keyword is on the window display format)
If you need to read function keys that are defined on the SFLCTLFMT, then:
Thus, your RPG code should look like this:
The user presses [ENTER] twice because the programming requested it twice. Don’t request input when the subfile and control record are displayed and the user won’t have to supply it. Don’t READ (nor EXFMT, which is a combined WRITE/READ) if you don’t intend to wait for input. Just WRITE. And ensure that the display file is compiled DFRWRT(*NO) so that WRITEs cause data to be written to the device before READ requests are processed.