Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask COBOL Expert


Home >> COBOL

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.

COBOL, Programming

  • Category:- COBOL
  • Reference No.:- M9512280

Have any Question?


Related Questions in COBOL

Write a program that will provide a list of their employees

Write a program that will provide a list of their employees with the following information: Field Size Type Additional Information Employee Number 5 Alphanumeric Employee Name 20 Alphanumeric Position Title (PT) 10 Alpha ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As