如何使用COBOL在文本文件的表格中插入记录并搜索并显示满足条件的记录? [英] How to insert records in a table in a text file using COBOL and search and display record(s) which satisfy a condition?

查看:258
本文介绍了如何使用COBOL在文本文件的表格中插入记录并搜索并显示满足条件的记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编写一个COBOL程序来读取一个输入文件INPUT.TXT,并显示RATING ='B'的学生的详细信息。我正在使用[ http://www.compileonline.com/compile_cobol_online.php ]。 INPUT.TXT中的记录(请注意,输入文件是一个简单的文本文件):

  EMPID NAME COMPANY评级

112211 UMESH CAPGEMINI
221122 ISHAN ZALONI
134231 AJMERA GOOGLE $ $ $ 232144 NIYANTA WIPRO B
561144 KANKANA ZETA
324556 CHRISTOPHER TCS C
123443 SIDDIKA TCS A

到目前为止,所有员工的细节(在对输入文件中的记录进行大量调整之后)。所以,我需要解决以下问题:
$ b $ pre $ 1.在'输入'中以表格形式插入记录。 txt'

2.搜索特定记录

我完全不知道至于如何解决我的第一个问题。

我不需要完整的程序/代码。我只是需要一些具体的建议,需要我的第二个问题需要涵盖的主题(S)。

解决方案

第一个问题,你可以简单地使用一个分隔符像;然后你可以通过给分隔符将文件导入到excel:

  01 NEWFILE。 
05 EMPID PIC 9(6)。
05 FILLER PIC X VALUE';'。
05名称图片A(10)。
05 FILLER PIC X VALUE';'。
05公司PIC X(17)。
05 FILLER PIC X VALUE';'。
05评级图X(1)。

要搜索,您可以简单地通过与您使用的相同的读取文件来查找记录。如果只想读取文件一次,则可以将其内容存储在数组中,然后使用PERFORM VARYING语句在其中进行搜索。



另外,要将文件写入文件,请将其作为输入/输出打开:

  OPEN IO文件名

另外一件事,这些东西可以简单的在Google找到,是基本的COBOL。

I am trying to write a COBOL program to read an input file "INPUT.TXT" and display the details of students whose RATING='B'.I am using [ http://www.compileonline.com/compile_cobol_online.php ] for my program. The records in "INPUT.TXT" (please note that the input file is a simple text file) are:

      EMPID  NAME     COMPANY          RATING

      112211 UMESH    CAPGEMINI        A
      221122 ISHAN    ZALONI           A
      134231 AJMERA   GOOGLE           B
      232144 NIYANTA  WIPRO            B
      561144 KANKANA  ZETA             A
      324556 CHRISTOPHER  TCS          C
      123443 SIDDIKA       TCS         A

So far, I have been successful in just displaying the details of all the employees( that too after making a lot of adjustments of the records in the input file). So, I need a fix to the following problems-

              1. inserting the records in the form of a table in 'input.txt'

              2. searching for a particular record

I am completely unaware as to how to solve my 1st problem.

I don't need the complete program/code. I just need some "specific" advice regarding the topic(s) need I need to cover for my 2nd Problem.

解决方案

For the first question, you could simply use a separator like ; and then you can import the file into excel by giving the separator:

01  NEWFILE.                         
      05  EMPID  PIC 9(6).  
      05  FILLER PIC X VALUE ';'.  
      05  NAME   PIC A(10).   
      05  FILLER PIC X VALUE ';'.                      
      05  COMPANY PIC X(17). 
      05  FILLER PIC X VALUE ';'. 
      05  RATING  PIC X(1).

To search you can simply go through the file with the same read you used and find the record. If you want to read the file only once, you could store it's content in an array, and use the PERFORM VARYING statement to search in it.

Also, to write into the file, you open it as input/output:

OPEN I-O filename 

Another thing, these things can be found simply in Google, this is basic COBOL.

这篇关于如何使用COBOL在文本文件的表格中插入记录并搜索并显示满足条件的记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆