How to Read a File Using SQR?

Your rating: None Average: 3.6 (10 votes)

Here is some SQR code that will enable you to read a file. The code will also track # of records being read and will print out how many records have been rejected as well as total records read.

! Procedure: Read-Input-File !
! Descr:     Read file               !
Begin-Procedure Read-Input-File
#debug show 'Entering Read-Input-File'

Read 1 into $Record:3000  !skip the headings

Move 0 to #Tot_Recs
Move 0 to #Recs_Rej

While Not #end-file
        Read 1 into $Input:3000 Status=#Read_stat
        If #end-file
                Do Close-file
Add 1 to #Tot_Recs     
If #Read_Stat <> 0              !SQR returns zero if the read is successful
        Show 'Bad return from the Read command, errno= ' #Read_Stat
        Show ' Record # = ' #Tot_Recs
        Print 'Could not read record # ' (+1, 1)
        Print  #Tot_Recs () edit 8888888888
        Add 1 to #Recs_Rej
        Show 'Calling Process-Input-Record to process record # ' #Tot_Recs
        Do Process-Input-Record
!At this point all records are read from the file

End-Procedure Read-Input-File

Please try to help out with unanswered topics on the forum. Chances are you have had the same issue/question some time in your IT career!


Have a question? Please ask it on the forum instead.
Guest's picture
Guest (not verified)
sqr code from excel

Thanks for the post, Do u have the code for reading from excel and inserting into peoplesoft.

CompShack's picture
User offline. Last seen 7 years 17 weeks ago. Offline
Joined: 12/09/2007
Posts: 167
Do it just the same

The file I'm reading above was actually an excel file that has been saved as a .txt file! Have you tried doing that to your file and then attempt to read it?

Give back to the community and help it grow!
* Help with unanswered forum questions and issues
* Register or login to share your knowledge at your own blog

Guest's picture
Guest (not verified)
Re: How to Read a File Using SQR?

How to read a data from external file and insert into a record by using SQR. I need a basic program