-2

I am making a payslip project using IBM mainframes and I am asked to create a payslip report for an employee every month. This payslip is supposed to be stored into a VSAM file in a format as follows as follows:

Sample Report Format As to be stored into VSAM

The data can be fetched from DB2 via a COBOL program but the problem is that I don't know the method to write contents into the file in such a user formatted style.

So can anyone please send me a COBOL code to help me out because when I searched on the internet, all I could find was how to store data in a key-sequenced record format.

Also please tell as to what type of VSAM I should use.

Sarthak Mehra
  • 359
  • 1
  • 2
  • 12
  • 1
    You don't really need VSAM to output a report. But if VSAM is mandatory, you could go for ESDS accessed in a sequencial way. To output your different lines, you could redefine a single 133 length filler with the different fields you need and alternatively write each line to your file. – David Larochette Jul 19 '18 at 10:13

1 Answers1

0
   Id division.
   Program-id. VSAMSEQW.
   Environment division.
   Input-output section.
   File-control.
       Select F1
          Assign to AS-DD1
          Organization is sequential
          File status is FS FS2.
   Data division.
   File section.
   FD  F1.
   1   R1 pic X(133).
   Working-storage section.
   1 fs pic 99.
   1 fs2.
     2 rc pic s9(4) binary.
     2 fc pic s9(4) binary.
     2 fb pic s9(4) binary.
   1 X pic X(10).
   Procedure division.
   Declaratives.
   F1-error section.
       Use after standard error procedure on F1.
   1.  Display "Error declarative entered"
       Display "  File status: " fs
       Display "  VSAM return code:   " rc
       Display "  VSAM function code: " fc
       Display "  VSAM feedback code: " fb
       Display "Testcase VSAMSEQW failed!"
       Move 16 to return-code
       Stop run
       .
   End declaratives.
   MainPgm section.
       Display "Entering VSAMSEQW"

       Open output F1

  * Do whatever you need to get data and update R1
       Move "Line 1" to R1
       Write R1
  * 2nd output line
       Move "Line 2" to R1
       Write R1

       Close F1

       Display "Exiting VSAMSEQW"
       Goback.
Ka Lam
  • 381
  • 1
  • 6