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

Cobol code automation to replace DB2 SQL using Rexx


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
frozenblood
Warnings : 1

New User


Joined: 16 Oct 2012
Posts: 37
Location: INDIA

PostPosted: Sat Feb 23, 2013 1:07 pm
Reply with quote

I am working for a DB2 migration project. Here I will need to replace DB2 SQL code with other(EMS) technology. So I will need to comment out few particular(Selected) DB2 SQL's with the EMS replacement codes. It effects more than 300+ modules.

So the thought is to automate the part of the coding which could save hours of coding by commenting out the DB2 SQL codes using the replacement code automatically for the effected modules.

Thoughts are:
> There will be one input file where we can put the module name and the DB2 SQL which needs to be commented out and the replacement code which needs to be inserted after commenting out the DB2 SQL.
> The DB2 SQL will be commented out and tagged(R350E).
> The new replacement code will be inserted immediately after the DB2 SQL and tagged(R350E).
> The catch is we can search the DB2 SQL using 'EXEC SQL & END EXEC'.

Example code:
Code:
DB2 SQL needs to comment out:
EXEC SQL                                 
    SELECT NBR                       
    INTO   :SKXREF-NBR               
    FROM   SKXREF                       
    WHERE  SSU  = :SKXREF-SSU           
END-EXEC.                               
                                         
EVALUATE TRUE                           
  WHEN SQLCODE = ZEROS                   
  WHEN SQLCODE = 1403                   
    CONTINUE                             
                                         
  WHEN OTHER                             
    DISPLAY PV-ABEND-PARAGRAPH           
    SET ERROR-1009          TO TRUE     
    PERFORM 9999-SQL-ERROR               
END-EVALUATE.                           

Replacement Code needs to be inserted after commenting out DB2 SQL:
Some Cobol Code               
Some Cobol Code               
   


Output expected->
Code:

R350E*  EXEC SQL                                 
R350E*      SELECT NBR                       
R350E*      INTO   :SKXREF-NBR               
R350E*      FROM   SKXREF                       
R350E*      WHERE  SSU  = :SKXREF-SSU           
R350E*  END-EXEC.                               
                                         
R350E*  EVALUATE TRUE                           
R350E*    WHEN SQLCODE = ZEROS                   
R350E*    WHEN SQLCODE = 1403                   
R350E*      CONTINUE                             
R350E*                                           
R350E*    WHEN OTHER                             
R350E*      DISPLAY PV-ABEND-PARAGRAPH           
R350E*      SET ERROR-1009          TO TRUE     
R350E*      PERFORM 9999-SQL-ERROR               
R350E*  END-EVALUATE.                           

R350E  Some Cobol Code
R350E  Some Cobol Code


Please let me know if there any previous references where same type of automation is done or any idea how can it be implemented.

Thanks in advance.

Repetitious attachment deleted. Bad Cobol now replaced with something "representative"
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Sat Feb 23, 2013 1:48 pm
Reply with quote

Is this the same : ibmmainframes.com/viewtopic.php?t=60455 ?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Feb 23, 2013 2:43 pm
Reply with quote

Other than the bad Cobol, what is your problem?

You identify the start of what is to be replaced, the end of what is to be replaced, comment all of those, then after the end of what is to be replaced do your insertion.

Make sure the code you are inserting works (even compiles) first.

Presuming the EMS-STRING is going to be the target of your STRING statement - there is utterly, utterly no need to INITIALIZE it immediately before setting it to any other value.

Note that you are not doing anything for the start of your "response time".

Also, despite the indentation shown, MOVE FUNCTION ... is dependent on the "SUCCESS" WHEN clause, as there is no END-EVALUATE terminator so the first full-stop/period terminates the code that is part of the WHEN.

I imagine (fervently hope) that this is not the real code you want to insert, but you do us a disservice by not showing, or abstracting to show, us something realistic.
Back to top
View user's profile Send private message
frozenblood
Warnings : 1

New User


Joined: 16 Oct 2012
Posts: 37
Location: INDIA

PostPosted: Sat Feb 23, 2013 2:43 pm
Reply with quote

Hi, yes it is. the details mentioned here.
Back to top
View user's profile Send private message
frozenblood
Warnings : 1

New User


Joined: 16 Oct 2012
Posts: 37
Location: INDIA

PostPosted: Sat Feb 23, 2013 2:50 pm
Reply with quote

Please don't bother about the EMS coding. I have the good cobol code with me which executes. This is a sample coding I provided as example which needs to be inserted.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Mon Feb 25, 2013 7:00 pm
Reply with quote

Sure this can be done, but not a small task (a medium one).

The first thing to be assured of:
Is the code to be commented out ALWAYS the same?
Is the SELECT written the same (each statement on each line)?
Is there ALWAYS and Evaluate True and End Evaluate afterward?

Other questions:
How large are these 300+ modules (number of lines of code)?
Are all these modules in the same production Source Library?
Is the list of modules already known?

If it were me I would do something with a Rexx program:
Have a loop to edit each module of the list (if the list is already known).
Have an Edit macro to find the code and comment it out.
This macro will then copy the new code in from a separate member in the same library.

If the list is not known, I would use a LM (Library manager) loop to look a every module to identify the candidates.

I am sure there are other ways to handle this, but based on the requirements, I would start this way.

You see this is not a small task. Not one for a Rexx beginner in my opinion.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Mon Feb 25, 2013 7:22 pm
Reply with quote

And what is "EMS" ?
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Tue Feb 26, 2013 5:49 pm
Reply with quote

PeterHolland wrote:
And what is "EMS" ?

Good question; the references I can find are all to software running on toy computers.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Tue Feb 26, 2013 6:53 pm
Reply with quote

Akatsukami wrote:
PeterHolland wrote:
And what is "EMS" ?

Good question; the references I can find are all to software running on toy computers.


Same here, so i was wondering if we are fooled around.
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 765
Location: Whitby, ON, Canada

PostPosted: Tue Feb 26, 2013 9:06 pm
Reply with quote

In my shop, "EMS" is a local acronym with two different meanings, neither of much means anything to the outside world.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Tue Feb 26, 2013 11:17 pm
Reply with quote

Well Don we are not asking you, but the TS.

And searching for EMS on the urban dictionary is also very clarifying.
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 -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
Search our Forums:

Back to Top