Program for inventory , COBOL Programming

Assignment Help:

PROGRAM FOR INVENTORY 

We have to write a program to update the inventory file. Consider 2 files,viz, invfile an tranfile. Invfile has 3 fields pno,name,qty. Tranfile has 3 fileds tpno,trcode,tqty. By readin tranfile records if trcode=1 then update the qty with qty+tqty in invfile. If trcode=2 the update the qty with qty-tqty in invfile.

 identification division.

  program- id.

  environment division.

  input-output section.

  file-control.

    select invfile assign to disk

    organization is indexed

    access mode is dynamic

    record key is pno

    file status is fs.

    select tranfile assign to disk

    organization is line sequential.

  data division.

  file section.

  fd  invfile

    label records are standard

    value of file- id is "inv.dat".

  01  invrec.

    02 pno  pic 9(5).

    02 name pic x(5).

    02 qty  pic 9(5).

  fd tranfile

  label records are standard

  value of file- id is "tran.dat".

01 tranrec.

  02 tpno  pic 9(5).

  02 trcode pic 9.

  02 tqty    pic 9(5).

working-storage section.

01  ans pic x value space.

01  fs  pic x(2) value spaces.

01  key- in pic x value space.

  procedure division.

  p-1.

    open i-o invfile.

    if fs = "30"

      open output invfile

      close invfile

      open i-o invfile.

    perform g-w-inv until ans = 'n' or 'N'.

    move space to ans.

    open output tranfile.

    perform g-w-tran until ans = 'n' or 'N'.

    close tranfile.

    open input tranfile.

  read-para.

    read tranfile at end go to close-para.

    move tpno to pno.

    read invfile key is pno invalid key 

        display(5 5) "No Record Found for" ; pno

       accept key- in

       go to read-para.

    if trcode = 1 

      add tqty to qty

      rewrite invrec.

    if trcode = 2 

      subtract tqty from qty 

      rewrite invrec.

     go to read-para.

  close-para.

    close invfile tranfile.

  op-para.

  open input invfile.

r-para.

  read invfile next record at end go to cl-para.

  display(1 1) erase.

  display(3 5) "Part No: " pno.

  display(5 5) "Name : " name.

  display(7 5) "Qty : " qty.

  accept key- in.

  go to r-para.

cl-para.

  close invfile.

  stop run.

g-w-tran.

  display(1 1) erase.

  display(2 5) "Tran Details ....".

  display(3 5) "Part No: ".

  accept tpno.

  display(5 5) "Trancode : ".

  accept trcode.

  display(7 5) "Quantity : ".

  accept tqty.

  write tranrec.

  display(12 5) "Add more [y/n] :".

  accept ans.

g-w- inv.

  display(1 1) erase.

  display(2 5) "Inven Details....".

  display(3 5) "Part No: ".

  accept pno.

  display(5 5) "Name : ".

  accept name.

  display(7 5) "Quantity : ".

  accept qty.

  write invrec invalid key display(10 5) "Rec Exists!".

  display(12 5) "Add more [y/n] :".

  accept ans.


Related Discussions:- Program for inventory

Slash insertion - edit characters for numeric data, / (Slash Insertion): ...

/ (Slash Insertion): The edit character slash (/) also termed as virgule or stroke, may appear anyplace in the picture. When used, it will be inserted. More than one slash can

Divide verb, DIVIDE VERB: The aim of the DIVIDE verb is to divide one ...

DIVIDE VERB: The aim of the DIVIDE verb is to divide one number by the other and to store the result.  There are few forms of this verb. One of its forms is as shown below:

Program for perform - thru, PROGRAM FOR PERFORM - THRU: We have to wri...

PROGRAM FOR PERFORM - THRU: We have to write a program to elaborate PERFORM ...THRU statement Identification division. Program- id.  Perfthru. Environment division.

Blank insertion and zero insertion, B (Blank Insertion) : The occurren...

B (Blank Insertion) : The occurrence of a B anyplace in the picture will insert a space character in the edited data. There can be more than one B in the picture. Examples:

Picture clause, Picture Clause: The picture clause explains the genera...

Picture Clause: The picture clause explains the general characteristics of an elementary data item. These characteristics are elaborated below: Class: In COBOL the

Perform with times option, PERFORM WITH TIMES OPTION: The format of ...

PERFORM WITH TIMES OPTION: The format of a PERFORM TIMES statement is as shown below: Illustration:   A)  Perform the para-2 5 times. In this situation the specifie

Blank when zero - edit characters for numeric data, BLANK WHEN ZERO: ...

BLANK WHEN ZERO: BLANK WHEN ZERO is an editing clause that may be used along with a picture. This will set the whole data item to blanks of its value is equal to zero. Though,

Program for if -else, PROGRAM FOR IF -ELSE: We have to write a program...

PROGRAM FOR IF -ELSE: We have to write a program to check whether the given number is ODD or EVEN. You can use IF..ELSE. Identification division. Program- id. IfElse.

Program using occurs clause, PROGRAM USING OCCURS CLAUSE: We have to w...

PROGRAM USING OCCURS CLAUSE: We have to write a simple program to demonstrate Occurs Clause. Get the employee details for 3 persons and compute the total salary. identifica

Rules for constructing an arithmetic expression, Rules for constructing an ...

Rules for constructing an Arithmetic Expression: The rules for constructing an arithmetic expression are as shown below: (i) When an arithmetic expression specifies a calcu

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd