View previous topic :: View next topic
|
Author |
Message |
Chris Chapel
New User
Joined: 11 Sep 2007 Posts: 10 Location: Marshfield, WI
|
|
|
|
I was curious whether enterprise COBOL has a structure to define the scope, similar to the WITH <object> block in VB or C# .NET. We have many programs where multiple files have the same definition (or parts of the record definition) and we have a single COBOL Copybook to define. I could use COPY REPLACING... with tags, but I prefer to keep the Copybooks clean and usable for Compuware File-Aid record mapping.
Here is an "actual" source code example:
Code: |
MOVE 'O' TO CPR-TYPE-FLAG OF OLD-COMP-RECORD.
MOVE WS-DEM-TYPE-FLAG TO CPR-DEM-TYPE OF OLD-COMP-RECORD.
MOVE GBAC-PROMOTION-CODE (1:4) TO CPR-OFFER-4
TO CPR-OFFER-4 OF OLD-COMP-RECORD.
MOVE GBAC-ORDR-NBR (3:)
TO CPR-SALESID OF OLD-COMP-RECORD.
MOVE MIL-ACTV-EXT-ORDR-NBR-2
TO CPR-PARENT-SALESID OF OLD-COMP-RECORD.
MOVE GBAC-SHIPPING-HANDLING-AMT
TO CPR-SH-DOLLARS OF OLD-COMP-RECORD.
MOVE CPR-SH-DOLLARS OF OLD-COMP-RECORD
TO CPR-SH-DOLLARS-EDIT OF OLD-COMP-RECORD.
MOVE MATCH-SW TO CPR-MATCH-FLAG OF OLD-COMP-RECORD.
MOVE 'O' TO CPR-TYPE-FLAG OF NEW-COMP-RECORD.
MOVE WS-DEM-TYPE-FLAG TO CPR-DEM-TYPE OF NEW-COMP-RECORD.
MOVE GBAC-PROMOTION-CODE (1:4) TO CPR-OFFER-4
TO CPR-OFFER-4 OF NEW-COMP-RECORD.
MOVE GBAC-ORDR-NBR (3:)
TO CPR-SALESID OF NEW-COMP-RECORD.
MOVE MIL-ACTV-EXT-ORDR-NBR-2
TO CPR-PARENT-SALESID OF NEW-COMP-RECORD.
MOVE WS-DOLLARS TO CPR-SH-DOLLARS OF NEW-COMP-RECORD.
MOVE CPR-SH-DOLLARS OF NEW-COMP-RECORD
TO CPR-SH-DOLLARS-EDIT OF NEW-COMP-RECORD.
MOVE MATCH-SW TO CPR-MATCH-FLAG OF NEW-COMP-RECORD. |
Here is what I would envision for a scope definition.
...to structure with "scope declaration"
Code: |
WITH OLD-COMP-RECORD
MOVE 'O' TO CPR-TYPE-FLAG
MOVE WS-DEM-TYPE-FLAG TO CPR-DEM-TYPE
MOVE GBAC-PROMOTION-CODE (1:4) TO CPR-OFFER-4
MOVE GBAC-ORDR-NBR (3:) TO CPR-SALESID
MOVE MIL-ACTV-EXT-ORDR-NBR-2 TO CPR-PARENT-SALESID
MOVE GBAC-SHIPPING-HANDLING-AMT TO CPR-SH-DOLLARS
MOVE CPR-SH-DOLLARS TO CPR-SH-DOLLARS-EDIT
MOVE MATCH-SW TO CPR-MATCH-FLAG
WITH-END.
WITH NEW-COMP-RECORD
MOVE 'O' TO CPR-TYPE-FLAG
MOVE WS-DEM-TYPE-FLAG TO CPR-DEM-TYPE
MOVE GBAC-PROMOTION-CODE (1:4) TO CPR-OFFER-4
MOVE GBAC-ORDR-NBR (3:) TO CPR-SALESID
MOVE MIL-ACTV-EXT-ORDR-NBR-2 TO CPR-PARENT-SALESID
MOVE WS-DOLLARS TO CPR-SH-DOLLARS
MOVE CPR-SH-DOLLARS TO CPR-SH-DOLLARS-EDIT
MOVE MATCH-SW TO CPR-MATCH-FLAG
WITH-END. |
I have to believe that other COBOL developers would be frustrated with the overly verbose (at times) structures.
Any help would be appreciated.
-Chris. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
I have to believe that other COBOL developers would be frustrated with the overly verbose (at times) structures.
|
what we COBOL developers do is create EDIT Macros that will insert the proper OF/IN syntax, thus relieving the coder of such mundane tasks as qualifying.
changing the name of a business attribute (field name such as total balance) was done in the past, but, among other bad habits, this actvity has changed.
due to development tools such as rochade, key, etc... data dictionarys,
a business attribute gets one name - and it stays that way.
By NOT changing the name of a field from one copybook to another, we can (easily) trace the movement thru modules.
you can make things easy to code and impossible to debug
or
you can develop tools to make your coding easier so that debugging is easier. |
|
Back to top |
|
|
Chris Chapel
New User
Joined: 11 Sep 2007 Posts: 10 Location: Marshfield, WI
|
|
|
|
Dick,
I'm curious to a practical example (or excerpt) of what you refer as:
Quote: |
what we COBOL developers do is create EDIT Macros that will insert the proper OF/IN syntax, thus relieving the coder of such mundane tasks as qualifying. |
I'm familar with ISPF Edit Macros (we have a few that I use regularly, but none directly related to COBOL Source Code edit functions). |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
I'm not real bright sometimes, but I am lazy.
When I have a lot of OF/IN requirements, I just replace it with a symbol such as /I or /O for OF the input or output record name and just do a change in the edit screen when done. |
|
Back to top |
|
|
Chris Chapel
New User
Joined: 11 Sep 2007 Posts: 10 Location: Marshfield, WI
|
|
|
|
Got it. The physical typing is less (very smart) but the end result is the same structure (after the tag change all's):
Code: |
MOVE WS-A TO REC-A OF OUTPUT-RECORD |
|
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
I normally code with two or three sessions going.
1 for the cobol source
1 for the copybook that I am currently pulling reference names from.
1 for whatever else i need
the edit macro , I called it qualref or something,
would view the copybook.
put cursor on the reference that I wanted
(the first project could have the reference 3 or 4 times in under different
-group elements)
had a pf key for qualref
the macro would work backwards, picking up and stacking each group item name in a stem until I reached the 01 level.
then I would overlay the screen (one time I used a popup, after that I just inserted lines in the copybook (remember I was in view) with everything starting in pos 50:
Code: |
elementary element ref name
in group-ref name
in group-ref name
in structure ref name
|
then I would just CUT in the one session, swap, PASTE in the other.
before CUT&PASTE i would select, cntl-c, swap, I10 and then cntl-V.
swap again and invoke the following macro which would return the copybook to original state
Code: |
/* REXX */
ADDRESS ISPEXEC "CONTROL ERRORS RETURN"
ADDRESS ISREDIT
"MACRO "
"X ALL"
"DEL ALL X"
"(MEMNAME) = MEMBER"
"COPY" MEMNAME "AFTER .ZF"
EXIT
|
might seem a little complicated, but at the time i developed it, I was working in german and could not spell worth a pee, so I use copy/paste all the time.
also meant that the other developers were using the field from the correct group. |
|
Back to top |
|
|
|