Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

PROGRAM THAT ILLUSTRATES EXAMPLE OF STRING AND UNSTRING

Posted By: Isabel Hughes     Category: Cobol     Views: 10533

PROGRAM THAT ILLUSTRATES EXAMPLE OF STRING AND UNSTRING.

Code for PROGRAM THAT ILLUSTRATES EXAMPLE OF STRING AND UNSTRING in Cobol

       IDENTIFICATION DIVISION.
       PROGRAM-ID. P1.

       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT INFILE ASSIGN TO DISK
               ORGANIZATION IS LINE SEQUENTIAL.
           SELECT OUTFILE ASSIGN TO DISK
               ORGANIZATION IS LINE SEQUENTIAL.
       
       DATA DIVISION.
       FILE SECTION.
       FD INFILE VALUE OF FILE-ID IS "STRSTUD.DAT".
       01 INREC.
              05 INRNO   PIC X(2).
              05 INNAME  PIC X(20).
              05 INADDRESS PIC X(50).
       FD OUTFILE VALUE OF FILE-ID IS "STRSTUD.RPT".
       01 OUTREC  PIC X(130).

       WORKING-STORAGE SECTION.
       01 HEAD1  PIC X(80) VALUE "                  DETAILS OF STUDENT".
       01 DETAILS.

           05 O-RNO       PIC X(2).
           05             PIC XX.
           05 O-NAME      PIC X(20).
           05             PIC XX.
           05 ADR-STREET  PIC X(15).
           05             PIC XX.
           05 ADR-CITY    PIC X(15).
           05             PIC XX.
           05 ADR-STATE   PIC X(10).
           05             PIC XX.
           05 ADR-CODE    PIC X(5).
      
       01 EOF PIC X VALUE "Y".


       PROCEDURE DIVISION.
       PARA1.
           OPEN INPUT INFILE.
           OPEN OUTPUT OUTFILE.
               WRITE OUTREC FROM HEAD1.
               PERFORM UNTIL EOF="N"
                    READ INFILE
                         AT END MOVE "NO" TO EOF
                         NOT AT END PERFORM UNSTR
                    END-READ
               END-PERFORM
           CLOSE INFILE.
           CLOSE OUTFILE.
           STOP RUN.

       UNSTR.
            MOVE INRNO TO O-RNO
            MOVE INNAME TO O-NAME
            UNSTRING IN ADDRESS 
                    DELIMITED BY '/'
                    INTO ADR-STREET
                     ADR-CITY
                     ADR-STATE
                     ADR-CODE
            END-UNSTRING
            WRITE OUTREC FROM DETAILS.


INPUT FILE : STUDENT.DAT
**********************************
01HARSHAD GEDIYA     NIRNAYNAGARCHANDLODIYAAHMEDABAD 
02BHAVIKA         NURTANNAGARBARODAGUJARAT32584
17HARSHAD GEDIYA     NIRNAYNAGARAHMEDABADGUJARAT38241
11SHASHANK DESAI     NARANPURAAHMEDABADGUJARAT38245
55HEMAL SHETH        NAVRNGPURAAHMEDABADGUJARAT38257


OUTPUT FILE:- STUDENT.RPT
***************************

        DETAILS OF STUDENT

01 AMISH THHCKER      NARAYAN NAGAR/NARNPURIYA/GUJARAT/38241
02 BHAVIKA          NURTAN NAGAR/BARODA/GUJARAT/32584
17 HARSHAD GEDIYA     NIRNAY NAGAR/AHMEDABAD/GUJARAT/38241
11 SHASHANK DESAI     NARANPURA/AHMEDABAD/GUJARAT/38245
55 HEMAL SHETH        NAVRNGPURA/AHMEDABAD/GUJARAT/38257
  
Share: 


Didn't find what you were looking for? Find more on PROGRAM THAT ILLUSTRATES EXAMPLE OF STRING AND UNSTRING Or get search suggestion and latest updates.

Isabel Hughes
Isabel Hughes author of PROGRAM THAT ILLUSTRATES EXAMPLE OF STRING AND UNSTRING is from London, United Kingdom.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!