首页 > 其他分享 >INFO3105 COBOL 设计

INFO3105 COBOL 设计

时间:2023-05-20 15:44:49浏览次数:38  
标签:INFO3105 do fields numeric report COBOL need 设计 data


INFO3105 Week 3 Class 1
Review
Numeric Edited fields
Lab4
Introduction to Summary Report Programming with COBOL
Definition of a Control Break – “A change of category used to trigger a subtotal. For example, if
data are sub totaled by province, a control break occurs when BC changes to ON.” Lots of COBOL
programs/reports are written as control break programs. The first pre-requisite to
writing a control break program has nothing to do with the program itself; rather it’s the
data that you need to be concerned with. The data must be sorted on the control break
field; therefore if we were using the example given in the above definition, the data
would have had to be sorted on province. Below we see the layout of the control break
program we’ll be working on next:
Notice that the report is written so that all of the salespeople from a particular branch
are listed on a single page. Which field would the data for this report sorted by? Well
obviously it’s the branch number field. Below is some of the data used by this report,
see if you can locate the branch information in it:
And here is the file layout for this data
:
The data here shows salespeople for
branches 100 and 200
So returning to the output we see we need to produce at least 3 different types of
output:
1. Heading information (at the top of page)
2. Detailed information (actual sales person data)
3. Summary information (branch totals).
So what you need to do is lay the report out to see where everything fits, historically
programmers would use something called a Printer Spacing Chart see page 95 of the
text for an example. Then once the design of the report is done, you can map the
columns to the layout in COBOL, for instance here is the 1st Heading Line for the report
from page 1:
We see here there are some fields designated with the keyword “FILLER”. This tells the
compiler basically what we have is some space to allocate but we can’t reference it
directly as variable. Use filler when the data isn’t important to the logic of the program.
Constant strings are embedded in quotation marks this is known traditionally as hard
coding the data. The keyword SPACES is used to put blanks in each character
designated by the PIC X(..) clause. So instead of counting out 5 actual spaces we can
just write it as PIC X(5) VALUE SPACES. One other point to take note of is the picture
clauses used here. PIC 9 is for numeric data, PIC X is for alphanumeric, and PIC Z9 is
for formatted numeric data, it indicates if there is number is not large enough to
encompass the entire picture clause just place spaces (instead of zeroes) in the leading
characters.
Returning to the listing on page 1, how many different lines of output do you need to
create? The answer is 7 (there are actually 9 but the 8th and 9th aren’t visible here, see
below for the final lines example).
We saw how to write the individual lines out in our labs 1-3. In labs 1-3 the output was
basically the same as our input. Here the last two report columns do not exist in the
data but are actually to be calculated by our program based on the data. The net sales
column is simply gross sales subtract returns. The commission column is calculated as
net sales multiplied by a commission rate (last column of the input data).
To summarize, the 9 different line layouts you need to create are:
1. Heading line 1 – page no, and date
2. Heading line 2 – constant with Salesperson By Branch text
3. Heading line 3 – Branch indicator
4. Heading line 4 – Individual Column Headings
5. Detail line – containing individual salesperson data
6. Branch Total – containing branch totals (formatted) for each columns
7. Single Underlines – typical in a report like this under the branch totals (see
below)
8. Grand Totals – containing accumulation of Branch Totals (formatted)
9. Double Underlines – indicates the end of Report (just use the “=” instead of ‘-‘)
End of the Report
Detail Line Formatting
The first four headings are relatively straight forward to layout. Line 5 (the detail line) will
ask you to format the numeric fields and the last two fields need to be “Computed”.
Page 195 of the text lists all of the different ways to format data. We’ll be using
something similar to the last one with the $ signs but without CR designation.
COBOL only lets you do math on numeric fields, NOT on numeric edited fields. So
you’ll have to typically follow this pattern with numeric fields that require calculations:
1. move the input to a working storage field
2. do some math on the working storage field
3. move the working storage field to the numeric edited field
Let’s see the syntax for doing the 3 steps by looking at what goes on in the detail line
with the Net Sales column: Assuming we have done our READ, we would calculate our
Net Sales field as follows:
 Calculate the difference of the Gross Sales and Sales Returns :
COMPUTE WS-NET-SALES = SALESPERSON-GROSS-SALES -
SALESPERSON-RETURN-SALES
 Move the working storage field (unedited) to the edited field
o 05 WS-NET-SALES PIC S9(7)V99 VALUE ZERO.
o ..
o ..
o 05 WS-SL-SLSP-NET PIC $$$,$$$.99.
o ..
o ..
o MOVE WS-NET-SALES TO WS-SL-SLSP-NET
When calculating commissions we need to worry about rounding and we can do this
with the keyword ROUNDED (page 32 of the text) as follows:
Lab 5 - 2%
 Submit to the FOL dropbox (no need to get the full program working yet):
1. the source code for the 9 different output lines (including output field
definitions)
2. the source code for a paragraph called SALESPERSON-CALCULATIONS
that contains all of the compute statements for the report (remember you’ll
need both branch and grand totals)
Also, read pages 316-318 of the text.

 

标签:INFO3105,do,fields,numeric,report,COBOL,need,设计,data
From: https://www.cnblogs.com/messagejava/p/17417297.html

相关文章

  • 软构学习-5、6-设计规约、抽象数据类型(ADT)
    目录5设计规约行为等价性Spec结构Spec强度比较Diagrammingspecifications6抽象数据类型(ADT)操作的抽象类型分类:RepresentationIndependence5设计规约本章大纲:方法的规约前置/后置条件欠定规约、非确定规约陈述式、操作式规约规约强度及其比较如何写出好的规约......
  • 免费下载R机械设计 V3.5
        R机械设计是一款为机械工程师在设计过程中提供计算、查询服务的免费设计平台。软件包含:一般设计资料、气动、液压传动、联接件、机械传动、机器人、轴承、操作件、管件、润滑与密封、弹簧、材料、工具、模具、刀具、夹具、电机减速机、电制等多个大模块。软件通过当......
  • C语言程序设计(第四版)谭浩强版 课后答案 第八章 指针
    1、输出3个整数,按由小到大的顺序输出,写的复杂了,加上分析会变得简单,像下面输出3个字符(从小到大)#include<stdio.h>intmain(){voidcompare(int*a,int*b,int*c);inta,b,c;printf("pleaseinputthreenumbers:");scanf("%d%d%d",&a,&b,&c);c......
  • 程序与设计
    2-27在命令行窗口中启动的Python解释器中实现在Python自带的IDLE中实现print("Helloworld")编码规范每个import语句只导入一个模块,尽量避免一次导入多个模块不要在行尾添加分号“:”,也不要用分号将两条命令放在同一行建议每行不超过80个字符使用必要的空行可以增加代码的可读性运......
  • 程序与设计
    shell命令概述Shell作用:命令解释器介于操作系统内核与用户之间,负责解释命令行获得命令帮助内部命令help命令的“--help”选项使用man命令阅读手册页命令行编辑的几个辅助操作Tab键:自动补齐反斜杠“\”:强制换行快捷键Ctrl+U:清空至行首快捷键Ctrl+K:清空至行尾快捷键Ctr......
  • boot-admin 项目数据库缺省字段设计之最佳实践
    数据库(Database)中的缺省字段(也称为默认字段),就是在一般情况下,每个数据表(Table)必须包含的字段(Field),这类字段用于满足特定的数据需求,字段值的填充或更改一般遵照一定的逻辑要求。缺省字段的设计应该考虑到数据的完整性和一致性,以确保数据的正确与可靠,设计合理的表字段对于数据的有效......
  • java基于springboot+vue的漫画网站管理系统,附源码+数据库+lw文档+PPT,适合毕业设计、课
    1、项目介绍考虑到实际生活中在漫画网站方面的需要以及对该系统认真的分析,将系统权限按管理员和用户这两类涉及用户划分。(a)管理员;管理员使用本系统涉到的功能主要有:首页、个人中心、用户管理、漫画分类管理、漫画投稿管理、分类管理、排行榜管理、交流论坛、系统管理等功能......
  • 编程打卡:面向对象程序设计测试
    ``gopackagemainimport"bufio"import"flag"import"fmt"import"io"import"os"import"strconv"varinfile*string=flag.String("i","unsorted.dat","Filecontains......
  • 场景设计
    一、库存扣减逻辑1)依赖缓存不依赖数据库,因为缓存能抗更高的tps。纯redis实现可能带来的问题:a、如果redis实际扣减成功了,但是redisclient接口返回失败。可能导致库存的浪费。怎么解决?可以加入库存数据库,每次更新完redis后也更新数据库。然后写一个对账程序,通过对比redis和数据库......
  • 关于STM32Cube_FW_F1_V1.8.0内的example顶层程序设计逻辑 与 RTC_Calendar增补
     Examples内程序结构STM32Cube_FW_F1_V1.8.0\Projects\STM3210E_EVAL\Examples内程序结构分析如下:使用外设XXX向工程添加 stm32f10x_XXX.c修改stm32f10x_conf.h 在stm32f1xx_hal_msp.c中写 外设XXX写初始化程序在stm32f1xx_it.c中写中断服务程序在main.c中写配置程......