Load All – Using Position To

pts.
Tags:
Programming Languages
RPG
Can I use a Position To field in a Load all subfile. I don't want to clear the subfile every time as we do in a single Page subfile. How will the Page up and Page down features be affected if I use a Position to in a Load All subfile? Any help would be appreciated.

Answer Wiki

Thanks. We'll let you know when a new response is added.

I think you’ll have difficulty implementing a Position To in a Load All subfile. How will you identify which record in the subfile to position to? The subfile only allows RRN access if you want to chain to or position to a specific record.

To do it you would need to identify the relative record number of the record you want to position to.

A dirty method would be to record in an array or multiple-occurrence data structure where parts of the position to key change. For example, if you want to position on say Surname, you have a 28 element single character array.

In element 1 you store the RRN of the first subfile record with a surname beginning with A, in element 2 the RRN for a surname beginning with B, etc through to element 6 for Z.

In 27 you store the first RRN with a non-alphanumeric first character in the surname and in 28 the first RRN with a surname beginning with a digit.

When you do your position to, you complete the Position-To field and press Enter or a Fn key. The program then takes the first character and finds the corresponding element to pick up the RRN. You then chain to the RRN and read through until you find a match on the surname or a surname that is greater than the position to. That gives you your positioning RRN which you can use for the top line of the subfile.

It’s messy and depending on the number of records could be unworkable. You can expand the concept by recording changes of RRN on say the first three characters of the position to field instead.

The best way to handle a position to is to use a single page if you want to allow paging up/rolling back through the subfile or an expanding subfile if you don’t mind not being able to page up/roll back.

Using Page Up and Page Down in a Load All subfile makes no difference, the system still handles all of the paging. By using a Position To you handle the positioning to the appropriate RRN and tell the subfile which record to position to. The paging is handled automatically.

Hope that helps

All the best

Jonathan

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TheQuigs
    You needn't clear and reload the subfile, but what you can do is a loop to read each subfile record by the relative-record-number (RRN) until the position-to value matches. Then move the appropriate RRN to a field specified on the keyword SFLRCDNBR. Here's a sample code for the the subfile control record where I move RRN to DSPREC. A DSPREC 3S 0H SFLRCDNBR(CURSOR *TOP)
    0 pointsBadges:
    report
  • TomLiotta
    You can certainly use a PostionTo field on a load-all subfile if you feel like doing the programming to support it. But it's not a very bright thing to do. A simple page-at-a-time subfile is far easier to manipulate with a PositionTo. You can use features of the database to do the positioning for you rather than having to create the logic for it yourself. Further, since a load-all subfile should generally never have more than a couple hundred rows, a PositionTo field usually doesn't add much value. Positioning is much more useful when you have many more rows than a subfile can hold. Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following