Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to write Rexx program to size and line count

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
sreejeshcs

New User


Joined: 28 May 2007
Posts: 31
Location: Pune

PostPosted: Thu Oct 12, 2017 7:26 am    Post subject: How to write Rexx program to size and line count
Reply with quote

hello,

We are migrating mainframe CSV file to Hadoop, I need help to write a Rexx Program which will read list file names from a input file and give output as file name , file size & number of lines to automate the validation. Input to this program is mainframe file names.

Thanks
Sreejesh Sreenivasan
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10374
Location: italy

PostPosted: Thu Oct 12, 2017 8:45 am    Post subject: Reply to: How to write Rexx program to size and line count
Reply with quote

Quote:
I need help


tell the level of Your Rexx knowledge
define the extent of help You need
Back to top
View user's profile Send private message
sreejeshcs

New User


Joined: 28 May 2007
Posts: 31
Location: Pune

PostPosted: Thu Oct 12, 2017 11:19 am    Post subject: I
Reply with quote

I have basic knowledge if someone can guide i can write the program.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1072
Location: Oostende, Belgium

PostPosted: Thu Oct 12, 2017 1:06 pm    Post subject:
Reply with quote

The deaf leading the blind...

What don't your organisation trust? FTP, MQ, Connect:Direct?

No, it's better to get a user with basic knowledge to knock up something that is unlikely to verify anything. Number of lines might stay the same in a transfer, but file-size will change, as every line will get a CR/LF added.

Please close this topic, it does not belong in a forum for experts!
Back to top
View user's profile Send private message
sergeyken

Active User


Joined: 29 Apr 2008
Posts: 227
Location: Maryland

PostPosted: Thu Oct 12, 2017 7:39 pm    Post subject: Re: How to write Rexx program to size and line count
Reply with quote

sreejeshcs wrote:
hello,

We are migrating mainframe CSV file to Hadoop, I need help to write a Rexx Program which will read list file names from a input file and give output as file name , file size & number of lines to automate the validation. Input to this program is mainframe file names.

Thanks
Sreejesh Sreenivasan

Based on your question, my impression is that your familiarity not only with REXX, but with Information Technology (i.e. "computers") as a whole, stopped at the level of computer games guru. Is this correct?
If so then you need (1) RTFM, (2) ask your boss about details of the job, (3) go to the beginner's forum.
Back to top
View user's profile Send private message
sreejeshcs

New User


Joined: 28 May 2007
Posts: 31
Location: Pune

PostPosted: Fri Oct 13, 2017 8:39 am    Post subject:
Reply with quote

below code is failing. from listfile i am able to read file name\. from the file name i am not able to read
Code:

do index = 1 to listfile.0
    csvfile = strip(listfile.index)
   
/* read input file */

    "execio * diskr csvfile (stem filecsv. fini"
    if rc \= 0 then do
      say 'error reading input csvfile.  RC =' rc
      exit 8
    end
    say filecsv.0 'records read from file' infile
    outindex = outindex + 1
    outfile.jdx = strip(listfile.index)','filecsv.0
end
Back to top
View user's profile Send private message
sreejeshcs

New User


Joined: 28 May 2007
Posts: 31
Location: Pune

PostPosted: Fri Oct 13, 2017 9:26 am    Post subject:
Reply with quote

Tried below option but i m getting below error. Can some one help ?


Code:
/* alocate csvfile  */
    "ALLOC FI(CSVDD) DA("csvfile") SHR REUSE"

Spool Output:

6 records read
6 datasets extracted
A.B.C.D
INVALID DATA SET NAME, A.B.C.D
MISSING DATA SET NAME OR *+
MISSING NAME OF DATA SET TO BE ALLOCATED
The input or output file CSVDD is not allocated. It cannot be opened for I/O.
EXECIO error while trying to GET or PUT a record.
error reading input file.  RC = 20
READY
END
Back to top
View user's profile Send private message
sreejeshcs

New User


Joined: 28 May 2007
Posts: 31
Location: Pune

PostPosted: Fri Oct 13, 2017 11:04 am    Post subject:
Reply with quote

Resolved the issue . Can some one help to find number of columns in a Tab delimited file in Rexx ?
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1932
Location: UK

PostPosted: Fri Oct 13, 2017 2:48 pm    Post subject:
Reply with quote

Please use the code tags when posting code, data and anything else that needs a fixed pitch font.

When asking for help to resolve a problem you should provide, not only the code, but the trace.

To find the number of tabs in a record read the record a byte at a time counting the number of tab characters. You may need to look at the data with HEX ON to determine what the EBCDIC code for tab is - or look up your reference card.

An alternative way would be to use PARSE.


EDIT: Perhaps a better way would be to use POS in a loop, counting how the times the tab character is found.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1072
Location: Oostende, Belgium

PostPosted: Sat Oct 14, 2017 3:07 pm    Post subject:
Reply with quote

sreejeshcs wrote:
below code is failing. from listfile i am able to read file name\. from the file name i am not able to read
Code:

do index = 1 to listfile.0
    csvfile = strip(listfile.index)
   
/* read input file */

    "execio * diskr csvfile (stem filecsv. fini"
    if rc \= 0 then do
      say 'error reading input csvfile.  RC =' rc
      exit 8
    end
    say filecsv.0 'records read from file' infile
    outindex = outindex + 1
    outfile.jdx = strip(listfile.index)','filecsv.0
end

Hadoop = Big Data
The idea is completely stupid, using EXECIO to count the number of lines in a file. Your support staff will be ever so happy if you do this with a few dozen files containing a few million records each.

Please close this thread, it does not belong on this forum, which is for experts, and not dimwits like this git abusing the title "software engineer"!
Back to top
View user's profile Send private message
steve-myers

Active Member


Joined: 30 Nov 2013
Posts: 587
Location: The Universe

PostPosted: Sun Oct 15, 2017 7:53 am    Post subject:
Reply with quote

sreejeshcs wrote:
...Can some one help to find number of columns in a Tab delimited file in Rexx ?
Meaningless. The tab character - if that is what you are using - is a single character which is interpreted as a tab character when the spreadsheet program reads the file and is used as a field separator. It is 1 character in the input, 1 character as transmitted, and 1 character in the file at the work station.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1827
Location: NY,USA

PostPosted: Mon Oct 16, 2017 10:53 am    Post subject:
Reply with quote

Wouldn't DFSORT a better choice , why REXX?
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1072
Location: Oostende, Belgium

PostPosted: Mon Oct 16, 2017 3:40 pm    Post subject:
Reply with quote

Nic Clouston wrote:
Please use the code tags when posting code, data and anything else that needs a fixed pitch font.

When asking for help to resolve a problem you should provide, not only the code, but the trace.

To find the number of tabs in a record read the record a byte at a time counting the number of tab characters. You may need to look at the data with HEX ON to determine what the EBCDIC code for tab is - or look up your reference card.

An alternative way would be to use PARSE.


EDIT: Perhaps a better way would be to use POS in a loop, counting how the times the tab character is found.

One single REXX statement will do it, and there are (at least) two of them.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10374
Location: italy

PostPosted: Mon Oct 16, 2017 4:04 pm    Post subject: Reply to: How to write Rexx program to size and line count
Reply with quote

Quote:
Can some one help to find number of columns in a Tab delimited file in Rexx ?


the definition of <number of columns> might get murky ...

each record might have different number of columns ( tabs/columns )
( emtpy columns at the end of the record might be missing - no separator stored )
Back to top
View user's profile Send private message
steve-myers

Active Member


Joined: 30 Nov 2013
Posts: 587
Location: The Universe

PostPosted: Mon Oct 16, 2017 10:36 pm    Post subject:
Reply with quote

Mr. Sorichetti is correct. Mainframe text editors (e.g. the ISPF editor) do not use tabs, at least within a data set.
Code:
****** ***************************** Top of Data ******************************
==MSG> -CAUTION- Data contains invalid (non-display) characters. Use command   
==MSG>           ===> FIND P'.' to position cursor to these                   
000001 ----+----1----+----2----+----3                                         
000002 124 122 256 9999                                                       
****** **************************** Bottom of Data ****************************

The blanks between the numbers are actually EBCDIC tab characters. Now I send the data set to a PC and display it with Windoze notepad, and I see it spread out like this -
Code:
----+----1----+----2----+----3
124     122     256     9999
Notepad obviously recognized the tab characters.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Looping REXX - unable to interrupt RAVISANKAR07 CLIST & REXX 3 Wed Dec 06, 2017 1:08 pm
No new posts The same REXX program doesnt work for... jackzhang75 CLIST & REXX 5 Wed Dec 06, 2017 2:51 am
No new posts ISMF Difference between volume count ... upendrasri IBM Tools 2 Tue Dec 05, 2017 12:40 pm
No new posts Rexx - File tailoring samzee71 CLIST & REXX 10 Thu Nov 30, 2017 10:47 pm
This topic is locked: you cannot edit posts or make replies. Rexx to Grab ISMF Information. upendrasri All Other Mainframe Topics 16 Sun Nov 26, 2017 12:35 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us