Zone wise Sale of Products details.


       IDENTIFICATION DIVISION.
       PROGRAM-ID. ZONE-SALES.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER.
       OBJECT-COMPUTER.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  SALES.
           02 PRODUCT OCCURS 4 TIMES.
              03  ZONE  PIC 9999 OCCURS 5 TIMES.
       77  I         PIC 9.
       77  J         PIC 9.
       77  BP        PIC 9999.
       77  BZ        PIC Z.
       01  DISP-HEAD PIC X(20) VALUE "  Z1  Z2  Z3  Z4 TOT".
       01  UL        PIC X(20) VALUE ALL "-".
       01  DISP-REC.
           02 E-Z1   PIC ZZZ9.
           02 E-Z2   PIC ZZZ9.
           02 E-Z3   PIC ZZZ9.
           02 E-Z4   PIC ZZZ9.
           02 E-Z5   PIC ZZZ9.

       PROCEDURE DIVISION.
       MAIN-PARA.
           PERFORM READ-DATA VARYING I FROM 1 BY 1 UNTIL I > 3
                   AFTER J FROM 1 BY 1 UNTIL J > 4.
           PERFORM SUM-PARA1 VARYING I FROM 1 BY 1 UNTIL I > 4.
           PERFORM SUM-PARA3 VARYING I FROM 1 BY 1 UNTIL I > 3.
           DISPLAY DISP-HEAD.
           DISPLAY UL.
           PERFORM DISP-PARA VARYING I FROM 1 BY 1 UNTIL I > 4.
           DISPLAY UL.
           PERFORM COM-PARA1 VARYING I FROM 1 BY 1 UNTIL I > 3.
           DISPLAY " ".
           STOP RUN.
       READ-DATA.
           DISPLAY "Enter Quantity of Product : " I " of Zone : " J.
           ACCEPT ZONE(I, J).
       SUM-PARA1.
           MOVE 0 TO ZONE(4, I).
           PERFORM SUM-PARA2 VARYING J FROM 1 BY 1 UNTIL J > 3.
       SUM-PARA2.
           COMPUTE ZONE(4, I) = ZONE(4, I) + ZONE(J, I).
       SUM-PARA3.
           MOVE 0 TO ZONE(I, 5).
           PERFORM SUM-PARA4 VARYING J FROM 1 BY 1 UNTIL J > 4.
       SUM-PARA4.
           COMPUTE ZONE(I, 5) = ZONE(I, 5) + ZONE(I, J).
       DISP-PARA.
           MOVE ZONE(I, 1) TO E-Z1.
           MOVE ZONE(I, 2) TO E-Z2.
           MOVE ZONE(I, 3) TO E-Z3.
           MOVE ZONE(I, 4) TO E-Z4.
           MOVE ZONE(I, 5) TO E-Z5.
           DISPLAY DISP-REC.
       COM-PARA1.
           MOVE 0 TO BP.
           MOVE 0 TO BZ.
           PERFORM COM-PARA2 VARYING J FROM 1 BY 1 UNTIL J > 4.
           DISPLAY "Product : " I " Sold More in Zone : " BZ.
       COM-PARA2.
           IF ZONE(I, J) > BP
              MOVE ZONE(I, J) TO BP
              MOVE J TO BZ.

No comments:

Post a comment