0

Statement: Earlier files were fetched from remote server location to mainframe. Then those files content were get and saved at mainframe in a sequential file. But sometime, some file names contained spaces. Due to this job fails while getting its content.

Now to solve this problem, we fetched all files from server and separated good files and bad files. Now we fetch only good file contents.

Problem: While renaming the files, we add prefix Process_ and Odate(fetched from Control M) to file name. But earlier it was done in jcl as below through unix code.

Pseudo code: print "rename " $1 " " "Process_" %%DAT "_" $1

We are fetching ODATE from a software control-M.

Jcl code:

//JOBNAME JOB (DEE),'Job Desc',CLASS=P,MSGCLASS=J,
//       MSGLEVEL=(1,1),COND=(0,NE)                           
//* %%SET  %%DAT = %%$ODATE
//STEP01 EXEC PROC1

PROC1 code:

//STEP02 EXEC PGM=SORT                                                               
//SORTIN   DD  DSN=DS.FILE1,        
//             DISP=SHR                     
//SORTOUT  DD  DSN=DS.FILE2,     
//             UNIT=SYSSF,                                   
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=0),            
//             SPACE=(27920,(29,6),RLSE),      
//             DISP=(NEW,CATLG,DELETE)                       
//SYSIN    DD  DSN=DS.PARM(PARM03),DISP=SHR       

PARM03 contains: Here I am creating unix code to rename file:

SORT FIELDS=COPY                                               
OUTFIL BUILD=(1:C'print "get " r_fi',18:SEQNUM, -              
    3,ZD,22:C'" //DD:upload"',/,1:C'print "rename " r_fi',  -
         21:SEQNUM,3,ZD,24:C' ', -                          
25:C' " " "Process_" %%DAT "_" r_fi',53:SEQNUM,3,ZD,80:X)      
/*                                                          

The unix code which I am creating dynamically: Here depending on the number of files p_fi01, p_fi02, p_fi03..... is generated. I am saving the unix code in a dataset and passing it as instream to run.

The problem is, it is not able to get the value in DAT variable. Is there any way, I can pass the value of D from jcl to proc and append it with
"Process_" using sort card in proc.

Example data: File File1.csv contents are fetched and then renamed as Process_20140101_File1.csv

deepaklearner
  • 151
  • 1
  • 6
  • 22
  • @BillWoodger I was so excited to see another COBOL programmer on here XD – SaggingRufus Jan 31 '14 at 13:54
  • @BillWoodger: I have used DFSORT here. I have provided some example data also. – deepaklearner Feb 01 '14 at 11:14
  • @SaggingRufus: I can't share all code as per policy. I have tried to elaborate more. If you need some more information. I will provide. Thank you so much for your help. – deepaklearner Feb 01 '14 at 11:27
  • @BillWoodger I have Z/OS DFSORT V1R12. – deepaklearner Feb 03 '14 at 20:57
  • @BillWoodger: Thanks you so much. I cant express how happy I am. The code is working. By mistake I had written JP0 inside single quote, so it was writing the same. Thanks again. :) – deepaklearner Feb 03 '14 at 21:44
  • @BillWoodger: You are great... :) – deepaklearner Feb 03 '14 at 21:46
  • If you look next to the answers, there's a sort of empty tick-shape. If you click on that you can "accept" and answer as being the most helpful to you. From no accepts on your questions, I don't think you know how to do that. You also get two points for each answer you accept. Then, I think, you'd also have enough to vote. So you can also vote for any questions which have helped you (including ones you have accepted). – Bill Woodger May 18 '15 at 18:54

1 Answers1

1

Assuming that the rest of your code is OK, it is fairly simple with DFSORT, using JPn, which is a special DFSORT symbol which allows the separate values of up to 10 parameters to be used in control cards.

Here is an example:

// SET INPARM='ABC' 
//* 
//STEP0100 EXEC PGM=SORT,PARM='JP0"&INPARM"'
//SYSOUT   DD SYSOUT=* 
//SYMNOUT  DD SYSOUT=* 
//SORTOUT  DD SYSOUT=* 
//SYSIN    DD * 
  OPTION COPY 
  INREC BUILD=(JP0) 
//SORTIN   DD * 
IRRELEVANT DATA, JUST AN EXAMPLE 

I have used SET to create a JCL symbol, but you have yours already from CONTROL-M, so just replace &INPARM on the PARM with your CONTROL-M symbol.

JPn means JP0 through JP9. Three separate pieces of data could look like this:

//STEP0100 EXEC PGM=SORT,PARM='JP0"&INPARM1",JP1"&INPARM2",JP2"&INPARM3"'

The SYMNOUNT DD is optional, but very, very useful, as it will show you the translated values of the symbols.

Assuming that the rest of your code is correct, you would make this change:

25:C' " " "Process_"',JP0,C'"_" r_fi',53:SEQNUM,3,ZD,80:X) 

And include a PARM on the EXEC card, PARM='JP0"[yourControl-M-symbol]"'

SyncSort does not have JPn, so that is lucky for you that you have DFSORT. A different technique would be required for SyncSort.

Bill Woodger
  • 12,968
  • 4
  • 38
  • 47
  • Thanks a lot. I am trying. Will let let you know, it works or not. :-) – deepaklearner Feb 01 '14 at 12:16
  • @Raushan You might want to consider accepting this answer so that others will see that it is: 1) What you were looking for; 2) Correctly sloved your problem; 3) Is the best answer posted (this might be the only answer, but it is not uncommon for others to post subsequent answers in the hopes that they will be given the checkmark) – NealB Feb 04 '14 at 17:21