0

INPUT:

MEMBER:XPTO1
STEPALT2
MEMBER:XPTO2
MEMBER:XPTO3
STEPALT3STEPALT VERIFY
VERIFY2
MEMBER:XPTO4
VERIFY1 VERIFY02A01STEP

OUTPUT:

 MEMBER:XPTO1   STEPS:STEPALT2
 MEMBER:XPTO3   STEPS:STEPALT3 STEPALT  VERIFY  VERIFY2
 MEMBER:XPTO4   STEPS:VERIFY1  VERIFY02 A01STEP

or

OUTPUT2:

 MEMBER:XPTO1   STEPALT2
 MEMBER:XPTO3   STEPALT3 STEPALT    VERIFY  VERIFY2
 MEMBER:XPTO4   VERIFY1  VERIFY02 A01STEP

Know fact: Each member name or step name can have a maximum of 8 characters How can i do this with REXX?

Bill Woodger
  • 12,968
  • 4
  • 38
  • 47
csbl
  • 265
  • 1
  • 6
  • 19
  • Whack them into a stem-variable which you use and reset on change of "key" (which is the arrival of a record with "MEMBER:"). When using, print your appropriate text before the first and second entries, then just squirt out the rest. – Bill Woodger Apr 13 '16 at 15:44
  • How did this get an upvote? – Bill Woodger Apr 13 '16 at 15:46
  • Then I should use something like: IF curr_Key \== prev_Key THEN DO /* do something */ curr_Key = prev_Key end ? – csbl Apr 13 '16 at 16:55
  • 1
    No, the "key" is when the first field on your current record is "MEMBER:" in the first seven positions. You then process any previous records (so watch out for first time) and reinitialise. As you get the next records, which aren't "MEMBER:", store each successive length of eight (until spaces or nothing or whatveer) in the next "by count" in the stem-variable. That'll deal with multiple records as part of the "group", Remember to output the data for the last group when you finish with the input. – Bill Woodger Apr 13 '16 at 19:53
  • You should show us what you have tried. SO isn't here to write the code for you. – harald Apr 14 '16 at 07:42
  • I have not asked anyone to write the code for me. Just for a guideline, which I got from Bill, so I do not understand your post. According to your logic I should not write the code here for in that case, according to you, it would be writing the code for someone else. – csbl Apr 14 '16 at 14:33
  • Thank you for your help Bill. – csbl Apr 14 '16 at 14:35

1 Answers1

2

This may be of use, it should detect when a new member has been located.

IF SUBSTR(mydata,1,7) = "MEMBER:" THEN DO
  your code here to extract member data
END
ELSE DO
  your code to handle input that doesn't include a member
END

Note I don't have the means to run and check this, so treat it as a guide. Also mydata is the current line of input data

As per comment I found some Rexx. Here's one that shows EXECIO and compound variables being used to process input data (Note that this is designed to be run in batch with //INPUT01 DD inputdataset,DISP=SHR for the input data).

Here's the Code :-

 /* REXX - OPCDLYMN                                                    */0000100
 /*--------------------------------------------------------------------*/0001000
 /* OPC/ESA Log Monitor                                                */0002000
 /*--------------------------------------------------------------------*/0003000
 OPCDLYMN:                                                               0003100
    rec_count = 0                                                        0003200
    Do Forever                                                           0004000
       "EXECIO 1 DISKR INPUT01 (STEM In.)"                               0004100
       If rc ¬= 0 Then Leave                                             0004200
       rec_count = rec_count + 1                                         0004300
       If Substr(in.1,17,8) = "EQQE007I" Then Do                         0004400
          eqqe007i_typ = Substr(in.1,26,4)                               0004420
          eqqe007i_dly = Strip(Substr(in.1,83,9))                        0004430
          eqqe007i_day = Substr(in.1,2,2)                                0004440
          eqqe007i_mon = Substr(in.1,5,2)                                0004450
          eqqe007i_dat = eqqe007i_day"/"eqqe007i_mon                     0004460
          eqqe007i_tim = Substr(in.1,8,8)                                0004470
          eqqe007i_hr  = Substr(eqqe007i_tim,1,2)                        0004480
          eqqe007i_min = Substr(eqqe007i_tim,4,2)                        0004490
          eqqe007i_sec = Substr(eqqe007i_tim,7,2)                        0004500
          If eqqe007i_typ = "ALL " Then do                               0004520
             Say Right(eqqe007i_dly,9)" delays on "eqqe007i_dat||,       0004540
              " at "eqqe007i_tim                                         0004550
          End                                                            0004560
       End                                                               0004600
    End                                                                  0005000
    Say "End of processing "rec_count" records processed"                0006000

In. is the STEM IN.1 is a compound variable, based upon the stem.

Note you can use "EXECIO * DISKR INPUT01 (STEM in.)", which would read in all data (I think In.0 would then hold the count and In.1, In.2... to nn (where nn is, I think, the value held by in.0)). However, this can(could) result in memory issues. Hence, why I generally read in individual lines.

Note In If rc ¬= 0 Then Leave the character before = (ie ¬) is not always available (mainly UK keyboards I think). Instead you can use /= (NOT EQUALS).

So this program reads in all the data line by line until there is no more (rc is set by EXECIO to non-zero. if there is an error such as end of data).

rec_count is incremented so records the number of records read.

If the 17th to 24th characters are EQQE007I then the lines is further processed, otherwise another iteration of the DO Loop is started.

The procsessing undertaken then is similar in that various parts of the input line are extracted. If ALL (with a following space) exists at character 26-29 then information is out via Say (goes to SYSOUT or SYSPRINT if I recall correctly).

If you adapt this, then you'd likely need to make a copy of the current line for comparison in the next iteration.

Final Note the 7 numerics to the right of each line aren't part of the code.

MikeT
  • 51,415
  • 16
  • 49
  • 68
  • There are some "open source" rexx implementations that you can use on your PC. People have opinions about which is better for them, so just do a bit of research to see what fits best to what you'd like. You've typoed the first line (length, location of closing of literal). Something on the use of a stem would be good to include. – Bill Woodger Apr 15 '16 at 08:24
  • @Bill I'm aware but I very much doubt that I'll be writing Rexx again, so I don't see a need. However, as I professionally used Rexx amongst other things for something like 20 years. I feel that I can give pointers at least. What I may do is try to find if I still have any of the code that I wrote (it's been close to 7 years now). I assumed, as the question wasn't about how to read the input, that **EXECIO** and thus perhaps stems were used or known about. – MikeT Apr 16 '16 at 07:17
  • @Bill, sheesh you forced me to go and look for some code :) – MikeT Apr 16 '16 at 08:34
  • Thank you Mike! That helped! I noticed that I had forgotten to say that to you! – csbl Mar 01 '17 at 16:37