MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Merge 20 file contents with last qualifier as first record

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
Nabanita Das
Beginner


Joined: 09 Nov 2005
Posts: 33
Topics: 10

PostPosted: Fri Nov 11, 2005 1:15 am    Post subject: Merge 20 file contents with last qualifier as first record Reply with quote

I do not know whther this is the right section to post my query.

I have 20 sequential files with date tag like D060405 as the last qualifier.
I want these files to be merged in one file with the dates as separators.

For example:

File1.d060405
file2.d061105
file3.d061805

and so on..

My desired output should be a merged filesay FINALFIL with content:

060405
content of file1
061105
content of file2
061805
content of file 3 and so on...

Problem here is that I do not know how to read the date from the last qualifier from the file name. Nowherelese the date is mentioned.

Can it be accomplished through DFSORT?
Please help me out.

Thanks and Regards,
Nabanita Das
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Fri Nov 11, 2005 3:20 am    Post subject: Reply with quote

Nabanita Das,

Reading the dataset name dynamically during runtime is not possible with any sort product. Instead you can use a combination of REXX/SAS and sort. Will you be interested for this ?

Is this a one time run or are you going to move the code to production ?

Thanks,
Phantom
Back to top
View user's profile Send private message
Nabanita Das
Beginner


Joined: 09 Nov 2005
Posts: 33
Topics: 10

PostPosted: Fri Nov 11, 2005 3:33 am    Post subject: Reply with quote

Phantom,

For the current assignment this is going to be one time code. But we get similar requests very often for data correction wherein we need to process many files. So my intention is to keep this code ready whenever we get similar requests.Also my intention here is to learn how to dynamically read the date from the filename

Please guide me how to accomplish this using REXX/SAS.

Thanks and Regards,
Nabanita
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Fri Nov 11, 2005 3:59 am    Post subject: Reply with quote

Nabanita Das,

I am preparing a customized rexx code for you. But I have One more question. How big are your 20 datasets ???

Thanks,
Phantom
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Fri Nov 11, 2005 4:27 am    Post subject: Reply with quote

Nabanita Das,

The code below will work irrespective of the size of your input datasets.

Here is the Rexx code to get the last qualifier of your input datasets. This is customized from Doug Nadel's BATCHPDF code. To understand the code, you must first know something about DATA AREAS. Anyway, you can use this code to satisfy your requirement.

Code:

/* REXX */                                                             
  ARG DDNS                                                             
  DSQUAL. = ''                                                         
  SAY 'DDNAME: ' DDNS                                                 
  CALL GET_ALLOCATIONS DDNS                                           
                                                                       
  DO I = 1 TO DSQUAL.0                                                 
       PUSH DSQUAL.I                                                   
      "EXECIO 1 DISKW OUT"||I||" (FINIS"                               
  END                                                                 
EXIT 1                                                                 
                                                                       
/*-------------------------------------------------------------------*/
/*------------------ SUBROUTINES FOLLOW -----------------------------*/
/*-------------------------------------------------------------------*/
GET_ALLOCATIONS:  PROCEDURE EXPOSE DDNAME. DSQUAL. DSNAME.             
NUMERIC DIGITS 10                      /* ALLOW UP TO 7FFFFFFF       */
TIOTPTR=24+PTR(12+PTR(PTR(PTR(16))))   /* GET DDNAME ARRAY           */
TIOELNGH=C2D(STG(TIOTPTR,1))           /* NENGTH OF 1ST ENTRY        */
A=0                                                                   
DDNAME=' '                                                             
DO UNTIL TIOELNGH=0                    /* SCAN UNTIL DD FOUND        */
  TIOEDDNM=STRIP(STG(TIOTPTR+4,8))     /* GET DDNAME FROM TIOT       */
  IF SUBSTR(TIOEDDNM,1,1) <>'00'X THEN                                 
    DO                                                                 
      IF SUBSTR(TIOEDDNM,1,1) <>" " THEN                               
        DDNAME=TIOEDDNM                                               
      IF DDNAME=ARG(1) THEN                                           
        DO                                                             
          A=A+1                                                       
          DDNAME.A=DDNAME                                             
          TIOELNGH=C2D(STG(TIOTPTR,1)) /* LENGTH OF NEXT ENTRY       */
          TIOEJFCB=STG(TIOTPTR+12,3)                                   
          JFCB=SWAREQ(TIOEJFCB)        /* CONVERT SVA TO 31-BIT ADDR */
          DSNAME.A=STRIP(STG(JFCB,44)) /* DSNAME JFCBDSNM            */
          LAST_QUAL_IDX = LASTPOS('.', DSNAME.A) + 1                   
          DSQUAL.A = SUBSTR(DSNAME.A, LAST_QUAL_IDX)                   
        END                                                           
    END                                                               
  TIOTPTR=TIOTPTR+TIOELNGH             /* GET NEXT ENTRY             */
  TIOELNGH=C2D(STG(TIOTPTR,1))         /* GET ENTRY LENGTH           */
END                                                                   
DSQUAL.0=A                                                             
DROP DDNAME. DSNAME.                                                   
RETURN                                                                 
/*-------------------------------------------------------------------*/
PTR:  RETURN C2D(STORAGE(D2X(ARG(1)),4)) /* RETURN A POINTER         */
/*-------------------------------------------------------------------*/
STG:  RETURN STORAGE(D2X(ARG(1)),ARG(2)) /* RETURN STORAGE           */
/*-------------------------------------------------------------------*/
SWAREQ:  PROCEDURE                                                     
IF RIGHT(C2X(ARG(1)),1) \= 'F' THEN    /* SWA=BELOW ?                */
  RETURN C2D(ARG(1))+16                /* YES, RETURN SVA+16         */
SVA = C2D(ARG(1))                      /* CONVERT TO DECIMAL         */
TCB = PTR(540)                         /* TCB PSATOLD                */
JSCB = PTR(TCB+180)                    /* JSCB TCBJSCB               */
QMPL = PTR(JSCB+244)                   /* QMPL JSCBQMPI              */
QMAT = PTR(QMPL+24)                    /* QMAT QMADD                 */
DO WHILE SVA>65536                                                     
  QMAT = PTR(QMAT+12)                  /* NEXT QMAT QMAT+12          */
  SVA=SVA-65536                        /* 010006F -> 000006F         */
END                                                                   
RETURN PTR(QMAT+SVA+1)+16                                             
/*-------------------------------------------------------------------*/


Store the REXX program in your REXX library in the name "GETDSN". Then run the following JCL which will get the Date from the last qualifier and also merges all your input files together.

Code:

//R010     EXEC PGM=IKJEFT1A                                 
//SYSOUT   DD  SYSOUT=*                                     
//SYSPRINT DD  SYSOUT=*                                     
//SYSTSPRT DD  SYSOUT=*                                     
//INPUT    DD  DSN=MY.INPUT.FILE1,           
//             DISP=SHR                                     
//         DD  DSN=MY.INPUT.FILE2,           
//             DISP=SHR                                     
//         DD  DSN=MY.INPUT.FILE3,           
//             DISP=SHR                                     
//SYSEXEC  DD  DSN=MY.REXX.LIBRARY,DISP=SHR                 
//OUT1     DD  DSN=&&T1,DISP=(,PASS)                         
//OUT2     DD  DSN=&&T2,DISP=(,PASS)                         
//OUT3     DD  DSN=&&T3,DISP=(,PASS)                         
//SYSTSIN  DD *                                             
  %GETDSN INPUT                                             
/*                                                           
//R020     EXEC PGM=SORT                                     
//SORTIN   DD  DSN=&&T1,DISP=SHR,VOL=REF=*.R010.OUT1         
//         DD  DSN=MY.INPUT.FILE1,DISP=SHR   
//         DD  DSN=&&T2,DISP=SHR,VOL=REF=*.R010.OUT2         
//         DD  DSN=MY.INPUT.FILE2,DISP=SHR   
//         DD  DSN=&&T3,DISP=SHR,VOL=REF=*.R010.OUT3
//         DD  DSN=MY.INPUT.FILE3,DISP=SHR   
//SORTOUT  DD  SYSOUT=*                                     
//SYSOUT   DD  SYSOUT=*                                     
//SYSIN    DD  *                                             
  SORT FIELDS=COPY 
/*                 


NOTE:
In the JCL above, for Step R010, you need to define output (OUTxx) files as many as your inputs. In the example above, I am trying to merge 3 input files and hence I have defined 3 OUTxx datasets. You need to tailor your JCL to suit your needs.

Hope this helps,

Thanks,
Phantom
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Fri Nov 11, 2005 4:33 am    Post subject: Reply with quote

phantom,

It would be a good idea to create a symbols dataset with the last qualifier and use that in the sort step.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Fri Nov 11, 2005 4:47 am    Post subject: Reply with quote

Oh Yes!.

Need to try that option. Unfortunately, I typed an un-authorized command which "Suspended" my mainframe ID. Need to call our system folks during US day time to un-suspend it.

Thanks,
Phantom
Back to top
View user's profile Send private message
Nabanita Das
Beginner


Joined: 09 Nov 2005
Posts: 33
Topics: 10

PostPosted: Fri Nov 11, 2005 7:50 am    Post subject: Reply with quote

Thanks Phantom and Kolusu. I will try this out and get back to you.

Thanks and Regards,
Nabanita Das
Back to top
View user's profile Send private message
Nabanita Das
Beginner


Joined: 09 Nov 2005
Posts: 33
Topics: 10

PostPosted: Wed Nov 23, 2005 5:38 am    Post subject: Reply with quote

Hi Phantom,

After I ran the job I am facing problem. I am pasting the sysout for the step R010.
%GETDSN INPUT
DDNAME: INPUT
36 +++ DSQUAL.A = SUBSTR(DSNAME.A, LAST_QUAL_IDX)
5 +++ CALL GET_ALLOCATIONS DDNS
Error running GETDSN, line 36: Incorrect call to routine

Please let me know where I am going wrong. I have used the exact REXX code and JCL you have given. I have just replaced the input files and output filenames and my rexx library.

Thanks and Regards,
Nabanita
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group