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
 

 

Layout from the titles

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

New User


Joined: 16 Mar 2009
Posts: 55
Location: India

PostPosted: Fri Jul 15, 2011 5:41 pm    Post subject: Layout from the titles
Reply with quote

Hi,

I have a title records which is of length 13 and I need to write a layout in rexx.

For example,

Record of length - 133
Code:
 CLAIM NUMBER    CO LOSS IND


Layout
Code:
 01 WS-TITLE1.
       05  FILLER   PIC X(1) VALUE SPACES.
       05  WS-H1  PIC X(4)  VALUE 'CLAIM'.
       05  FILLER   PIC X(1) VALUE SPACES.
       05  WS-H2  PIC X(6)  VALUE 'NUMBER'.
       05  FILLER  PIC X(4) VALUE SPACES.
       05  WS-H3  PIC X(2) VALUE 'CO'
       05  FILLER   PIC X(1) VALUE SPACES.
       05  WS-H4  PIC X(4)  VALUE 'LOSS'.
       05  FILLER   PIC X(1) VALUE SPACES.
       05  WS-H5  PIC X(3)  VALUE 'IND'.
       05  FILLER   PIC X(106) VALUE SPACES.
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 Jul 15, 2011 5:52 pm    Post subject:
Reply with quote

Well done, off you go then, and thanks for letting us know.

If you have any questions, please feel free to ask them.
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 990
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Fri Jul 15, 2011 5:54 pm    Post subject:
Reply with quote

Quote:
and I need to write a layout in rexx.


Why? REXX does not use layouts. What you may be able to use is stem variables e.g.

Code:
WS-Title1.WS-H1
WS-Title1.WS-H2

etc.


Then you you either parse input into these stem variables or concatenate them (with appropriate spacing) into an output variable. REXX variables do not have attributes such as used in Cobol or PL/1.

Garry.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Fri Jul 15, 2011 5:56 pm    Post subject:
Reply with quote

Garry,
I guess the TS is trying to generate COBOL layout statements from a input string using REXX. But then, only TS knows exactly what he is trying to do.
Back to top
View user's profile Send private message
venkatatcts

New User


Joined: 16 Mar 2009
Posts: 55
Location: India

PostPosted: Fri Jul 15, 2011 6:10 pm    Post subject:
Reply with quote

Yes exactly. I need a help how to calculate filler when there is a space and length for each variable in rexx.

Thanks.
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 990
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Fri Jul 15, 2011 6:29 pm    Post subject:
Reply with quote

venkatatcts wrote:
Yes exactly. I need a help how to calculate filler when there is a space and length for each variable in rexx.

Thanks.


And still we have no idea what you are trying to achieve or why ! Are you inputting data to build a record or are you extracting data from a record?

The LENGTH function will tell you how many bytes the variable currently occupies. LEFT and RIGHT functions will allow you to extract data from the LEFT or RIGHT of a variable padding the result to a specified length. POS will give the position of a given value (e.g. space) in a variable...... The list goes on and on....

Garry.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Fri Jul 15, 2011 6:40 pm    Post subject:
Reply with quote

Hello,
Refer the string manipulation functions
LENGTH - to get the length of a string,
WORDS - to determine the number of words in a string,
WORD - to get a particular WORD from a string.
With these 3 functions and some looping based on the number of words on the string,and with some appending, the requirement could be done.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Fri Jul 15, 2011 11:53 pm    Post subject: Reply to: Layout from the titles
Reply with quote

edited to fix a glitch ( the TS did not BBCODE the sample string )
I mildly disagree icon_biggrin.gif
a smarter parsing is needed, WORD,WORDS and friends will ignore the spaces
but a trick with POS will fix it

since I am in a very very good good mood mood here is a snippet ,
most probably very dirty, since it was very quick icon_biggrin.gif

Code:
#!/opt/oorexx/bin/rexx
trace "O"
/*        1234567890123456789012345678901234567890 */
string = "CLAIM  CLAIM  NUMBER CO LOSS IND"
string = " CLAIM NUMBER    CO LOSS IND"
lrec = 133
leng = 0
offs01 = 7
offs05 = 10

stmt.1 = copies(" ",offs01) || "01 WS-TITLE"
stmt.0 = 1


f = 0 /* field number */
curr = 1
do  i = 1 to words(string)
    w = word(string,i)
    next = pos(w,string,curr)
    if  next > curr then do
        flen = next-curr
        leng = leng+flen
        s = stmt.0+1
        stmt.s = copies(" ",offs05) || "05 "left("FILLER",8) left("PIC X("flen")",10) "VALUE SPACES."
        stmt.0 = s
        curr = next
    end
    wlen = length(w)
    f = f + 1
    s = stmt.0+1
    stmt.s = copies(" ",offs05) || "05 "left("WS-H"f,8) left("PIC X("wlen")",10) "VALUE '"w"'."
    stmt.0 = s
    leng = leng + wlen
    curr = curr + length(w)
end
if lrec > leng then do
    s = stmt.0+1
    stmt.s = copies(" ",offs05) || "05 "left("FILLER",8) left("PIC X("lrec-leng")",10) "VALUE SPACES."
    stmt.0 = s
end

do  s = 1 to stmt.0
    say right(s,2) stmt.s
end

exit




and here is the result ( Your computations for the final filler were wrong icon_biggrin.gif )

Code:
 1        01 WS-TITLE
 2           05 FILLER   PIC X(1)   VALUE SPACES.
 3           05 WS-H1    PIC X(5)   VALUE 'CLAIM'.
 4           05 FILLER   PIC X(1)   VALUE SPACES.
 5           05 WS-H2    PIC X(6)   VALUE 'NUMBER'.
 6           05 FILLER   PIC X(4)   VALUE SPACES.
 7           05 WS-H3    PIC X(2)   VALUE 'CO'.
 8           05 FILLER   PIC X(1)   VALUE SPACES.
 9           05 WS-H4    PIC X(4)   VALUE 'LOSS'.
10           05 FILLER   PIC X(1)   VALUE SPACES.
11           05 WS-H5    PIC X(3)   VALUE 'IND'.
12           05 FILLER   PIC X(105) VALUE SPACES.


it takes into account also multiple spaces ...


tested on my mac using Object REXX,but since the snippet does not use anything platform specific, it will work also on TSO

if I have time tomorrow I might IPL zOS and test under TSO

if somebody asks why I provided the snippet...
I coded it instead of solving a crossword puzzle

but for what reason is not enough to code
Code:
01 WS-title.
   05 FILLER PIC X(1)   VALUE SPACES.
   05 FILLER PIC X(132) VALUE 'CLAIM NUMBER CO LOSS IND'.


I strongly suggest that everybody install on his/her PC object REXX
it is very handy for quick and dirty proofs of concepts
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Sat Jul 16, 2011 12:52 pm    Post subject:
Reply with quote

Quote:
WORD,WORDS and friends will ignore the spaces

I did not notice that the filler sizes were different.

The code above is slick.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Sat Jul 16, 2011 6:38 pm    Post subject: Reply to: Layout from the titles
Reply with quote

Quote:
I did not notice that the filler sizes were different.

in the sample posted the <words> were separated by one single space,
but since that is an uncommon situation in titles I was being proactive in providing a more general approach icon_biggrin.gif

the starting post was bbcoded for clarity and my snippet was abridged !
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1715
Location: UK

PostPosted: Sun Jul 17, 2011 7:41 pm    Post subject:
Reply with quote

To make it more general the desired record length should also be passed.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Sun Jul 17, 2011 9:17 pm    Post subject: Reply to: Layout from the titles
Reply with quote

Quote:
To make it more general the desired record length should also be passed.


when doing a proof of concept I rarely care to pass the parameters,
it' s boring to retype them every time a test is run! icon_cool.gif

furthermore while it might be simple to pass the lrecl for the title line,
not the same can be said for the string , parsing parms with multiple space
is not trivial for a newcomer!


but here is how to do it
Code:

 000008 Parse arg args                                                         
 ==CHG> strdel = left(args,1)                                                   
 000010 strstr = 2                                                             
 ==CHG> iif verify(strdel,"""'","M") = 0 then do                                     
 000012    say "no starting string delimiter"                                   
 000013    exit                                                                 
 000014 end                                                                     
 ==CHG> strend = pos(strdel,args,strstr)                                       
 000016 if strend = 0 then do                                                   
 000017    say "no ending   string delimiter"                                   
 000018    exit                                                                 
 000019 end                                                                     
 000020 strlen = strend - strstr                                               
 000021 string = substr(args,strstr,strlen)                                     
 000022 say length(string) ">>>"string"<<<"                                     
 000023 lrecl1 = strip(substr(args,strend+1))                                   
 000024 if lrecl1 = "" then lrecl1 = 133                                       
 000025 say lrecl1                                                             
 000026 exit                                                                   



tested and working ( at least it was before the cut and paste

for proper string handling must be invoked with
<rexxscriptname> 'a b c d e f' <lrecl>
<rexxscriptname> "a b c d e f" <lrecl>

anyway some care must be taken when writing scripts for different environments

under tso the apost's and the quotes are passed
so it is quite easy to determine a string argument
under unix like the apost' s and quotrs are not passed
and while the spaces are mantained all the pams are junked in one big string

so it is pretty complicated to pass more than one parameter

but for proper handling also the length of the title string should be tested agains the lrecl and the script failed if greater !
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Mon Jul 18, 2011 9:57 am    Post subject:
Reply with quote

Ahem.. ahem.. Someone seems to be in extremely good-mood streak (:
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 File comparsion - Records are in diff... Suganya87 COBOL Programming 11 Tue May 10, 2016 1:05 pm
No new posts JCL Utility in accordance to the copy... meetsupriyo JCL & VSAM 3 Tue Dec 08, 2015 8:46 pm
No new posts Selecting a redefined record layout i... mallik4u Compuware & Other Tools 1 Wed Oct 08, 2014 8:14 am
No new posts partially intializing values from a l... mohitsaini COBOL Programming 2 Thu Sep 11, 2014 9:23 am
No new posts Read file in Rexx using layout. Saini19 CLIST & REXX 12 Fri Sep 20, 2013 1:05 pm


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