ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Sort Printer file records

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

  • Sort Printer file records

    Hi Friends,

    How to sort the printer file records based on particular field value. If i'm having country code in my PF records. I want to get the printer file output based on this country code fields in Ascending order. Please ASAP if possible.


    Scenario is OVRDBF one PF and call RPG from there to PRTF, but in printer file, we need to sort the records based on one particular field (Country code field).

    Thanks & Regards,
    Murali...

  • #2
    Re: Sort Printer file records

    You don't sort records in a printer file. Printer files are for output only. You sort the records on input from the PF. There are a number of ways to do that, all of which involve changing either the program (I'm assuming it's a CLP) that executes the OVRDBF, or the RPG that writes to the PRTF.

    You might try using the OPNQRYF command before issuing the OVRDBF. Searching these fora for "OPNQRYF" returns many results that can show you how to use it.
    "Time passes, but sometimes it beats the <crap> out of you as it goes."

    Comment


    • #3
      Re: Sort Printer file records

      i'm not getting the result in OPNQRYF also. i have tried the following:

      Following is the SQL command for my requirement. I'm getting perfect output in STRSQL.

      select bjinv#,bjbill,bjctcd,cuctcd from bjmast,cumast
      where bjbill=cucode
      order by cuctcd

      But if i'm converting it to OPNQRYF, with same SQL statement, i'm not getting the records, It's throwing the compile time error. I'm having the following OPNQRYF command.

      OPNQRYF FILE((BJMAST) (CUMAST)) +
      FORMAT(BJMAST) +
      QRYSLT(&QRYSLT) +
      KEYFLD( +
      (BJCT *ASCEND) +
      (BJMAST/BJBRCD *ASCEND) +
      (BJMAST/BJBILL *ASCEND) +
      ) +
      JFLD( +
      (BJMAST/BJBILL CUMAST/CUCODE *EQ) +
      ) +
      JORDER(*FILE) +

      i cant find, where i did the mistake.

      Comment


      • #4
        Re: Sort Printer file records

        place this above your qpnqryf

        ovrdbf share(*Yes)

        you'd be better off using SQL


        if you use free and opnqryf in the same program...Worlds will end!

        Why do you not want to use SQL?>
        jamie
        All my answers were extracted from the "Big Dummy's Guide to the As400"
        and I take no responsibility for any of them.

        www.code400.com

        Comment


        • #5
          Re: Sort Printer file records

          Worlds will end????????????????????????????????

          Maybe a few planets spinning off of their axis ....... but never an ended world!!!

          GLS
          The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

          Comment


          • #6
            Re: Sort Printer file records

            NOOOO WAY!!!! I never use SQL as well OPNQRYF in my codes.

            Just i have tried with STRSQL for my required output. '

            But in my existing appliation, they are using OVRDBF & OPNQRYF command.
            So i cant use RUNSQLSTM or Free in my current application.


            I should follow the OPNQRYF only, but i'm not getting the sorted output. It's throwing the compile time error.

            Comment


            • #7
              Re: Sort Printer file records

              Okay I think Im following you..
              You must give us more details as far as the errors...

              what are they???

              Im gonna guess the format of the file BJMAST is not BJMAST but BJMASTR --or-- ????
              that could be an issue.

              here is an example from my system two files and a format
              PHP Code:
                  OVRDBF     FILE(APCPYBLJTOFILE(APCPYBLSHARE(*YES)  
                                                                         
                  
              OPNQRYF    FILE((APCPYBL) (APAVEND)) FORMAT(APCPYBLJ) +
                               
              QRYSLT('ACDUED = %RANGE(' *CAT &FRDATZ +  
                               *
              BCAT &TODATZ *CAT ')  *AND ACAPGR = +    
                               "PAYAB"'
              KEYFLD((ACGL#2) (AAALPH) +      
                               
              (ACVEN#) (ACDUED)) JFLD((1/ACVEN# +       
                               
              2/AAVEN#)) JDFTVAL(*YES) 
              All my answers were extracted from the "Big Dummy's Guide to the As400"
              and I take no responsibility for any of them.

              www.code400.com

              Comment

              Working...
              X