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

Create table from List


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

New User


Joined: 12 Jul 2021
Posts: 2
Location: Netherlands

PostPosted: Mon Jul 12, 2021 4:37 pm
Reply with quote

I want to create a REXX to make a table overview of a list.
So input is like:
$AABAPPL A290 Active RacList
$AABAPPL A390 Active RacList
$AABAPPL FA00 Active RacList
$AESPDFA A390 Active
$AESPDFA FA00 Active
$AESPDFA T390 Active

Ouput like
A290 A390 FA00 T390
$AABAPPL AR AR AR
$AESPDFA A A A
Is there an easy way to do in REXX

Stan
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10803
Location: italy

PostPosted: Mon Jul 12, 2021 6:00 pm
Reply with quote

the output sample posted does not make any sense
did You mean something like

Code:

          A290  A390  FA00  T390
$AABAPPL  AR    AR    AR    --
$AESPDFA  --    A     A     A
Back to top
View user's profile Send private message
stanvanoers

New User


Joined: 12 Jul 2021
Posts: 2
Location: Netherlands

PostPosted: Mon Jul 12, 2021 6:17 pm
Reply with quote

Yes, that's the ouput I want to have.
It reformat my example.
Stan
Back to top
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1231

PostPosted: Mon Jul 12, 2021 7:37 pm
Reply with quote

There is no such function in REXX to do this job at one shot. You need to use a number of available REXX functions (there are multiple options), and to implement some processing logic using several REXX statements.

First of all, you must design an algorithm of actions: how you can reach your goal? When any algorithm is in your mind, it can be implemented using various tools, not only REXX.

REXX is not a sort of computer game with a red button “DO MY JOB”. Without available algorithm in your mind the job cannot be done using any tool…

One of important questions is: what is the expected size of your “list”, your “table”, and the number of possible different “columns” and “rows” in your table? The required algorithms can vary seriously depending on those amounts…
Back to top
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1231

PostPosted: Mon Jul 12, 2021 10:04 pm
Reply with quote

I have a ready solution in REXX, but do not plan to present it unless the TS has demonstrated at least his minor efforts to do first steps towards doing his job...
Code:
********************************* TOP OF DATA *****
           A290  A390  FA00  T390
---------- ----- ----- ----- -----
$AABAPPL   AR    AR    AR    --
$AESPDFA   --    A     A     A
---------- ----- ----- ----- -----
    End of table
******************************** BOTTOM OF DATA ***


The same can be achieved using any programming language, or even standard utilities, like SORT, FileAid, and 100500 of others.
The only problem is: to get familiar with creation of algorithms, not learning any programming language!

This is what to start with, if you really need REXX solution
Code:
/* REXX */

Table. = '--'
Names. = ''
Codes. = ''

"EXECIO * DISKR SYSIN (FINIS"
If RC /= 0 Then
   Exit 8

Do i = 1 By 1 While Queued() > 0
   Parse Pull Ident Code Status1 Status2 .
   Status = Status1 Status2
   . . . . . . . . . . . . . . .
End i

. . . . . . . . . . . . . . . . . .
Say Header
Say SubHeader
Do j = 1 By 1 While Names.j <> ''
   . . . . . . . . . . . . . .
   Say TableRow
End j

Say SubHeader
Say "    End of table"

Return 0

The only thing left, is to replace all '. . . . . . . . . .' lines with REXX statements to perform a reasonable algorithm. icon_lol.gif
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 512
Location: Denmark

PostPosted: Tue Jul 13, 2021 3:50 pm
Reply with quote

REXX do not have tables, it has stems (which are not arrays either). So you need to build some sort of stem structure, and format the report.
Here is a small sample showing one way to handle n number of applications and n number of devices. And I don't care whether TS has demonstrated at least minor efforts or not, we all learn from examples.

Code:
/* make sample data list */                                             
queue '$AABAPPL A290 Active RacList '                                   
queue '$AABAPPL A390 Active RacList '                                   
queue '$AABAPPL FA00 Active RacList '                                   
queue '$AESPDFA A390 Active         '                                   
queue '$AESPDFA FA00 Active         '                                   
queue '$AESPDFA T390 Active         '                                   
queue '$BBBAPPL FA00 RacList '                                         
/* make data stems */                                                   
appls=''                                                               
devs=''                                                                 
stat.='--  '                                                           
do queued()                                                             
  parse pull appl dev stat1 stat2                                       
  if stat1<>'' then stat.appl.dev=left(stat1,1) || left(stat2,1) || '  '
  if wordpos(appl,appls)=0 then appls=appls appl /* add unique word */ 
  if wordpos(dev,devs)  =0 then devs=devs dev    /* add unique word */ 
end                                                                     
/* report */                                                           
say '        'devs                                                     
do an=1 to words(appls)                                                 
  appl=word(appls,an)                                                   
  rec=left(appl,8)                                                     
  do dn=1 to words(devs)                                               
    dev =word(devs ,dn)                                                 
    rec=rec stat.appl.dev                                               
  end                                                                   
  say rec                                                               
end                                                                     

The code is really only suitable for smaller datasets, if you have a large number of applications and/or devices, then I suggest that you look at other options, preferably SAS if you have that.
Back to top
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1231

PostPosted: Wed Jul 14, 2021 7:00 pm
Reply with quote

Willy Jensen wrote:
REXX do not have tables, it has stems (which are not arrays either). So you need to build some sort of stem structure, and format the report.

Using character strings as REXX stem name parts is possible, but not recommended.
Besides of making the code difficult to understand, it is even dangerous when parts of (unpredicted!) input data are used directly as a stem's "indexes"; in this case the code might either fail, or produce wrong results if something is wrong in input data.

Even the simplest sample of this code is hard to understand:
Code:
/* REXX */

S. = 'N/A'

X = 'A'
Y = 'B'
Z = 'X'
T = 'Y'

Say "S.A.B = '"S.A.B"'"
S.X.Y = 'S.X.Y'
Say "S.X.Y = '"S.X.Y"'"
Say "S.A.B = '"S.A.B"'"

Say ""
Say "S.Z.T = '"S.Z.T"'"
S.Z.T = 'S.Z.T'
Say "S.Z.T = '"S.Z.T"'"

return 0

Code:
S.A.B = 'N/A'
S.X.Y = 'S.X.Y'
S.A.B = 'S.X.Y'

S.Z.T = 'N/A'
S.Z.T = 'S.Z.T'


To be on safe side, it is highly recommended to "translate" the character values (especially those taken from input data) into their numeric indexes. In this case no unexpected variable substitution is ever possible.
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 512
Location: Denmark

PostPosted: Thu Jul 15, 2021 3:16 pm
Reply with quote

I grant you that you must be very careful when using character strings as stem parts, but I haven't seen anywhere, offiicial at least, where it says not recommended. But yes it might bite you if you are not careful. As to being difficult to understand, well some us seems to be just fine with it.
You don't say how you would translate the character values, so here is a slightly modified sample, using the IMHO very unappreciated VERIFY function, where I add '0' to the front of the the stem parts.
Code:
do queued()                                                             
  parse pull appl dev stat1 stat2                                       
  if stat1<>'' then ,                                                   
   zz=Value('stat.0'appl'.0'dev,left(stat1,1) || left(stat2,1) || '  ')
  if wordpos(appl,appls)=0 then appls=appls appl /* add unique word */ 
  if wordpos(dev,devs)  =0 then devs=devs dev    /* add unique word */ 
end                                                                     
/* report */                                                           
say '        'devs                                                     
do an=1 to words(appls)                                                 
  appl=word(appls,an)                                                   
  rec=left(appl,8)                                                     
  do dn=1 to words(devs)                                               
    dev =word(devs ,dn)                                                 
    rec=rec Value('stat.0'appl'.0'dev)                                 
  end                                                                   
  say rec                                                               
end 
Back to top
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1231

PostPosted: Thu Jul 15, 2021 5:33 pm
Reply with quote

After all, the original problem was not in choosing the preferred style of coding, but in the initial inability of 99% of newcomers to develop any elementary algorithm, even a primitive one. The only way of thinking is: “click a button - and get the result”, no more than one step in mind!

Just presenting them a ready-to-use solution would not solve this nowadays basic problem…
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 REXX table content on panel will be r... CLIST & REXX 6
No new posts create table with more than 32k recor... DB2 1
This topic is locked: you cannot edit posts or make replies. COBOL-Common routine that contains al... COBOL Programming 4
No new posts LMDINIT/LIST/FREE Looping problem TSO/ISPF 12
No new posts Map VSAM Dataset to a Table/Tablespace DB2 5
Search our Forums:

Back to Top