I'm unable to reproduce the problem you describe. Here's the RPG code I'm trying to use:
Code: Select all
H DFTACTGRP(*NO)
FDROPDOWND CF E WORKSTN EXTDESC('SKTEST/DROPDOWND')
F EXTFILE(*EXTDESC)
F HANDLER('PROFOUNDUI(HANDLER)')
D divs s 30a dim(6)
D code s 8a dim(6)
D x s 10i 0
/free
dou btnCancel = *on;
// typically, you'd get these from a file or something,
// but since I don't have your files, here are a bunch
// of sample data for "divisions" and a code that
// corresponds to each division.
divs(1) = 'Eastern';
code(1) = 'E';
divs(2) = 'Western';
code(2) = 'W';
divs(3) = 'South';
code(3) = 'S';
divs(4) = 'North';
code(4) = 'N';
divs(5) = 'United Kingdom';
code(5) = 'U';
divs(6) = 'Germany';
code(6) = 'G';
// now load divisions and their values into drop-down choices
// (building list dynamically in a variable)
for x = 1 to %elem(divs);
if x = 1;
divnames = divs(x);
divisions = code(x);
else;
divnames = %trimr(divnames) + ',' + divs(x);
divisions = %trimr(divisions) + ',' + code(x);
endif;
endfor;
// now set the value of the dropdown (DIVSEL field) to
// the code for the first division, as an example.
divno = code(1);
// display screen... it shows the first divsion selected:
exfmt screen1;
// populate the last division selected so the user can
// see what was selected last time the screen was
// displayed.
lastDivno = divno;
enddo;
*inlr = *on;
/end-free
Here's the corresponding display file:
Code: Select all
A R SCREEN1
A 1 2HTML('QPUIREC0 ')
A 1 3HTML('{"screen":{"record format nam-
A e":"SCREEN1"},"items":[{"id":"CssBu-
A tton1","field type":"css button","v-
A alue":"Cancel","left":"251px","top"-
A :"114px","width":"90px","theme":"G -
A - Red","small button":"true","icon -
A position":"left","icon":"delete","r-
A esponse":{"fieldName":"btnCancel","-
A customTrue":"","customFalse":"","da-
A taType":"indicator","formatting":"I-
A ndicator","indFormat":"1 / 0"}},{"i-
A d":"Dropdown1","field type":"select-
A box","value":{"fieldName":"DIVNO",-
A "dataLength":"8","trimLeading":"fal-
A se","trimTrailing":"true","blankFil-
A l":"false","rjZeroFill":"false","da-
A taType":"char","formatting":"Text",-
A "textTransform":"none","designValue-
A ":"[DIVNO]"},"left":"83px","top":"4-
A 5px","choices":{"fieldName":"DIVNAM-
A ES","dataLength":"200","trimLeading-
A ":"false","trimTrailing":"true","bl-
A ankFill":"false","rjZeroFill":"fals-
A e","dataType":"char","formatting":"-
A Text","textTransform":"none"},"widt-
A h":"198px","choice values":{"fieldN-
A ame":"DIVISIONS","dataLength":"200"-
A ,"trimLeading":"false","trimTrailin-
A g":"true","blankFill":"false","rjZe-
A roFill":"false","dataType":"char","-
A formatting":"Text","textTransform":-
A "none"}},{"id":"CssButton2","field -
A type":"css button","value":"Ok","le-
A ft":"143px","top":"114px","width":"-
A 90px","theme":"F - Green","small bu-
A tton":"true","icon position":"left"-
A ,"icon":"check","response":{"fieldN-
A ame":"btnOkay","customTrue":"","cus-
A tomFalse":"","dataType":"indicator"-
A ,"formatting":"Indicator","indForma-
A t":"1 / 0"}},{"id":"Label1","field -
A type":"output field","css class":"l-
A abel","value":"Last division select-
A ed:","left":"58px","top":"210px","w-
A idth":"150px"},{"id":"OutputField1"-
A ,"field type":"output field","css c-
A lass":"outputField","value":{"field-
A Name":"LASTDIVNO","dataLength":"8",-
A "trimLeading":"false","trimTrailing-
A ":"true","blankFill":"false","rjZer-
A oFill":"false","dataType":"char","f-
A ormatting":"Text","textTransform":"-
A none","designValue":"[LASTDIVNO]"},-
A "left":"227px","top":"210px"}]}')
A BTNCANCEL 1A H
A BTNOKAY 1A H
A DIVISIONS 200A H
A DIVNAMES 200A H
A DIVNO 8A H
A LASTDIVNO 8A H
When I run this program, the screen comes up with the first option selected (because I set divno = code(1) in the RPG)
- first display.png (7.6 KiB) Viewed 2423 times
When I make a selection and click "Ok", the program will show the corresponding code to what I displayed, and then the RPG code resets the selection back to the first one selected, and re-displays the screen and I see this:
- next display.png (7.79 KiB) Viewed 2423 times
So this all appears to work properly for me. If you run my sample program, does it fail for you? Or does it work just as it does for me? If it works as it does for me, what do you need to change to make it fail (the way you're describing)?
Thanks!