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

Does COBOL Scope Definition Block Structure Exist?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Chris Chapel

New User


Joined: 11 Sep 2007
Posts: 10
Location: Marshfield, WI

PostPosted: Fri May 08, 2009 1:56 am
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri May 08, 2009 2:49 am
Reply with quote

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
View user's profile Send private message
Chris Chapel

New User


Joined: 11 Sep 2007
Posts: 10
Location: Marshfield, WI

PostPosted: Fri May 08, 2009 2:57 am
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Fri May 08, 2009 3:15 am
Reply with quote

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
View user's profile Send private message
Chris Chapel

New User


Joined: 11 Sep 2007
Posts: 10
Location: Marshfield, WI

PostPosted: Fri May 08, 2009 3:21 am
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri May 08, 2009 3:26 am
Reply with quote

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
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts SCOPE PENDING option -check data DB2 2
Search our Forums:

Back to Top