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
 

 

Does COBOL Scope Definition Block Structure Exist?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Does COBOL Scope Definition Block Structure Exist?
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    Post subject:
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    Post subject:
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: 2150
Location: At my coffee table

PostPosted: Fri May 08, 2009 3:15 am    Post subject:
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm
No new posts Submit job from Cobol with input data abdulrafi COBOL Programming 4 Wed Feb 01, 2017 12:41 pm
This topic is locked: you cannot edit posts or make replies. COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am


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