Question

my code goes like this:

femp        uf   e           k disk                   
dvar1             s              5p 0                
c     *loval        setll     emp                   
c                   read      emp                   
c                   dow       not %eof(emp)         
C                   eval      ecode = ecode + 10     
c                   eval      var1=ecode             
c                   update    recemp               

c     var1          setgt     emp                   
c                   read      emp                   
c                   enddo                            
c                   eval      *inlr=*on

Here is a file named emp with record format name recemp with ecode as the key ...

Now when i am reading the file and then updating the ecode without using setgt ..the pointer is not moving ahead it is updating the same ecode value many time ...

Now when i use set gt pointer picks the next record but it dint work when two ecode values are same ...else also it will not be working with descending key values...

Is there any solution so that i can set pointer regardless of the fact whether the values are same or ascending or descending.

Was it helpful?

Solution

You want to update 'ecode' field in each record in file 'emp' - is that correct? If so, just use another 'read' without 'setgt' and it will do just fine.

uf e k disk
c *loval setll emp
c read emp
c dow not %eof(emp)
C eval ecode = ecode + 10
c update recemp

c read emp

c enddo
c eval *inlr=*on 

OTHER TIPS

If you want to update the key value in every record, you should open the file in arrival sequence (don't use the 'k' in the F-spec). Also, don't use SETGT inside the loop unless you specifically are trying to skip records.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top