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

Want to make tool on REXX


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
deepak khera

New User


Joined: 07 Jan 2009
Posts: 4
Location: chennai

PostPosted: Sat Mar 07, 2009 11:27 am
Reply with quote

I want to make a tool on REXX which can copy the data present on host or transfer the data(code) present in member of PDS in mainframe into a word document form or notepad. Alternatively we follow a lenghty process as shown in attachment.
I am a beginner in REXX so need help.Please guide me.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sat Mar 07, 2009 11:59 am
Reply with quote

Hello,

You can create a text fle on the mainframe that may be easily downloaded to the pc. This will not be in WORD format (or any other like Excel). It will just be a .txt file.

The downloaded .txt file may be opened by any of the Windows applications. If the text file has been created with delimiters, it will open very nicely in excel.
Back to top
View user's profile Send private message
prino

Senior Member


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

PostPosted: Sat Mar 07, 2009 12:25 pm
Reply with quote

It's very easy to create basic RTF documents on the mainframe, here's a very short example of one that has all the tags that you really need, paste it into a TEXT editor on the PC, save it as 'whatever.rtf' and it will open in about any word-processor

Code:
{\rtf1\ansi\deff0
{\fonttbl
{\f0\fmodern\fcharset0\fprq1 Courier New;}}
\paperw11907\paperh16840\margl851\margr851\margt851\margb851\pard\plain\sl-180\slmult0\fs18
{
{\b For a new trip:\par}
\par
 o if mod(tripno, 10) = 1\par
   - allocate new output library\par
\par
 o getvar('}{\b textRAHP}{') -> Manual\par
   - PCxxxx   - update with PC generated versions\par
   - PCWxxxx  - update with PC generated versions\par
\par
 o getvar('}{\b execRAHP}{') -> EHHUEXEC (Member) / BHHUEXEC (All, batch)\par
   - REXXDATE - add new LLnn/LSnn/LTnn entries\par
   - REXXDATL - add line t.nn with date/time for new trip\par
\page
 o getvar('}{\b diffRAHP}{')\par
   - L?nn     - run PLI(RUN2PDS) (File: TRnn)\par
\par
 o getvar('}{\b diffRAHP}{') -> EHHUDIFF (Member) / BHHUDIFF (All, batch)\par
   - CHG01#NN - add entries for new trip\par
   - DEL01#NN - add entries for new trip\par
   - $$$INDEX - add entries for new LLxx/LSxx/LTxx\par
   - $$$INDEZ - add entries for new LLxx/LSxx/LTxx\par
}}


If you load the .RTF in Macro$atan's Word and save it without even touching it, this one will more than quadruple in size, by filling it with truckloads of completely unnecessary tags. The essential one in this file are the first four, the RTF header, font table and dimensions, a \par tag at the end of each paragraph (or a \page) and text enclosed in {\b ... } groups to be bolded. (or {\i to... italicize, {\b\u\ to bold and underline.

Creating this kind of very simple files on the mainframe is a doddle, if you don't require any formatting, just plonk the first five lines at the top of your text, a \par at the end of each line and '}}' at the end. Transfer to the PC and you've got a valid .RTF document. Experiment with other small RTF documents to see how to change fonts, text sizes etc.
Back to top
View user's profile Send private message
prino

Senior Member


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

PostPosted: Sat Mar 07, 2009 12:55 pm
Reply with quote

Creating something that loads into a spreadsheet is either very simple, just separate your columns with ',' or whatever your locale considers the 'c' in csv and load it into any program that handles these things.

However, it is a not very well known fact that Macro$atan's product can also load CSV files with embedded formulae. To create one of these files, you will have to keep track of columns (and if you want to make matters really complex, rows). Here is a short example I found. I no longer have the file it operated on, but by creating a file with the necessary element at the positions this piece of code does it's substr's might give you some clues.

Code:
/* REXX */
arg infile
"alloc f(in) da("infile") shr reu"
'execio * diskr in ( stem in. finis'
"free f(in)"

out.1 = 'post_no,ac_type,' ||,
        'bill_ccy,bill_amt,bank_ccy,bank_amt,link,' ||,
        'trans_ref,1'

p = 1
q = length(out.1) + 4
i = 1

do while i <= in.0
  tref  = substr(in.i, 3, 12)
  tp    = p + 1

  links = ''
  bill. = 0
  bank. = 0

  do while i   <= in.0 &,
           tref = substr(in.i, 3, 12)
    pono = substr(in.i, 15, 3)
    pp   = p + 1

    do while i   <= in.0 &,
             tref = substr(in.i,  3, 12) &,
             pono = substr(in.i, 15,  3)
      p     = p + 1
      out.p = substr(in.i,  15,  3)',' ||,           /* A posting no  */
              substr(in.i,  34,  1)',' ||,           /* B a/c type    */
              substr(in.i,  39,  3)',' ||,           /* C billing ccy */
              substr(in.i,  42, 16)',' ||,           /* D billing amt */
              substr(in.i,  58,  3)',' ||,           /* E banking ccy */
              substr(in.i,  61, 16)',' ||,           /* F banking amt */
              substr(in.i, 352,  4)',' ||,           /* G link        */
              substr(in.i,   3, 12)',' ||,           /* I reference   */
              p','                                   /* sequence no   */
      q = max(q, length(out.p) + 4)

      l = substr(in.i, 352, 4)
      if pos(l, links) = 0 then
        links = links || l || '.'

      bill.l = bill.l + strip(substr(in.i, 42, 16))
      bank.l = bank.l + strip(substr(in.i, 61, 16))

      i      = i + 1
    end

    p     = p + 1
    out.p = ',' ||,                                              /* A */
            ',' ||,                                              /* B */
            ',' ||,                                              /* C */
            '=sum(D'pp':D'p - 1'),' ||,                          /* D */
            ',' ||,                                              /* E */
            '=sum(F'pp':F'p - 1'),' ||,                          /* F */
            ',' ||,                                              /* G */
            ',' ||,                                              /* H */
            p','                                                 /* I */
    q     = max(q, length(out.p) + 4)
  end

  do ? = tp to p while links \= ''
    l     = substr(links, 1, 4)
    links = substr(links, 6)

    do ! = ? to p until match
      match = l = substr(out.!, 49, 4)
    end

    out.! = out.! || l','bill.l','bank.l','

    q = max(q, length(out.!) + 4)
  end
end

"del excel.csv"
"alloc f(out) da(excel.csv) " ||,
                    "new reu " ||,
                    "space(30, 60) " ||,
                    "recfm(v b) lrecl("q") " ||,
                    "blksize(0) release"
'execio * diskw out ( stem out. finis'
"free f(out)"


Don't ask me how this worked, I wrote it in 2003, as an Q&D help for an analyst who wanted to verify some conversion output. In a more elaborate version I once wrote years earlier I actually converted packed numerical values to readable ones, code for that is something like

Code:
tmp = substr(dat.i, offset, $len % 2 + 1)
tmp = right(c2x(tmp), $len + 1)
if $prc \= 0 then
  tmp = substr(tmp, 1, $len - $prc) ||,
        '.' ||,
        substr(tmp, $len - $prc + 1)

select
  when substr(tmp, length(tmp)) = 'C' |,
       substr(tmp, length(tmp)) = 'F' then
    tmp = '+' || tmp

  when substr(tmp, length(tmp)) = 'D' then
    tmp = '-' || tmp

  otherwise
    do
      tmp    = "x'"substr(dat.i, offset, $len % 2 + 1)"'"
    end
end
Back to top
View user's profile Send private message
deepak khera

New User


Joined: 07 Jan 2009
Posts: 4
Location: chennai

PostPosted: Sun Mar 08, 2009 1:04 am
Reply with quote

Hi Prino,

Thanks for your reply.
But I have a small request I am not able to understand the exact idea of your given example even the terms used by you like( RTF documents,TEXT editor, .RTF in Macro$atan's Word) are not very much clear to me. As I am beginner so if you can explain me in a bit easier way it will be helpful for me.

Regards,
Deepak
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sun Mar 08, 2009 1:38 am
Reply with quote

Hello,

RTF is "rich text format" it is a data formatting protocol that is supported by many Windows applications (like e-mail and the ms-office products). If you are working on a mainframe via a 3270-type terminal connection (which is the most likely), you cannot use data in rich text format). The typically 24x80 screen uses one standard character per position and is not selectable within the data.

A TEXT editor is a program that allow the user to edit text data (notepad is a text editor). So is EDIT in tso/ispf.

Macro$atan's Word is slang for Microsoft Word.
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Sun Mar 08, 2009 12:52 pm
Reply with quote

dick,

As prino said, converting a textual dataset to RTF is pertty easy. We do that when e-mailing reports from the mainframe to managers.

RTF reference is free to download and it is pretty easy to understand.

O.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sun Mar 08, 2009 1:45 pm
Reply with quote

Hi O,

Quote:
As prino said, converting a textual dataset to RTF is pertty easy.
yup, it is. Similar to embedding pcl escape sequences in a report so that a form can be generated "on the fly" from the mainframe. I'd not do either if this was the first attempt to download data and use it cross-platform.

I just wanted to make sure that Deepak understood that the rtf formatted data would not be visable on the mainframe screen.
Back to top
View user's profile Send private message
deepak khera

New User


Joined: 07 Jan 2009
Posts: 4
Location: chennai

PostPosted: Sun Mar 08, 2009 6:09 pm
Reply with quote

Thanks Dick for giving explanation of the terns but my problem is still unresolved.
I have to create a code on RExx which can serve the purpose of transferring a piece of code present on host or mainframe to a .txt file(as a from of back-up).
The above example given by Prino is not clear to me. It will be help if anyone of you can provide me the algorithm, how to proceed?
What are things required when you are making a tool on Rexx.An exaple will solve the purpose.


Regards,
Deepak
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Sun Mar 08, 2009 7:16 pm
Reply with quote

deepak khera wrote:
What are things required when you are making a tool on Rexx.


It would help if you would outline your intended process specifically. What is the process flow? What are the input and output? What environments are involved? Where will the process execute? Are you using existing commands and programs and utilities, or is this something new that you're designing from scratch?

Your stated objective:

Quote:

I have to create a code on RExx which can serve the purpose of transferring a piece of code present on host or mainframe to a .txt file(as a from of back-up).


doesn't mean much to probably anyone but you.
Back to top
View user's profile Send private message
prino

Senior Member


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

PostPosted: Sun Mar 08, 2009 7:50 pm
Reply with quote

deepak khera wrote:
olved.
I have to create a code on RExx which can serve the purpose of transferring a piece of code present on host or mainframe to a .txt file(as a from of back-up).


Making backup files from mainframe data sets on a PC, wow, can you please tell us the brand of PC, I never though I'd see the day when PCs became more reliable than mainframes...
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sun Mar 08, 2009 11:25 pm
Reply with quote

Hello,

Quote:
I have to create a code on RExx which can serve the purpose of transferring a piece of code present on host or mainframe to a .txt file(as a from of back-up).
That is what you've chosen as the solution to your requirement. If you post the actual requirement (rather than a possible solution) someone may have an alternative to suggest.

In general there are 3 "pieces" needed to do what you want.
1 - from the full mainframe data (database, vsam, other file) create a file to download. This might be text only or text with delimiters. It will contain no binary or packed decimal data - only text.
2 - transfer the file fro the mainframe to the destination (typically ftp or ndm). EBCDIC to ASCII conversion should be automatic.
3 - read/import the downloaded file into the pc application.

Notice there is no mention of rexx here.
Back to top
View user's profile Send private message
dharmendra_kp

New User


Joined: 10 Mar 2005
Posts: 33
Location: Lewiston

PostPosted: Mon Mar 09, 2009 1:58 pm
Reply with quote

[I have to create a code on RExx which can serve the purpose of transferring a piece of code present on host or mainframe to a .txt file(as a from of back-up).
]

I don't think you need a REXX tool to transfer few hundred souce files from a minframe to PC. I thing you can do it manually using group FTP ('mget'). [/quote]
Back to top
View user's profile Send private message
deepak khera

New User


Joined: 07 Jan 2009
Posts: 4
Location: chennai

PostPosted: Mon Mar 09, 2009 3:03 pm
Reply with quote

I make my question more specific, I want to prepare a tool on REXX which has following requirements
1) It should be able to transfer, suppose, a cobol code present in a member of a PDS to a notepad(plain).
2) It will run in mainframe environment. OS is Z/OS.

I thought of this idea as I used to follow process in which I used to go through command 6 of ISPF menu and then from the option menu I do batch transfer files and then provide the source(host) and destination(desktop or any drive on PC) address and other requisite. I found it to be lenghty proess so thought making it easier by making a tool. Please see the above attchement.I was not sure how to proceed so I thought of taking help from you people.

I would like to answer to Prino surprise, my purpose of mentioning word "back-up" is just for refernece.[/u]
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Mon Mar 09, 2009 7:14 pm
Reply with quote

Hello,

If you want to take some existing source members from a pds on the mainframe, the easiest way to do this is to use the tcp/ip software already installed on your desktop.

You would use the ftp function, log onto the mainframe, change directory into the pds (a pds may be viewed as a directory in ftp) for the remote file, change into the local directory where you want to store the files, click/select some or all of the members you want to download, and download.

You will not want to try to write code on the mainframe to "send" the files to your desktop via ftp. Your desktop is not set up as an ftp server (most likely) and to send files from the mainfrme, the mainframe process must connect to an ftp server. Your desktop is most likely a client rather than a server.
Back to top
View user's profile Send private message
Pedro

Global Moderator


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

PostPosted: Mon Mar 09, 2009 9:40 pm
Reply with quote

Why don't you just use the z/OS facilities for backing up files?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Mon Mar 09, 2009 9:48 pm
Reply with quote

Because then they are not portable. . . icon_wink.gif
Back to top
View user's profile Send private message
bhagyac

New User


Joined: 17 Apr 2008
Posts: 44
Location: bangalore

PostPosted: Tue Nov 23, 2010 4:30 pm
Reply with quote

Hi Dick,

need some clarification on "tcp/ip software". I didnot understand, which software u are referring to. Please help.

Thank you.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Tue Nov 23, 2010 10:00 pm
Reply with quote

Hello,

Quote:
need some clarification on "tcp/ip software". I didnot understand, which software u are referring to.
It is most likely that your mainframe terminal eumlator is connceted to the mainframe via tcp/ip.

If you are not sure of how things are connected in your environment, you should talk with your desktop or network support people to learn what is available on your system.
Back to top
View user's profile Send private message
Pedro

Global Moderator


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

PostPosted: Wed Nov 24, 2010 2:03 am
Reply with quote

Deepak had said:
Quote:
I used to go through command 6 of ISPF menu and then from the option menu I do batch transfer files and then provide the source(host) and destination(desktop or any drive on PC) address and other requisite.


It is not clear what he refers to, but does not sound like the normal FTP.

You may be able to do what you want by utilizing ISPF's WSA client, which you can download from ISPF option 3.7. After starting WSA, then from rexx, you can use:

1. WSCON service to connect to WSA
2. EDIT WSFN(ws-filename) MACRO(mymac) to open a new workstation file. Do #2 in a loop to get all of your files.
3. write a 'mymac' editor macro that copies from z/OS file and saves and exits.
4. WSDISCON


This will work for a small number of files, but I do not recommend for larger numbers.

The benefit of this approach is that you do not need an FTP server on your workstation and that you can run the process from the z/OS side.

Warning: if you are doing this for backup purposes, you also need to have a process in place to recover a dataset from a backup copy.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed Nov 24, 2010 2:47 am
Reply with quote

Hello,

No, this is most likely not ftp. . .

Long ago "the way" to transfer files from the mainframe to the pc was using "IND$FILE" - which was available via ISPF Option 6 - Command.

Many sites no longer permit use of this. . .
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 Run rexx with JCL Job CLIST & REXX 1
No new posts Run rexx in batch job CLIST & REXX 7
No new posts Does anyone know rexx for VSE CLIST & REXX 3
No new posts TSO ALLOC In REXX Needs Improvement JCL & VSAM 3
No new posts REXX/CMS How to place command console... CLIST & REXX 4
Search our Forums:

Back to Top