Friday, December 17, 2010

How do I setup the Assemble-Link Job(JCL)?

Before you start writing Programs, you need to set up an Assemble-Link job(JCL), that'll help assemble your program into a Load Module. Once you have a Load-Module ready, you can run it and see the magic.

Most installations have ready-to-use PROCS such as ASMHC to assemble a Program, ASMHCL to assemble-and-link a Program and ASMHCLG to Assemble-Link-Go(Run) the program. If these aren’t found at your shop, try looking for ASMAC, ASMACL and ASMACLG. Better even ask your System Programmer for a JCL. The Assembler-software on Mainframes is the Program ASMA90. This is how I have setup my Assemble-link Job. I am going to use the ready-made PROC ASMACL.  There are two important customizations or overrides you need to do. ASMACL expects you to supply two Files – //SYSIN, the Input Source Program, and //SYSLMOD, the output Load Module. I have stored my Source-Program in the Member ASPROGR01 under the Library SYSADM.DEMO.SRCLIB. I hooked up and attached SYSIN inlet to this file SYSADM.DEMO.SRCLIB(ASPROG01). The Assembler internally passes its output to the Linker. The Linker-Software HEWL, produces an Output Load Module and stores it in the SYSLMOD File. I would like the Executable Load Module ASPROG01 to be created under SYSADM.DEMO.LOADLIB. Hence, SYSLMOD output is hooked to the File SYSADM.DEMO.LOADLIB(ASPROG01).

What are the differences between COBOL and Assembler?

Assembler Language differs from all of the other languages such as COBOL, PL/I, RPG etc. It resembles the actual machine-instructions that you are likely to find on a Mainframe. Assembler-Language is a Low-level language. For performing a complex-task, you need to write several instructions. On the other hand, COBOL and other modern platforms such as Java or C# are High-Level Languages(HLL). In these languages, its possible to represent a complex task by one single-instruction.

COBOL looks more English-like. Its quite verbose. Writing a program in Assembler requires a different line-of-thinking, different thought pattern. Unlike COBOL, Assembler-Language statements don’t terminate with a period. Assembler language commands don’t even come close to English.

Alright, now let's keep this between you, me and the gatekeeper – COBOL Programs are actually transformed to Machine code. In fact, you can see the equivalent Machine-code corresponding to your COBOL-Program, for yourself when you run the Compiler IGYCRCTL with the PARM='LIST' Option. You would find that 1 COBOL Instruction generates several Machine-Instructions. By contrast, 1 Assembler-Instruction generates only one single Machine-Instruction. Guess what, you need to code several lines-of-Assembler to achieve the same effect as one line-of-COBOL.

Another paradigm-shift of thinking is needed, with the order of operands. COBOL does a MOVE A TO B, or ADD 1 TO COUNTER, take the first thing and do something to the second. In Assembler, you’d have to code MVC B,A or AP COUNTER,=P'1', the second operand normally does something on the first.

COBOL Programs are broken down into divisions, sections and para's – its strictly organized and structured. In Assembler, you just start coding. You decide your own custom-organization and enforce it, follow it throughout the program.

How does the SUBTRACT Operator work in COBOL?

When you want to find the difference of two or more quantities in COBOL, you use the SUBTRACT operator. The SUBTRACT operator subtracts one quantity from another, and finds out the result. In its simplest form, SUBTRACT has the following syntax :
Syntax
SUBTRACT one-quantity FROM second-quantity

For example,

SUBTRACT WS-VAR-2 FROM WS-VAR-1

Consider the variable WS-VAR-1 = 10, WS-VAR-2=30, subtracting WS-VAR-2 from WS-VAR-1 would result in the difference between 30 and 10. The answer is 20. This final result is stored in WS-VAR-2. SUBTRACT B FROM A is equivalent to the statement A = A – B.

Image03[2] 

The example above is shown in the code snippet below :

Image04[2]

COBOL ADD Operator Example

Syntax
ADD A B C GIVING D E
The GIVING Clause may also specify a list of destination/receiving variables. In that case, sum(addition) is copied to the each of the variables mentioned in the GIVING Clause. For example,
Assume that A = 10, B = 15 and C=20.

Now the sum of A B C = 10 + 15 + 20 = 45. The sum 45 is stored in each of the variables mentioned in the list(D, E). Thus,
D = 45 and E = 45, after the above statement is executed.

Example :

Image16[2]
Result :

Image17[1]

ADD operator in COBOL example

Syntax
ADD A B GIVING RESULT

If you would like the final result of arithmetic to be stored in a separate resultant variable, you can always write a GIVING clause at the end. Thus, if A=5 and B=10, the sum(addition of A and B), would yield 15. This sum 15 is stored in the RESULT Variable. On omitting the GIVING Clause, the sum is stored in one of the operands being added. GIVING Clause allows you to specify a separate destination(receiving variable) which shall hold the final result of computation.
Example
Image14[2]

Result
Image15[1]

COBOL Tutorial – Arithmetic Operators part 2

How is the the ADD Operator used in COBOL.?

The ADD operator can be used to add two or more quantities. In the assembly language, we write the instruction ADD A B to find the sum of A and B. The final sum is stored in A. On the same lines, the ADD Operator in COBOL has the following syntax :

Syntax
ADD one-quantity TO second-quantity

The final sum result is stored in the second-variable. For example, if A=10, and I write

ADD 5 TO A
After performing the above step, the computer adds 5 to the value of A, so A=15. Suppose a variable B=5, then I may also write

ADD B TO A
Syntax
ADD A B C TO SUM
In this case, all the three group of numbers A B and C, would be added to SUM. So, assuming A=10, B=15, and C=20, if initially RESULT = 100, after addition of A, B and C to SUM, the value of RESULT = 100 + (10+15+20) = 145.

Example 

Image12[1] 

Result 

Image13[1]

COBOL Tutorial – Arithmetic Operators

Q. How do you perform Arithmetic in COBOL? For example, how do you write a simple program that calculates the Interest to be paid on a Principal p?

You often need to do Math in COBOL. You can perform Arithmetic in COBOL using Arithmetic Operators. When you perform some arithmetic on two or more numeric quantities, such an expression is called an Arithmetic Expressions. There are 4 main Arithmetic Operators in COBOL – ADD, SUBTRACT, MULTIPLY and DIVIDE.

You can even write complex arithmetic expressions by using the COMPUTE verb. I have written about the syntax of each operator, followed by examples and some results. 

Basic Framework of JCL

So, you’ve got the gist of the concept behind JCL, all the JCL that you going to write from hereon, maybe for the next 10-20 years, would be composed of three main statements :

//name JOB parameters...
//name EXEC parameters...
//name DD parameters...
Each of this JCL Statements have a label – a symbolic name assigned to them. Its like naming kids. Well, there could be so many boys in your area, but how do distinguish them? Of course, by their names.

In the same way, a JCL may contain a bunch of DD Statements, one for Input file, one for the output file, one for the error file. How do you tell them apart, by naming them. As a good practice, we always give names to all our JCL Statements. Names kinda help you to refer back to these statements in the future. You want to point out a particular JCL Statement to your friend, just spell out its name.

But, notice carefully, each label(name) is preceded with two slashes //. The two slashes are a JCL Statement’s signature. They indicate that the statement is a JCL Statement(one of JOB, EXEC, DD). Every JCL Statement wear the two slashes //. A naked statement without // won’t be treated as a JCL Statement.

Now, every JOB, EXEC and DD Statement has got these whole lot of parameters. What you’ll be learning throughout these tutorials is mostly the parameters. Parameters add stuff and meaning to the JCL Statement. 

Now, let me give you a booster, that’s going to help you organise the way you think about this JCL.

- JCL is made up of mainly JOB, EXEC and DD.
- JOB is easy to learn and use.
- EXEC is easy and fun to use.
- DD Statements take three forms
   1. DD Statements to read a file.(easy)
   2. DD Statements to write to the logs.(easy)
   3. DD Statements to create a new file(hard!); you’d have to learn parameters such as DISP, UNIT, DCB, SPACE and several others to code this.

Have a good look at this chart :

Image99[1]

ibm mainframes interview questions with answers | IBM Mainframes,TCS,DELL,Wipro,Infosys

(1) How should an elementary item subscript be declared to be more efficient?
a) s9(8)comp
b) s9(16)comp
c) S9(4)comp
d) s9(2)comp


(2) A word in the Computer memory is identified by_________

a) word length
b) word size
c) word address
d) None of the above


(3) In an EVALUATE statement, can I give a complex condition on a when clause?

a) Yes
b) No
c) Compilation error
d) Syntax error


(4) What is the other verb for RELEASE and WRITE ?

a) READ and WRITE
b) Rewrite and Read
c) Write and Read
d) Write and Open


(5) How could you write a program in a structured format?

a) Bottom-up approach
b) Each module serving different function
c) Program is divded into many exit point
d) No go to's


(6) Which is more efficient, level 77 OR 01?

a) 77
b) 01
c) Both
d) Neither


(7) Execution of a subordinate module is caused by the use of the COBOL verbs ------------in the superior module

a) Perfrom
b) Search
c) Evaluate
d) None of the above


(8) Which of the following is true about the file which is referenced in a delete statement?

a) Opened in INPUT mode
b) Opened in OUTPUT mode
c) Opened I/O mode
d) None of the above


(9) Can the OCCURS clause be at the 01 level?

a) Yes
b) No
c) only in 77 level number
d) All of the above


(10) The following are Data division entries
01 A PIC 9(2) VALUE IS 50
01 B PIC 9(3) VALUE IS 950
The following is the procedure Division statement
ADD A TO B ON SIZE ERROR DISPLAY 'ON SIZE ERROR'
DISPLAY 'B' B
What is the value of B when it is displayed?


a) 950
b) 1000
c) 100
d) None of the above


(11) How many sections are there in data division?.

a) 6
b) 3
c) 4
d) None of the above


(12) An index can be modified only by a

a) Add
b) Evaluate
c) Perform
d) If


(13) How is sign stored in a COMP field ?

a) in last nibble
b) in Least significant bit
c) In the most significant bit. Bit is ON if -ve, OFF if +ve
d) None of the above



(14) Indicate which one of the following is not true about the SET verb.

a) The verb can be used to set one or more indexes to a particular value
b) The verb can be used to move the current value of an index to one or more identifiers
c) The verb can be used to increment one or more identifiers by a positive integral value.
d) The verb can be used to decrement one or more indexes by a positive integral value.


(15) How many bytes are allocated for a data item PIC S9(10) binary .

a) 5
b) 6
c) 8
d) 10


(16) Consider the below code
01 WS-COUNT PIC 9 VALUE 5.
PROCEDURE DIVISION.
PERFORM NEW-SECTION THRU NEW-SECTION-EXIT WS-COUNT TIMES
STOP RUN.
NEW-SECTION.
-----------------------------
MOVE 10 TO WS-COUNT. -------- --------.
NEW-SECTION-EXIT.
EXIT.
How many times will NEW-SECTION be performed


a) 5 times
b) 10 times
c) 50 times
d) will go in loop


(17)
01 ws-n pic 9(2) value zero.
a-para.
move 5 to ws-n.
perform b-para ws-n times.
b-para.
move 10 to ws-n.
how many will b-para will execute?


a) 10 times
b) 0 times
c) 5 times
d) 50 times


(18) ACCEPT WS-DATE FROM DATE WILL RETURN THE CURRENT DATE

a) IN DDMMYY FORMAT
b) IN YYYYMMDD FORMAT
c) IN YYMMDD FORMAT
d) IN MMDDYY FORMAT


(19) Can you REWRITE a record in an ESDS file? Can you DELETE a record from it?

a) Can rewrite (record length must be same), but not delete.
b) Both rewrite and delete is possible
c) Can delete ,but can not rewrite
d) Can not do both



(20) PERFORM RTN-1 VARYING I FROM 1 by 2 UNTIL I > 2 AFTER J FROM 1 BY 1 UNTIL J > 2 AFTER K FROM 2 BY -1 UNTIL K < 1 .
HOW MANY TIMES RTN-1 WILL BE EXECUTED ?

a) 4 times
b) 5 times
c) 6 times
d) 8 times

Monday, December 28, 2009

SQL - Unexpected Token "date/interval" - DB2

Question:
I want to display the ending date of a project and the estimated date. the ending date is the actual date that the project will end. now assuming that the ending date was delayed 50%,I want to display this date as estimated date.

how can I increase a date value by 50%?

example:
PROJECTNO - ENDING DATE - ESTIMATED DATE
PROJ10001 - Jan 26, 1986 - Mar 12, 1986.



Answer:
If you are increasing by 50%, you are adding 50% with the hundred percent you already have. 150% = 1.5, so multiply the date by 1.5

What are the Differences & Similarities among DB2, Oracle, SQL Server, MS Access?

Similarities:
Similarity is that they are all Relational Database, and they all are proprietary software. Otherwise there exist no similarity. All of them and developed/owned by companies like IBM, Oracle and Microsoft and work totally different ways towards the same need, that is storing organized relational data and retrieving them easily. 


Differences: 
All have different user interfaces and use different scripting languages (Oracle - PL/SQL, SQL Server - T/SQL, Access - VBA, etc.). Most (if not all) also have a few add-ons to SQL (built-in functions and the like).

Information on DB2 certification

well there are 3 levels in DB2 certification exam. associate(entry); Administrator/Developer(intermediate) and Administrator(Advanced) levels. Currently IBM DB2 9 version is working in IT industry.

At the entry level there is Exam 730 and the intermediate there are two exams. it depends on the candidate which exam he/she want to give. 1st exam is 731, which is on LUW (Linux, Unix and Windows) and z/OS. Advanced level exam 734 is the last exam in IBM DB2 9 certification list.

In JCL (Job Control Language), does a FLUSH return code have any numeric value?

Answer:
No. Flush means the step did not execute. Valid return codes for steps that execute are in the range of 0-4095.

What are the advantages of job control language?

The Following are the Advantages of Job Control Language.
Identifies the job.
Usually provides information to enable the computer services department to bill the appropriate user department.
Defines how the job as a whole is to be run, e.g. its priority relative to other jobs in the queue.

What are all the JCL statements used in JCL? & What are the JCL statements you have coded so far?

//JOB marks the beginning of a job, contains job information //EXEC marks the beginning of a job step, identifies program, cataloged procedure to be executed //DD (data definition), identifies a data set and its attributes //OUTPUT (specifies processing options for system output(sysout) data sets) //(null) (end of job) /* (end of data placed in input stream) //PROC (procedure) //PEND (procedure end) //*

Could I use TIME = 34 HOURS in JCL?

I don't think you can specify time parameter in that manner. The syntax is,
Time = X
or
Time = (X,Y)
where x = no of minutes, y is no of seconds

e.g: TIME=5
TIME=(2,30)

The purpose of this parameter is to limit the time the job may run, in case an error is made that causes the job to perform extra processing needlessly.

I guess it will give a syntax error if you code TIME = 34 HOURS

What is ICEGENER in JCL?

ICEGENER is an integral component of IBM's DFSORTprogram product and can be used as a replacement or substitutefor the IEBGENER program. Most installations use theprogram in a selective way. The program is often entered as aname change in the PGM parameter on the JCL EXEC card inplace of IEBGENER.The ICEGENER program is far more efficient thanIEBGENER and can improve an installation's batch throughputbecause a large number of processes invoke IEBGENER. Atour installation we were using ICEGENER on a selective basis.Recently I installed a user modification that forces ICEGENERto be called even if IEBGENER is coded in the JCL.The following job streams were used to modify the installationdefaults to accomplish this task. The modifications allowIEBGENER to be called when necessary, if, for example, theuser coded IEBGENER control cards in the SYSIN dataset, orin the event of an ICEGENER failure.

NOT CATLGD 2 JCL Error-How to Avoid it?

The NOT CATLGD 2 JCL Error mostly occurs, when the dataset in question already exists. Here, OUTFILE is trying to create a new dataset OUTFILE.TEST.DATA. So, probably this dataset already pre-exists and is cataloged. To ensure such errors don’t occurs, we must purge/delete datasets using IEFBR14. 

Introduction to COBOL Programming-Cobol Tutorial Programming Guide

COBOL is a high-level programming language first developed by the CODASYL Committee (Conference on Data Systems Languages) in 1960. Since then, responsibility for developing new COBOL standards has been assumed by the American National Standards Institute (ANSI).
Three ANSI standards for COBOL have been produced: in 1968, 1974 and 1985. A new COBOL standard introducing object-oriented programming to COBOL, is due within the next few years.
The word COBOL is an acronym that stands for COmmon Business OrientedLanguage. As the the expanded acronym indicates, COBOL is designed for developing business, typically file-oriented, applications. It is not designed for writing systems programs. For instance you would not develop an operating system or a compiler using COBOL.

Saturday, December 12, 2009

What are the differences between COBOL and COBOL II?


What are the differences between COBOL and COBOL II?
There are at least five differences: COBOL II supports structured programming by using in line PERFORMs and explicit scope terminators, it introduces new features (EVALUATE, SET .. TO TRUE, CALL .. BY CONTEXT, etc), it permits programs to be loaded and addressed above the 16 megabyte line, it does not support many old features (READY TRACE, REPORT-WRITER, ISAM, etc.), and it offers enhanced CICS support.