Accessing an variable within a loop twice

In a procedure I have defined a global variable of type record as temporary; the record is filled. In a REPEAT…UNITL loop I go through the entire record in read mode. Within this same loop I need to find another entry of the same record (using GET(…)). What is the best way to do this[?] The possibilities I see are copying the entire record into another variable (how?) or just using the same variable again (does this have an effect on my loop?)? Suggestions? Thanks a lot.

Declare a second variable for your record i.e.: myTempRec2 Mark it as temporary too. Before you start the loop copy your orginal record into the above variable: myTempRec2.COPY(myOriginalTempRec); Within the loop you then can access myTempRec2 using GET without channging the record pointer of myTempOriginalRec.

Hi Josef, thanks for your reply. That is what I initially tried to do - but it does not quite work. I think the system only copies the current record of “myOriginalTempRec” and not ALL the records (in terms of tables speaking it only copies one line (the first one) and not all the lines of the temporary record. [?] All I really need is a second, independant record pointer!

Just a new guess: What about saying myTempRec2 := myOriginalTempRec;

No, that was my very first guess. Here I could understand that it only copies the content of the target of the record pointer.

You have to fill both temptables. Everytime you insert a record in your original temptable you have to put the same record in your second temptable. Then you have all your records in both temptables and can work with GET(…) on the second temptabe and the pointer of your loop is not changed. Hope this helps. Greetings, Frank

You can declare your temporary record variable as an array with dimension 2. This provides two separate “views” of the same set of temporary records. TempRec[1].FIND('-'); REPEAT TempRec[2].GET(...); UNTIL TempRec[1].NEXT = 0;

Thank you guys. Very helpful indeed!!