Quantcast
Channel: IBM Mainframe Computers Forums
Viewing all articles
Browse latest Browse all 9405

CLIST & REXX :: RE: Need to code a Rexx PGM

$
0
0
Author: daveporcelan
Posted: Thu Oct 06, 2016 10:55 pm (GMT 5.5)

Quote:
Why REXX?


Rexx is by far easier to code in the Cobol.

To get the OP on the right track...

Allocate input file
Use EXECIO to read input file into Stem variable INREC. (for example)
Set up a loop varying variable I until of data (INREC.0)
Use the following logic to 'rebuild' each INREC.I when needed

Code:
TOPOS = POS('TO ',INREC.I)
SELECT
  WHEN TOPOS = 0  THEN NOP
  WHEN TOPOS < 40 THEN DO
    PART1 = LEFT(INREC.I,TOPOS-1)
    PART2 = SUBSTR(INREC.I,TOPOS)
    INREC.I = PART1||PART2
  END
  WHEN TOPOS > 40 THEN DO
    PART1 = LEFT(INREC.I,39)
    PART2 = SUBSTR(INREC.I,TOPOS)
    INREC.I = PART1||PART2
  END
  OTHERWISE NOP /* TOPOS = 40 */
END


Allocate output file
Use EXECIO to write output file from Stem variable INREC.

This is just one approach, untested at that.


Viewing all articles
Browse latest Browse all 9405

Trending Articles