View previous topic :: View next topic
|
Author |
Message |
frozenblood Warnings : 1 New User
Joined: 16 Oct 2012 Posts: 37 Location: INDIA
|
|
|
|
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 |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
frozenblood Warnings : 1 New User
Joined: 16 Oct 2012 Posts: 37 Location: INDIA
|
|
|
|
Hi, yes it is. the details mentioned here. |
|
Back to top |
|
|
frozenblood Warnings : 1 New User
Joined: 16 Oct 2012 Posts: 37 Location: INDIA
|
|
|
|
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 |
|
|
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
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 |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
And what is "EMS" ? |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
PeterHolland wrote: |
And what is "EMS" ? |
Good question; the references I can find are all to software running on toy computers. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
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 |
|
|
don.leahy
Active Member
Joined: 06 Jul 2010 Posts: 765 Location: Whitby, ON, Canada
|
|
|
|
In my shop, "EMS" is a local acronym with two different meanings, neither of much means anything to the outside world. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
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 |
|
|
|