The document discusses business data processing systems and their various components. It describes payroll, sales, purchase, inventory, and cost accounting systems. It explains how data is collected and transformed into meaningful information that can be used to operate and control a business. Various files and reports generated by these systems are also outlined. The role of a system analyst and the system development life cycle process are summarized.
1. 1
BUSINESS DATA
PROCESSING
How to process a business.
IPO cycle.
Data into meaningful information.
Information as Data.
Pros/Cons of the business.
2. 2
DATA CAN BE INFORMATION-
HOW??
It is required to operate the business
-information from customer.
-Information regarding the stock available.
-To generate the previous invoice.
-Current status of the market.
Data is required to control the business
-About performance and results
Data originates from the outside demand
- Steps to improve the business.
Although these steps may vary
according to the need of specific
business.
3. 3
VARIOUS BUSINESS SYSTEMS:-
Payroll or wage control system
Sales control and accounting system
Purchase control and accounting system.
Inventory control and accounting system
Production control system
Cost accounting system
4. 4
ROLE OF VARIOUS SYSTEMS:
Contribution to financial and accounting
statements.
Actions to be taken to make the business more
efficient and profitable.
Make the system automated.
Gather req. information to generate various
reports at the door step.
Various procedures and problems.
6. 6
PAYROLL OR ACCOUNTING
SYSTEM:
Mainly employ and remunerate the
workforce
Manual, technical and managerial skills
Personnel attributes ,capabilities .
Terms of employment.
Computation of each employee’s gross
earning & salary.
Regarding employment criteria
Computation of employee net payment
based on gross earnings.
HRA,TA,DA,PF
Accounting for amounts deducted from
earnings.
7. 7
SALES CONTROL AND
ACCOUNTING SYSTEM:
Determine the value of the order to check the
credit rating of the customer
Print combined invoice and delivery note.
Update the stock record
Update the stock record file for the inventory and
issue order notes.
Enter details in back order file if the items are out
of stock.
Prepare list of the collections of goods in the
inventory.
Prepare delivery schedules for the inventory.
Prepare and print order analysis reports.
9. 9
FILES/DATA TO BE MAINTAINED:
Stock description file
List all goods supplied by the firm.
Details of the min. order quantity.
Unit cost/item
Discount ( if any)- as per conditions
Has to be changed when price alters
Custom or file
Customers detail ( name ,code_no, address etc.)
Outstanding transactions ( order no, amount involved, date of the
invoice dispatched)
Addition of new customers /deletions of old customers.
Alteration in their credit limits
Back-order File
If delivery has to be made later on particular date
Detail of such type of customer
Sales ledger file
Details of all the orders which has been dispatched
Cost of the items and date on which payment was received.
Details of the invoice / modifications if mistake has been made
10. 10
FILES/DATA TO BE MAINTAINED:
Exception file
Request from customer after getting delivery regarding
Incorrect stock number ( manual record has to be maintained
so as to tally the order).
Further queries can be solved .
Suspense file
Wrong order delivered .
Cheque /cash received only for items received rather than full
order placed.
Can be used in future for further queries.
11. 11
SALES CONTROL AND
ACCOUNTING SYSTEM:
No separate delivery /invoice notes are
made
• OCR based forms can be generated to
avoid errors and to save time.
• Record about company’s / individual sales
rep. efficiency and performance.
• Statistics about various customers so that
alterations can be made according to the
situations.
• Increasing/decreasing demands for the
particular items so as to make the future
strategy.
12. 12
PURCHASE CONTROL AND
ACCOUNTING SYSTEM:
Required material,components,tools,equipments and other
material needed by the company.
Information at right time/place/price
Rules to be followed are: Obtaining quotations of price,
delivery date and quality from prospective suppliers.
Placing order with suppliers, monitoring delivery and
chasing overdue orders.
Check quality, type of the goods received.
Passing information to accounts deptt. for further action
regarding the payments to be made.
Checking suppliers invoice and statements before making
the final payments.
Accumulating the various statistical data pertaining to the
price ,delivery achievements and quality for the purpose
of improving subsequent decisions regarding the
placements of purchase orders
14. 14
MATERIAL MANAGEMENT
Tangible components of the supply
chain,
Covers acquisition of spare parts &
replacements.
Quality control of purchasing and
ordering.
Standards involved in ordering,
shipping and warehousing.
15. 15
FUNCTIONS RELATED WITH
MATERIAL MANAGEMENT:
Identification
Cataloging
Standardization
Need determination
Scheduling
Procurement
Inspection
Quality control
Packaging
Storage
Inventory control
Distribution
Disposal
Information tech (software availability)
16. 16
INVENTORY CONTROL SYSTEM
Closely connected in practice with stores control.
Monitoring and decision control,operation.
Supply and demand.
Methods of minimizing the overall cost:
Cost of storage,reordering,capital tied up in stock
Stock depreciation & deterioration.
Loss of profit due to out-of-stock.
Maintenance of records related to stock control :
Stock level,issues,outstanding orders,reorder level
Can be applied to raw material,brought-out, made-in-
components, subassemblies, finished and part-finished
products, machines and consumable items.
Others factors are:
Size & weight of the stock items,stability,identification.
Equipment handling,security,packaging,labeling &
space.
17. 17
VARIOUS REPORTS REGARDING
INVENTORY CONTROL SYSTEM:
Receiving report forms.
Requisition and issuance slip form.
Warehouse transfer form.
Inventory adjustment Form.
Transaction Listing.
Stock Status
Stock management.
Historical Price List – Per Item/Vendor
Inventory Valuation per classification( Quantity/Value)
Non-Moving Inventory classification ( Quality Value).
Current 12 months consumption
Historical consumption
Issue register, excess stock register, under
stock,consumption,category wise consuption,account head wise
consumption
18. 18
ACCOUNT RECEIVABLE
MANAGEMENT SYSTEM:
Calculate sales price and taxes by client, product
and order destination.
Allow to add new clients.
Prepare invoices for product kits.
Insert comments between rows of item
information.
Calculates the commissions and produces a
report about commission to be paid.
Produces invoices with detailed administration
fees.
Group all receipts in one ledger.
19. 19
PRODUCTION CONTROL SYSTEM:
Production planning ( how to make ,what to make)
Material requirement for each time period.
Quantity of components and subassemblies.
Amount of equipment, machine, tools needed at
each stage.
Amount of each labour category.
Loading of each production unit.
Progress for each job.
Reason for delay.
Other type of planning ( according to the need)
20. 20
COST ACCOUNTING SYSTEM:
Actual/standard costs are compared.
Variance.- used for info. & planning
Profit variance: Sales variance/cost variance.
Sales variance: volume variance (actual/standard)
Cost variance: Material / labour.
Cost-Production (methods of production/material compromise.
Marginal costing, break-even analysis, budgeting
Marginal costing- extra cost involved.
Break-even analysis-level of profit.
Budgeting- controlling analysis by forecasting.
Computer power.
Raw-data, information
Activity and information.
21. 21
BUSINESS SYSTEMS
To provide goods & services to society.
Business: Exchange of goods, money or services
for mutual benefits.
Process data for info. generation.
Business Functions
Various internal/external functions
Marketing & Sales
Finance
Human Resources
Production
Purchasing & Stores
General Administration
22. 22
BUSINESS SYSTEMS
Marketing and sales:
Transfer in ownership of goods and services.
To reach the ultimate customer.
All activities regarding marketing of the product.
Sales – A part of Marketing.
Finance:
Funds to run the business.
Funds to be converting to the reality.
Plans to raise the funds.
Use suitable sources of funds.
Funds with min. rate of interest.
Human Resources:
Workforce
Managers & subordinates.
Contribution of all the members of the company
23. 23
BUSINESS SYSTEMS
Production:
Creation & services req. to satisfy the customer needs.
Product Planning.
Product Development.
Production administration.
Execution of plans.
Polices regarding the production.
Purchasing & Stores:
Need material & goods.
Req. store to keep goods for later stage.
Purchasing and storing are closely related.
24. 24
BUSINESS SYSTEMS
General Administration:
Direct or Indirect way to control the business.
Establish the principal objective of the organization.
Prepare plan & policies to achieve the goal.
Job to be assign to each department/person.
Delegation of powers.
Performance evaluation on regular basis.
25. 25
SYSTEM LIFE CYCLE
Also called water fall Model
Various stages are:
Initial investigation.
Feasibility Study.
Designing.
Implementation.
Maintenance
26. 26
SYSTEM LIFE CYCLE
Initial investigation:
Understand the problem ( Problem def inning phase)
Modules.
Estimated cost involved.
Detail study- Max efforts.
Feasibility Study:
Test of the proposed system.
Workability.
Impact on organization.
Effective use of resources.
Technical,Economical,Operational feasibility ( computerization)
Formal proposal can be presented with:
Details of the problem,suggestions,cost benefit analysis.
Recommendations, conclusions
27. 27
SYSTEM LIFE CYCLE
Designing:
Justification, estimate and impact of system on organization.
Methods of data capture.
Formats of the output to be used in future.
Choose best out of the availability.
Discussion with mgmt. regarding cost-benefit analysis and other
objectives also.
Security aspects are:
Hardware & software to be used.
Inputs(Data entry screens ,default values etc.)
Outputs (report screens, screen designs etc.)
The user Interface.
Testing plan.
28. 28
SYSTEM LIFE CYCLE
Conversion Plans.
Documentation
Data Validation.
Security Features.
Implementation:
Manual to Computerization.
New computers instead of old ones.
Training,testing,conversions etc.
Maintenance:
Corrective & perfective measures for repairing.
Changes to be made with changing environment.
29. 29
SOFTWARE DEVELOPMENT:
Software required to as
per nature and vol. of
work.
For better services to
the customer.
Own SDC (Software
Development center)
Software personals to
make suitable software.
Computerization req.
training- need software
Training to indivisual.
Problem defining
phase.
System analysis.
System design mgmt.
Programming analysis
and preparation.
System
implementation.
Maintenance.
30. 30
SOFTWARE DEVELOPMENT
Problem defining phase:
Identify the problem & available solutions
Main role of volume & nature of work.
Coordination between data processing employee &
management of the organization.
System Analysis:
Data & facts regarding manual procedures.
Technical & economical feasibility.
Effect of computerization on the organization.
Weak points and their solution (available)
System design:
How to produce efficient & effective system.
Best suitable and favorable design adopted.
31. 31
APPLICATIONS OF COMPUTERS
Organize and store many similarly structured
pieces of info.
Retrieve a single piece of info. From many stored
records.
Print info. Quickly and accurately.
Perform complicated mathematical calculations.
Perform the same activity almost indefinitely.
Facilitate comm. Among individuals,
departments and branches.
Link the office to many sources of data available
through larger networks.
32. 32
HOW TO IMPROVE
Accounts Receivable: If properly organized and
maintained. Requires large hours of posting sales and
receipts and especially of preparing statements.
Advertising: Complicated to handle large/Mass data.
Inventory: High volume turnover can cause errors in
tracking inventory causes lost sales and in maintences.
Payroll: tough to implement an employee incentive
plans.
Planning: tough in manual for planning.
33. 33
COMPUTER BUSINESS
APPLICATIONS
Financial modeling programs prepare and
analyze financial statements.
Spreadsheets and accounting packages
Word processing programs.
DTP
Critical path analysis programs divides large
program into modules
Legal programs track cases and tap information
from the data bases.
Payroll system
File mgmt system.
34. 34
REALISTIC
EXPECTATION:
Don’t expect a computer to clean up a mess
in the office.
Don’t install a computer:
If you don’t have the right people to do the job.
With the idea that any info. You want is instantly
available.
Computer require structured, formal processing that
may produce informal system.
To help define the jobs that must be done, but it must
be well defined.
To occur like magic, need methodical work.
To exactly fit your present methods of completing jobs.
If not willing to listen to new ideas then you will not be
able to install computer successfully.
36. 36
NEED FOR SYSTEM ANALYST
Analyze input, process and, out & flow of
data.
Improvement in support of users and
functioning of the business.
For poor installation system analyst lends
structure to analysis and design of info.
System.
Series of processes systematically
undertaken to improve the efficiency of
the system.
Computerized info. System.
37. 37
NEED FOR SYSTEM ANALYST
Works with current and eventual users of
info. System.
Latest tech. in organization setting.
Users involvement, user move as forefront
as a software development team.
More emphasis on the working of the
software users, on performing analysis of
their business ,problem & objectives .
38. 38
ROLE OF SYSTEM ANALYST
Consultant:
with mgmt,users
Supporting expert:
existing & proposed system
Agent of change:
modification ( if required)
39. 39
SYSTEM LIFE CYCLE ( CONTI…..
Preliminary survey
Feasibility study.
Detailed system study.
System analysis.
System Design.
Coding
Testing.
Implementation
Maintenance
40. 40
PRELIMINARY STUDY
Brief investigation of the system under consideration.
Preparation of system proposal.:
Problem Def, Objectives Terms of reference,Contraints,
Expected benefits in the light of user environment.
System proposal made by the SA,presented to mgmt:
accepted or rejected or modifications.
System study Phase passes through the following
steps:
Prob. Def and project initiation.
Background analysis.
Inference of findings( system proposal)
41. 41
FEASIBILITY STUDY:
Test of the proposed system as per:
workability, users req,effective use of
resources ,cost effectiveness
Technical,economic,operational and scheduled
feasibility.
Main goal is not to solve the problem but to
achieve the scope.
Cost and benefits are estimated with greater
accuracy to find ROI( Return on investment)
Resources needed to complete the investigation.
42. 42
DETAILED SYSTEM STUDY
Problem and requirements.
Pros and cons including new areas of interest.
Data and finding in the shape of DFD’s,data
dictionary, logical data structure and miniature
specifications
What the new system is accomplished based on
users requirements.
Functional hierarchy by the new system and
their relationship with the other.
Functional network: for more than one
procedure.
List of attributes in the entities.
43. 43
SYSTEM ANALYSIS:
Collecting factual data, understand the process
involved, identifying the problem, recommending
feasibility.
Studying the business process, gathering the
operational data, understand the information
flow, finding bottlenecks and evolving solutions
to overcome the weakness of the
system.subdividng the complex process,
identification of data store and manual process.
44. 44
SYSTEM ANALYSIS:
Finding answers for business process HOW?
Give birth to new efficient system.
scope for future growth within organization
constraints.
Iterative process that continues until a
preferred and acceptable solution emerges.
45. 45
SYSTEM DESIGN
Most crucial phase in the development of the
system.
Logical system design is converted to physical
system design.
Two stages are:
Preliminary or general design.
Structured or detailed design.
The tools and the techniques used are:
Flowcharts
Data Dictionary.
Structured English
Decision table
46. 46
SYSTEM DESIGN
Decision tree
Defining the req. system output.
Data req. and producing output.
Med. And format of files and database.
Devising processing methods and use of
software to produce output.
Determine the methods of data capture
and data input.
Designing input forms, user interface.
48. 48
CODING
Coding the design into computer
understandable language.
To convert pgm. Specifications into
computer instructions.
Procedures into controlled specifications.
Must be modular in nature, fast
development and future changes (if required)
49. 49
TESTING
Before actual implementation –
a test run to check the bugs. After codifying –
a test plan should be run on given set of data.
Output must match with the expected
results.
Two types of test are:
Program Test.
System test.
50. 50
TESTING
Program Test:
Coded, compiled and bought to working nature
must be individually tested with the prepared
test data.
Bugs noted and debugged.
System Test:
After pgm. Test system test is carried out.
Complete system is run on actual data.
Results are checked and analyzed, errors are
removed and further tested with the expected
output.
Finally users are called with their own data.
51. 51
IMPLEMENTATION
Theory is turned into practice.
Major steps are:
Conversion
User Training.
Documentation.
Hardware and Software req. for implementation
made fully operational initially.
Conversions are most important—old data has
to be converted to be operated in new formats
of new system.
Database needs to be setup with security and
recovery procedures fully defind.
52. 52
IMPLEMENTATION
After loading training starts.
Types of training:
How to execute the package, Enter data, Process
data, take reports
After training working has to be shifted from
manual to computerized is called
“ Change over”
53. 53
IMPLEMENTATION
“ Change over”
Direct changeover- Complete replacement (old
to new)
Parallel Changeover- ( Both manual & computerized)-
less risky but most expensive ( work doubled).
Pilot run- run on previous periods data for
whole or part of the system– results are
compared with previous results. Less expensive
and risky from parallel changeover.
Build confidence and errors are traced easily
without effecting the operations.
54. 54
MAINTENANCE
Review of the system from time to time.
To eliminate errors during the working phase
and tune the system to any validations in its
working environment.
Used for:
Knowing full capabilities of the system.
Required changes or additional requirements.
Studying the performance.
55. 55
SOFTWARE DEVELOPMENT
Modifications accordingly (if required)
Programming analysis & preparation:
New system of app. Specification is turned over to one or
more programmes.
Smaller modules.
Suitable programming lang. ( according to speed)
System implementation:
Testing about 50% for different stages.
System is run for shorter time period for testing.
If run successfully then implemented.
Maintenance:
Documentation is important aspect of maintenance.
Rules changes for within or other vendors providing
software.
56. 56
SOFTWARE DEVELOPMENT
In case of other vendors picked:
Whether software meets requirement completely.
Whether updating facility available in software.
If party suitable software adopted- modification available.
Single/multiuser software available.
Decision making:
Support for information system.
Problem should be known well in advance.
Intelligence- problem exist, design- alternative solution,
choice- pick the best solution.
Types of decision:
Programmed & non-programmed.
Programmed:- well defind,repetitive,routine decision.
Pre-defind rules or algorithm implemented.
57. 57
TYPES OF DECISION:
Non programmed decision:
Occasional, no predefined rules, new analysis
every time.
Implementation of info. system:
Preparing people for introduction of new system.
Developers thinking:
High level of use
High level of user satisfaction.
Accomplishment of the original objectives.
Appropriate nature of use.
Institutionalization of the system.
58. 58
UNSUCCESSFUL IMPLEMENTATION
OF INFORMATION SYSTEM:
Reasons are:
Analysis goes wrong.
Less time spent in research.
Objective is unclear.
Inadequate involvement with the user.
No flexibility is not built in the design.-no further
changes can be made.
Not much focus on low level processing, not
enough on the information flow.
Mgmt. Can over-specify their requirements.-
resulting in unrealistic or excessive demands.
No training to the users.
Poor documentation.
59. 59
UNSUCCESSFUL IMPLEMENTATION
OF INFORMATION SYSTEM:
Badly thought-out conversion.
Mgmt. should be involved in design process.
Build around the info. Need of the managers
rather than what exactly computer can easily
produce.
Inadequate teamwork and lack of professional
standard.
60. 60
SUCCESSFUL IMPLEMENTATION:
User involvement and user enthusiasm.
Training to the user.
Proper mgmt. of the system development to
prevent cost overruns/delay etc.
Mgmt. support (change in work habits,
organization changes are most likely to be
accepted by the staff.)
62. 62
DATA PROCESSING SYSTEM
Process data to the meaningful system.
Process of collection, storage and distribution.
Input, Manipulation and editing,Storage and
output.
Examples:
Result preparation system.
Payroll system.
Input
Manipulation (sort of editing)
Classifying- Similar items are grouped as a one according
to the code system.
Sorting – Rearrangement of data(Asc / Desc)
Verifying- accuracy of data.
Comparing more than one data item.
Recording of same compared data.
Summarizing –the final data.
63. 63
DATA PROCESSING
Output:
final information, reporting, can be used for analysis
Storage:
Hard disk, magnetic disk, floppy disk.
64. 64
METHOD OF DATA PROCESSING
Manual.
Semi-Manual.
Mechanical.
Electronic.
Manual:
Processing by individual(through brain)
slow, prone to mistakes
Vol. of work increase-error increases.
Semi-Manual method:
Man and small instruments
(calculators,typewriters,totalling machines) are used.
One’s brain and competence.
65. 65
METHOD OF DATA PROCESSING:
Mechanical data processing system:
Use mechanical devices
Speed,accuracy,neatness,control.
Electronic method:
Electronic devices are used.
Also called EDP.
Speed, storage capacity, accuracy,compact,handy.
Items used:-Input devices, storage( permanent,
temporary),output.
66. 66
APPLICATIONS OF DATA
PROCESSING
Sales department:
Invoice, return inwards book, sales tax,reciepts vouchers,
debtors collected, debtors outstanding, finished goods
inventory
Purchase department:
Purchase invoices, creditors paid, creditors to be paid,
inventory position, purchase day book, vendors record
Pay & cash (salary )department:
Payroll,payslips,emp. Loan account, bank position, salary
deduction, IT deductions,PF statements
Financial & cost accounting:
Receipt & payment account, trial balance, depreciation
account, work in progress, budget figures, job costing.
67. 67
CONSTITUENTS OF COMPUTERIZED
SYSTEMS:
Hardware
Software
Procedures
Hardware:
Data preparation,input,processing,storage ,printing.
Software:
System software.
Operating system software.
Language software.
Application software.
Req. for performing various activities in institution.
68. 68
ADVANTAGES OF EDP
Speed
Accuracy
Storage capacity
Diligence-tiredness
Cost reduction.
Space requirement.
Versatility-transfer data internally, functions of
comparisons,arithmatic operations, exchange
info with outside world.
Automation
Diligence.
Volume of data.
MIS
Flexibility.
69. 69
DISADVANTAGES OF EDP:
Installation cost.
Stand by arrangements (UPS),air-conditioners.
New hardware and software
Efficient and knowledgeable persons.
Disk failure/corrupted.
Lack of judgment of computer.
70. 70
ON-LINE PROCESSING:
Remains in direct control of CPU.
Processes data immediately.
Used to overcome batch processing.
E.g. railways, airline reservation system,banking,stock-
exchange, foreign-exchange mgmt,work progress in plants,
stock control
Data stored in secondary storage.
Validation is checked before storage.
Validation data is processed & update the master file
immediately.
Updated hardware/software req.
High storage capacity.
Transaction,inquiry,response.
Record lock facility is available.
71. 71
BATCH-PROCESSING SYSTEM:
No. of similar transactions collected/grouped in
batches and processed at once without any
interruption.
Results obtained periodically.
e.g. accounting system, payroll system.
Cost effective.
Data is accessed sequentially.
72. 72
BATCH-PROCESSING SYSTEM:
Advantages:
Handle large amount
of data .
Output very quickly
while printing.
presence of user is not
compulsory while
processing.
Suits for lengthy jobs.
Disadvanges:
Take longer time
duration in processing.
Since master file is
updated so it will take
time for final updation.
Results are often
delayed.
No direct access to
system.
73. 73
COMPARISONS:
Batch processing:
Files are on-line while
processing.
User has no direct access
to the system.
Data is collected and
processes in batches.
Master file is updated
after the last record is
completed.
Suitable for high volume
transactions.
On-line processing:
Files are always on-line.
User has direct access to
the system.
Data is processed as soon
as transaction takes
place.
Master file is updated as
soon as transaction takes
place.
Suitable foe reservation
and business control
system.
75. 75
DATA ORGANIZATION
Organized before processing
Hierarchical Approach is recommended.
Various terms are:
Data Item
Field
Record
File
76. 76
DATABASE
Collection of related files:
Variable & fixed length records
Variable length records:
Record A Record B Record C Record D Record D
120 bytes 120 bytes 120 bytes 120 bytes 120 bytes
Record A Record b Record C Record D Record E
120 bytes 150 bytes 200 bytes 500 bytes 270 bytes
77. 77
DATA BASE
Logical v/s Physical records
Logical
Physical
IBG
R1 R2 R3 IBG R4 R5 IBG R6 R7 R8
78. 78
FILE ORGANIZATION:
Data and information
Data:
Collection of well defined numbers,informations and
facts.
Data is meaningful fact.
E.g. 4532432 not mean anything, related to any item
means anything.
Information:
Processes data on which decisions and actions are
based.
Organized and classified data to provide the
meaningful information to receiver.
80. 80
CHARACTERSTICS OF INFORMATION:
Accuracy: should be accurate
Form: in the useful form to the user
and understandable.
Relevance: information gains in value if
relevant.
Perfect timing: provide within time.
Completeness: complete when needed.
Purpose: Info. should have purpose when
provided.
Reliability: should be reliable.
Validity: closeness of info to the purpose.
81. 81
DATA FIELDS
Individual data items in a record.
Size of the field.
Cumulative size( sum of all the fields)
Records in the file with same structure
Records in the file with variable structure
Diff. between same and variable field record.
Header Item Item Item Item Item
Header Item Item Item
Header Item Item Item item
82. 82
CONCEPT OF DATA FIELD:
Individual data items are called data field.
Primary field:
Uniquely identify the record/column
Secondary field:
Second to the primary field.
Data collection:
Initial stage (internal/external)
Internal:
predefined formats.e.g. loan cases
External:
depend upon the survey(availability)
83. 83
DATA VERIFICATION & INTEGRITY:
Data editing:
Addition of relevant records and deletion of
irrelevant records.
Generally done by the supervisor, not by DEO
Data checking:
Accuracy checks to remove the irrelevant data.
Relevant messages regarding data entry screens.
Conditional checks can be applied.
84. 84
DATA BANK
Data Bank
Keeping points in consideration.
Random methods not followed.
Little deviation accepted
Data should be bulky rather than small volume.
Some source from where derived.
Interaction with events and audience.
E.g . Employee database/catalogue of the university
library.
85. 85
DATA VERIFICATION & INTEGRITY:
Data verification:
Whether up to the requirements or not.
Apply check controls for verification.
Integrity:
Data contained in the table or file accurate or consistent.
Data preparation:
Preparation of database for info. Generation.
Depends upon:
Present trends in the market
Available products.
Price range of the product.
Target consumer.
Deviation in the taste of the customer.
Potential area for marketing of the product.
86. 86
FILE CONCEPTS:
Bit,Byte,fields,record,file.
Biodata (file name)
Name Age Sex address Qualification
Raman 21 M Una Bsc
Suresh 22 M Una BA
Simpy 23 M Una B.Com
Rekha 21 F Una BBA
Monika 21 F Una BCA
87. 87
FILE CHARACTERISTICS
Responsibility of system software known as IOCS
( Input-output control system)
Record Size- size of record in a tape/ chosen by
the programmer
Block size- consecutive records .No. of records is
called “Blocking factor”
Buffers-I/o operations independent of CPU
known as data channel.
Label records/Disk dictionary-file header stores
most imp. Info. Called file title. IOCS maintains
data dictionary.
88. 88
TYPES OF FILES:
Master file
Transaction file
Backup file(dump file)
Report file
Archival file
Transfer file
Master file:
Primary file, permanent nature, records kept for long
terms.
E.g. Biodata of emp, banking system
Two categories:
Reference master file-records unlikely to change in nature.
Dynamic master file-frequently updated records.e.g routine
business activities, reservation chart.
89. 89
TYPES OF FILES:
Transaction file:
Also called movement or input file.
For daily updation of records( e.g. sale/purchase)
Used to update the master file.
Temporary in nature.
Not of any use after updating the master file.
Backup file:
Duplicate copy of master/transaction file.
Used for security.
Report file:
Also called Output file.
E.g. water, electricity bills, monthly salary of emp.
90. 90
TYPES OF FILES:
Archival file:
Information regarding the past events of the firm.
Used for info. and conclusions.
Transfer file:
Used to carry data regarding an event
(business/production transaction)
Used to serve input to another process to create or
update another file.
Used for sorting file.
Sorted file can also be used to update master file.
91. 91
FILE ORGANIZATION:
Serial files
Sequential files
Index sequential file.
Random/direct access file.
Serial file:
Records are stored one after another serially.
No order of arrangements
E.g. magnetic tape.
92. 92
FILE ORGANIZATION:
Sequential file:
Files are arranged as serial.
Data is asc/desc.
Used sequential search.
Master files/batch processing.
Updation (add/delete)takes lot of time.
Advantages:
Files are simple, easy to design.
If processing rate is high then system is economical and
efficient.
Input medium is less expensive.
Record key is required to locate the record.
Can be created on any design.
93. 93
FILE ORGANIZATION:
Disadvantages:
When activity rate is slow updation is time
consuming.
Only disk file are to be updated.
Add/del is tedious job.
Relative files:
Each record is identified by its original position
within the file. Can be accessed randomly as well
as seq.. For sequential access simple execute
READ and WRITE.
94. 94
For random access you must define the data item
as a relative key and then specify, in the data
item, the ordinal number of the record you want
to READ and WRITE.
Indexed File:
Each record include a primary key to distinguish one
record from another
Primary key is unique.
Can be accessed randomly by entering value of the
records primary key
Can be accessed sequentially
Also contain alternative key( one or more additional
keys)- need not to be unique.
95. 95
Index sequential file:
Created on magnetic disk.
Retrieved by direct/sequential method.
Advantages:
Updation simple,recors linked between two files,
quick access to the file is possible, economical and
efficient.
96. 96
FILE ORGANIZATION:
Disadvantages:
Storage space is not fully utilized.
Records can be linked between two files.
Expensive hardware/software is needed.
Add/delete is tedious as it effects the index file.
Only stored on direct access storage devices like
disks.
Random/direct access method:
Direct access to the record without reading the
previous number.
Use index number.
97. 97
FILE ORGANIZATION:
Advantages:
Immediate updation is possible in a lesser time.
Job is efficient as time consuming is less.
Immediate access to the file is possible.
Disadvantages:
Expensive-hardware is req.
Less efficient in terms of utilizing storage space.
Not well suited for batch processing.
Access on magnetic disk, tape if useless.
98. 98
FILE OPERATION:
Accusing of records:-
No updation is done ,only records are accessed.
File enquiry:
if there is any dispute between party and the
company.
File updation:
records are updated in the master file.
File maintenance:
addition/deletion/updation of records.
99. 99
FILE PROCESSING IN CASE OF
SEQ/SERIAL ACCESS DEVICES:
Updation:
Magnetic tape as storage media.
It is not possible to add records after the record is
read.
Involves the creation of new master file.
Should be in seq. file.(e.g. cassette)
Maintenance:
Add records to correct seq.
Referencing:
Searching/ref a record, each record has to be go
through.
Enquiring:
Used for particular enquiry.
100. 100
FILE PROCESSING ON DIRECT
ACCESS STORAGE MEDIA:
Two ways are there:
When data is organized in serial manner.
When data is organized in non-serial manner.
Serial manner:
Similar to record stored on tape.
True direct access can not be applied as data is on
tape.
Only possibility is binary search.
Non-serial:
Possible to add record at the place of reading.
Original master file is updated by the updated
master file.
101. 101
FILE MAINTENANCE:
File maintenance:
Not possible to store the Updated record at the same
place after updation.
Sufficient space should be there.
Indexing:
Record keys are listed with the app. Key address.
Address generation:
Mathematical formulae can be applied to solve the
problem.
File activity ratio:
No. of record accessed/total no. of record
102. 102
ADDRESSING OF RECORDS:
Direct access:
Primary keys are used to access the records.
Records are seek & read in one pass.
Processing time is min.
E.g. result system ( primary key as roll no.)
Disadvantage:
Wastage of storage space req. for every address.
Indirect access:
Address is generated by the mechanism hashing scheme.
Transforms the key space to the address space of the records.
Diff. routines are used and best is used after analysis.
Corresponding to a record a unique address is generated.
In this address record is to be resided.
If record key generates the same address then collision occurs.
Otherwise synonyms occurs.
103. 103
METHODS OF DEVELOPING HASHING
SCHEME:
Method of division:
Each key is divided by a suitable no, quotient is used for
addressing the records in a direct file.
Method of remainder:
Each key is divided by a suitable no, remainder is used for
addressing the records in a direct file.
Method of truncation:
Uses division method, uses power of 10 for division.
E.g. 8-digiy key is assigned to 3-digit address.
5524682 results in 682.
Method of folding:
Extracting of digits by folding the key address upon itself.
613083=613+083=696
Method of extraction:
Suitable group of digits can be extracted from the key field.
552468261- 3 digits can be selected from the middle to give the
result, also 2,5,8 digit can be used to give the address as 566
105. 105
INDEX SEQ. ACCESS METHOD:
Original file is kept in desired sequence.
On entry for every block of record is made.
e.g. suppose 40 records in each block & n is no of total
blocks, then there will be n/40 entries in the index file, if
n=32000 then
INDEX FILE=TOTAL RECORDS/BLOCK SIZE
File labels:
header label and trailer label.
Header labels:-file name, date written, purge data( date
on which data deleted)
Trailer labels:-
Last record in the file, contain all info of the header
file. also record of record count
Header label trailer label
107. 107
ELEMENTS OF COBOL:
Valid characters
Letters,digits,characters,special characters.
Punctuation characters.
Grammatical rules as in English language
E.g. ( ) , . ; + _ * / :
Semicolon or comma must not proceeded by a space.
At least one space between two successive words.
Command can be used as a separator between two
statements.
Relational characters must be preceded by a space also
followed by a space.
COBOL Characters.
Reserved words, user define words.
108. 108
ELEMENTS OF COBOL:
Reserved words
ADD,READ,OPEN,SUBTRACT,CLOSE,ZERO,
SELECT,WRITE,DIVIDE,SPACE,MOVE,PICTURE.
User define words.
Literals/Constants.
Literals is a constant( integer or real)
Numeric literals.
Non numeric literals.
Figurative constants
109. 109
LITERALS
Numeric literals:
At least have one digit but not more than 18 digits.
Characters 0-9 can be used.
No blank is allowed between sign and first
characters.
It may have sign + of –
If sign is omitted it is treated as positive.
Decimal point is allowed in literals.
It may appear anywhere except as last character.
E.g 26, -8,333, 0.5 are valid
22. ,+ 89, 21,564 are invalid
110. 110
LITERALS
Non numeric literals:
String of COBOL characters enclosed within quotation
marks. E.g. “Marks”
Rules;
Max 120 characters in strings.
Start and end with “ ”.
Any characters any be placed between “ ”.
Figurative constants:
Special type of literal in COBOL.
e.g. ZERO,ZEROS,ZEROES
SPACE,SPACES,
LOW-VALUE
HIGH-VALUES
QUOTE,QUOTES
ALL
MOVE ZERO(ZEROS) TO WORK.
111. 111
DIVISIONS OF COBOL PROGRAM
IDENTIFICATION DIVISION.
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
IDENTIFICATION DIVISION:
First division.
Simplest division.
Must be coded in every COBOL programe.
Main purpose is to identify the source pgm. And related
info.
No. of paragraphs without sections.
Division header is must and followed by ( . )
E.g. PROGRAM-ID. CALC
Other lines are optional.
112. 112
IDENTIFICATION DIVISION
IDENTIFICATION DIVISION 1
PROGRAME-ID. Program-name 2
[ AUTHOR . [Comment entry] ] 3
[ INSTALLATION. [Comment entry] ] 4
[ DATE –WRITTEN. [ Comment entry] ] 5
[ DATE-COMPILED. [ Comment entry] ] 6
[ SECURITY. [comment entry] ] 7
If entry is put in [ ] then it is optional and may be omitted.
4- name at which source pgm. was written.
5- when pgm. was written.
6- when was compliled
7- security level attached to the pgm by programmer.
Must begin in area A (column 8-11)
Coding of comment section area is in area B (column 12-72)
113. 113
ENVIRONMENT DIVISION:
Machine dependent section .
Req. in every program and come after identification
division.
To specify the configuration of the computer used to
compile the source pgm. and to run object pgm.
Info. Related to i/o Hardware,characterstics,control
tech. OS characteristics.
Division has two sections:
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION
114. 114
ENVIRONMENT DIVISION:
CONFIGURATION SECTION:
Contain three paragraphs:
SOURCE –COMPUTER.-computer used for
compilation.e.g IBM-PC
OBJECT –COMPUTER- on which it is to be executed.
SPECIAL-NAMES PARAGRAPH
Assign user defined name.
Used to change editing characters.
e.g POINT IS COMMA.
PRINTER IS LP
If any of the above paragraphs are included in
pgm,then header must be entered.
1st
and 2nd
are for documentation purpose and serves as
comments.
115. 115
Relation in three division
The i/o device that will be used to read or write
will be define in ENVIRONMENT DIVISION.
DATA DIVISION specify the characteristics and
structure of the data within the files.
PROCEDURE DIVISION specify the read and
write statements for using these files.
116. 116
INPUT OUTPUT SECTION:
Must specify if user is using any i/o within a
program for i/o purpose.
This is the header area.
Must be start in area A.
If data files are not required then this section is
not required as COBOL processes on files so this
is the must part. concerned with i/o devices.
This section has two parts:
FILE-CONTROL paragraph.
I-O-CONTROL paragraph
117. 117
INPUT OUTPUT SECTION:
FILE-CONTROL paragraph:
Names the files that are to be processed and
associate files into specific i/o devices.
Example:
SELECT BILL-FILE ASSIGN TO DISK
SELECT BILL-LIST ASSIGN TO PRINTER.
Assign clause does the association between file and
devices. there are separate clauses for seq,direct,index-
seq. files.
Some other clauses are:
ORGANISATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL.
118. 118
I-O-CONTROL paragraph:
Special control req. to control the exe. Of the
program.
SAME AREA clause defines that two or more
files uses the same memory.
119. 119
Example:
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE –COMPUTER.
OBJECT-COMPUTER IBM-PC
SPECIAL –NAMES.
PRINTER IS LP.
CO1 IS CHANNEL-1.
CURRENCY IS “RS”
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT OLD FILE ASSIGN TO DISK.
SELECT TRANS-FILE ASSIGN TO FLOPPY.
SELECT REPO-FILE ASSIGN TO PRINTER.
I-O CONTROL.
SAME AREA FOR
OLD-FILE.
TRANS-FILE.
REPO-FILE.
120. 120
DATA - DIVISION
Complex of all the division in COBOL.
Define all the variables.
Data that the program accept as input to manipulate , to create
output.
Three categories are:
Data in the files that is as input and output.
Data in the work areas on computers.
Constant data that is to be used by the program.
SOME TERMS ARE:
Item
Elementary item.
Group item.
Independent item.
121. 121
DATA DESCRIPTION ENTERIES :
PICTURE CLAUSE
General characteristics of an elementary data item
CLASS
Three class-numeric, non numeric, alphanumeric
SIGN
Signed/unsigned-implicitly considered as unsigned and during
exe. Treated as positive
POINTER LOCATION
Position of decimal point in case of numeric data, if not specified
then immediately after the rightmost digit
SIZE
No of characters /digits req. to store the data.
CODE CHARACTER
Diff. codes are used to store the various kind of data.
122. 122
DATA DESCRIPTION ENTERIES :
PICTURE
PIC –Both are the characters tics.
Code characters:
9-indicates the corresponding character
position contains a numerals.
X-any allowable characters from the
COBOL character set.
A-contains only letter or space character
P-position of the assumed decimal point
when point lies outside the data item.
S-data item is signed.
123. 123
Exp. Of code characters:
PICTURE IS S999V999
PIC IS PPP999
PIC XXXXXX OR X(6)
VALUE CLAUSE:-
Value is literal
Exp:- VALUE IS 3.5.
VALUE IS “MY DATA”.
VALUE ZERO.
125. 125
Data Division Header
Req. part of every COBOL Program.
Start with the header DATA DIVISION
It contains three sections:
FILE SECTION
WORKING STORAGE SECTION
FILE SECTION
Described the data of the files that is described in
File-Control paragraph on Environment Division.
WORKING STORAGE SECTION
Data used in program that is not part of the
input and output.
126. 126
File section
File description entry followed by one or more
record description, must start with level
indicator. File name should be same as
desc.Descrived in environment section.
Exp
FD file-name LABEL records are
standard/omitted
Standard means specified for disk files
Omitted means for card reader/printer files.
127. 127
Example:
Card column date field type
1-5 salesman-no num
11-15 quantity numeric
21-3.0 unit-price numeric ( 2
decimal
places)
31-40 amount numeric ( 2
decimal
places)
Let the file name be card-file
The entries in the file section should be
128. 128
Example:
FD CARD-FILE.
01 CARD-RECORDS
02 SALESMAN-NO PIC 9(5)
02 FILLER PIC(X(5)
02 QUANTITY PIC 9(5)
02 FILLER PIC(X(5)
02 UNIT-PRICE PIC9(8)V99
02 AMOUNT PIN 9(8)V99
02 FILLER PIC(X(40)
Filler can be used for those fields on the cards which do not
contain any data such are described as alphanumeric data.
129. 129
Working-storage section:
Can be group items containing all its
subdivisions. There may be elementary data item
which do not belong to this group such are
defined by a special no 77. it must begin in area
A.
Example:
130. 130
Example:
Working-storage section
77 alpha-string pic x(20)
77 data-N pic 9(3) value zero
01 date
05 day pic 99
05 filler pic X value”/”
05 month pic 99
05 filler pic X value “/”
05 year pic 99
01
Inter-string pic x(20)
131. 131
Editing:
Print the numeric data suppressing the leading
zeros.
Edit characters for numeric data are:
Z,*,$,-,+,CR,DB,., , ,B,O,/
Z(zero suppression)-same as 0-9 except the
leading zeros in the source data. Z can not
appear to the right of 9. it may also be noted that
after the decimal point either the digit position
are indicated by all Z or none at all.
133. 133
* (ASTERISK)
SIMILER TO z EXCEPT THE LEADING ZEROS ARE REPLACED BY *
**999 04678 *4678
**999 00052 **052
**999 1^68 **001
$ (CURRENCY SIGN)
APPEARS AT THE RIGHTMOST LEFTMOST POSITION. $
SIGN IS INSERTED.
$99999 985 $00985
$ZZ999 985 $BB985
$**999 985 $**985
134. 134
- (MINUS SIGN)
Appear either at right or left place
-9999 -382 -0382
9999- -382 0382-
-zzzv99 -46^52 -b4652
-zzzv99 46^52 bb4652
+ (plus sign)
Similar to – (minus sign)
135. 135
CR and DB
Can appear only at rightmost position ,similar to
minus sign edit
9999cr -4562 4562cr
9999cr 4562 4562bb
Zzzcr -42 b42cr
Zzz9v99db -152^25 b15225db
Zzz9v99db 152^25 b15225bb
137. 137
B(blank insertion)
Insert a space character
99B99B99 1510182 15b01b82
0(zero insertion)
0 will be inserted instead of blank.
9900 12 1200
09990 456 04560
138. 138
/(slash insertion)
99/99/99 150681 15/06/81
999/999/99 3245 000/032/45
Blank when zero:
Will set entire data to blanks if its value equal to
zero. * can not be used when blank when zero is
specified. it is ignored by the compiler.
Example:-
Zzz.99 blank when zero 2^5 bb2.50
999.99 blank when zero 0 bbbbbb
Zzz.99 blank when zero 0 bbbbbb
139. 139
Floating insertion:
Appears in multiples of the left hand side of the
picture.
$$$$9.99 235^25 b$235.25
$$$$9.99 342 b$342.00
++++.99 -475^25 -475.25
++++.99 45 b+45.00
----.99 -3^ $$-3.50
----.99 -3^5 $$-3.50
140. 140
Special –name paragraph
If currency symbol other than $ is req. to for editing then
symbol may be edited in SPECIAL-NAMES paragraph of
the ENVIRONMENT DIVISION.This character may not be
adigit or letter A to D,L<P,R,S,V,X,Z or special character
blank *,-,.( ) +’ ‘ = / etc.
SPECIAL-NAME.
CURRENCY SIGN IS “character”
DECIMAL POINT IS COMMA.
141. 141
CLASS AND CATEGORIES OF DATA
Alphabetic,Nummeric,numeric edited,
Alphanumeric and alphanumeric edited.
A B
9 P S V
9 P V and at least one of the editing symbol
like B / Z O + - * CR DB
X 9 and must contain 9 and A
X 9,A,B,O and at least 0 or /
142. 142
Levels of data item:
Elementary and Group
Elementary
Level class category
Elementary alphabetic alphabetic
Numeric numeric
Alphanumeric numeric edited
Alphanumeric
Alphanumeric edited
Group
Alphanumeric elementary data within the group
144. 144
Blank Clauses:
Blank:
The screen description entry has various clauses
in ACCEPT and DISPLAY clauses.
Level-number [screen name]
[blank screen] [location-spec] [BLANK LINE] [BELL]
Underline
Reverse video field name blank when zero
Highlight justified right
Blink just
[auto,secure,required,full]
145. 145
Justified:
Used to justify (reverse) the standard left hand alignment
of the alphanumeric/alphabetic data.
JUSTIFIED RIGHT
JUST
SYNCHRONISED CLAUSE:
Allocates contiguous storage space to data items.
Comp-1 allocates 4 bytes.
First byte starts immediately. After previous data.
Data may not start with the word boundary.
This difficulty is solved by SYCHRINIZED.
Syntax:
SYCHRONIZED
SYNC
148. 148
Rules for rename clause:
Written only after the last record entry.
Used only after the level number 66.
Data name-2 and data-name-3 can be names of
elementary data items but no case they be the
members of 01,66,77,88
Data-name should not be used as qualifier.
Data-name-2 as well as data-name-3 can not
have OCCOURS clauses.
If data-name -3 be mentioned then it should be
follow data-name-2
149. 149
Redefine clause:
Use for the purpose allows the said area to be referred by
more than one data name with different size and picture.
Syntax:
Level number data-name-1 REDEFINES data-name-2
Example:
01 SALARY-REC
02 SALES-TYPE PIC 9
02 SALES-BY-COPIES.
03 QUANTITY PIC 9(4)
03 COPIES-PRICE PIC 9(7)VPP
02 TOTAL-SALES REDEFINES SALES-BY-
COPIES.
03 BILL-AMOUNT PIC 9(9)VPP
03 FILLER PIC X(2)
150. 150
Rules for redefine clause:
Level number of data name 1 and data name 2
are identical.
Both should be of same size except when redefine
clause used for 01 level.
Multiple redefine clause can be used.
Entries of new description can not have value
clause.
Redefine clause should not be used for records
(01 level)
Redefine clause can not be used for level no. 66
and 88.
151. 151
Working storage section:
Used to provide the heading for reports.
Contain entries for independent (non-contiguous)
items and record description entries.2nd
are not
part of external files and are developed and
processed internally.
1st
have no hierarchical relation with each others
and defined with level no 77.
2nd
are data items and have definite relationship
with each other.
Record are formed according to to the rules of
record description.
152. 152
Working-storage section:
It begin with a header followed by a period.
Working-storage section
77 non-contiguous data items
01 record description entries.
Record items:
Basic components of COBOL.
Identified by having a data name with 01 level
number.
Level will be in area A and data name in area B.
May be elementary data item or group item.
154. 154
Working-storage section:
FILLER CLAUSE:
05 FILLER PIC X(12)
Filler is mostly used in records for printing purpose to leave
blanks between two fields.
Example:
01 PRINT-REC
05 EMP-ID PIC X(5)
05 FILLER PIC X(5)
05 SALARY-DATE PIC X99
05 FILLER PIC XX
05 SALARY-MONTH PIC XXX
IF EMP-CODE IS T1121
SALARY-DATE IS 10
SALARY-MONTH IS AUG
OUTPUT WITH FILER CLAUSE WILL BE
T1121 10 AUG
OUTPUT WITHOUT FILLER CLAUSE IS
T112110AUG
156. 156
CATEGORIES OF DATA:
Numeric items:
Are described by giving 9 in the PIC clause.
S represents the operational sign.
V and S are sizes os an item.
157. 157
Usage clause:
Used to specify the form in which numeric data is
stored in the computer. this clause appears in
data description or record description eneteries
in the FILE-SECTION and WORKING-
STORAGE SECTION.
Format is:
DISPLAY
COMPUTATIONAL OR COMP
USAGE [IS] COMPUTATIONAL-1 OR COMP-1
COMPUTATIONAL-2 OR COMP-2
COMPUTATIONAL-3 OR COMP-3
INDEX
158. 158
Usage clause:
DISPLAY:
It indicates that one character can be stored in
each byte of an item. if usage is display the data
item need not to be numeric valid even for
alphanumeric. it is the default clause.
COMPUTATIONAL:
It must be numeric. specified for numeric data
items. The amount of storage to be occupied by
the binary data item depends on the no. of digits
in its PIC.
1-4 pic 2 bytes
5-9 pic 4 bytes
10-18 8 bytes.
159. 159
Usage clause:
05 UNITS PIC S9(8) USAGE COMP
OR
05 UNITS PIC S9(8) COMP
Another example:
05 PAYMENT COMP
10 COMP PIC S9(3)V99
10COMP PIC S9(3)V99
Comp-1 items are 4 bytes in length
Comp-2 items are 8 bytes in length
Comp-3 items are stored in packed decimal
format (2 digits per byte) with low order for bits of the right
bit bytes containing the operational sign. increases the
effectiveness of the programe.saves time.
If the data is for simple i/o purposes. DISPLAY clause
should be used in default.
160. 160
Value clause:
Used to initialize the data item before the
program execution starts..
Allowed in working-storage section.
Does not allow this clause in file section.
It is permitted in the description of elementary
items and group items.
Format is
Value is literal
77 tax-rate pic 9v99 value 0.25 (numeric)
77 sex-code pic x value ‘M’ non-numeric
77 marks pic 999 value zero
77 qualification pic 999 value zero
161. 161
Occurs clause:
it becomes quite often necassry to handle a group consisting of
similer items . Such a group is called table.
Example: Suppose ten diff. items of discount rate
01 DISCOUNT
02 DISCOUNT-1 PIC 99
02 DISCOUNT-12PIC 99
02 DISCOUNT-3 PIC 99
02 DISCOUNT-4 PIC 99
02 DISCOUNT-5 PIC 99
02 DISCOUNT-6 PIC 99
02 DISCOUNT-7 PIC 99
02 DISCOUNT-8 PIC 99
02 DISCOUNT-9 PIC 99
THIS CAN BE REWRITTEN AS
01 DISCOUNT
02 DISCOUNT PIC 99 OCCOUR 8 TIMES.
162. 162
Rules for occur clause.
It can not be a negative number.
Can be specified for an elementary item or a group item.
Can not be specified for level no 01,66,77,88
When data item is define with occur clause then such data
name and its subordinate items ( if any) can not be
referred in PROCEDURE DIVISION.
The range of value is from 1 to highest possible value of the
subscript.
The subscript should be enclosed in set of parenthesis.
When array is defined with occur clause ,the value clause
can not be specified for that particular item.
Can not appear in the same data description entry which
contain an OCCUR clause but the REDEFINE can appear
for a group item whose subordinate items are define with
the OCCUR clause.
Can appear in the data description entry in any order.
163. 163
Procedure division
Contains the statements which specify the operations to be
performed by the comp. it always start with a COBOL
verb.
ADD ALLOWANCE TO BASIC –PAY.
IF TOTAL-PAY IS GREATER THAN 1000 GO TO PARA-TAX-
CALCULATION.
A comma or semicolon may be used to delimit statements followed
by space.
Sentences can be grouped to form the paragraph and paragraphs
can be used to form sections. It can be headed by the name. section
names are user defined.
Operations required to process the data are as under:
Input/output
Data manipulation.
Arithmetic calculations.
Sequence control.
164. 164
Procedure division
EX:
MOVE ’akshay’ to name
Accept no
Add DA, basic giving gross
A sentence can be composed of more than one
statements.
Add a to b
Move salary to gross
Subtract deductions from gross.
PARAGRAPH IS MADE OF MORE THAN ONE
STATEMENT.
165. 165
INSERT-REC
MOVE IN-REC TO OUT-REC
WRITE OUT-REC
READ IN-FILE AT END STOP.
A section is the largest division of the
procedure division.
It consists of section header and one or more
paragraph one after the another.
COBOL verbs:
procedure division are prescribed by the use of
COBOL verbs they take place either at
compilation/execution time.
167. 167
INPUT/OUTPUT VERBS:
ACCEPT STATEMENT:
Although COBOL is used to handle large amount of data,
but sometimes it is necessary to read very important data
or initial data from terminal. For that purpose ACCEPT
clause is used.
Format:
ACCEPT identifier FROM mnemonic-name
ACCEPT DARATE
MORE:
ACCEPT DARATE FROM CDR
WHERE CDR IS THE SPECIAL NAME DEFINE IN
Environ. Div.
ACCEPT CUR-DATE FROM DATE
OS places the system date into the CUR-DATE.
168. 168
INPUT/OUTPUT VERBS:
DISPLAY CLAUSE:
Used for output
Display “good-morning”
Display abc
Display value stored in abc on screen
Display “ my name is “ abc.
MOVE VERB:
Move the data from one area of storage to one or
more storage area.
MOVE A TO B
MOVE AA TO AB.
MOVE N1 TO N2
169. 169
INPUT/OUTPUT VERBS:
Move:
Move numeric to numeric:
Data is aligned on the assumed decimal point in the
destination area.
Digit on the either end that do not fit are omitted.
Numeric part on right and decimal part on left.
If receiving data is large then sending data blank
all the left positions are filled with zeros.
170. 170
Numeric to alphanumeric:
when source is numeric and receiver is
alphanumeric
Move num to anum
Pic 999 pic x(5)
123 123 bc
Move 125.7 to dollars
Dollars pic 9(4)v99 012370
Move zeros to amount
Amount pic 999v99 00000
172. 172
INPUT/OUTPUT VERBS:
Another group is
05 p-item
07 p1 pic x(7)
07 p2 pic 9(7)
M1 has 4 data items and p-item has 2 data items
and both are 14 bytes.
Fact move is not possible but group move is
possible
Move m-item to p-item
03 m-item pic x(14)
03 p-item picx(14)
It is not necessary that both items should have
the same length .they may be larger or smaller
173. 173
INPUT/OUTPUT VERBS:
Perform statement:
Used to execute a group of consecutive statements
written elsewhere in the program.
Temporary departure from the normal sequential
execution.
After ex. Of the req. statement control implicitly
returns to the next statement following the
PERFORM statement.
possible for specified number of times.
Syntax:
PERFORM proc-name-1 THROUGH proc-name-2
PERFORM COMPUTE-INCOME-TAX
PERFORM START-COMPUTATION THRU END-COMPUTAION
174. 174
RULES FOR RANGE OF A PERFORM STATEMENT:
a GOTO statement is allowed within the range
of perform statement.
There is no restriction as to which should be the
last statement of a range. When the if sentence is
used at the end of a range the next sentence
refers to the return mechanism.
The use of perform statement within the range of
another perform statement is possible.
The range of the statements that should be
performed get linked up with the perform
statement only when the later is executed.
175. 175
PERFORM with TIMES option:
PERFORM para-2 5 times.
PERFORM para-2 thru para-4 5 times.
PERFORM with UNTIL option:
Perform para-2 UNTIL i>5.
PERFORM para-2 THRU para-4 UNTIL k>n
PERFORM with VARYING option:
PERFORM para-2 VARYING I from 1 by 1 UNTIL
i>20.
177. 177
Arithmetic verbs:
ADD:
Add value TO data-name.
ADD values GIVING data-name.
Example:
ADD AB TO AMOUNT.
ADD 20 TO TOTAL.
ADD NI,N2 TO TOTAL.
INVALID STATEMENTS:
ADD ‘223’ TO TOT-ITEM.
ADD TOTAL TO 920
ADD VAT TO ‘TOTAL’
ADD 25.50 TO TOTAL
178. 178
ANOTHER FORMAT OF ADD:
VALID:
ADD P,Q GIVING X.
ADD 5,TIME GIVING T.
ADD X,Y,3,N GIVING SUN-1,SUM-2
INVALID:
ADD A TO B GIVING C.
ADD A AND B GIVING C
ADD AB GIVING C
The reserve word TO,AND, is not allowed.
182. 182
01 PART-SUM
03 PART-1 PIC 9
03 PART-2 PIC 9
PROCEDURE DIVISION
ST-1
DISPLAY (1,1,) ERASE
DISPLAY (10,10)”ENTER AFOUR DIGIT NUMBER”
ACCEPT(10,40) GIVEN-NO
ADD DIG-1, DIG-2 GIVING SUM
ADD DIG-3, DIG-4 TO SUM
MOVE SUM TO PART-SUM
ADD PART-1, PART-2 GIVING SUM
MOVE SUM TO PART-SUM
DISPLAY (112,10) “SINGLE DIGIT IS”,PART-2
STOP RUN.
183. 183
SUBTRACT STATEMENT:
To subtract one or the sum of two or more numeric
data items from one.
To set the value of one or more items equal to the
result.
Format:
Subtract id-1 or nl-1 from id(s)
Subtract id-1 or nl-1 FROM id or nl GIVING id(s)
Example:
SUBTRACT A FROM B
SUBTARCT 20 FROM X
SUBTRACT A,B FROM C
SUBTRACT A FROM C,D
SUBTRACT A,B FROM C,D
184. 184
EXAMPLE:
SUBTRACT A FROM B GIVING C
SUBTRACT 80 FROM 50 GIVING C
SUBTTRACT TAX,PF FROM GROSS GIVING NET.
MULTIPY STATEMENT:
Used to multiply numeric data items.
MULTIPLY VALUE BY DATA-NAME.
Rules:
All operands must be numeric items except id(s) after
GIVING .
Example:
MULTIPLY A BY B
MULTIPLY 10 BY A
MULTIPLY A BY B GIVING C
MULTIPLY 10 BY A GIVING C,D
185. 185
More on multiply statement:
Example:
program to convert temp from cel. To Fahrenheit.
IDENTIFICATION DIVISION
PROGRAM-ID DIVISION
ENVIRONMENT DIVISION
DATA DIVISION
WORKING-STORAGE SECTION.
77 CENT-TEMP PIC 999V99
77 FAR-TEMP PIC 999V999
77 TEMPORARY PIC 999V999
PROCEDURE DIVISION
START-1
DISPLAY “TYPE IN TEMP. IN CENTIGRATDE IN FORM 999.99”
ACCEPT CENT-TEMP.
MUTIPLY CENT-TEMP BY 1.8 GIVING TEMPORARY.
ADD TEMPORARY,32 GIVING FAR-TEMP.
DISPLAY “TEMPRATURE IN FAHRENHITE IS”,FAR-TEMP.
STOP RUN.
186. 186
DIVIDE STATEMENT:
TO DIVIDE DATA ITEM INTO ANOTHER AND
SO ON.
EXAMPLE:
DIVIDE A INTO B
DIVIDE 4 INTO X.
DIVIDE Y INTO X.
ILLEGAL STATEMENT:
DIVIDE C INTO 9.5
DIVIDE X,Y INTO Z.
FORMAT-2
DIVIDE …… INTO ….. GIVING …..
DIVIDE A INTO B GIVING C
DIVIDE 5.1 INTO 10.5 GIVING D
187. 187
FORMAT-3
DIVIDE … INTO….GIVING…..REMAINDER
DIVIDE… BY….GIVING….REMAINDER.
EXAMPLE:
DIVIDE A INTO B GIVING Q REMAINDER R
DIVIDE A BY B GIVING Q REMAINDER R
ROUNDED OPTION:
IF FIGURE IS 80.236 THEN IN ROUNDED FORM IS
80.24
THE EXCESS DIGIT IN RIGHT IS DROPPED.
THE LAST DIGIT IS INCREASED BY 1.
ROUNDED IS DONE ONLY AFTER DECIMAL
ALIGNMENT.
ROUNDED OF NEGTIVE RESULT IS DONE BY
ROUNDING THE ABSOLUTE VALUE AND MAKING
THE RESULT NEGTIVE.
188. 188
EXAMPLE:
ADD A TO B ROUNDED
ADD A TO B GIVING A ROUNDED.
SUBTRACT 10 FROM SALES ROUNDED.
MULTIPLY P BY Q GIVING R ROUNDED.
DIVIDE S INTO T GIVING Q ROUNDEDE
REMAINDER R.
189. 189
SIZE ERROR OPTION:
Due to insufficient size the size error occurred.
The SIZE ERROR option is written immediately after any
arithmetic operation.
Format:
ON SIZE ERROR
Ex:
ADD A B GIVING C ON SIZE ERROR
ROUNDED ON SIZE ERROR:
ADD A TO B ROUNDED ON SIZE DISPLAY” RESULT IS TOO
LARGE”
In this rounded effect the last digit in PIC clause while SIZE
ERROR is concerned with value and size given in the data item.
We can also use the ; separating the ON SIZE ERROR clause
from the rest of the arithmetic statement.
DIVIDE COMMISION BY SALES-MEN GIVING AVG-COMM
ROUNDED ON SIZE ERROR GO TO ERR-PARA.
190. 190
THE COMPUTE VERB:
ARITHMATIC OPERATION EXPRESSION:
The compute verb is used in arithmetic expression.
GROSS-DEDUCTIONS
(1+RATE/100)*N
Writing COBOL Expression:
P+Q-R
Precedence rule for expression evaluation:
Perform all unary – and + first.
** next.
* and / next.
Add and subtract ( binary + and -) last in the order in
which they appear.
Scan the exp. From left to right.
Example:
A+B/C-D
192. 192
COMPUTE ROUNDED:
COMPUTE data-name ROUNDED =arithmetic
expression
COMPUTE NET-VALUE ROUNDED=GROSS-
DISCOUNT
COMPUTE…SIZE ERROR:
When computed value is large and size defined in
the PIC clause is not sufficient to hold the value.
Example:
COMPUTE P=Q/2*T ON SIZE ERROR PERFORM
ERR-B THRU ERR-R
193. 193
COMPUTE USAGE:
A data name declared Numerical data can be stored
through DISPLAY and COMPUTATIONAL (COMP) form.
If it is in DISPLAY editing and displaying is easier. but in
calculations it takes a lot of time hence inefficient. if a
data name participates in calculations number of times,
then it is advised to declare the items the data item as
USAGE COMP.
as DISPLAY may be converted to COMP form:
03 NETPAY pic 999v99
WORKING STORAGE SECTION
03 WS-NET PIC 9999V99 USAGE COMP
PROCEDURE DIVISION
MOVE NETPAY TO WS-NET
194. 194
CONDITION:
It is an entity which have one or more value in a given
time.
Types:
Relational condition
Sign condition
Class condition
Condition-name condition
Negated simple condition
Compound condition
If condition:
Check if the result is true/false
SALES IS LESS THEN 50000
195. 195
IF SALES IS LESS THAN 50000
MOVE BASIC TO SALARY
ELSE
COMPUTE SALARY=BASIC+BASIC*0.1
RELATIVE CONDITIONS:
HAS SIMILAR NAME LIKE RELATIONAL EXPRESSION,
LOGICAL EXPRESSION ,LOGICAL CONDITION,
CONDITIONAL EXPRESSION. Compare two expressions. when
both are numeric items USAGE of both may be diff.First operand
is called subject and second operand is called object
IS [NOT] GREATER THAN IS [NOT]>
IS [NOT] LESS THAN IS [NOT]<
IS [NOT] EQUAL TO IS [NOT]=
196. 196
IF SENTENCE:
IF SENTENCE –first form
IF GROSSPAY IS GREATER THAN 150000
COMPUTE TAX=(GROSSPAY-100000)*0-10
ADD TAX TO GROSS-TAX.
If statement is true then seq. of statement following the IF is
carried out eELSE statements up to full stop( . ) are not
executed.
IF SENTENCE –second form
IF GROSS PAY <150000
COMPUTE TAX=GROSSPAY*0.10.
ELSE
COMPUTE TAX=GROSSPAY*0.5.
obserb the placement of ( .) after the complete IF statement.
197. 197
More on relative conditions:
Two types:
Comparison of numeric operands
Comparison of non-numeric operands.
Numeric operands:
Depends upon two conditions;
Sign of the number.
Magnitude of the number.
When the decimal and packed decimal items are
compared ,binary items are converted to packed decimal
before the comparison begins.
025(999) 25(99) equal
10-(99-) 000+(99v99+) operand 1 is < operand 2
10001(9999v99) 110000(9999v9) operand 1 > operand 2
198. 198
Complete example of numeric
comparison :
check odd/even
IDENTIFICATION DIVISION
PROGRAM-ID IF-STATE
AUTHER ABC.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION
77 NUMBER PIC 9(4)
77 REMAIN PIC 9
PROCEDURE DIVISION
DISPLAY “TYPE A 4-DIGIT NUMBER:”
ACCEPT NUMBER
DIVIDE NUMBER BY 2 GIVING NUMBER REMAIN
IF REMAIN EQUAL TO 0
DISPLAY “ THE NUMBER IS EVEN”
ELSE
DISPLAY “ THE NUMBER IS ODD”
STOP RUN
199. 199
NON-NUMERIC OPERANDS:
Comparison of two non-numeric operand ,need
not to be variables. they are either <,> or =.at
least one of them may be non-numeric like
”ABC”.if one of the operand is numeric then also
it is considered as alphanumeric and comparison
takes pace accordingly.
IF NAME-1 IS EQUAL TO NAME-2
MOVE DESIG TO POST
ELSE
MOVE DESIG TO POSTING.
Alphanumeric comparison is done by comparing the value of the
characters starting from left to right. Compare until two chanter
are found that are not equal or until the end of the file is
reached.
200. 200
NON-NUMERIC OPERANDS:
Secondly if the operands are of equal size.
If operands are of diff. length the shorter operand
is extended on the right side by the required
blanks to make both operands equal
A250 9250 OP1 >OP2
450 45J OP1<OP2
MNOPQ ABC OP1>OP2
PQRb PQR op1=op2
Abc2 abc op1>op2
201. 201
IF-CLASS CONDITION
Check whether is numeric or alphabetic
IF SUM IS NUMERIC (between 0-9)
IF NAME IS ALPHBETIC ( between a-z)
Example:
05 AGE PIC S9999
IF AGE IS NUMERIC
PERFORM TEST-1
ELSE
PERFORM TEST-2
05 TCOD PIC A
IF TCOD IS ALPHBETIC
MOVE FAST TO NEW-MAST
202. 202
NESTED –IF STATEMENT:
If within another IF is called as nested IF
Syntax:
i) IF statement….
If statement …
ELSE
…..
…
ii)
IF Statement…
IF statement….
ELSE
ELSE IF ….
ELSE NEXT SENTENCE.
203. 203
EXAMPLE:
IF EMP-CODE=1
IF DAYS-WORKED IS GREATER THAN 200
MOVE ONE TO BONUS-CODE
ELSE
NEXT SENTENCE
ELSE IF DAYS-WORKED IN GREATER THAN
250
MOVE 2 BONUS-CODE
ELSE NEXT SENTENCE.
204. 204
SIGN CONDITION:
This determines whether or not the algebraic value of an arithmetic
expression is <,>,=
An operand is
Positive is value>0
Negative if value<0
Zero if value=0
Example:
IF AMOUNT IS NOT ZERO
MOVE AMOUNT TO NEW-AMOUT
ELSE
MOVE OLD-AMOUNT TO NEW-AMOUNT
Example2:
IF P*Q IS POSITIVE
PERFORM COMPT
ELSE
PERFORM ERR-PROC.
205. 205
IF-PRGRAMMING EXAMPLE:
PROBLEM:
Fix-deposit interest criteria of a bank is
>=3 years 10%
=1 and <3 years 9%
Program:
IDENTIFICATION DIVISION
PROGRAM-ID FIXED-DEP
AUTHER ABC
ENVIRONMENT DIVISION
DATA DIVISION
WORKING-STORAGE SECTION
77 DEP-NO PIC X(5)
77 DEP-NAME PIC X(25)
207. 207
PROCEDURE DIVISION
DISPLAY “DEPOSITOR NAME=30 CHARACTERS”
ACCEPT DEP-NAME
DISPLAY”YEARS OF DEPOSIT-2 DIGITS”
ACCEPT DEP-TIME
SEL-INT
MOVE DEP-NAME TO O-DEP-NAME
MOVE DEP-TIME TO O-DEP-YEARS
IF DEP-TIME IS LESS THAN 3
MULTIPLY DEP-AMNY BY 0.09 GIVING INT
ELSE
MULTIPLY DEP-AMNY BY 0.10 GIVING INT
208. 208
ADD INT DEP-AMNT BY 0.20 GIVING INT
MOVE INT TO O-INT
DISPLAY OUT-REC
STOP RUN.
CLASS CONDITION:
Check whether the value of operand is numeric
or alphanumeric.
Identifier IS [NOT] NUMERIC/ALPHBETIC
209. 209
RULES FOR CLASS CONDITION:
Name of the identifier should be DISPLAY or some
form of DISPLAY.
For numeric option the identifier should be either
numeric/alphanumeric.
For alphabetic option the identifier must be
alphabetic/alphanumeric
It may be a group item. However for numeric option
group item must not contain elementary items
E.g if non-numeric value is stored in numeric value
an error will occur but not displayed.
IF GROSS-PAY IS NOT NUMERIC GO TO PARA-
ERROR.
210. 210
CONDITION-NAME CONDITION:
This is itself a condition and have true/false condition.
Can not be defined independently.
Always associated with a condition variable.
Can be defined in any section of DATA DIVISION.
And must be placed immediately after the conditional
variable.
May be more than one condition name.
A condition name either have a single variable or
have a set of values.
Condition may be true/false.
88 condition name value/values is/are literel-1 thru
literal-2 literal-3 thru literal-4
211. 211
RULES FOR CONDITION-NAME
Condition name are mentioned at level no 88.
Works as per naming rules. if same name is used
in more then one place, the condition name must
be qualified by the name of its conditional
variable.
The name of the conditional variable can be used
as a qualifier for any of the condition name.
The value specified by the VALUE clause in the
condition name entry must not conflict with the
data desc of the conditional variable.
When THRU clause is used literal-1 must be less
then literal-2 and so on.
212. 212
A conditional variable can be any elementary
item or group item
77 TAX-PAYERS-TATUS PIC 9
88 INDIVISUAL VALUE IS 1
88 HUF VALUE IS 2
88 PROPERIETER VALUE IS 3
88 PARTNERSHIP VALUE IS 4
88 SENIOR-CITIZEN VALUE ARE 1,4
88 VALID-STATUS VALUE ARE 0 THRU 4
213. 213
The following statements can be used in the
above mentioned structure:
IF HUF SUBTRACT 150000 FROM
GROSSPAY
IF PROPRIETOR SUBTRACT 195000 FROM
GROSS-PAY
IF NOT VALID -STATUS GO TO ERROR -IN-
STATUS
214. 214
NEGATED SIMPLE CONDITION;
Any of the simple condition can be preceded by
the logical operator NOT. This operator reverse
the condition of the condition.
This can be used in two ways- in simple
conditions it can be used as a part of the
condition.---it can be precede a simple condition a
simple condition to make it a negated simple
condition.
Example: TAX NOT LESS THAN 100000
Another (second way ) is NOT LESS THAN
100000
215. 215
COMPOUND CONDITION:
Two simple conditions can be connected by the
logical operators AND or OR to form a compound
condition.
Exp:
BALANCE GREATER THAN 999 AND
BALANCE LESS THAN 100001.
BALANCE GREATER THAN 999 OR BALANCE
LESS THAN 100001.
216. 216
COMPOUND CONDITION: EXAMPLE
Sorting of numbers:
SORTING-NUMBERS
PERFORM SORTING
VARYING 1 FROM 1 BY 1 UNTILL I=N OR NO-EXCHANGE
SORTING
MOVE 0 TO EXCHANGE-FLAG
SUBTRACT 1 FROM N GIVING K
PERFORM COMPARISON
VARYING J FROM 1 BY 1 UNTIL J>K
COMPARISON
SET A1 TO J
IF NUMBER(A1)>NUMBER(A1+1)
MOVE NUMBER(A1) TO TEMP
217. 217
MOVE NUMBER (A1+1) TO NUMBER (A1)
MOVE TEM TO NUMBER(A1+1)
MOVE 1 TO EXCHANGE –FLAG
Entries for WORKING-STORAGE SECTION
01 DATA-ENTRY FOR SORTING-NUMBERS
02 I PIC 9(3)
02 J PIC 9(3)
02 K PIC 9(3)
02 N PIC 9(3)
02 EXCHANGE-FLAG VALUE IS ZERO
02 TEMP PIC 9(6)V99
The above program can be sorted by using the statement
PERFORM SORTING.
219. 219
TYPE OF FILES;
Sequential files
Index sequential files
Direct files
Sequential files:
Records are arranged on the basis on the basis of
their physical locations in the files.
Records are according to the key as well as in the
physical sequence.
Creation of the file is easy.
Only you can go forward.
Most of the records are processed each time file is
read.
Can be organized in all storage devices like tape,disk.
220. 220
CREATION OF SEQ. FILE ON DISK:
In order to specify that a file will b eon the tape
or disk certain enteries must be specify the FILE-
CONTROL section.
ENVIRONMENT-DIVISION
INPUT-OUT SECTION. FILE CONTROL
SELECT file-name ASSIGN TO system-name
[; RESERVE interger-1 (AREA AREAS)]
[; ORGANIZATION IS SEQUENTIAL]
[;ACCESS MODE IS SEQUENTIAL]
[; FILE STATUS is data-name]
221. 221
SWLECT clause is must and must be specified first.
ASSIGN clause specifies the association of file to a storage media.
ORGANIZATIO specify the logical structure.
ACCEES specify in which read and write operations are done.
FILE STATUS is optional
EXAMPLE:
ENVIRONMENT DIVISION
INPUT-OUTPUT SECTION
FILE-CONTROL
SELECT EMP-IN-FILE ASSIGN TO DISK.
ORGANIZATION IS SEQUENTIAL.
ACCESS MODE IS SEQUENTIAL.
FILE STATUS IS EMP-FIL-STATUS
222. 222
SEQUENTIAL FILES: DATA DIV.
ENTRIES
FD file name
BLOCK CONTAIN clause.
LEVEL RECORDS clause.
Every file must be defined within FD ,defined in
FILE-SECTION which is first section of DATA DIV,
FD is heading must be in Area A and remaining
part will be in Area B.
Example:
FD STOCK
LEVEL RECORS ARE OMMITED.
BLOCK CONTAINS 12 RECORDS.
RECORD CONTAINS 128 CHARACTERS
DATA RECORD IS TARTS-REC
223. 223
SEQUENTIAL FILES:
PROCEDURE DIVISION ENETERIES:
To use the file they must be opened with the
appropriate phrases INPUT,OUTPUT or I_O in
OPEN statement.
For reading a file –READ … AT END statement
is used.
WRITE statement is used to write a file. If the
file is printer file ADVANCING option to control
the page movement.
After the job is completed file must be CLOSED.
We can create a seq. file on disk directly from the
terminal. Data packages are available to do so, data
is entered through the terminals. If data package is
not available we can create seq file through terminal.
224. 224
IDENTIFICATION DIVISION
PROGRAM-ID DISK-FILE –CREATION
AUTHER ABC
ENVIRONMENT DIVISION
INPUT-OUTPUT SECTION
FILE-CONTROL
SELECT MASTER-FILE ASSIGN TO DISK
DATA DIVISION
FILE SECTION
FD MASTER-FILE
BLOCK CONTAINS 12 RECORDS
LEVEL RECORDS ARE STANDARD.
01MASTER-REC PIC X(80)
227. 227
SEQ. DATA FILE ON DISK
PROGRAMMING
To create a seq. file of emp. In an organization.
output layout should be
1-5 Employee number
6-35 Employee Name
36-80 Address
IDENTIFICATION DIVISION
PROGRAM-ID EMP-CREATE-SEQ-FILE
AUTHER ABB
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
228. 228
SELECT MASTER-FILE ASSIGN TO DISK.
DATA DIVISION.
FILE SECTION.
FD MAIN-FILE
LEVEL RECORDS ARE STANDARD
VALUE OF FILE-ID IS ‘MAIN.DAT’
01 MASTER-REC PIC X(80).
WORKING-STORAGE SECTION
01 TERMINAL-REC
03 T-NUMB PIC 99999
03 T-NAME PIC X(30)
03 T-ADDRESS PIC X(45)
231. 231
UPDATING A SEQUENTIAL FILE:
Creation of one or more disk files from existing seq.
file
Updating data of master file.
Updating data of master file using the transaction
file.
Disk file can be updated using a single file b’coz that
can be opened in i-o mode both for read and write.
Tape file can be used only for input or output one at a
time .
To update a tape file we have a to create a new file.
Existing file is read-in one at a time. Changes can be
made to any or all records but each record if changed
must be written to output tape otherwise will be lost.
232. 232
Ex.:-
suppose we have a master file with records
about an employee. We need to change pension-
code on the records of all women employees by
setting pension-code equal to X.
PROCEDURE DIVISION.
MAIN-LOGIC
OPEN INPUT OLD-FILE
OUTPUT NEW-FILE
READ OLD-FILE
AT END MOVE ‘Y’ TO FILE-EOF.
PERFORM UPDATE-FILE UNTIL FILE-
EOF=‘Y’
233. 233
CLOSE OLD-FILE NEW-FILE
STOP RUN
UPDATE-FILE
IF SEX-CODE=‘F’
MOVE ‘X’ TO PENSION=CODE
WRITE NEW-REC FROM OLD-REC
READ OLD-FILE AT END MOVE ‘Y’ TO FILE-
EOF
234. 234
ANOTHER EXAMPLE:
Another type of creation data from a disk file
called QTYFILE is to used to control CALCFILE
ans TRS-FILE
QTYFILE:
1-5 account number
6-7 month
8-9 day
10-13 qty1
14-17 qty2
18-21 qty3
22-25 qty4
235. 235
CALCFILE AND TRSFILE:
1-5 account number
6-7 month
8-9 day
10-14 sum
15-19 sum2
20-24 difference
25-34 product1
35-40 product2
41-45 quotient
45-50 remainder
51 code1
236. 236
Atleast one of the four field quantity 1,2,3,4 in the
QTYFILE is >=14 then record is created iin
CALCFILE .if three fields are <14 then records are
created on TFILE .both CALFILE,TFILE have same
record.
Formulas are;
Sum1=qty1+qty2+qty3
Diff=qyu4-qty3
Product1=qty3*qty2
Prod2=qty3*qty2
Quotient=q1+q2+q3/q2 with remainder in remain
Code=M if q2<100,N if q2>100,P if q2=100.
237. 237
SOLUTION:
IDENTIFICATION DIVISION
PROGRAM-ID SEQ-FILS-CRE.
AUTHER SWARN
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT QTYFILE ASSIGN TO DISK.
ORGANIZATION IS SEQUENTIAL.
ACCESS IS SEQUENTIAL.
SELECT CALCFILE ASSIGN TO DISK.
ORGANIZATION IS SEQUENTIAL.
ACCESS IS SEQUENTIAL.
SELECT TRSFILE ASSIGN TO DISK.
ORGANIZATION IS SEQUENTIAL.
ACCESS IS SEQUENTIAL.
240. 240
FD TRSFILE
RECORD CONTAINS 51 CHARACTERS
BLOCK CONTAIN 11 RECORDS
LABEL RECORDS ARE STANDARD.
DATA RECORD IS TREC.
01 TREC PIC X(51)
WORKING-STORAGE SECTION.
77 WSUM PIC S999V99
77 EOF-FLG PIC X VALUE ‘N’
PROCEDURE DIVISION.
MAIN-ROUTINE.
OPEN INPUT QTYFILE.
OUTPUT CALCFILE TRSFILE
READ QFILE AT END MOVE ‘Y’ TO EOF-FLAG.
PERFORM PROC-ROUTINE UNTIL EOF-FLAG=‘N’
CLOSE QTYFILE CALCFILE TRSFILE.
STOP RUN.
241. 241
PROC-ROUTINE
MOVE QTY-ACCNO TO C-ACTNO.
MOVE QTY-MONTH TO C-MONTH.
MOVE QTY-DAY TO C-DAY.
ADD QTY1 QTY2 QTY3 GIVING SUM1.
SUBTRACT QTY4 FROM QTY3 GIVING DIFFERENCE.
MULTIPLY QTY3 BY QTY2 GIVING PROD1.
MULTIPLY QTY3 BY QTY2 GIVING PROD2 ROUNDED.
ADD QTY1 QTY3 QTY4 GIVING WSUM.
DIVIDE QTY-2<100
MOVE ‘M’ TO CODE1.
ELSE
IF QTY-2>100
MOVE ‘N’ TO CODE1.
242. 242
IF QTY-1<10 AND QTY-2 <10 AND QTY <10
WRITE TREC FROM CREC.
ELSE
WRITE CREC.
READ QTYFILE AT END MOVE ‘Y’ TO EOF-
FLAG.
243. 243
REWRITE STATEMENT:
A disk seq file can be opened in i/o to allow to
read and write to same file.there is one
statement in COBOL to update the seq.file –
REWRITE statement.It replaces the logical
record accessed by the previous READ statement
with the contents of the specified record.
Format is:
REWRITE record name [FROM identifier]
REWRITE EMP-REC
REWRITE LEAVE-REC FROM WORK-REC.
244. 244
.
POINTS TO BE REMEMBER WHILE REWRITE
STATEMENT:
The file associated with the record name must be
disk file.
File must be opened in i/o mode.
REWRITE replaces the record that has was accessed
by the most recent READ statement.
Length of the record referenced by record name in the
REWRITE statement must be equal to the length of
the record that is being replaced.
Current record pointer is not effected by the execution
of the REWRITE statement.
REWRITE …..FROM is equivalent to
MOVE identifier TO record name
REWRITE record name
245. 245
UPDATING SEQ. FILE :ACCESSING
RECORDS.
Before updating file must be read which is possible only
after accessing the record.Two types of files are – Master
file and Transaction File.
Master File:- each record contains a identifying field
which is called key field (unique one) ,can be a number or
name/combination of both. Records are arranged in seq
according to the key.
Transaction file:- each record contain a key and has fewer
records as compared to master file ,records are sorted on
same key-seq as in master file.
In order to access a record in seq file we have to read every
proceediing record in that file.after each READ key seq. no.
are to be compared.when they are equal matching record is
accessed.required action is to be taken on the information
of the record.
247. 247
Proceed with the following steps:
Read first transaction record-1080
Read first master file-1078
Compare the key fields,here these fileds are not equal
Tran#>master#
Now read next master record i.e 1080.
Compare both key fields.Now these fields are equal
Tran#=mat3
Desired record is found in the master file,display
YES-if found and so on
248. 248
The logic can be as follow:
If trans-key>mast-key
Get new master record.
Else
If trans-key=mast=key
Handle mast-achieved
Else
Handle no-match
End if
Points to be noted:
If trans file ends before master file stop the execution of the
program. It means theres is no more records to be accessed.
If master file reaches its end before the transaction file then
print “NOT FOUND” for each record in the transaction file.
249. 249
UDATING SEQ. FILE-PROGRAM FOR
ACCESSING RECORDS:
PROCEDURE DIVISION
MAIN-LOGIC
OPEN INPUT MASTER-FILE TRANS-FILE
OUTPUT OUT-FILE
PERFORM GET-MASTER
PERFORM GET-TRANS
PERFORM PROCESS-RECS UNTIL T-EOF=‘Y’ OR M-
EOF=‘Y’
IF M-EOF=‘Y’
PERFORM NO=MATCH UNTIL T-EOF=‘Y’
CLOSE MASTER-FILE TRANS-FILE OUT-FILE.
GET-MASTER
READ MASTER-FILE AT END MOVE ‘Y TO M-EOF
250. 250
GET-TRANS
READ TRANS-FILE AT END MOVE ‘Y’ TO T-EOF
PROCESS- RECS
IF T-KEY>M-KEY
PERFORM GET-MASTER.
ELSE
IFT-KEY=M-KEY
PERFORM GET-MASTER
ELSE
PERFROM NO-MATCH.
MATCH-HIT
MOVE M-KEY TO OUT-KEY
MOVE ‘YES-FOUND’ TO OUT-MESSAGE.
WRITE OUT-REC
251. 251
PERFORM GET-TRANS
PERFORM GET-MASTER.
NO-MATCH
MOVE T-KEY TO OUT-KEY
MOVE ‘ NOT FOUND ‘ TO OUT-MESSAGE.
WRITE OUT-REC
PERFORM GET-TRANS.
252. 252
UPDATING SEQ. FILE:ADDING
RECORDS:
WHEN NEW RECORDS ARE ADDED THESE NEW RECORDS
ARE TO BE INCORPORATED TO MASTER FILE.RECORDS
CAN NOT BE ADDED TO SEQ. FILE DIRECTLY WHETHER
THE FILE IS ON TAPE OR DISK. THE MAMSTER FILE MUST
BE COPIED,ONE RECORD ATA TIME, WITH NEW RECORD
INSERTED AT THE APPROPRIATE LOCATIONS.
YRANSACTION FILE MASTER FILE
801 789
863 800
864 863
-- 865
-- 866