I need to write a program that shows more than one way to display a subfile. Both views are of the same file but sorted differently and show different fields of the same file when the user presses a function key. Can I do this in one program or do I have to make 2 seperate programs and toggle between the two? Some code examples would be helpful. Thank you in advance.
You can do this with a page-at-a-time subfile. That allows you to condition the fields to display or not display. Along with this use embedded SQL to define your sort using the Prepare/Execute statements.
Actually, you can do it in one subfile, and it can be self-extending.
The subfile has a single displayable line, and the subfile control has a field or fields to show the (variable) column headings.
Fill the single display field from the data, set the correct heading values and display the subfile. If the user changes the view, reload the subfile with the different data, formatted into the single display field, change the column headings and display the subfile.
I use this quite often, and it's especially useful when there are different views of the same selected data, because then you can store the alternate views in hidden fields in the subfile record. When the user toggles the view (for the same selection criteria), we copy the hidden data (already formatted) to the displayable field, change the column headings and redisplay - without re-reading the database.
(Of course, check the volatility of the data! You may have to reload to keep the screen up-to-date.)
Sloopy
Sloopy
The long character field is a great idea but just for output fields.
And the Hidden fields work well.
Whwn the alternate format key is pressed the code should loop through all the records in the subfile Chaining into each on the RRN building the new character field from the hidden fields and then updating the subfile record.
Vatchy
My experience was that the No Display fields still took real estate, hiding any other column in the same space. Please let me know if there is a solution.
Phil
I've created multiple view subfile programs. I use page-at-a-time processing & different logical views for presentation (I use RRN-chaining against the physical, storing the RRN in a hidden field in the subfile), & use a combination non-display subfile / data queue to store & sort options.
Philpl1jb
Don't use NonDisplay fields, just condition the fields to show/not show with indicators. This only works with page-at-a-time subfiles, not with extendable/load-all subfiles.
You can display multiple formats by using indicators, you need to have logicals based on the key that you wanted to display and need to play with the indicators in the program. You need to use one long character field, hidden fields in the subfile format. Lets say, when Indicator X{25} is on, display subfile in one format and when it is off display subfile in other format. Like this, you can display subfile with multiple ways......
Its very simple buddy,
Use window subfile , that is two different window and write subfile and exfmt other one.
IN display file, create a field of any lengh with same name in both window of NON DISPLAY type,
Now call your program, you will see two window and when you press TAB, it will jump to other window and it will show the records.
Free Guide: Managing storage for virtual environments
Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content!
Discuss This Question: 9  Replies