ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Display records from a Physical File

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Re: Display records from a Physical File

    Hello All,

    I have created a PF with two records in it. One is alphanumeric and the other is a numeric field.

    A UNIQUE
    A R RPF9
    A ALPHAN 25A TEXT( 'ALPHA NUMERIC DATA')
    A NUMENRIC 25S 0
    A K ALPHAN

    I want to write a RPG program to extract the numbers from ALPHAN and store in Numeric part respectively.

    Note: While updating the PF i have not entered the Numeric part i.e: its 0

    ALPHAN NUMENRIC
    000001 flywtliru235271@hjgkiu& 0


    Output should be like

    flywtliru@hjgkiu& 235271


    I am able to display it simply.

    FPF9 IF E k DISK
    dalpha1 s 30a
    c *loval setll pf9
    c* if %equal
    c dow *in90 = *off
    c read pf9 90
    c eval alpha1 = ALPHAN
    c alpha1 dsply
    c eval alpha1 = *blank
    c enddo
    c* endif
    c seton lr

    Please advice

    Nilesh

    Comment


    • #17
      Re: Display records from a Physical File

      You might look into the %CHECK built-in function. It returns the first position of the string that does not match something in your comparator string. Based on your example, the string is flywtliru235271@hjgkiu& and the comparator string would be all of the letters of the alphabet. The %CHECK BIF would return position 10 because it is a number and therefore doesn't match anything in your comparator string. You have to account for things like blanks and special characters when creating your comparator string. Otherwise, you may get an incorrect position returned depending on where the number falls within ALPHAN. The ILE RPG Reference manual(which you can get from the IBM site) has an example of the %CHECK BIF. I'm sure there are better ways but that's just my two cents.
      Part of the inhumanity of the computer is that, once it is competently programmed and working smoothly, it is completely honest. - Isaac Asimov

      Comment


      • #18
        Re: Display records from a Physical File

        Thanks a lot

        Comment


        • #19
          Re: Display records from a Physical File

          Your code:
          Code:
           c *loval setll pf9
          Try this:
          Code:
          c 1 setll pf9

          Comment


          • #20
            Re: Display records from a Physical File

            Remove the *Loval since there is no key fields in the file
            Use *start instead of *Loval
            Thanks
            Venkat

            Comment


            • #21
              Re: Display records from a Physical File

              You almost certainly don't need the SETLL line at all, as others have mentioned. You can delete the whole line. You would use SETLL if you need to move around to a different part of the file. It looks like this program is not part of a group of programs, so it will automatically start at the beginning of the file.

              Since you are learning, you can make the program work with just a few source lines. Make it simple first. You can study SETLL later when the rest of the program makes more sense to you.
              Tom

              There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

              Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

              Comment

              Working...
              X