On 2021-01-12 16:12, Robert Prins wrote:
I'm currently using this...

I've posted the question to <https://ibmmainframes.com/viewtopic.php?t=68044>, and someone came up with a really very elegant way of performing this task, but his solution, unlike the one I posted in the start of this thread, cannot handle data in a legacy format, which is a must, as the code to look at older results automagically invokes sort to convert members that contain split (into chunks of 121 bytes) members into merged ones.

So I added some additional code that correctly processes the old data, but then I realised that instead of using my hack, it would be more useful to select a unique column in the second table that does not appear in the same format in the same place in the legacy data.

Fow what it's worth, and for those not willing to access the above post, the JCL I use is below:

//PRINOSOR JOB (PRINO),
//             'Test LW merge',
//             CLASS=A,
//             MSGCLASS=H,
//             MSGLEVEL=(2,0),
//             NOTIFY=&SYSUID
//*********************************************************************
//MERGELW EXEC PGM=SORT
//*
//SYSOUT    DD SYSOUT=*
//*
//SORTIN    DD DSN=&SYSUID..@@121.TEXT,  /* FB(121)
//             DISP=SHR
//*
//SORTOUT   DD SYSOUT=*
//*
//SYSIN     DD *
* Merge the LW file
*
* See: https://ibmmainframes.com/viewtopic.php?t=68044

  OPTION COPY
* --------------------------------------------------------------------
* Put '0120' in columns 364-367

  INREC IFTHEN=(WHEN=INIT,OVERLAY=(364:+120,ZD,LENGTH=4)),

* Whatever                       0120
* --------------------------------------------------------------------
* Test column 9 for '+' or '|' OR column 41 for '+' or '|'
* - copy 365 ('1') to 364
* - add seqno to 367, for two records

    IFTHEN=(WHEN=GROUP,BEGIN=(9,1,SS,EQ,C'+|',OR,41,1,SS,EQ,C'+|'),
      PUSH=(364:365,1,367:SEQ=1),RECORDS=2),

* T-1 / P-1                      1121
* T-1 / P-2                      1122
* --------------------------------------------------------------------
* Test column 44 for '+' or '|'
* - copy 366 ('2') to 364
* - add seqno to 367, for three records

*!! CHANGE 44 below to 80 and things go wrong!!

    IFTHEN=(WHEN=GROUP,BEGIN=(44,1,SS,EQ,C'+|'),
      PUSH=(364:366,1,367:SEQ=1),RECORDS=3),

* T-2 / P-1                      2121
* T-2 / P-2                      2122
* T-2 / P-3                      2123
* --------------------------------------------------------------------
* Test column column 367 for '1'
* - add columns 1-121 at column 122

    IFTHEN=(WHEN=GROUP,BEGIN=(367,1,ZD,EQ,+1),
      PUSH=(122:1,121)),

* Whatever                       0120
* T-1 / P-1 T-1 / P-1            1121
* T-1 / P-2 T-1 / P-1            1122
* Whatever  T-1 / P-1            0120
* T-2 / P-1 T-2 / P-1            2121
* T-2 / P-2 T-2 / P-1            2122
* T-2 / P-3 T-2 / P-1            2123
* Whatever  T-2 / P-1            0120
* --------------------------------------------------------------------
* Test column column 367 for '2'
* - add columns 1-121 at column 243

    IFTHEN=(WHEN=GROUP,BEGIN=(367,1,ZD,EQ,+2),
      PUSH=(243:1,121))

* Whatever                       0120  x 0...: 1,121
* T-1 / P-1 T-1 / P-1            1121
* T-1 / P-2 T-1 / P-1 T-1 / P-2  1122
* t-1 / P-1 t-1 / P-1 T-1 / P-2  1121  x 1..1: 122,1+1,121
* t-1 / P-2 t-1 / P-1 t-1 / P-1  1122
* Whatever  t-1 / P-1 t-1 / P-1  0120  x 0...: 1,121
* T-2 / P-1 T-2 / P-1 t-1 / P-1  2121
* T-2 / P-2 T-2 / P-1 T-2 / P-2  2122
* T-2 / P-3 T-2 / P-1 T-2 / P-2  2123  x 2..3: 122,121+243,121+1,121
* --------------------------------------------------------------------

  OUTFIL FNAMES=(SORTOUT),
    INCLUDE=((364,1,ZD,EQ,+0),OR,
             (364,1,ZD,EQ,+1,AND,367,1,ZD,EQ,+2),OR,
             (364,1,ZD,EQ,+2,AND,367,1,ZD,EQ,+3)),

    FTOV,VLTRIM=C' ',

    IFTHEN=(WHEN=(364,1,ZD,EQ,+0),BUILD=(1,121)),

    IFTHEN=(WHEN=(364,1,ZD,EQ,+1,AND,367,1,ZD,EQ,+2),
      BUILD=(122,121,1,121)),

    IFTHEN=(WHEN=(364,1,ZD,EQ,+2,AND,367,1,ZD,EQ,+3),
      BUILD=(122,121,243,121,1,121))

The input file (@@121.text) is included (I hope) as a plain-text (58 lines, no trailing spaces) attachment, or can be scraped from <https://ibmmainframes.com/viewtopic.php?t=68044&start=14> (with the JCL and expected output)

Paste it into an FB(121) dataset, paste the JCL, and submit it, and SYSOUT from SORT will show two merged tables, so far so good.

If you look at the input or, to make things a bit easier, the output, and then look at the second and third IFTHEN statements, the second tests for a '+'or '|' in columns 9 & 41, the third just checks for the same two characters in column 44.

I've not (yet) checked why the second IFTHEN uses two columns and the third IFTHEN only one column as the three columns checked are mutually exclusive, but...

column 44 is also present in the legacy data, so I thought, "Why not change that one into 80?" which is the next column in the second table that only contains '+' and '|', or even column 116?

Well, much to my surprise, or rather more to my horror, using column 80 does not work, the result is that table one does *NOT* appear at all in the output. And using column 116? Output is once again correct!

So what's so special about 80? 9, 41 and 44 are unique in the entire set of sort control statements, and 80 also doesn't appear, yet replacing 44 by 80 results in incorrect output.

I've gone over it again and again, but I'm totally clueless, unless this is one of those bugs that nobody's encountered before(*). So, if someone can confirm the problem, or that this is a case of Edgar Allan Poe's "The Purloined Letter", i.e. so obvious that it hides in plain sight, please reply to this post!

Thanks,

Robert

(*) In 2007,I found out that the Enterprise PL/I compiler (V3.5) would actually generate, IIRC, an

"IBM1997I S Internal compiler error: no WHEN clause satisfied within module 
name"

if a field in a based structure was initialised by a another variable squared as in "2 wtimesq fixed (9) init ((lift_list.wtime ** 2))"
--
Robert AH Prins
robert.ah.prins(a)gmail.com
The hitchhiking grandfather - https://prino.neocities.org/
Some REXX code for use on z/OS - https://prino.neocities.org/zOS/zOS-Tools.html

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN
1
 
+------+-------------------------------+-------------------------------+-------------------------------+----------------
---------------+-------------------------------+-------------------------------+-------------------------------+
 |      | Monday                        | Tuesday                       | 
Wednesday                     | Thursday
               | Friday                        | Saturday                      
| Sunday                        |
 |      
+----+---------+--------+-------+----+---------+--------+-------+----+---------+--------+-------+----+---------+-
-------+-------+----+---------+--------+-------+----+---------+--------+-------+----+---------+--------+-------+
 | Year | #D |      KM |   Time |    V= | #D |      KM |   Time |    V= | #D |  
    KM |   Time |    V= | #D |      KM |
  Time |    V= | #D |      KM |   Time |    V= | #D |      KM |   Time |    V= 
| #D |      KM |   Time |    V= |
 
+------+----+---------+--------+-------+----+---------+--------+-------+----+---------+--------+-------+----+---------+-
-------+-------+----+---------+--------+-------+----+---------+--------+-------+----+---------+--------+-------+
 | 1980 |  4 |  1049.2 |  12:23 |  84.7 |  2 |   355.0 |   4:02 |  88.0 |  2 |  
 260.0 |   2:50 |  91.8 |  1 |    77.0 |
  0:54 |  85.6 |  2 |   366.0 |   4:31 |  81.0 |  1 |   128.0 |   1:58 |  65.1 
|  1 |   746.0 |   7:06 | 105.1 |
 
+------+----+---------+--------+-------+----+---------+--------+-------+----+---------+--------+-------+----+---------+-
-------+-------+----+---------+--------+-------+----+---------+--------+-------+----+---------+--------+-------+
1
 
+-----+-----------------------------------+-----------------------------------+-----------------------------------+-----
------------------------------+-----------------------------------+-----------------------------------+------------------
-----------------+-----------------------------------+
 |     | Monday                            | Tuesday                           
| Wednesday                         | Thur
sday                          | Friday                            | Saturday    
                      | Sunday
                 | Total                             |
 |     
+------+----------+---------+-------+------+----------+---------+-------+------+----------+---------+-------+-----
-+----------+---------+-------+------+----------+---------+-------+------+----------+---------+-------+------+----------+
---------+-------+------+----------+---------+-------+
 | Day |    # |       KM |    Time |    V= |    # |       KM |    Time |    V= 
|    # |       KM |    Time |    V= |    #
 |       KM |    Time |    V= |    # |       KM |    Time |    V= |    # |      
 KM |    Time |    V= |    # |       KM |
    Time |    V= |    # |       KM |    Time |    V= |
 
+-----+------+----------+---------+-------+------+----------+---------+-------+------+----------+---------+-------+-----
-+----------+---------+-------+------+----------+---------+-------+------+----------+---------+-------+------+----------+
---------+-------+------+----------+---------+-------+
 |   1 |   27 |   4462.0 |   42:47 | 104.3 |   28 |   5466.2 |   53:48 | 101.6 
|   61 |   7389.2 |   67:51 | 108.9 |   35
 |   5004.6 |   44:29 | 112.5 |   59 |   7552.0 |   73:40 | 102.5 |   16 |   
1049.5 |   10:15 | 102.4 |   20 |   2878.4 |
   26:51 | 107.2 |  246 |  33801.9 |  319:41 | 105.7 |
 
+-----+------+----------+---------+-------+------+----------+---------+-------+------+----------+---------+-------+-----
-+----------+---------+-------+------+----------+---------+-------+------+----------+---------+-------+------+----------+
---------+-------+------+----------+---------+-------+
 | Tot |  971 | 119197.7 | 1119:08 | 106.5 | 1009 | 137611.1 | 1306:19 | 105.3 
|  871 | 119047.8 | 1109:28 | 107.3 |  673
 |  93883.3 |  915:33 | 102.5 |  650 |  77116.4 |  758:42 | 101.6 |  321 |  
38841.0 |  377:36 | 102.9 |  293 |  44228.8 |
  407:06 | 108.6 | 4788 | 629926.1 | 5993:52 | 105.1 |
 
+-----+------+----------+---------+-------+------+----------+---------+-------+------+----------+---------+-------+-----
-+----------+---------+-------+------+----------+---------+-------+------+----------+---------+-------+------+----------+
---------+-------+------+----------+---------+-------+

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to