Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Read file in Rexx using layout.

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

New User


Joined: 12 Apr 2012
Posts: 23
Location: Singapore

PostPosted: Fri Sep 20, 2013 1:05 pm    Post subject: Read file in Rexx using layout.
Reply with quote

Can we read a file with layout in REXX, similar to what we do with Copybook in COBOL module?

My requirement: I want to read a file in REXX and fetch certain fields from the same to perform certain processing (which can be considered as black box here in this discussion). However I want to make it auto-mated, in the sense that although I can also manually browse the copybook to know the offset/displacement of respective fields with 3.4 option and then edit my REXX accordingly, however I don't want to do it that way.

I want it to be done with the help from REXX so that this tool becomes independant of any hard-coded values, so that in case my copybook structure changes in future, I don't have to change REXX.

I have already tried using a combination of PARSE and SUBSTR to determine the lengths of fields, but my coding fails when COMP/COMP-3/VARCHAR are encountered.

Any suggestion/advice are welcomed. Please let me know if anything was not clear here.
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Sep 20, 2013 1:21 pm    Post subject:
Reply with quote

WOW, your coding fails. That was useful.
Why does it fail, what errors are you getting, where is your code. Have you ran trace ?

Psychic day was Wednesday this week icon_rolleyes.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Fri Sep 20, 2013 1:27 pm    Post subject: Reply to: Read file in Rexx using layout.
Reply with quote

how do You plan to provide the LAYOUT ?

PARSE will just split the input string into tokens,
after that You will have to process each variable according to the format

the info needed is at least
position, length, format

without using parse
You will need something along the lines of ...

Code:

...
...
...

pos.1 = 1
len.1 = 4
fmt.1 = "C"

pos.2 = 12
len.2 = 4
fmt.2 = "B"

...
...
...

out = ""
do i = 1 to number_of_fields
    select
        when fmt.i = "C" then do
            out = out || substr( rec, pos.i, len.i)
        end
        when ...
        end
        when ...
        end
end


and You will have simply to change the format table

for char data the process is obvious.,
the same for binary data

for processing PACKED data search the forum for my working snippets
Back to top
View user's profile Send private message
Saini19

New User


Joined: 12 Apr 2012
Posts: 23
Location: Singapore

PostPosted: Fri Sep 20, 2013 3:13 pm    Post subject: Reply to: Read file in Rexx using layout.
Reply with quote

Enrico - we are on same lines. I have done the same thing only as you are thinking, which as I said earlier is not actually working for packed/varchar fields.

Expat - I'm sure this ain't English language forum and I was pretty clear on my topic details as others understood it well.
Back to top
View user's profile Send private message
prino

Active Member


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

PostPosted: Fri Sep 20, 2013 3:30 pm    Post subject: Re: Reply to: Read file in Rexx using layout.
Reply with quote

Saini19 wrote:
Enrico - we are on same lines. I have done the same thing only as you are thinking, which as I said earlier is not actually working for packed/varchar fields.


And why the fluffing 'ell do you keep repeating "is not working"???

Tell us what is not working!
Back to top
View user's profile Send private message
Saini19

New User


Joined: 12 Apr 2012
Posts: 23
Location: Singapore

PostPosted: Fri Sep 20, 2013 3:42 pm    Post subject: Reply to: Read file in Rexx using layout.
Reply with quote

REXX will never understand packed/varchar fields the way COBOL does. Even if we PARSE, it will still consider the value inside PIC to calculate length, but that is not the case with packed/varchar fields.

I hope now it is clear what is not working, if it wasn't earlier.
Back to top
View user's profile Send private message
prino

Active Member


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

PostPosted: Fri Sep 20, 2013 3:48 pm    Post subject: Re: Reply to: Read file in Rexx using layout.
Reply with quote

Saini19 wrote:
REXX will never understand packed/varchar fields the way COBOL does. Even if we PARSE, it will still consider the value inside PIC to calculate length, but that is not the case with packed/varchar fields.

I hope now it is clear what is not working, if it wasn't earlier.

No, you still haven't told us why it isn't working. REXX is perfectly capable of handling any type of data you throw at it. Hell, I've got what you need, but for PL/I copybooks, and my REXX code can handle the equivalent of any COBOL COMP-x type, and if I really wanted it, I could easily add a routine to handle such exotic things as PL/I AREA's.

It's obvious that you cannot be bothered to search the forum to look for the snippets that have been posted to handle COMP-x and VARCHAR.
Back to top
View user's profile Send private message
Saini19

New User


Joined: 12 Apr 2012
Posts: 23
Location: Singapore

PostPosted: Fri Sep 20, 2013 3:58 pm    Post subject: Re: Reply to: Read file in Rexx using layout.
Reply with quote

prino wrote:
It's obvious that you cannot be bothered to search the forum to look for the snippets that have been posted to handle COMP-x and VARCHAR.


You never know what I would have searched by now, so stop assuming and carry on.

And yes, before I close the topic from my end with You, I would suggest You to mature, and reply only with solutions rather than telling the World what you have with you without sharing.

Period.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1713
Location: UK

PostPosted: Fri Sep 20, 2013 4:36 pm    Post subject:
Reply with quote

Why should he share - it is HIS work. What he did share was that it is perfectly possible but without you showing a sample of what your code is and what precisely went wrong no other precise help can be given.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Sep 20, 2013 6:51 pm    Post subject:
Reply with quote

Hello,

Rather than complaining about the replies posted, you need to actually post what has been asked for . . .

If you cannot or will not post the bit of code that fails and tell why it failed (it didn't work is Not why), it may be impossible to help you.

If you have not, run a trace and post the result of the trace along with the code you excecuted.
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 641
Location: Whitby, ON, Canada

PostPosted: Fri Sep 20, 2013 7:04 pm    Post subject:
Reply with quote

When faced with this task in the past, I opted for the simple expedient of writing a Rexx program to convert the Cobol copybook to an equivalent series of Rexx SUBSTR commands, with function calls to handle packed data. I then cut and pasted the generated code into the Rexx program that was reading the data.

Not very dynamic, but it did the job.
Back to top
View user's profile Send private message
Pedro

Senior Member


Joined: 01 Sep 2006
Posts: 2019
Location: Silicon Valley

PostPosted: Fri Sep 20, 2013 8:57 pm    Post subject: Reply to: Read file in Rexx using layout.
Reply with quote

Quote:
Psychic day was Wednesday this week

I had premonitions of it on Monday and Tuesday. icon_lol.gif

Quote:
I'm sure this ain't English language forum

This is a technical forum. You will get better results if you post sample code, sample data, and an explanation of what you intended and what you got. And a trace. It is not clear why you resist.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Sun Sep 22, 2013 3:17 pm    Post subject: Reply to: Read file in Rexx using layout.
Reply with quote

Quote:
which as I said earlier is not actually working for packed/varchar fields.

icon_eek.gif

Quote:
for processing PACKED data search the forum for my working snippets


You did not care to tell how to provide the layout ...
You did not care to search the forum on how to unpack things

in addition for numeric fields
You should add to the info provided for the input structure
also the mask/picture/format for the output numeric fields

for varchar fields You need to tell us how they are implemented in Your records
unless You just mean to strip the trailing x'40' or trailing x'00'

whining it does not work is just wasting the time of the people who try to help You icon_evil.gif
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 Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us