To insert, change & delete a piece of code using rexx/Macro



IBM's Command List programming language & Restructured Extended Executor

To insert, change & delete a piece of code using rexx/Macro

Postby venkateshm » Wed Jun 06, 2012 10:40 pm

Hi,
i'm working on migration project, i need to insert, change and delete a SAME LINES OF CODE for many applications. To do efficiently and effectively can we use REXX/MACRO. Iam new to REXX and coded few programs with the help of this forum, iam very much thankful. Below is a sample code:

INPUT: test.startus.app1 (ps file)
IDENTIFICATION DIVISION.
PROGRAM-ID.SANSOFT.
*
ENVIRONMENT DIVISION.
SOURCE-COMPUTER. STRATUS/32
OBJECT-COMPUTER. STRATUS/32
*
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-STUDENT-NAME PIC X(6) VALUE SPACES.
01 JUL-DATE PIC 9(7) VALUE ZEROS. //YYYY-MM-DD
01 GREG-DATE PIC 9(8) VALUE ZEROS. //YYYYDDD
PROCEDURE DIVISION.
DECLARATIVES.
FIRST DECLARATION
SECOND DECLARATION
THIRD DECLARATION
END-DECLARATIVES.


CALL S$DATE_TIME USING JUL-DATE, //FUNCTION TO CONVERT JULIAN DATE TO GREGOIAN DATE
GREG-DATE.

DISPLAY 'GREGORIAN DATE:' GREG-DATE.

IF !UPPER-CASE(WS-STUDENT-NAME) = 'ABCDEF'
DISPLAY 'STUDENT NAME :' WS-STUDENT-NAME
END-IF.

CALL S$STOP_PROGRAM. //FUNCTION TO STOP PROGRAM

DESIRED OUPUT: test.mf.app1 (ps file)

IDENTIFICATION DIVISION.
PROGRAM-ID.SANSOFT.
*
ENVIRONMENT DIVISION.
SOURCE-COMPUTER. IBM-371
OBJECT-COMPUTER. IBM-371
*
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-STUDENT-NAME PIC X(6) VALUE SPACES.
01 GREG-DATE PIC 9(8) VALUE ZEROS.
*****YYYY-MM-DD
01 JUL-DATE PIC 9(7) VALUE ZEROS.
******YYYYDDD

PROCEDURE DIVISION.

ACCEPT JUL-DATE.
COMPUTE DD = FUNCTION INTEGER-OF-DAY (JULIAN-DT).
COMPUTE GREG-DATE = FUNCTION DATE-OF-INTEGER (DD).

*****FUNCTION TO CONVERT JULIAN DATE TO GREGOIAN DATE
DISPLAY 'GREGORIAN DATE:' GREG-DATE.
IF FUNCTION UPPER-CASE(WS-STUDENT-NAME) = 'ABCDEF'
DISPLAY 'STUDENT NAME :' WS-STUDENT-NAME
END-IF.

STOP RUN.

CHANGE: wherever the code contains
'!upper-case" ---> "function upper-case
SOURCE-COMPUTER. STRATUS/32 ----> SOURCE-COMPUTER. IBM-371

DELETE: after procedure divison if DECLARATIVES are there i want to delete those lines.

INSERT: i want to replace a piece of code like date logic
CALL S$DATE_TIME USING JUL-DATE,
GREG-DATE.

COMPUTE DD = FUNCTION INTEGER-OF-DAY (JULIAN-DT).
COMPUTE GREG-DATE = FUNCTION DATE-OF-INTEGER (DD)

can any body suggest me how can i do this using REXX/MACRO. It will be more helpful for me....
Thanks in advance.....
venkateshm
 
Posts: 10
Joined: Sun May 13, 2012 8:57 pm
Has thanked: 0 time
Been thanked: 0 time

Re: To insert, change & delete a piece of code using rexx/Ma

Postby dick scherrer » Wed Jun 06, 2012 11:31 pm

Hello,

It appears there are some typos in your post. If you re-post, i'll delete the original.

Suggest you consider GOBACK instead of STOP RUN. They are not exactly the same.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: To insert, change & delete a piece of code using rexx/Ma

Postby parthiban » Wed Jun 06, 2012 11:37 pm

u can try the built in functions,

POS() - to find out the string
translate() - will replace the string with other string
Parthiban jayaraman
mainframe rexxer,
Banglore
parthiban
 
Posts: 66
Joined: Mon Oct 20, 2008 7:54 pm
Location: Bangalore-India
Has thanked: 0 time
Been thanked: 0 time

Re: To insert, change & delete a piece of code using rexx/Ma

Postby Akatsukami » Wed Jun 06, 2012 11:53 pm

Venkateshm, what you are trying to do really has nothing to do with Rexx per se; it is all ISPF edit commands. I recommend that you read the Edit macro commands and assignment statements chapter of the z/OS ISPF Edit and Edit Macros manual.

There is, of course, a possibility that you will not do so, or are incapable of understanding it -- and if you read some of the threads here, you will see that this is not intended as an insult, but as a resigned recognition of reality. I therefore append a suitable macro. Certain simplying assumptions are made to it, so that it may not handle every COBOL program that you'd wish.
/* Rexx */                                                             
/* Written Heisei 24.06.06 by Akatsukami-sama */                       
  address isredit                                                       
  MACRO                                                                 
  "CHANGE 'STRATUS/32' 'IBM-371' ALL"                                   
  "CHANGE '!UPPER-CASE' 'FUNCTION UPPER-CASE' ALL"                     
  "CURSOR = 1"                                                         
  "FIND DECLARATIVES"                                                   
  "(L1) = CURSOR"                                                       
  "FIND END-DECLARATIVES"                                               
  "(L2) = CURSOR"                                                       
  "DELETE &L1 &L2"                                                     
  "CURSOR = 1"                                                         
  "FIND 'CALL S$DATE_TIME'"                                             
  "(L1) = CURSOR"                                                       
  "FIND '.'"                                                           
  "(L2) = CURSOR"                                                       
  "DELETE &L1 &L2"                                                     
  "LINE_BEFORE &L1 = 'COMPUTE DD = FUNCTION INTEGER-OF-DAY (JULIAN-DT).'"
  "LINE_BEFORE &L1 = 'COMPUTE GREG-DATE = FUNCTION DATE-OF-INTEGER (DD)'"
  "CURSOR = 1"                                                         
  "FIND 'CALL S$STOP_PROGRAM'"                                         
  "(L1) = CURSOR"                                                       
  "FIND '.'"                                                           
  "(L2) = CURSOR"                                                       
  "DELETE &L1 &L2"                                                     
  L1 = L1 - 1                                                           
  "LINE_AFTER &L1 = 'GOBACK.'"                                         
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: To insert, change & delete a piece of code using rexx/Ma

Postby venkateshm » Thu Jun 07, 2012 8:41 am

Hi Dick,
corrections are done..
i'm working on migration project, i need to insert, change and delete a SAME LINES OF CODE for many applications. To do efficiently and effectively can we use REXX/MACRO. Iam new to REXX and coded few programs with the help of this forum, iam very much thankful. Below is a sample code:

INPUT: test.startus.app1 (ps file)
IDENTIFICATION DIVISION.
PROGRAM-ID.SANSOFT.
*
ENVIRONMENT DIVISION.
SOURCE-COMPUTER. STRATUS/32
OBJECT-COMPUTER. STRATUS/32
*
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-STUDENT-NAME PIC X(6) VALUE SPACES.
01 JUL-DATE PIC 9(7) VALUE ZEROS. //YYYY-MM-DD
01 GREG-DATE PIC 9(8) VALUE ZEROS. //YYYYDDD
PROCEDURE DIVISION.
DECLARATIVES.
FIRST DECLARATION
SECOND DECLARATION
THIRD DECLARATION
END-DECLARATIVES.


CALL S$DATE_TIME USING JUL-DATE, //FUNCTION TO CONVERT JULIAN DATE TO GREGOIAN DATE
GREG-DATE.

DISPLAY 'GREGORIAN DATE:' GREG-DATE.

IF !UPPER-CASE(WS-STUDENT-NAME) = 'ABCDEF'
DISPLAY 'STUDENT NAME :' WS-STUDENT-NAME
END-IF.

CALL S$STOP_PROGRAM. //FUNCTION TO STOP PROGRAM

DESIRED OUPUT: test.mf.app1 (ps file)

IDENTIFICATION DIVISION.
PROGRAM-ID.SANSOFT.
*
ENVIRONMENT DIVISION.
SOURCE-COMPUTER. IBM-371
OBJECT-COMPUTER. IBM-371
*
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-STUDENT-NAME PIC X(6) VALUE SPACES.
01 GREG-DATE PIC 9(8) VALUE ZEROS.
*****YYYY-MM-DD
01 JUL-DATE PIC 9(7) VALUE ZEROS.
******YYYYDDD

PROCEDURE DIVISION.

ACCEPT JUL-DATE.
COMPUTE DD = FUNCTION INTEGER-OF-DAY (JULIAN-DT).
COMPUTE GREG-DATE = FUNCTION DATE-OF-INTEGER (DD).

*****FUNCTION TO CONVERT JULIAN DATE TO GREGOIAN DATE
DISPLAY 'GREGORIAN DATE:' GREG-DATE.
IF FUNCTION UPPER-CASE(WS-STUDENT-NAME) = 'ABCDEF'
DISPLAY 'STUDENT NAME :' WS-STUDENT-NAME
END-IF.

GO BACK.

CHANGE: wherever the code contains
'!upper-case" ---> "function upper-case
SOURCE-COMPUTER. STRATUS/32 ----> SOURCE-COMPUTER. IBM-371

DELETE: after procedure divison if DECLARATIVES are there i want to delete those lines.

INSERT: i want to replace a piece of code like date logic
CALL S$DATE_TIME USING JUL-DATE,
GREG-DATE.

COMPUTE DD = FUNCTION INTEGER-OF-DAY (JULIAN-DT).
COMPUTE GREG-DATE = FUNCTION DATE-OF-INTEGER (DD)

can any body suggest me how can i do this using REXX/MACRO. It will be more helpful for me....
Thanks in advance.....
venkateshm
 
Posts: 10
Joined: Sun May 13, 2012 8:57 pm
Has thanked: 0 time
Been thanked: 0 time

Re: To insert, change & delete a piece of code using rexx/Ma

Postby dick scherrer » Thu Jun 07, 2012 8:48 am

Hello,

Thanks for the update :)

Did you see the code provided by Akatsukami ?

Try that and let us know if it does what you want.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: To insert, change & delete a piece of code using rexx/Ma

Postby venkateshm » Thu Jun 07, 2012 9:03 am

Hi Dick,
i looked the code of Akatsukami, it was very helpul. i will implement this and let you know...

Akatsukami,
i searched a lot for this... i did not get any clear picture. After seeing one post (for change all)in this forum i came to know that, using macros we can write ISPF edit commands. But i am having few doubts(deleting few lines and inserting) which made me to post....
thank you Akatsukami very much, your code is very much helpful......
venkateshm
 
Posts: 10
Joined: Sun May 13, 2012 8:57 pm
Has thanked: 0 time
Been thanked: 0 time


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post