ibm-midrangerpglerpg

Changing the focus of the cursor to the Subfile Control Option Not Subfile Data Option, While also using RCDNBR


I am a beginner learning RPGLE and working with subfiles. I have attached an image where the red highlighted area is designed using SFLCTL, and the blue highlighted area displays data fetched from the physical file and loaded using SFLDATA.

I am using RCBNBDR(SFLRCDNBR(Cursor)) to handle record positioning.

The issue I am facing is that the cursor initially focuses on the first record of the subfile (Option 1) in the blue highlighted area instead of the option field in the red highlighted area above. If I remove RCBNBDR, the cursor correctly points to the main option field, but I need both functionalities: RCBNBDR for handling records and the cursor initially pointing to the main option field.

How can I achieve this?

Home Page

Home Page


Solution

  • Use DSPATR(PC) in the DDS source for the options field in your red area.

    DSPATR(PC) means "place cursor", and can optionally be conditioned with indicators. Together with an appropriate RTNCSRLOC definition in the record format for the red area, you can place the cursor e. g. into the field it was before the user pressed enter.

    See my GitHub project for examples, especially v_lodpag*. I'm using the described facility to place the cursor to the position-to field initially, and when the user presses the "home" key, to quickly jump from the subfile to the pos-to field.