Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to avoid these records from writing ?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
tamminenisidhartha
Currently Banned

New User


Joined: 31 Oct 2012
Posts: 43
Location: INDIA

PostPosted: Wed Nov 07, 2012 3:39 pm    Post subject: How to avoid these records from writing ?
Reply with quote

I have the input file like this.

Code:
emp dep  emp type   emp sal
         
000011        P            100
000011        T            200
000011        S            500
000023        P            300
000024        P            400


I would like to know this. I want to eliminate only emptype " P and T " records from writing if they have same emp dep value.

Code:
Note : In this example, The Emptype for first two records is " P and T ".
          And they have the same empdep value.
          Here the EMPTYPE " S" also has the same empdep value.
          But it should be written into the output file.
          So I would like to avoid only this pair of record from writing into
          the output file.


Here's he logic on what I have been working on.

Code:
     IF K = SUBSTR(INREC.EMPNO,1,6) THEN DO;
     IF P ¬= SUBSTR(INREC.TYPE1,1,4) THEN DO;
     WRITE FILE(OUTFILE) FROM (INREC);       
     END;                                   
     ELSE DO;                               
     WRITE FILE(OUTFILE) FROM (HEADER);     
     WRITE FILE(OUTFILE) FROM (INREC);       
     END;                                   
     END;                                   
  END;                                       
  K = SUBSTR(INREC.EMPNO,1,6);               
  P = SUBSTR(INREC.TYPE1,1,4);               
  READ FILE(INFILE) INTO (INREC);           


I have coded this inside a do while loop.

I hope you understood my question.

Code'd
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Wed Nov 07, 2012 3:53 pm    Post subject: Reply to: How to avoid these records from writing ?
Reply with quote

Your post has been Code'd to preserve formatting. Please do this yourself in future.

You will need to store the P/T records as you only know by the receipt of a T after the P (or P after the T) that the P (or T) is not needed for that key.

What's all the SUBSTR for?
Back to top
View user's profile Send private message
tamminenisidhartha
Currently Banned

New User


Joined: 31 Oct 2012
Posts: 43
Location: INDIA

PostPosted: Wed Nov 07, 2012 4:33 pm    Post subject:
Reply with quote

I have been comparing the values by passing them into the variables using substring function.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Wed Nov 07, 2012 5:03 pm    Post subject: Reply to: How to avoid these records from writing ?
Reply with quote

but why not use a proper DCL for the record layout

if the layout changes, You will not to have to chase around for the offsets
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Thu Nov 08, 2012 12:38 am    Post subject: Re: Reply to: How to avoid these records from writing ?
Reply with quote

enrico-sorichetti wrote:
but why not use a proper DCL for the record layout

if the layout changes, You will not to have to chase around for the offsets

The data the TS shows suggests that the records are not necessarily of a fixed format (although heesh might have munged the example by putting explanatory column headers in the Code tags).

Tammi-kun, are more employee types possible than "P", "S", and "T"? May the data be assumed to be sorted by department?
Back to top
View user's profile Send private message
tamminenisidhartha
Currently Banned

New User


Joined: 31 Oct 2012
Posts: 43
Location: INDIA

PostPosted: Thu Nov 15, 2012 11:45 am    Post subject:
Reply with quote

The data is srted by EMPDEP already and the employee types are only of P, S, T types.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Thu Nov 15, 2012 8:49 pm    Post subject: Reply to: How to avoid these records from writing ?
Reply with quote

Very well. Consider the following program:
Code:
 foo36:  proc options (main) reorder;

 %dcl (true,false,digits,space)     char;
 %true   = '''1''B';
 %false  = '''0''B';
 %digits = '''0123456789''';
 %space  = ''' ''';

 dcl tulin                          file record input
                                    env (fb recsize(80)),
     tulout                         file record output
                                    env (fb recsize(132));

 dcl eyecatch (11)                  unsigned fixed bin (32) static
         init ('E69989A3'XU, 'A3859540'XU, '82A840C1'XU,
               '9281A3A2'XU, 'A4928194'XU, '8960A281'XU,
               '948140C8'XU, '8589A285'XU, '8940F2F4'XU,
               '4BF1F14B'XU, 'F1F50000'XU);

 dcl (eof_tulin, set_aside)         bit init(false),
     emptyp                         char,
     (empdep, lastdep)              char (79),
     (recin, recaside)              char (80) init((80)' '),
     recout                         char (132),
     (p, q)                         fixed bin (31);

 dcl (index, substr, verify)        builtin;

 on endfile (tulin) eof_tulin = true;

 read file (tulin) into (recin);

 do while (¬eof_tulin);
   if (verify(substr(recin,1,1),digits)¬=0) then
   do;
     recout = recin;
     write file (tulout) from (recout);
   end;
   else do;
     p = index(recin,space);
     q = verify(recin,space,p);
     empdep = substr(recin,1,p-1);
     emptyp = substr(recin,q,1);

     if (empdep¬=lastdep) then
     do;
       if (set_aside) then
       do;
         recout = recaside;
         write file (tulout) from (recout);
       end;

       set_aside = false;
       lastdep   = empdep;
     end;

     select (emptyp);
       when ('S') do;
         recout = recin;
         write file (tulout) from (recout);
       end;
       when ('P', 'T') do;
         recaside  = recin;
         set_aside = ªset_aside;
       end;
       otherwise do;
         put skip edit ('Serious error!  Unknown EMPTYP = [', emptyp,
                        ']') (a,a,a);
         exit;
       end;
     end;
   end;

   read file (tulin) into (recin);
 end;

 if (set_aside) then
 do;
   recout = recaside;
   write file (tulout) from (recout);
 end;

 end foo36;


I have assumed that the first character of EMPDEP is always a decimal digit; that criterion may be used to eliminate header records from consideration. I further assume that, although EMPDEP is always separated from EMPTYP by at least one space (and that it contains no embedded spaces), the record is not of fixed format; thus the use of the INDEX and VERIFY functions to find EMPTYP (if the record is of fixed format, you are better off declaring a structure as suggested by Dr. Sorichetti). An EMPTYP of "P" or "T" causes the record to be set aside and the switch SET_ASIDE to be toggled; when EMPDEP changes, the set-aside record is written if SET_ASIDE is true, which it will not be if a pair of records is encountered. Note that signficantly different data may require changes.
Back to top
View user's profile Send private message
tamminenisidhartha
Currently Banned

New User


Joined: 31 Oct 2012
Posts: 43
Location: INDIA

PostPosted: Fri Nov 16, 2012 2:34 pm    Post subject: Reply to: How to avoid these records from writing ?
Reply with quote

@akatsukami.
Thank you.
I would execute the code and post the outcome here.
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 -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us