IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Conversion from VB to FB without specifying length


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
kajsatylen

New User


Joined: 04 May 2007
Posts: 6
Location: Greece

PostPosted: Wed May 09, 2007 6:42 pm
Reply with quote

Hi,

I need some help... I'm trying to copy (nothing fancy like sorting) a variable length file (lrecl 6004) to a fixed length file (of varying sizes, less than lrecl 6004). I'm using this for one of my files:

Code:

  SORT FIELDS=COPY                         
  OUTFIL FNAMES=SORTOUT,VTOF,OUTREC=(5,433)


which works fine. However, I want to be able to use a generic term for the rest of the record, i.e. instead of the record length of the fixed file (i.e. 433), as the record length isn't always the same. Is there a way of doing this? At the moment I'm using Fileaid (PADCHAR) command, but this is very inefficient and I need something that will run a bit faster.

Can anyone help?
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed May 09, 2007 6:48 pm
Reply with quote

I use ........................ which takes a 44 byte field from a VB record and puts it out into a FB 80 file. (In deference to superk, I did not use the term flat file).

Code:

//ICEMERGE EXEC PGM=ICETOOL                                         
//TOOLMSG  DD SYSOUT=*                                             
//DFSMSG   DD SYSOUT=*                                             
//INFILE   DD DSN=whatever,DISP=SHR   
//OUFILE   DD DSN=&PREFIX.&SYSUID..&SYSTID.FIXED,             
//            DISP=(,CATLG,DELETE),                                 
//            SPACE=(CYL,(10,10),RLSE)
//TOOLIN   DD *                                                     
COPY FROM(INFILE)  TO(OUFILE)  USING(COPY)                       
/*                                                                 
//COPYCNTL DD *                                                     
  OPTION  VLLONG                                                     
  INCLUDE COND=(9,1,EQ,C'M'),FORMAT=CH                               
  OUTFIL  FNAMES=OUFILE,CONVERT,
     OUTREC=(29,44,80:X),VLFILL=C' '     
/*                                                                 
//                                                                 
Back to top
View user's profile Send private message
kajsatylen

New User


Joined: 04 May 2007
Posts: 6
Location: Greece

PostPosted: Wed May 09, 2007 6:58 pm
Reply with quote

Thanks for your quick response!

Could you elaborate on this:

Code:

  OUTREC=(29,44,80:X),


What are the numbers? 44 appears to relate to the record length of the input file, which I could (presumably) specify as 6004 as I know that value every time. 80 appears to relate to the record length of the output file, however I don't know what this value will be. Am I mistaken?
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed May 09, 2007 7:16 pm
Reply with quote

Code:

   OUTFIL  FNAMES=OUFILE,CONVERT,
      OUTREC=(29,44,80:X),VLFILL=C' '


Not too sure about the exact specifics here, but this is what I understand

pos = position in the original record (input record) of the data I want to extract
len = length of data I want to extract from the position specified

pad to:X = pad up to position 80:X in the output record. The X usually means a blank, but just to be sure I've specified the fill charachter with VLFILL=C' '
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed May 09, 2007 9:14 pm
Reply with quote

kajsatylen,

I'm not really sure what you're trying to do.

For VTOF,OUTREC=(5,433) DFSORT will automatically pad any records shorter than 433 on the right with blanks to get a 433 byte record (VLFILL=C' ' is the default for this situation).

What do you mean by a "generic term for the rest of the record". Please explain more clearly what you're trying to do and give an example of the different variations you're talking about.
Back to top
View user's profile Send private message
kajsatylen

New User


Joined: 04 May 2007
Posts: 6
Location: Greece

PostPosted: Thu May 10, 2007 1:02 pm
Reply with quote

I want to be able to move a variable length records (length of variable file is 6004) to a fixed length file. The length of the fixed file varies each time so I don't want to hardcode the length. There won't be any padding involved as the record length for all the records on the variable file will equal that of the fixed length file.

Does that make any more sense?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu May 10, 2007 8:20 pm
Reply with quote

Quote:
Does that make any more sense?


Not really. Something is missing. You say
Quote:
length of the fixed file varies each time so I don't want to hardcode the length.
Say you want a length of 50 one time and a length of 100 the next time. How is DFSORT supposed to know that if you don't specify the length as 50 or 100? You need to specify the length somewhere. DFSORT can't guess the length you want, or read your mind. So what are you NOT saying about how DFSORT is supposed to know the length, or what am I missing here?

Are you trying to say that the length of each input record as indicated in the RDW is the same for all of the records and that's the length (-4 for the RDW) you want for the output file? For example, for one case the length of all the input records is 50 so you want the output length to be 46 and contain input positions 5-50 and for another case the length of all the input records is 85 so you want the output length to be 81 and contain input positions 5-85?

It's kind of unusual for a VB file to have records that are all the same length (that kind of defeats the purpose of having a VB file).
Back to top
View user's profile Send private message
kajsatylen

New User


Joined: 04 May 2007
Posts: 6
Location: Greece

PostPosted: Thu May 10, 2007 9:02 pm
Reply with quote

I guess that's the question. Can DFSORT do it? Looks like it can't. In, for example, a REPRO, the length doesn't have to be specified, it just takes the record and drops it in to the output file. If DFSORT doesn't have that facility, then I won't be able to use it.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu May 10, 2007 9:14 pm
Reply with quote

Quote:
Can DFSORT do it?


Do what????? You still haven't explained clearly what you want to do! (I think you think you have, but that's because you understand what you want to do - I don't, so you have to explain it to me clearly.)

Is the output data set NEW or OLD? Does it already have the RECFM and LRECL in the DSCB, or do you specify the RECFM and LRECL on the output DD statement, or what?

What is it exactly that REPRO does? Show me the REPRO job that does whatever it is you want to do.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Thu May 10, 2007 11:40 pm
Reply with quote

It is my guess about what OP whats to achieve -
Suppose there is an input file of RECLN=500 and VB,
he wants o/p in FB with length 500 without specifying parameters in JCL or SORTCARD/ pass variable value in SORTCARD..
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri May 11, 2007 1:07 am
Reply with quote

No, that's not what's wanted. OP said in the first post that the input has RECFM=VB and LRECL=6004, and that the output would have RECFM=FB and LRECL=133 or some other LRECL.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri May 11, 2007 12:35 pm
Reply with quote

My understanding of the OP problem is that he has a VB file or LRECL 6004 which is wanted in an FB format file with LRECL 6004.

Not knowing the length of each record within the VB file seems to be the problem, where as in the example I posted above, I know the length of the field that I am extracting, so coded it as 29,44, with the 80:X on the end.

I guess he's looking for something like
OUTREC=(5,to end of rec,6004:X)

Not sure of the syntax for this, but if I get a chance I will try and look it up.
Back to top
View user's profile Send private message
kajsatylen

New User


Joined: 04 May 2007
Posts: 6
Location: Greece

PostPosted: Fri May 11, 2007 2:07 pm
Reply with quote

Sorry if I'm being confusing.

I want to:

copy records from a RECFM=VB, LRECL=6004 file to a RECFM=FB, LRECL=??? <--- this length will change each time, but each record within the variable file will have the same length.

I want to be able to use the same control card regardless of the length of the output file.

The REPRO I use is as follows:

Code:
//STEP020 EXEC PGM=IDCAMS                                   
//DDI      DD DSN=FILE.INPUT,DISP=SHR         <----- VB, 6004
//DDO      DD DSN=FILE.OUTPUT,                               
//            SPACE=(CYL,(5,1)),                             
//            DISP=(,CATLG,DELETE),                         
//            RECFM=FB,LRECL=520,                           
//            DATACLAS=VPDCSMAL                             
//SYSIN    DD *                                             
 REPRO -                                                     
  INFILE(DDI) -                                             
  OUTFILE(DDO)                                               
//SYSOUT   DD SYSOUT=*                                       
//SYSPRINT DD SYSOUT=*                                       


This repro works because the length of the records on the variable file are the same as the record length of the fixed file. Does this make any more sense?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri May 11, 2007 8:44 pm
Reply with quote

Ok, I think I undestand and I think I know a way to do this with DFSORT. I just need to know one more thing.

You say
Quote:
the length of the records on the variable file are the same as the record length of the fixed file


For the given example, the output LRECL is 520. Is each variable input record 520 bytes including the RDW like this:

Code:

Input RECFM=VB

|RDW|data|
  4  516


and you want the 4-byte RDW and the 516 bytes of data in the output record like this:

Code:

Output RECFM=FB, LRECL=520

|RDW|data|
  4  516


Or is each variable input record 524 bytes including the RDW like this:

Code:

Input RECFM=VB

|RDW|data|
  4  520


and you want the 520 bytes of data in the output record (but not the RDW) like this:

Code:

Output RECFM=FB, LRECL=520

|data|
  520
Back to top
View user's profile Send private message
kajsatylen

New User


Joined: 04 May 2007
Posts: 6
Location: Greece

PostPosted: Wed May 16, 2007 1:01 pm
Reply with quote

The second of the two.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed May 16, 2007 9:39 pm
Reply with quote

Quote:
copy records from a RECFM=VB, LRECL=6004 file to a RECFM=FB, LRECL=??? <--- this length will change each time, but each record within the variable file will have the same length.


Here's a DFSORT/ICETOOL job that will do what you asked for.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=...  input file (VB/6004)
//CTL2CNTL DD DSN=&&T1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//OUT DD DSN=...  output file (FB/n)
//TOOLIN   DD    *
COPY FROM(IN) USING(CTL1)
COPY FROM(IN) USING(CTL2)
/*
//CTL1CNTL DD *
* Create the following control statement:
*    OUTFIL FNAMES=CTL2CNTL,VTOF,BUILD=(5,n)
* where n = length-4 from first input record.
* Use the OUTFIL statement to convert VB records of length n+4
* to FB records of length n.
  OPTION STOPAFT=1
  OUTFIL FNAMES=CTL2CNTL,VTOF,
    BUILD=(C'  OUTFIL FNAMES=OUT,VTOF,BUILD=(5,',
     1,2,BI,SUB,+4,EDIT=(TTTTT),C')',80:X)
/*
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Store the data for fixed length COBOL Programming 1
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts VB to VB copy - Full length reached SYNCSORT 8
No new posts 10 byte RBA conversion DB2 2
Search our Forums:

Back to Top