Validate code on RPG III

105 pts.
Tags:
AS/400
RPG
Hello! I need help on a validation in Purchasing Order Program on RPG III, I need that the program don't accept that exist a PO number with different Vendor's Numbers. This is my source code: Thanks!
FLSR115D CF  E                    WORKSTN                    
FLOSMSTP IF  E           K        DISK                       
FLOSVENP IF  E           K        DISK                       
FLOSPORP UF  E           K        DISK                      A
C/SPACE 1                                                    
C*  SETUP DATE FIELDS                                        
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                     MOVE SAVYMD    POYMD                   
C/SPACE 1                                                    
C*  P/O KLIST                                      
C/SPACE 1                                          
C           POKEY     KLIST                        
C                     KFLD           PONUM         
C                     KFLD           VENNBR        
C                     KFLD           ITMNUM        
C/SPACE 1                                          
C*  EXECUTE SCREEN TO ENTER VENDOR NUMBER          
C/SPACE 1                                          
C           START     TAG                          
C                     MOVE *BLANKS   PONUM         
C                     Z-ADD0         VENNBR        
C           SCRN01    TAG                          
C                     EXFMTLSF11501                
C/SPACE 1                                          
C*  F3 EXIT                                        
C/SPACE 1                                          
C           *IN03     IFEQ '1'                     
C                     SETON                     LR 
C                     RETRN                              
C                     END                                
C/SPACE 1                                                
C*  P/O NUMBER & VENDOR NUMBER CANNOT BE BLANK           
C/SPACE 1                                                
C           PONUM     CABEQ*BLANKS   SCRN01         79   
C           VENNBR    CABEQ*ZERO     SCRN01         78   
C/SPACE 1                                                
C*  VALIDATE VENDOR NUMBER                                 
C/SPACE 1                                                
C           VENNBR    CHAINLOSVENP              77       
C           *IN77     CABEQ'1'       SCRN01              
C/SPACE 1                                                
C*  VALIDATE P/O NUMBER & VENDOR NUMBER                  
C/SPACE 1                                                                       
C/SPACE 1                                                
C*  EXECUTE SCREEN TO ENTER ITEM NUMBER                                                            
C/SPACE 1                                              
C           SCRN02    TAG                              
C                     MOVE *BLANKS   ITM#              
C                     EXFMTLSF11502                    
C/SPACE 1                                              
C*  F3 TO EXIT PROGRAM                                 
C/SPACE 1                                              
C           *IN03     IFEQ '1'                         
C                     SETON                     LR     
C                     RETRN                            
C                     END                              
C/SPACE 1                                              
C*  F12 PREVIOUS SCREEN                         96     
C/SPACE 1                                              
C           *IN12     CABEQ'1'       START             
C/SPACE 1                                              
C*  ITMNUM CANNOT BE BLANKS                            
C/SPACE 1                                              
C           ITM#      CABEQ*BLANKS   SCRN02         76 
C/SPACE 1                                   
C*  CHAIN ITEM NUMBER                              
C/SPACE 1                                          
C                     MOVE ITM#      ITMNUM 20     
C           ITMNUM    CHAINLOSMSTP              75 
C           *IN75     CABEQ'1'       SCRN02        
C/SPACE 1                                          
C*  CHAIN ITEM NUMBER LOSPORP                      
C/SPACE 1                                          
C           POKEY     CHAINLOSPORP              95 
C           *IN95     IFEQ '0'                     
C                     MOVE *BLANKS   ACTION        
C                     MOVEL'  UPDATE'ACTION        
C                     ELSE                         
C                     MOVELITM#      ITMNUM        
C                     MOVELITMCST    LPOPRI        
C                     MOVE *BLANKS   POQ90         
C                     MOVEL' ADDITIO'ACTION        
C                     MOVE 'N '      ACTION        
C                     END                                      
C                     END                                      
C**************************************************************
C/SPACE 1                                                      
C*  EXECUTE SCREEN TO ENTER PURCHASING ORDER                   
C/SPACE 1                                                      
C                     SETOF                     72             
C           SCRN03    TAG                                      
C                     EXFMTLSF11503                            
C/SPACE 1                                                      
C*  F3 EXIT                                                    
C/SPACE 1                                                      
C           *IN03     IFEQ '1'                                 
C                     SETON                     LR             
C                     RETRN                                    
C                     END                                      
C/SPACE 1                                                      
C*  F12 PREVIOUS SCREEN                                        
C/SPACE 1                                                      
C           *IN12     CABEQ'1'       SCRN02                                                                         
C/SPACE 1                                            
C*  F11 DELETE RECORD                                
C/SPACE 1                                            
C           *IN11     IFEQ '1'                       
C           *IN95     ANDEQ'1'                       
C                     SETON                     70   
C                     GOTO SCRN03                    
C                     END                            
C           *IN11     IFEQ '1'                       
C           *IN72     ANDEQ'0'                       
C                     MOVEL' DELETIO'ACTION          
C                     MOVE 'N '      ACTION          
C                     SETON                     72   
C                     GOTO SCRN03                    
C                     END                            
C           *IN11     IFEQ '1'                       
C           *IN95     ANDEQ'0'                       
C                     DELETLOSPOR                    
C                     GOTO SCRN02                    
C                     END                            
C/SPACE 1                                              
C*  VENDOR ITEM, P/O PRICE & P/O QUANTITY              
C/SPACE 1                                              
C           LPOPRI    CABEQ*ZERO     SCRN03         74 
C           POQ90     CABEQ*ZERO     SCRN03         73 
C/SPACE 1                                              
C*  UPDATE/ADD RECORD TO LOSPORP                       
C/SPACE 1                                              
C           *IN95     IFEQ '0'                         
C                     Z-ADDSAVYMD    POYMD             
C                     UPDATLOSPOR                      
C                     ELSE                             
C                     WRITELOSPOR                      
C                     END                              
C/SPACE 1                                              
C                     GOTO SCRN02
1

Answer Wiki

Thanks. We'll let you know when a new response is added.
POKEY CHAIN LOSPORP     95

You are testing for the existence of the record using full key (Order,Vendor,Item) but not testing for Order on it’s own.

Having determined that this item is not yet in the order, you need to verify that the order is for the correct vendor (Order,Vendor exists), or that it’s a new order (Order does NOT exist), before continuing to add the record.

Discuss This Question: 5  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
    Seems like a fairly simple program. Have you tried running it in DEBUG mode to see where the problem is? It's a great learning tool to find problems.
    132,840 pointsBadges:
    report
  • k3v1N24
    No ToodN2000, I haven't try with the DEBUG mode.
    105 pointsBadges:
    report
  • ToddN2000
    With debug you can step line by line through your code and check the variables. This will let you know if you are building the correct keys, and seeing what you chains and validation test results are. Try it and if you still have issues come back with the error. Debug is great for testing your logic flow.
    132,840 pointsBadges:
    report
  • k3v1N24
    Thanks ToddN2000, the system takes like it's working fine, but still let it me add the PO with different Vendors. I need to do a validation and I have no clue what kind of OPCODE do I have to use.
    105 pointsBadges:
    report
  • ToddN2000
    If you cannot use the same PO, then you would need a LF with the primary be being the PO and then do a chain to see it exists.
    132,840 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: