Showing posts with label cobol. Show all posts
Showing posts with label cobol. Show all posts

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. 

Saturday, December 12, 2009

How COBOL FLAT files(Index,Sequential) are very secure for huge data?If not, How will you migrate with any Database with Frond end COBOL?

Question: How COBOL FLAT files(Index,Sequential) are very secure for huge data?If not, How will you migrate with any Database with Frond end COBOL?


Answer:


Well if you are using flat file you have advantage as well as disadvantages.
Advantage-It is Secure Physically edited.
Disadvantage - Logically speaking performance is slow difficult to find the particular record.

What is difference between Object oriented COBOL & MicroFocus COBOL?

Question :What is difference between Object oriented COBOL & MicroFocus COBOL?


Answers :
There is only one thing we can use Java or C++ in Mainframe instead of CICS



Monday, April 6, 2009

Basic Concepts of Job Control Language JCL - Tutorial 01

Q. What is a Job?
A. Mainframe computers are used to process data. They perform tasks or operations on the data, to generate valuable information as Output. A job is a set of tasks performed on input data, to produce output results.

For example, a job might consist of Reading Input data records from a file, arranging the Input data records in order(sort them), and write the sorted records data to Output File.

Q. What is a batch of Jobs? What do you mean by Batch Processing?
A. Think of an auto-assembly line in a car factory. Each car is processed automatically by a robot. There are several cars in Queue.

Analogous to this, in a Batch System, there is a series of jobs in queue, and are run one after the other, without any human intervention.

A complete batch of jobs, takes time to run, and give the finished product(output result). A batch of jobs can be seen as a production line in the factory.

So, there are data processing tasks, that take lot of time, e.g. generating credit card statement of all the customers of a bank. The output result(statements) cannot be immediately obtained. Large corporate organisations use a batch of jobs to perform such tasks at regular intervals, say for example monthly.

Everytime, you swipe your credit card, withdraw money from the Automated Teller Machine, transfer funds to your friend’s bank account, a Mainframe computer crunches the data, and runs a batch of jobs.

In fact, if you transfer funds to your friend’s account in a nationalised bank like State Bank of India, it doesn’t get credited immediately. The reason for this is, the entries get processed in batches(bunches) in different time slots(9-11 a.m.,11-1 p.m.,...) on the RBI’s NEFT Servers.



Q. What is Job Control Language(JCL)?
A. JCL specifies to the MVS Operating System, what resources your program expects to use. JCL acts as an interface between your COBOL program (JOB) and the OS.








Any JCL can be divided into 3 logical groupings as shown in the above diagram.

JOB Identification -
JOB1 - Name of the Job
JOB - This is a job. Everything that follows relates to this JOB.
(A123) - Account to which the computer time is to be billed.
'STUDENZONE S' - Programmer's name
PRTY = 6 - Jobs within a class are assigned a priority.


Program Identification -
//STEP1 - Stepname. JOB consists of many tasks(steps).
EXEC - Beginning of the JOB Step

PGM = PROGRAM1 ; Name of the program that is to be executed