Search

Showing posts with label COBOL. Show all posts
Showing posts with label COBOL. Show all posts

Wednesday, October 14, 2015

List possible compiler diagnostic messages



Use of Compiler diagnostic messages


A complete listing of compiler diagnostic messages can be generated with their explanations, by compiling a program with the program-id of ERRMSG specified in the PROGRAM-ID paragraph.

Example:

IDENTIFICATION DIVISION
PROGRAM-ID.ERRMSG.
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
STOP RUN.

Tuesday, August 12, 2014

Resolving error 37 of the Vsam file

Resolving error 37 of the Vsam alternate index


Whenever we define Vsam Alternate Index File we might face error 37 when we use to process the file via JCL first time:

The solution mentioned to resolve this is to initialize Vsam file once before directly opening in the program. But still many times you must have faced same error again and again whenever you try to read alternate index vsam file via a cobol program and through JCL.

Whenever we define VSAM alternate index file we have following components:


Cluster:          OLDMF.DATA.KSDALT
Data:              OLDMF.DATA.KSDALT.DAT
INDEX:            OLDMF.DATA.KSDALT.INX
AIX :               OLDMF.DATA.KSDALT1
PATH:             OLDMS.DATA.KSDALT.PATH

This filename and alternate index is used in the JCL to read the Cobol program and in JCL it is placed with its logical name as:

//OLDMF DD DSN= OLDMF.DATA.KSDALT,DISP=OLD
//OLDMFD DD DSN=OLDMF.DATA.KSDALT1,DISP=OLD
The problem is in the way we write our logical name. Even if you try to initialize file and you may still face the error. It will be resolved by the way we write logical name for the alternate index in the JCLs.
Correct declaration:
//OLDMF     DD   DSN= OLDMF.DATA.KSDALT,DISP=OLD

//OLDMF1    DD   DSN=OLDMF.DATA.KSDALT1,DISP=OLD
Always the logical name will be appended with the next sequence number starting from 1.


Sunday, March 17, 2013

Options to recover deleted flat files or member for PDS


Options to recover deleted files

There is option on mainframe to recover flat files. Here are the various commands to 
do that:

Go to Start 6 
HLIST BCDS DSN('filename') 
Wait for system response
Issue command HRECOVER 'filename' and wait for system response.


Useful free webinars for COBOL developers

Hello COBOL Developers!!

Here is amazing site for COBOL development, here there are web seminars where we can register and view them:

https://www.microfocus.com/resources/events/VCwebinars/VCwebinars.aspx

Topics included range from Visual COBOL, Using COBOL with JAVA, .NET etc.

XML with COBOL Basics

Introduction to XML coding with COBOL

By the growing Global transactions, its need of an hour to introduce common language that can be used cross platform. Here comes introduction to XML on COBOL. This blog gives brief introduction on XML usage with COBOL. It includes:
1. XML Introduction
2. XML Tags
I have focus on how actually developer can code in COBOL language as you can find lot of literature online. 

XML : 
It is Extensible Markup Language. It can be used cross platform hence universal in nature.It has tag language.Tags can be single or nested depending upon requirements.
Eg: <a>...</a>
Tag documents can be designed in free flow way.Tags can't overlap each other. Eg <p><r>... </p></r> <--  This is not allowed. There are few more rules which I will point it out in my example.

Example:

<?xml version = "1.0"?>
<!--comment line-->
<p>
</p>

As you can see above XML are:
1. Text based can be saved as .txt file or .xml file or as PS file in Mainframe environments.
2. It is case sensitive
3. Contains one root
4. Starts and end with matching tags
5. Any attribute value should be in quotes
6. Properly nested

You will find usage of XML Parser and XML-COBOL coding in my up coming blogs.

EBCDIC characters required in COBOL programing

Here is the chart for EBCDIC characters

Chart for EBCDIC characters




Saturday, March 16, 2013

Creating Different Dimension Tables in COBOL

As we saw single dimension table in my blog linked here . There are many other ways to use COBOL table.
Another Way of Single Dimension TABLE:

COBOL Declaration:


01  A1-TABLE.
      05 A2-TABLE OCCURS 100 TIMES
            15 P1-NO             PIC X(05).
            15 P1-NAME        PIC X(10).
             15 P1-TEL NO.
                   25   LAND-LINE  PIC 9(10).
                   25   MOBILE        PIC 9(11).

This declarlation will work in COBOL as table described below:

Interview Questions for COBOL


How do you do in-line PERFORM? 
        
PERFORM ... <UNTIL> ...
<sentences>
END-PERFORM

When would you use in-line perform?

     When the body of the perform will not be used in other paragraphs. If the body of the perform is a generic type of code (used from various other places in the program), it would be better to put the code in a separate Para and use
      PERFORM Para name rather than in-line perform.

 What is the difference between CONTINUE & NEXT SENTENCE ?
 They appear to be similar, that is, the control goes to the next sentence in the paragraph. 
 But, Next Sentence would take the control to the sentence after it finds a full stop (.). 
 Check out by writing the following code example, one if sentence followed by 3 display statements 
 If 1 > 0 then next sentence end if display 'line 1' display 'line 2'. display 'line 3'. Note- there is a dot (.) only at the end of the last 2 statements, see the effect by replacing Next Sentence with Continue.     

Sunday, March 3, 2013

Efficient use of decalartion in COBOL


Efficiently use of alphanumeric and numeric declaration in COBOL


In Working Section:

03  WS-ALPHX.                          
    05  WS-NUM          PIC 9(4).     

We can use this way as alphanumeric as well as to check numeric.

For Eg:

MOVE CAPIN(1:4)      TO WS-ALPHAX

IF WS-ALPHAX (1:1) IS NOT NUMERIC       
   MOVE 0 TO WS-ALPHAX (1:1)
END-IF      
                                  
IF WS-NUM IS NUMERIC                  
   MOVE WS-NUM TO CAPIN2
ELSE                                          
   MOVE 0              TO CAPIN2
END-IF                        

Search Option of COBOL


Here is how to use search option in COBOL

COBOL Declaration:


01  A1-TABLE.                                               
    03   FILLER                     PIC 9(02) VALUE  01.    
    03   FILLER                     PIC 9(02) VALUE  02.    
    03   FILLER                     PIC 9(02) VALUE  03.    
    03   FILLER                     PIC 9(02) VALUE  40.    
    03   FILLER                     PIC 9(02) VALUE  50.    
                                                               
01 AE-TABLE REDEFINES A1-TABLE.                            
    03  IE-CODE        PIC 9(02)  OCCURS 5 TIMES           
                           INDEXED BY P1.                     

Code in procedure division : 

      SET P1 TO 1.                                
      SEARCH IE-CODE                            
          AT END SET NOT-IE-CODE TO TRUE        
      WHEN AE-CODE IS EQUAL TO IE-CODE (P1)   
          SET IE-CODE1 TO TRUE

Sunday, November 4, 2012

COBOL z/OS Performance Improvements

COBOL tips for performance improvements

  • Always consider using SEARCH ALL option instead of checking long table by coding.
  • Internal SORT is usually uses longer CPU than External SORT.
  • Always consider using Evaluate, it creates program more modular.
  • Avoid using go to statement as they create irregular flow.

Saturday, November 3, 2012

COBOL Date Function to get correct offset from GMT

COBOL DATE FUNCTION

There was requirement were we had to send MT202 to Swift. Swift accepts time of GMT or either it accepts with correct offset and when we use current time option in COBOL it gives local time hence we were getting ET time.I had faced issue with time. The offset I was getting was not correct from GMT. 

For E.g.: ET time is 4 hrs offset from GMT when day-light saving is on and it is 5 hrs offset from GMT when day light saving is off.  

I used following function and by using this function we get the offset from GMT of where your application is running, then we can easily just use native COBOL.


See the CURRENT-DATE intrinsic function at: