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

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
LVL 1
Anthony6890Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill PrewIT / Software Engineering ConsultantCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Anthony6890Author 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 ConsultantCommented:
Can you share a screen shot or other capture of the error?


»bp
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

Theo KouwenhovenApplication ConsultantCommented:
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

Anthony6890Author 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 ConsultantCommented:
Great, glad you got it sorted out.


»bp
Theo KouwenhovenApplication ConsultantCommented:
Hi Anthony6890,

The code will work, but beware, use prompting (F4) to be sure it is in the right position.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
IBM System i

From novice to tech pro — start learning today.