× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Luqman,

<snip>
Secondly, how can I position the cursor in subfile through code, say after
validating the item no. the item name is displayed in 2nd column, and the
cursor should be position on 3rd column to enter quantity.
</snip>

You can use two easy ways:

1) You can use the DSPATR(PC) keyword on the field in the DDS. You condition it on an indicator. Set the indicator on for the subfile row you're working on before you update the record. This should position the cursor to the field.

2) You can use the CSRLOC DDS keyword to position the cursor to the field you're working on. This can be a little more complicated as you will need to derive the field's position in ROW-COL format: The column is easy as the field occurs in the same position on each subfile record. To derive the row you can use the following code:

DDS:
A                                      CSRLOC(#1ROW #1COL)

RPG:
C          If       %rmd(SFLRRN/SFLPAG) > 0
C          eval   #1ROW = 1st line + (%rmd(SFLRRN/SFLPAG) - 1)
C          else
C          eval   #1ROW = 1st line + (SFLPAG - 1)
C          endif

Here's an example:

Your subfile has 10 records per page, the first occurs on screen line 9. Field 3 is in pos 61.

a) You work on record with RRN = 17: The screen line = 9 + (%rmd(17/10)-1) = 9 + 6 = line 15.
b) You work on record with RRN = 30: The screen line = 9 + (10-1) = 9 + 9 = line 18.


You now set your row and col field values and the cursor will position as you wish:
a) #1ROW = 15, #1COL = 61
b) #1ROW = 18, #1COL = 61.



As an aside, you can keep the cursor position in the same place on the screen without ANY code in your RPG program:


Put these lines in your DDS and RTNCSRLOC populates CSRLOC, thanks to the *MOUSE option):
A CSRLOC(#1ROW #1COL)
A RTNCSRLOC(&#1RCD &#1FLD &#1POS)
A RTNCSRLOC(*MOUSE &#1ROW &#COL)
A OVERLAY
A #1ROW 3S 0H
A #1COL 3S 0H
A #1FLD 10A H
A #1RCD 10A H
A #1POS 4S 0H


Have fun

Larry Ducie



As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.