IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Insert a Format using Rexx Macro in Cobol Program


IBM Mainframe Forums -> TSO/ISPF
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
arpita soni

New User


Joined: 19 Jun 2007
Posts: 3
Location: mumbai

PostPosted: Fri May 21, 2010 12:14 pm
Reply with quote

Hi,
Using Rexx(macro) , I want to insert a Format like this in the cobol program: Kindly assist me with the code how can i acheive this:-
Format:-

*****************************
Identification Division.
*****************************
Environment Division.
*****************************
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri May 21, 2010 12:26 pm
Reply with quote

Please explain exactly what it is that you want to achieve.

Where do you want to insert these 5 lines. Are not the division names unique in a program and should not be used more than once. Far more detail is required before anybody will bother to get out of bed to even look at the request.
Back to top
View user's profile Send private message
arpita soni

New User


Joined: 19 Jun 2007
Posts: 3
Location: mumbai

PostPosted: Fri May 21, 2010 12:33 pm
Reply with quote

The above said lines will have more lines something to add like Author details, comment section which says what is the program name, program created date , version etc.. When a user will run this macro automatically the this Flower Box will be generated and the developer will not be formatting the data.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri May 21, 2010 12:42 pm
Reply with quote

OK... start writing some code and come back if You face problems.

looks like for You assist with the code means ... write the code for me

search the forums ( ISPF ) or GOOGLE for EDIT MACROS EXAMPLES
and You will find lots of examples to meditate on
Back to top
View user's profile Send private message
GaganGarg

Active User


Joined: 31 Mar 2010
Posts: 134
Location: India

PostPosted: Tue Jun 08, 2010 5:47 pm
Reply with quote

Try this:

Code:

/*REXX*/                                                               
"ISREDIT MACRO (ARGS)"                                                 
"ISPEXEC CONTROL ERRORS RETURN"                                         
INPUT="OPERA12.TEST(REXX)"                                             
"ALLOCATE DDN(FILE1) DSN('"INPUT"') SHR REUSE"                   
"EXECIO * DISKR FILE1(STEM A. FINIS)"                             
"FREE DDN(FILE1)"                                                 
DO I = 1 TO A.0                                                     
   LINE1= A.I                                                           
   "ISREDIT LINE_BEFORE 1 = (LINE1)"                                   
END


Lines that you want to inser must be present in a PS file or a PDS member. here i used a PDS OPERA12.TEST and member name is REXX.

Good to see you at this forum site icon_biggrin.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Jun 08, 2010 5:57 pm
Reply with quote

i realize that I am 'old school',
but I have not coded a COBOL program from scratch in about 20 years.

I start with an existing program
that compiles,
that complies with site standards
and then just delete what I don't need/want and change what is required.

GaganGarg,

your MACRO will work,
but if I may make a couple of suggestions.
1. if there are no arguments, don't use ARGS
2. the lines could have been 'hard coded' in your REXX,
thus saving the need for an allocate/execio for a file that always needs to exist.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Jun 08, 2010 5:59 pm
Reply with quote

GaganGarg wrote:
Try this:
Did YOU try it before posting ?
Back to top
View user's profile Send private message
GaganGarg

Active User


Joined: 31 Mar 2010
Posts: 134
Location: India

PostPosted: Tue Jun 08, 2010 6:01 pm
Reply with quote

Quote:
i realize that I am 'old school',
but I have not coded a COBOL program from scratch in about 20 years.

I start with an existing program
that compiles,
that complies with site standards
and then just delete what I don't need/want and change what is required.



I also never code from scratch. But everybody's organisations/clients standards may vary. so requirements may change from person to person.

Quote:

your MACRO will work,
but if I may make a couple of suggestions.
1. if there are no arguments, don't use ARGS
2. the lines could have been 'hard coded' in your REXX,
thus saving the need for an allocate/execio for a file that always needs to exist.


Thanks Dick Brenholtz for your valuable suggestions. I had just provided the draft version but i will keep in mind the above things. Thanks
Back to top
View user's profile Send private message
GaganGarg

Active User


Joined: 31 Mar 2010
Posts: 134
Location: India

PostPosted: Tue Jun 08, 2010 6:03 pm
Reply with quote

Yes i tried
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Jun 08, 2010 6:12 pm
Reply with quote

Well unfortunately, as the OP has failed to answer any of the questions that were asked of him, it would be a little difficult to try and offer any solution based on what we already know.

@GaganGarg
Sorry to question your testing of that, after a longer look it should work.
Another little tip
Why read the file when
Code:
"ISREDIT COPY 'OPERA12.TEST(REXX)' BEFORE "1
will give the same results.
Back to top
View user's profile Send private message
GaganGarg

Active User


Joined: 31 Mar 2010
Posts: 134
Location: India

PostPosted: Tue Jun 08, 2010 6:25 pm
Reply with quote

Yes... we can use. It doesn't come to my mind. Whatever come to my mind, i tried. You guys are expeirnced persons and you can suggest better solutions. Thanks for helping in improving my skills. icon_biggrin.gif

Quote:

@GaganGarg
Sorry to question your testing of that, after a longer look it should work.


Not a problem at all. After a longer look, one can say that the above macro will not work if the PDS member( to which we want to insert the lines of code) is empty. for that we have to insert one line (may be a blank line) manually before running this macro. I should had mentioned this. apologies for this.

But same is the case with "ISREDIT COPY 'OPERA12.TEST(REXX)' BEFORE "1 with this line of rexx code also.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Jun 08, 2010 6:42 pm
Reply with quote

try changing the 1 to .zf
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Jun 08, 2010 6:45 pm
Reply with quote

GaganGarg wrote:
Not a problem at all. After a longer look, one can say that the above macro will not work if the PDS member( to which we want to insert the lines of code) is empty. for that we have to insert one line (may be a blank line) manually before running this macro. I should had mentioned this. apologies for this.

But same is the case with "ISREDIT COPY 'OPERA12.TEST(REXX)' BEFORE "1 with this line of rexx code also.

Code:
"ISREDIT COPY 'OPERA12.TEST(REXX)' AFTER "0
will work for an empty dataset.

Here's the code that I used and tested before - it deletes the data currently in a dataset and then adds a subset from a master file.
Code:
"ISREDIT MACRO"                                       
"ISPEXEC CONTROL ERRORS RETURN"                       
"ISPEXEC VGET (STFRM ENDAT)"                           
"ISREDIT X ALL"                                       
"ISREDIT DELETE X ALL"                                 
"ISREDIT COPY 'DEV.SORTED.MASTER' AFTER "0 STFRM ENDAT
Back to top
View user's profile Send private message
GaganGarg

Active User


Joined: 31 Mar 2010
Posts: 134
Location: India

PostPosted: Tue Jun 08, 2010 6:52 pm
Reply with quote

Quote:


try changing the 1 to .zf



it works for both if dataset is empty or not.

Thanks Dick.
Back to top
View user's profile Send private message
sai.bhagavatula

New User


Joined: 05 Mar 2007
Posts: 10
Location: Sydney, Australia

PostPosted: Tue Jun 22, 2010 12:31 pm
Reply with quote

Btw, Mr. Gagangarg, if you further want to explore the ways of doing this, and learn more, SKELS can be useful.Skeletons are very simple and extremely useful in sitatustion like this.

Following sample rexx receives the skel name and output PDS as parameters and loads the skel into the output PDS with member name as tempjob.

Code:

ARG SKEL DSN                                                         
Tempdsn = Strip(Translate(DSN," ","'"))                             
Address TSO "Alloc F(ISPFILE) Dsn('"tempdsn"') Shr Reus"             
Address Ispexec "Ftopen "                                           
Address Ispexec "Ftincl " Skel                                       
Address Ispexec "Ftclose Name("tempjob")"                           
Address TSO "Free F(ISPFILE) "                                       


Note: This is a sample I created for a specific purpose, but you can modify this to do the loading into the member you are working on etc.,

Have fun!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> TSO/ISPF

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Using API Gateway from CICS program CICS 0
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Running REXX through JOB CLIST & REXX 13
Search our Forums:

Back to Top