# Create table from List

Author Message
stanvanoers

New User

Joined: 12 Jul 2021
Posts: 2
Location: Netherlands

 Posted: Mon Jul 12, 2021 4:37 pm 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
enrico-sorichetti

Superior Member

Joined: 14 Mar 2007
Posts: 10838
Location: italy

Posted: Mon Jul 12, 2021 6:00 pm

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
stanvanoers

New User

Joined: 12 Jul 2021
Posts: 2
Location: Netherlands

 Posted: Mon Jul 12, 2021 6:17 pm Yes, that's the ouput I want to have. It reformat my example. Stan
sergeyken

Senior Member

Joined: 29 Apr 2008
Posts: 1650

 Posted: Mon Jul 12, 2021 7:37 pm 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…
sergeyken

Senior Member

Joined: 29 Apr 2008
Posts: 1650

Posted: Mon Jul 12, 2021 10:04 pm

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.
Willy Jensen

Active Member

Joined: 01 Sep 2015
Posts: 639
Location: Denmark

Posted: Tue Jul 13, 2021 3:50 pm

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.
sergeyken

Senior Member

Joined: 29 Apr 2008
Posts: 1650

Posted: Wed Jul 14, 2021 7:00 pm

 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.
Willy Jensen

Active Member

Joined: 01 Sep 2015
Posts: 639
Location: Denmark

Posted: Thu Jul 15, 2021 3:16 pm

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
sergeyken

Senior Member

Joined: 29 Apr 2008
Posts: 1650

 Posted: Thu Jul 15, 2021 5:33 pm 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…
 View Bookmarks All times are GMT + 6 Hours

 Topic Forum Replies Similar Topics list pds members name starting with xyz CLIST & REXX 11 List of quiesced jobs JCL & VSAM 3 COBOL - create and write to output fi... COBOL Programming 0 Best way to create an automated line ... TSO/ISPF 3 Read a flat file and update DB2 table JCL & VSAM 2
Search our Forums:

 IBMMainframes.com is not an official and/or affiliated with IBM® in anyway Board Rules | FAQ | Downloads | Wiki | SiteMap | Contact Us