Search

Sunday, March 24, 2013

SYNCSORT or DFSORT - PART 3


Problem Statement
//*********************************************************************
//* I have two files. 
//* FILEA contains only timestamp X(26).
//* FILEB contains Office X(3), Account X(6), timestamp X(26) and Identity number X(3)
//* I want all records of FILEB for timestamp values not present in FILEA
//*********************************************************************

SORT JCL Used:
Step 1: Sorted FILEB with timestamp as first field.

//SORT01   EXEC PGM=SORT
//SORTIN   DD  DSN= REC.FILE, ---FILE B(WITH LAYOUT GIVEN)
//             DISP=SHR
//SORTOUT  DD  DSN=OUTOUT.FILE,
//             DISP=(OLD,CATLG,DELETE),
//             SPACE=(CYL,(10,50),RLSE),VOL=(,,,40),
//             DCB=(RECFM=FB,BLKSIZE=0,LRECL=80)
//SYSOUT   DD  SYSOUT=*
//SYSPRINT DD  SYSOUT=*
//SORTLIST DD  SYSOUT=*
//SYSIN    DD  *
        INREC FIELDS=(10,26,1,9,36,3)
        SORT FIELDS=(1,26,CH,A)
/*

Step 2 Remove/Discard duplicates on from the sorted file and the FILE A which is sorted on timestamp.

//SORT02   EXEC PGM=ICETOOL
//INPUT    DD  DSN=OUTOUT.FILE,DISP=OLD      
//         DD  DSN=TMSTMP.FILE,DISP=OLD --FILE A(TIMESTAMPS)
//OUTPUT   DD  DSN=FILE.DISCARD,
//             DISP=(OLD,CATLG,DELETE),
//             SPACE=(TRK,(1,5),RLSE),
//             DCB=(RECFM=FB,BLKSIZE=0,LRECL=80)
//FINAL1   DD  DSN=FINAL.FILE,
//             DISP=(OLD,CATLG,DELETE),
//             SPACE=(TRK,(1,5),RLSE),
//             DCB=(RECFM=FB,BLKSIZE=0,LRECL=80)
//TOOLMSG  DD  SYSOUT=*
//DFSMSG   DD  SYSOUT=*
//TOOLIN DD *
  SELECT FROM(INPUT) TO(OUTPUT) ON(1,26,CH) ALLDUPS DISCARD(FINAL1)
/*
 ICETOOL is used here to sort on timestamp and remove dupicate timestamp records.

Step 3 Sorted as per layout in FILE B.

//SORT03   EXEC PGM=SORT
//SORTIN   DD  DSN=FINAL.FILE,
//             DISP=SHR
//SORTOUT  DD  DSN=FINAL1.FILE,
//             DISP=(OLD,CATLG,DELETE),
//             SPACE=(CYL,(10,50),RLSE),VOL=(,,,40),
//             DCB=(RECFM=FB,BLKSIZE=0,LRECL=80)
//SYSOUT   DD  SYSOUT=*
//SYSPRINT DD  SYSOUT=*
//SORTLIST DD  SYSOUT=*
//SYSIN    DD  *
        INREC FIELDS=(27,9,1,26,36,3)
        SORT FIELDS=(1,26,CH,A)
/*
Sorted again in original file form.

Please refer PART1 and PART2 here.

Friday, March 22, 2013

JCL System Abend: SOC 1 and SOC 7

SYSTEM ABENDS

I am sure everyone is aware of system ABENDS. I have tried to list ABENDS for all the possible reasons. Hope you all find it useful.

SOC 1 

This abend can be faced in following situations. Rule out following possibilities:

  • Any file doesn't have open statement and directly trying to read it
  • The subscript it may be out of boundary for a defined COBOL table
  • Review JCL for missing or misspelled DD name
  • Problem in parm passed to subroutine related to addressing mode or Data mode
  • Recording mode may be wrong 
  • Sub program called is not found problem in dynamic link or static link
  • Check load module there can be a possibility if subroutine program id and program name not same. This means bad load module.
  • An uncontrolled loop moved data on top of instructions. 
  • Problem can be same name for array and subroutine  


    SOC 7 

This is a data exception and can only occur when decimal (packed) instructions are used. 


  • When alphanumeric data moved to packed decimal data (COMP 3).
  • When Programmer use a variable, which is not defined in working storage.
  • Period missing after imperative statements within AT END clause.
  • Binary field in an arithmetic operation is not large enough to accept result.
  • Failure to initialize a counter.
  • Invalid incoming data (e.g., blanks, decimal points, or commas in a numeric field).
  • Exceeding a table via a subscript (index) error, causing a reference to invalid data.
  • Moving zeroes or low-values to a group field defined as numeric.
  • An omitted or erroneous usage clause.
  • Passing parameters between programs in the wrong order.

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.


Introduction to most useful SYSIBM DB2 tables - PART 2


Here comes some more SYSIBM tables



SYSIBM.SYSSTMT : This table is input to bind process. It contains statements for every plan known in DB2.

SYSIBM.SYSPLANS: contains information on every plan known to DB2. The plan name is unique in the DB2 subsystem.

SYSIBM.SYSFOREIGNKEYScontains information foreign keys for table. 

SYSIBM.SYSDBAUTH: Contains information on database level authorizations for each user of each database.  Entries are made into this table when database-related GRANT or REVOKE commands are issued for the location.


Please refer PART1 link to get more information on SYSIBM tables.

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