IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Read file in Rexx using layout.


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
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
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: 8797
Location: Welsh Wales

PostPosted: Fri Sep 20, 2013 1:21 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Sep 20, 2013 1:27 pm
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
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

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Fri Sep 20, 2013 3:30 pm
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
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

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Fri Sep 20, 2013 3:48 pm
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
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: 2455
Location: Hampshire, UK

PostPosted: Fri Sep 20, 2013 4:36 pm
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

Moderator Emeritus


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

PostPosted: Fri Sep 20, 2013 6:51 pm
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: 765
Location: Whitby, ON, Canada

PostPosted: Fri Sep 20, 2013 7:04 pm
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

Global Moderator


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

PostPosted: Fri Sep 20, 2013 8:57 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sun Sep 22, 2013 3:17 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 2
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top