SETLL & READ

105 pts.
Tags:
AS 400
Hello, I am a beginner with AS/400, I am developing a program to SCAN IN records, this record can be scanned multiple times (Duplicated records). But I need a code that search if the record exist, if exist a record then sum the quantity field of that record with the quantity entered if is greater than 48 pop-up (error screen). if it's more then one record sum the quantity field of the records found, if the summary it's greater than 48 (error screen), if not write the record.
This is a code that I was using, it work with the first two record, if it's more it take the last record and summary with the record entered.
C          HSTKEY    CHAINSEWHSTTP             95
C          *IN95     IFEQ *OFF                   
C          BUNQTY    ADD  SCQTY     SUMQTY  50   
C          SUMQTY    CABGTBUNSAV    ERSC03       
C                    END
I am writing as RPG III.
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 9  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.
  • ToddN2000
    We need to see more code. What are you file layouts? Where is the test for 48? Where is the WRITE statement? Without seeing more code and any errors we can only make guesses as how to fix your issue.
    127,470 pointsBadges:
    report
  • k3v1N24
    Hello Todd,

    this my file is structure

    A                                      REF(OFFSHORE/FLDREFP)          
    A          R SEWHST                    TEXT('SEWING EMPLOYEE HISTORY +
    A                                      FILE')                         
    A            EMPLNO    R                                              
    A            BUNNBR    R                                              
    A            PLTSEC    R                                              
    A            STYLE     R                                              
    A            STYCLR    R                                              
    A            DIM       R                                              
    A            SIZE      R                                              
    A            OPRNBR    R                                              
    A            SAHS      R                                              
    A            BUNQTY    R                                              
    A            ENTYMD    R                                              
    A            CRTTME    R                                              
    A          K EMPLNO                                                   
    A          K BUNNBR                                                   
    A          K OPRNBR  

    and this is my source code
    F/SPACE 2                                                    
    FSWR201D CF  E                    WORKSTN                    
    FSEWEMPP IF  E           K        DISK                       
    FBUNDTLP IF  E           K        DISK                       
    FWIPPLTP IF  E           K        DISK                       
    FSTYOPRP IF  E           K        DISK                       
    FSEWHSTTPUF  E           K        DISK                      A
    I            DS                                              
    I                                        1   30BUNSEQ        
    I                                        4  100BUNDLE        
    I                                        1  100BUNTKT        
    C/SPACE 1                                                    
    C*  SET UP KEY LIST                                          
    C/SPACE 1                                                    
    C           BUNKEY    KLIST                                  
    C                     KFLD           BUNSEQ                  
    C                     KFLD           BUNDLE                  
    C           OPRKEY    KLIST                                  
    C                     KFLD           STYLE                   
    C                     KFLD           OPRNBR                  
    C           HSTKEY    KLIST                    
    C                     KFLD           EMPLNO    
    C                     KFLD           BUNDLE    
    C                     KFLD           OPRNBR    
    C/SPACE 1                                      
    C*  SET UP DATE                                
    C/SPACE 1                                      
    C           UYEAR     IFLT 40                  
    C                     MOVEL20        YYYY    40
    C                     ELSE                     
    C                     MOVEL19        YYYY      
    C                     END                      
    C                     MOVE UYEAR     YYYY      
    C                     MOVELUMONTH    MMDD    40
    C                     MOVE UDAY      MMDD      
    C                     MOVELYYYY      SAVYMD  80
    C                     MOVE MMDD      SAVYMD    
    C/SPACE 1                                      
    C*  EXECUTE SCREEN TO ENTER EMPLOYEE NUMBER
    C/SPACE 1                                          
    C           BEGIN     TAG                          
    C                     Z-ADD0         EMPLNO        
    C                     MOVE *BLANKS   EMPLNM        
    C                     EXFMTSWF20101                
    C/SPACE 1                                          
    C*  F3 EXIT                                        
    C/SPACE 1                                          
    C           *IN03     IFEQ '1'                     
    C                     SETON                     LR 
    C                     RETRN                        
    C                     END                          
    C/SPACE 1                                          
    C*  CHAIN EMPLOYEE NUMBER                          
    C/SPACE 1                                          
    C           EMPLNO    CHAINSEWEMPP              99 
    C           *IN99     CABEQ'1'       ERSC01        
    C/SPACE 1                                          
    C*  EXECUTE SCREEN TO SCAN BUNDLE NUMBER  
    C/SPACE 1                                         
    C           START     TAG                         
    C                     Z-ADD0         BUNTKT       
    C                     EXFMTSWF20102               
    C/SPACE 1                                         
    C*  F3 TO EXIT                                    
    C/SPACE 1                                         
    C           *IN03     IFEQ '1'                    
    C                     SETON                     LR
    C                     RETRN                       
    C                     END                         
    C/SPACE 1                                         
    C*  F5 PREVIOUS                                   
    C/SPACE 1                                         
    C           *IN05     CABEQ'1'       BEGIN        
    C/SPACE 1                                         
    C*  BUNDLE DETAIL                                 
    C/SPACE 1                                         
    C           BUNDLE    CHAINWIPPLTP              98  
    C           *IN98     CABEQ'1'       ERSC02           
    C                     MOVELSIZE      SAVSIZ  4        
    C                     MOVELDIM       SAVDIM  3        
    C                     MOVELBUNQTY    BUNSAV  50       
    C/SPACE 1                                             
    C           BUNKEY    CHAINBUNDTLP              97    
    C           *IN97     CABEQ'1'       ERSC02           
    C/SPACE 1                                             
    C*  EXECUTE SCREEN TO ENTER BUNDLE QUANTITY           
    C/SPACE 1                                             
    C           QTYSCR    TAG                             
    C                     Z-ADD*ZEROS    SCQTY            
    C                     Z-ADD*ZEROS    SUMQTY           
    C                     EXFMTSWF20103                   
    C/SPACE 1                                             
    C*  F3 EXIT                                           
    C/SPACE 1                                             
    C           *IN03     IFEQ '1'                        
    C                     SETON                     LR            
    C                     RETRN                       
    C                     END                         
    C/SPACE 1                                         
    C           OPRKEY    CHAINSTYOPRP              96
    C           *IN96     IFEQ '1'                    
    C                     Z-ADD0         SAMQTY       
    C                     ELSE                        
    C           SCQTY     MULT SAMS      SAMQTY  74   
    C                     Z-ADDSAMQTY    SAHS         
    C                     END                         
    C/SPACE 1                                         
    C*  F5 PREVIOUS                                   
    C/SPACE 1                                         
    C           *IN05     CABEQ'1'       BEGIN        
    C/SPACE 1                                         
    C*  WRITE SEWHSTP                                 
    C/SPACE 1                                         
    C           HSTKEY    CHAINSEWHSTTP             95
    C           *IN95     IFEQ *OFF                      
    C           BUNQTY    ADD  SCQTY     SUMQTY  50       
    C           SUMQTY    CABGTBUNSAV    ERSC03           
    C                    END                                       
    C                                                     
    C                     TIME           TMEDTE 140       
    C                     MOVELTMEDTE    SAVTME  40       
    C                     Z-ADDSAVYMD    ENTYMD           
    C                     Z-ADDSAVTME    CRTTME           
    C                     MOVELSAVSIZ    SIZE             
    C                     MOVELSAVDIM    DIM              
    C                     MOVELSCQTY     BUNQTY           
    C                     WRITESEWHST                     
    C/SPACE 1                                     
    C*  GOTO EXECUTE BUNDLE SCREEN                
    C/SPACE 1                                     
    C                     GOTO START              
    C/SPACE 1                                     
    C*  INVALID EMPLOYEE NUMBER                   
    C/SPACE 1                                     
    C           ERSC01    TAG                     
    C                     EXFMTSWF20104           
    C                     GOTO BEGIN              
    C/SPACE 1                                     
    C*  BUNDLE NUMBER NOT IN BUNDTLP              
    C/SPACE 1                                     
    C           ERSC02    TAG                     
    C                     EXFMTSWF20105           
    C                     GOTO START              
    C/SPACE 1                                     
    C*  BUNDLE QUANTITY CANNOT BE GREATHER THAN 48
    C/SPACE 1                                     
    C           ERSC03    TAG          
    C                     EXFMTSWF20106
    C                     GOTO QTYSCR  

    Sorry about the test for 48 I was wrong, it's that can't be greater then BUNSAV that it's BUNQTY from my Bundle Master File
    105 pointsBadges:
    report
  • Splat
    I'm not seeing any SETLL or READ operations in the code provided.
    12,845 pointsBadges:
    report
  • ToddN2000
    Nor do I see a loop of any kind. It looks like a one for one. Take a screen parameter, chain to the file for up date, return to the screen.
    Is the current code being run ? 
    127,470 pointsBadges:
    report
  • k3v1N24
    You right Splat there isn't any SETLL or READ Operations,

    Todd/Splat, I need help to know what OPCode should I have to use, if it's a SETLL, READ, DOW, DOU. I need to validate that the BUNQTY of BUNNBR records scanned in SEWHSTP can't be greater than BUNQTY from WIPPLTP wich is my Bundle Master File.

    Yes Todd the current code run, but no as I want it.
    105 pointsBadges:
    report
  • ToddN2000
    You could always try running it using STRDBG. That way can can exactly what the code is doing. That might let you know where a code change is needed. For me it sounds like I would use a SETLL, READE then a DOW. Something like this.C MYKEY SETLL                  
    C     MYKEY         READE    MYFILE
    C                   DOW      NOT%EOF(MYFILE)
    C** your code here                      
    C                     X 
    C                     X  
    C                     X  
    
    C**                            
    C     MYKEY         READE     MYFILE    
    C                   ENDDO 

    127,470 pointsBadges:
    report
  • ToddN2000
    something may have glitched in my last post. The .C MYKEY SETLL   should have been in the code section.                  
    127,470 pointsBadges:
    report
  • k3v1N24
    Yes, I would try it.

    Thanks Todd.
    105 pointsBadges:
    report
  • k3v1N24
    I will*
    105 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.

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

Following

Share this item with your network: