Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Cobol code automation to replace DB2 SQL using Rexx

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
frozenblood
Warnings : 1

New User


Joined: 16 Oct 2012
Posts: 34
Location: INDIA

PostPosted: Sat Feb 23, 2013 1:07 pm    Post subject: Cobol code automation to replace DB2 SQL using Rexx
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: 2422
Location: Netherlands, Amstelveen

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

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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Sat Feb 23, 2013 2:43 pm    Post subject: Reply to: Cobol code automation to replace DB2 SQL using Rex
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: 34
Location: INDIA

PostPosted: Sat Feb 23, 2013 2:43 pm    Post subject: Reply to: Cobol code automation to replace DB2 SQL using Rex
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: 34
Location: INDIA

PostPosted: Sat Feb 23, 2013 2:50 pm    Post subject: Reply to: Cobol code automation to replace DB2 SQL using Rex
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: 645
Location: Pennsylvania

PostPosted: Mon Feb 25, 2013 7:00 pm    Post subject:
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: 2422
Location: Netherlands, Amstelveen

PostPosted: Mon Feb 25, 2013 7:22 pm    Post subject:
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: 1738
Location: Bloomington, IL

PostPosted: Tue Feb 26, 2013 5:49 pm    Post subject:
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: 2422
Location: Netherlands, Amstelveen

PostPosted: Tue Feb 26, 2013 6:53 pm    Post subject:
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: 641
Location: Whitby, ON, Canada

PostPosted: Tue Feb 26, 2013 9:06 pm    Post subject:
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: 2422
Location: Netherlands, Amstelveen

PostPosted: Tue Feb 26, 2013 11:17 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts PL/I code tuning/Performance improvement Virendra Shambharkar PL/I & Assembler 4 Mon Dec 05, 2016 11:57 am
No new posts What is the code in CLIST to enable t... jackzhang75 CLIST & REXX 1 Fri Dec 02, 2016 3:02 am
No new posts IDEAL - Code Retrieval yugendran CA Products 0 Fri Nov 25, 2016 3:27 pm
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us