Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
how to sort the report on particular id with same report

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
balbudheprashant
Warnings : 2

New User


Joined: 24 Aug 2007
Posts: 5
Location: Pune

PostPosted: Fri Aug 31, 2007 5:38 pm    Post subject: how to sort the report on particular id
Reply with quote

Hi,
when i am trying to sort the report on one field (wk-empid) I am getting the sorted records but at the same time I loose the report structure . I am attaching the code
please let me know where I have to put the sort logic

Code:
       IDENTIFICATION DIVISION.
       PROGRAM-ID.CLREPROT.
       AUTHOR.PRASHANT BALBUDHE.
      /THIS  PROGRAM IS USED TO DISPLAY THE REPORT OF EMPLOYEE IN COMP.
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
            SELECT FILE1 ASSIGN TO DD1
                   ORGANIZATION IS SEQUENTIAL
                   ACCESS MODE IS SEQUENTIAL
                   FILE STATUS IS FS1.
            SELECT FILE2 ASSIGN TO DD2
                   ORGANIZATION IS SEQUENTIAL
                   ACCESS MODE IS SEQUENTIAL
                   FILE STATUS IS FS2.
             SELECT FILE4 ASSIGN TO DD3
                   ACCESS MODE IS SEQUENTIAL.

       DATA DIVISION.
       FILE SECTION.

       FD FILE1 RECORDING MODE F.

       01 FILE1REC.
          02 EMPNAME PIC X(20).
          02 EMPADD  PIC X(30).
          02 EMPID  PIC 9(5).
          02 EMPDEPT PIC X(10).
          02 FILLER PIC X(15) VALUE SPACES.

       FD FILE2 RECORDING MODE IS F.

       01 FILE2REC.
          02 WS-EMPNAME PIC X(20).
          02 WS-EMPADD  PIC X(30).
          02 WS-EMPID  PIC 9(5).
          02 WS-EMPDEPT PIC X(10).
          02 FILLER PIC X(15) VALUE SPACES.

       SD FILE4 RECORDING MODE F.

       01 WK-FILE2REC.
          02 WK-EMPNAME PIC X(20).
          02 WK-EMPADD  PIC X(30).
          02 WK-EMPID  PIC 9(5).
          02 WK-EMPDEPT PIC X(10).
          02 FILLER PIC X(15) VALUE SPACES.

       WORKING-STORAGE SECTION.

       01 FS1 PIC XX.
       01 FS2 PIC XX.
       01 WS-PG-CNT  PIC 9(2) VALUE ZERO.
       01 WS-LN-CNT  PIC 9(2) VALUE IS ZEROS.
       01 ARE-THERE-MORE-RECORDS PIC X(3) VALUE 'YES'.
             88 NO-MORE-RECORDS VALUE 'NO'.
             88 MORE-RECORDS    VALUE 'YES'.
       01 WS-REPORT.
          05 REC-HEADING1.
             10 FILLER PIC X(30) VALUE '------------------------------'.
             10 FILLER PIC X(20) VALUE 'REPORT  INFORMATION.'.
             10 FILLER PIC X(30) VALUE '------------------------------'.
          05 REC-HEADING2.
             10 FILLER  PIC X(5) VALUE 'PAGE:'.
             10 WS-PAGE PIC Z9 VALUE ZEROS.
             10 FILLER PIC X(30) VALUE '------------------------------'.
             10 FILLER PIC X(01) VALUE SPACES.
             10 FILLER PIC X(5) VALUE 'DATE:'.
             10 FILL1 PIC 99.
             10 FILLER PIC X VALUE IS '/'.
             10 FILL2 PIC 99.
             10 FILLER PIC X VALUE IS '/'.
             10 FILL3 PIC 99.
             10 FILLER PIC X.
             10 FILLER PIC X(5) VALUE 'TIME:'.
             10 FILL4 PIC 99.
             10 FILLER PIC X VALUE IS ':'.
             10 FILL5  PIC 99.
             10 FILLER PIC X(19) VALUE SPACES.
          05 REC-HEADING3.
             10 FILLER PIC X(8)  VALUE 'EMPNAME'.
             10 FILLER PIC X(16) VALUE SPACES.
             10 FILLER PIC X(6)  VALUE 'EMPADD'.
             10 FILLER PIC X(20) VALUE SPACES.
             10 FILLER PIC X(5)  VALUE 'EMPID'.
             10 FILLER PIC X(1)  VALUE SPACE.
             10 FILLER PIC X(7)  VALUE 'EMPDEPT'.
             10 FILLER PIC X(17) VALUE SPACES.
          05 RPTDATE.
             10 CURRYEAR   PIC 99.
             10 CURRMONTH  PIC 99.
             10 CURRDATE   PIC 99.
          05 RPTTIME.
             10 CURRHR     PIC 99.
             10 CURRMIN    PIC 99.
          05 REC-HEADING4.
             10 FILLER pic x(80) VALUE spaces.
       05 REC-FOOTER.
             10 FILLER PIC X(30) VALUE SPACES.
             10 FILLER PIC X(30) VALUE '--------END-OF-REPORT---------'.
             10 FILLER PIC X(20) VALUE SPACES.

       PROCEDURE DIVISION.
       0000-BEGIN.
                 PERFORM 1000-OPEN-PARA.
                 PERFORM 6000-CLOSE-PARA.
                 PERFORM SORT-PARA
                 PERFORM 2000-READ-PARA.
                 PERFORM 3000-HEADER-PARA.
                 PERFORM 4000-DETAIL-PROCESS-PARA UNTIL NO-MORE-RECORDS.
                 PERFORM 5000-FOOTER-PARA.
                 GOBACK.
       1000-OPEN-PARA.
                 OPEN INPUT FILE1,OUTPUT FILE2
                 DISPLAY 'FILE STATUS:'FS1
                 DISPLAY 'FILE STATUS:'FS2
                 ACCEPT RPTDATE FROM DATE
                 ACCEPT RPTTIME FROM TIME
             EXIT.
       2000-READ-PARA.
                 READ FILE1 AT END SET NO-MORE-RECORDS TO TRUE
                 END-READ
               EXIT.
       3000-HEADER-PARA.

                 WRITE FILE2REC FROM REC-HEADING1
                 ADD 1  TO WS-PG-CNT
                 MOVE WS-PG-CNT TO WS-PAGE
                 MOVE CURRYEAR TO FILL1
                 MOVE CURRMONTH TO FILL2
                 MOVE CURRDATE TO FILL3
                 MOVE CURRHR TO FILL4
                 MOVE CURRMIN TO FILL5
                      WRITE FILE2REC FROM REC-HEADING2
                      WRITE FILE2REC FROM REC-HEADING3
                      WRITE FILE2REC FROM REC-HEADING4
                 MOVE 0 TO WS-LN-CNT
               EXIT.
       4000-DETAIL-PROCESS-PARA.
                      IF WS-LN-CNT > 4
                           PERFORM 3000-HEADER-PARA
                      END-IF
                 MOVE EMPNAME TO WS-EMPNAME
                 MOVE EMPADD TO WS-EMPADD
                 MOVE EMPID TO WS-EMPID
                 MOVE EMPDEPT TO WS-EMPDEPT
                   WRITE FILE2REC
                 ADD 1 TO WS-LN-CNT
               READ FILE1 AT END SET NO-MORE-RECORDS TO TRUE
               END-READ
               PERFORM 6000-CLOSE-PARA
            EXIT.
       5000-FOOTER-PARA.
                    WRITE FILE2REC FROM REC-HEADING4
                    WRITE FILE2REC FROM REC-FOOTER
             EXIT.
       6000-CLOSE-PARA.
               CLOSE FILE1,FILE2
               DISPLAY 'FILE STATUS 'FS1
               DISPLAY 'FILE STATUS 'FS2
               
            GOBACK.
Back to top
View user's profile Send private message

balbudheprashant
Warnings : 2

New User


Joined: 24 Aug 2007
Posts: 5
Location: Pune

PostPosted: Fri Aug 31, 2007 6:11 pm    Post subject: how to sort the report on particular id with same report
Reply with quote

Hi,
when i am trying to sort the report on one field (wk-empid) I am getting the sorted records but at the same time I loose the report structure . I am attaching the code
please let me know where I have to put the sort logic

Code:
IDENTIFICATION DIVISION.
PROGRAM-ID.CLREPROT.
AUTHOR.PRASHANT BALBUDHE.
/THIS PROGRAM IS USED TO DISPLAY THE REPORT OF EMPLOYEE IN COMP.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT FILE1 ASSIGN TO DD1
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL
FILE STATUS IS FS1.
SELECT FILE2 ASSIGN TO DD2
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL
FILE STATUS IS FS2.
SELECT FILE4 ASSIGN TO DD3
ACCESS MODE IS SEQUENTIAL.

DATA DIVISION.
FILE SECTION.

FD FILE1 RECORDING MODE F.

01 FILE1REC.
02 EMPNAME PIC X(20).
02 EMPADD PIC X(30).
02 EMPID PIC 9(5).
02 EMPDEPT PIC X(10).
02 FILLER PIC X(15) VALUE SPACES.

FD FILE2 RECORDING MODE IS F.

01 FILE2REC.
02 WS-EMPNAME PIC X(20).
02 WS-EMPADD PIC X(30).
02 WS-EMPID PIC 9(5).
02 WS-EMPDEPT PIC X(10).
02 FILLER PIC X(15) VALUE SPACES.

SD FILE4 RECORDING MODE F.

01 WK-FILE2REC.
02 WK-EMPNAME PIC X(20).
02 WK-EMPADD PIC X(30).
02 WK-EMPID PIC 9(5).
02 WK-EMPDEPT PIC X(10).
02 FILLER PIC X(15) VALUE SPACES.

WORKING-STORAGE SECTION.

01 FS1 PIC XX.
01 FS2 PIC XX.
01 WS-PG-CNT PIC 9(2) VALUE ZERO.
01 WS-LN-CNT PIC 9(2) VALUE IS ZEROS.
01 ARE-THERE-MORE-RECORDS PIC X(3) VALUE 'YES'.
88 NO-MORE-RECORDS VALUE 'NO'.
88 MORE-RECORDS VALUE 'YES'.
01 WS-REPORT.
05 REC-HEADING1.
10 FILLER PIC X(30) VALUE '------------------------------'.
10 FILLER PIC X(20) VALUE 'REPORT INFORMATION.'.
10 FILLER PIC X(30) VALUE '------------------------------'.
05 REC-HEADING2.
10 FILLER PIC X(5) VALUE 'PAGE:'.
10 WS-PAGE PIC Z9 VALUE ZEROS.
10 FILLER PIC X(30) VALUE '------------------------------'.
10 FILLER PIC X(01) VALUE SPACES.
10 FILLER PIC X(5) VALUE 'DATE:'.
10 FILL1 PIC 99.
10 FILLER PIC X VALUE IS '/'.
10 FILL2 PIC 99.
10 FILLER PIC X VALUE IS '/'.
10 FILL3 PIC 99.
10 FILLER PIC X.
10 FILLER PIC X(5) VALUE 'TIME:'.
10 FILL4 PIC 99.
10 FILLER PIC X VALUE IS ':'.
10 FILL5 PIC 99.
10 FILLER PIC X(19) VALUE SPACES.
05 REC-HEADING3.
10 FILLER PIC X(8) VALUE 'EMPNAME'.
10 FILLER PIC X(16) VALUE SPACES.
10 FILLER PIC X(6) VALUE 'EMPADD'.
10 FILLER PIC X(20) VALUE SPACES.
10 FILLER PIC X(5) VALUE 'EMPID'.
10 FILLER PIC X(1) VALUE SPACE.
10 FILLER PIC X(7) VALUE 'EMPDEPT'.
10 FILLER PIC X(17) VALUE SPACES.
05 RPTDATE.
10 CURRYEAR PIC 99.
10 CURRMONTH PIC 99.
10 CURRDATE PIC 99.
05 RPTTIME.
10 CURRHR PIC 99.
10 CURRMIN PIC 99.
05 REC-HEADING4.
10 FILLER pic x(80) VALUE spaces.
05 REC-FOOTER.
10 FILLER PIC X(30) VALUE SPACES.
10 FILLER PIC X(30) VALUE '--------END-OF-REPORT---------'.
10 FILLER PIC X(20) VALUE SPACES.

PROCEDURE DIVISION.
0000-BEGIN.
PERFORM 1000-OPEN-PARA.
PERFORM 6000-CLOSE-PARA.
PERFORM SORT-PARA
PERFORM 2000-READ-PARA.
PERFORM 3000-HEADER-PARA.
PERFORM 4000-DETAIL-PROCESS-PARA UNTIL NO-MORE-RECORDS.
PERFORM 5000-FOOTER-PARA.
GOBACK.
1000-OPEN-PARA.
OPEN INPUT FILE1,OUTPUT FILE2
DISPLAY 'FILE STATUS:'FS1
DISPLAY 'FILE STATUS:'FS2
ACCEPT RPTDATE FROM DATE
ACCEPT RPTTIME FROM TIME
EXIT.
2000-READ-PARA.
READ FILE1 AT END SET NO-MORE-RECORDS TO TRUE
END-READ
EXIT.
3000-HEADER-PARA.

WRITE FILE2REC FROM REC-HEADING1
ADD 1 TO WS-PG-CNT
MOVE WS-PG-CNT TO WS-PAGE
MOVE CURRYEAR TO FILL1
MOVE CURRMONTH TO FILL2
MOVE CURRDATE TO FILL3
MOVE CURRHR TO FILL4
MOVE CURRMIN TO FILL5
WRITE FILE2REC FROM REC-HEADING2
WRITE FILE2REC FROM REC-HEADING3
WRITE FILE2REC FROM REC-HEADING4
MOVE 0 TO WS-LN-CNT
EXIT.
4000-DETAIL-PROCESS-PARA.
IF WS-LN-CNT > 4
PERFORM 3000-HEADER-PARA
END-IF
MOVE EMPNAME TO WS-EMPNAME
MOVE EMPADD TO WS-EMPADD
MOVE EMPID TO WS-EMPID
MOVE EMPDEPT TO WS-EMPDEPT
WRITE FILE2REC
ADD 1 TO WS-LN-CNT
READ FILE1 AT END SET NO-MORE-RECORDS TO TRUE
END-READ
PERFORM 6000-CLOSE-PARA
EXIT.
5000-FOOTER-PARA.
WRITE FILE2REC FROM REC-HEADING4
WRITE FILE2REC FROM REC-FOOTER
EXIT.
6000-CLOSE-PARA.
CLOSE FILE1,FILE2
DISPLAY 'FILE STATUS 'FS1
DISPLAY 'FILE STATUS 'FS2
GOBACK.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Aug 31, 2007 6:19 pm    Post subject:
Reply with quote

What does the output look like?
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Sep 01, 2007 7:32 am    Post subject:
Reply with quote

Hi Prashant,

Try sorting FILE1 in the order you want before executing your pgm.
Back to top
View user's profile Send private message
balbudheprashant
Warnings : 2

New User


Joined: 24 Aug 2007
Posts: 5
Location: Pune

PostPosted: Mon Sep 03, 2007 11:15 am    Post subject: Hi
Reply with quote

Thanks,Jack
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts JOINKEYS Paired and Unpaired Sort MFwhiz DFSORT/ICETOOL 4 Fri Sep 29, 2017 1:48 am
No new posts Difference in SORT & ICETOOL Mohan Kothakota DFSORT/ICETOOL 5 Fri Sep 22, 2017 4:56 pm
No new posts OC4 in SORT Mohan Kothakota DFSORT/ICETOOL 2 Tue Sep 12, 2017 6:30 pm
No new posts SORT Trailer Count - LRECL Output co... amorante DFSORT/ICETOOL 5 Tue Aug 29, 2017 8:57 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us