Need Review of Multiple If Greater Than lines of Code to Confirm if Logic is Correct

Anthony6890
Anthony6890 used Ask the Experts™
on
I am reviewing some RPG logic, in conjunction with a question I posted about a week ago.  I think the way this logic is written doesn't suit the needs of what I'm looking to be the end result.  Below is the code in question...

  *IN88     CABEQ*ON       ITSN      
  ELRET     CABEQ0         ITSN      
  ELRET     IFGT 0                   
  ELRETT    IFGT 0                   
  ELRETS    IFGT 0                   
            GOTO BYPASS              
            END                      
            END                      

Open in new window


I've probably included more code than needed.  Essentially, I'm looking to see that if ELRET and ELRETT and ELRETS are greater than 0, to go to bypass.  It looks like my program isn't doing this, based on the results from last week's run.  I've attempted to change the second and third IFGT to ANDGT; however, when I go to compile, I get an error code 50 (I believe, but don't quote me on that.).

I was hoping if someone could confirm for me that my suspicions are right and that the code needs to be altered to ensure that all the IFGT lines are evaluated together.

Thanks.

-Anthony
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
IT / Software Engineering Consultant
Top Expert 2016
Commented:
In the interest of full disclosure it's been quite a few years since I coded in RPG on an AS/400.  So I don't have a way to test things out, but what you are looking for seems like it should be pretty straight forward.  I think you want to use ANDGT and I think you need to end the IF block with ENDIF rather than END (unless that's an RPG version thing).  So for the part you are focused on this feels like what you want:

  ELRET     IFGT 0                   
  ELRETT    ANDGT0                   
  ELRETS    ANDGT0                   
            GOTO BYPASS              
            ENDIF

Open in new window


»bp

Author

Commented:
Hi Bill,

Thanks for the response.  I tried your logic with the ENDIF after the bypass and I still got the same error as before.  I'm going to keep poking around to see why it doesn't like it....
Bill PrewIT / Software Engineering Consultant
Top Expert 2016

Commented:
Can you share a screen shot or other capture of the error?


»bp
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

Theo KouwenhovenApplication Consultant

Commented:
First the meaning of your code.... maybe that will help
  *IN88     CABEQ*ON       ITSN    If *IN88 is on, goto ITSN      
  ELRET     CABEQ0         ITSN      else if ELRET = 0 , goto ITSN
  ELRET     IFGT 0                   else if ELRET > 0  
  ELRETT    IFGT 0                        and ELRETT > 0
  ELRETS    IFGT 0                        and ELRETS > 0
            GOTO BYPASS                      goto BYPASS
            END                      endif 3
            END                      endif 2
			END                      endif 1

Open in new window


First, NEVER use END, use ENDIF, ENDSL, etc.
Second, I would NEVER use GOTO nor CABxx it is unstructured programming (spaghetti).

If it is really required, use CASxx and use subroutines.
Or better Use select..when and freeformat.

But if you really want!!!

  *IN88     CABEQ*ON       ITSN 			
  ELRET     CABEQ0         ITSN 			
            IF    ELRET  > 0 and
                  ELRETT > 0 and
                  ELRETS > 0                   
            GOTO BYPASS              
            ENDIF

Open in new window

Author

Commented:
Hi Bill, I figured out my issue, but your solution was the correct syntax.  After the GOTO Bypass command I had 3 End lines, presuming, one for each if statement.  I instead commented out the bottom two and used the ENDIF after the GOTO and it compiled perfectly.  Thanks for you assistance.

Theo, I did try your solution; however, the program didn't like the use of the symbols in the coding.  I didn't create this program, I'm only maintaining it, so to do a complete overhaul of it, doesn't work for me at this moment, but thanks for you help regardless.

-Anthony
Bill PrewIT / Software Engineering Consultant
Top Expert 2016

Commented:
Great, glad you got it sorted out.


»bp
Theo KouwenhovenApplication Consultant

Commented:
Hi Anthony6890,

The code will work, but beware, use prompting (F4) to be sure it is in the right position.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial