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

Building BIND Statement from input records


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

New User


Joined: 15 Oct 2007
Posts: 12
Location: Kentucky

PostPosted: Fri Apr 06, 2012 6:30 pm
Reply with quote

I'm trying to build a bind statement (Output).

Input Records delimited by Comma -1 row heading for reference only. data doesnt have 1st row.
PACKAGE,MEMBER,LIBRARY,OWNER,QUALIFIER,REPLVER
PRODEH,CLMADJ,ABC.AA.XYZ.XXX,SCOTT,DB2T1A,2011-01-01-12.34.56.123456
PRODEH,CLMPAYBL,ABC.AA.XYZ.YYY,WILSON,DB2T1A,2012-01-01-12.34.56.123456

where PACKAGE is fixed length =6
MEMBER variable length 5 to 8 (max)
LIBRARY fixed length =14
OWNER variable length 5 to 8 (max)
QUALIFIER - 6 length (Fixed)
REPLVER - 26 char fixed

Output Required
DSN SYSTEM(PROD)
BIND PACKAGE(PRODEH)+
MEMBER(CLMADJ) LIBRARY('ABC.AA.XYZ.XXX')+
OWNER(WILSON) QUALIFIER(DB2T1A)+
SQLERROR(NOPACKAGE) DEFER(PREPARE)+
VALIDATE(BIND) FLAG(I)+
ISOLATION(CS) CURRENTDATA(NO)
DEGREE(ANY) RELEASE(DEALLOCATE)+
EXPLAIN(YES) DYNAMICRULES(BIND)+
NOREOPT(VARS) KEEPDYNAMIC(NO)+
ENCODING(37)+
ACTION(REPLACE) REPLVER(2011-01-01-12.34.56.123456)
END
EXIT CODE(&LASTCC)
END

DSN SYSTEM(PROD)
BIND PACKAGE(PRODEH)+
MEMBER(CLMPAYBL) LIBRARY('ABC.AA.XYZ.YYY')+
OWNER(SCOTT) QUALIFIER(DB2T1A)+
SQLERROR(NOPACKAGE) DEFER(PREPARE)+
VALIDATE(BIND) FLAG(I)+
ISOLATION(CS) CURRENTDATA(NO)
DEGREE(ANY) RELEASE(DEALLOCATE)+
EXPLAIN(YES) DYNAMICRULES(BIND)+
NOREOPT(VARS) KEEPDYNAMIC(NO)+
ENCODING(37)+
ACTION(REPLACE) REPLVER(2012-01-01-12.34.56.123456)
END
EXIT CODE(&LASTCC)
END

Following output records comes from input. Rest all are hardcode.
PACKAGE
MEMBER
LIBRARY
OWNER
QUALIFIER
REPLVER

For Output record the 2nd column like LIBRARY,QUALIFIER,DEFER,FLAG etc can be started from position 25.
Max length of output record is 72.
Any help is appreciated !
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Apr 06, 2012 6:42 pm
Reply with quote

why not try Yourself, the requirement is pretty similar to this one
www.ibmmainframes.com/viewtopic.php?t=56189&highlight=
that You posted Yourself and for which You received a solution
the logic of which can be applied to the problem in this topic.
Back to top
View user's profile Send private message
sarbamrit

New User


Joined: 15 Oct 2007
Posts: 12
Location: Kentucky

PostPosted: Fri Apr 06, 2012 7:58 pm
Reply with quote

enrico-sorichetti wrote:
why not try Yourself, the requirement is pretty similar to this one
www.ibmmainframes.com/viewtopic.php?t=56189&highlight=
that You posted Yourself and for which You received a solution
the logic of which can be applied to the problem in this topic.


Hi Enrico,

Yes i did have a look at my previous solution. BUt I'm unable to unstring it. Reason: Input has comma delimited and position varies for different parameters based on other values. So I'm not sure how to get out of it.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Apr 06, 2012 8:08 pm
Reply with quote

That's what PARSE is for. Lots of examples.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Fri Apr 06, 2012 8:12 pm
Reply with quote

Amrit,

I am sure Frank or Kolusu will bail you out with a solution.

If they do not do your work for you, I am available to do so.

I have written a Rexx solution for this exact situation.

That code belongs to my cleint as they paid me to write it.

I can however write you custom code for your circumstances.

I work at a very reasonable rate of 500 dollars for a eight hour day.

Feel free to send me a PM so we can work out the details.
Back to top
View user's profile Send private message
sarbamrit

New User


Joined: 15 Oct 2007
Posts: 12
Location: Kentucky

PostPosted: Fri Apr 06, 2012 8:18 pm
Reply with quote

Bill Woodger wrote:
That's what PARSE is for. Lots of examples.


I thought abt PARSE also, but some of input records are of variable length and for PARSE command we need to provide FIXLEN or other which is not my case.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Apr 06, 2012 8:42 pm
Reply with quote

The FIXLEN is for the maximum length of a field. All PARSEd fields are fixed length. Each value in the field will be the same size, some will be padded with trailing space.

Code:
A,12345,B
A,1234567,B

If you PARSE ending at the commas and with FIXLENs of 1, 7 and 1 you will get

Code:
A12345  B
A1234567B
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Apr 06, 2012 8:46 pm
Reply with quote

sarbamrit wrote:
I thought abt PARSE also

stop thinking about it and read about it.
there are parameters that you can use, so that
  1. avoid using fix position notation
  2. allow for variable length records


of course you could always search the board
(lotta effort, i know
but today's Good Friday in the states
and i imagine Frank and Kolusu are taking a much deserved break.)
Back to top
View user's profile Send private message
sarbamrit

New User


Joined: 15 Oct 2007
Posts: 12
Location: Kentucky

PostPosted: Fri Apr 06, 2012 8:49 pm
Reply with quote

Bill Woodger wrote:
The FIXLEN is for the maximum length of a field. All PARSEd fields are fixed length. Each value in the field will be the same size, some will be padded with trailing space.

Code:
A,12345,B
A,1234567,B

If you PARSE ending at the commas and with FIXLENs of 1, 7 and 1 you will get

Code:
A12345  B
A1234567B


Yes.
My case is say in case of MEMBER(ABC123). I can also have MEMBER(ABC1234) or MEMBER(ABC12345). The issue of NOT using PARSE is FIXLEN need to be provided.
Code:
MEMBER(ABC123)
will become
Code:
MEMBER(ABC123  )
Code:
MEMBER(ABC1234)
will become
Code:
MEMBER(ABC1234 )
Code:
MEMBER(ABC12345)
will become
Code:
MEMBER(ABC12345)
whereas I dont want any spaces before my closing bracket.

I'm not sure how to achieve this using PARSE.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Apr 06, 2012 9:06 pm
Reply with quote

Do you remember being directed to your previous post? For getting rid of the spaces afterwards, you have things like JFY and SQZ.

If you want to "decode" your comma-delimited fields with DFSORT, you are going to use PARSE.

For getting rid of the spaces after you have formatted your commands, you use different functions.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Apr 06, 2012 10:05 pm
Reply with quote

sarbamrit,

You are building BIND cards and the parameters can be on different lines , you don't have to club parameters on to a single line. The output file should be 80 bytes and not 72 bytes. Use the following DFSORT JCL
Code:

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                         
PRODEH,CLMADJ,ABC.AA.XYZ.XXX,SCOTT,DB2T1A,2011-01-01-12.34.56.123456   
PRODEH,CLMPAYBL,ABC.AA.XYZ.YYY,WILSON,DB2T1A,2012-01-01-12.34.56.123456
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                 
  SORT FIELDS=COPY                                             
  INREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=06),                   
               %02=(ENDBEFR=C',',FIXLEN=08),                   
               %03=(ENDBEFR=C',',FIXLEN=14),                   
               %04=(ENDBEFR=C',',FIXLEN=08),                   
               %05=(ENDBEFR=C',',FIXLEN=06),                   
               %06=(ENDBEFR=C',',FIXLEN=26)),                   
  BUILD=(%01,SQZ=(SHIFT=LEFT,LENGTH=80,                         
                  LEAD=C'BIND PACKAGE(',TRAIL=C') +'),         
         %02,SQZ=(SHIFT=LEFT,LENGTH=80,                         
                  LEAD=C'MEMBER(',TRAIL=C') +'),               
         %03,SQZ=(SHIFT=LEFT,LENGTH=80,                         
                  LEAD=C'LIBRARY(',TRAIL=C') +'),               
         %04,SQZ=(SHIFT=LEFT,LENGTH=80,                         
                  LEAD=C'OWNER(',TRAIL=C') +'),                 
         %05,SQZ=(SHIFT=LEFT,LENGTH=80,                         
                  LEAD=C'QUALIFIER(',TRAIL=C') +'),             
         %06,SQZ=(SHIFT=LEFT,LENGTH=80,                         
                  LEAD=C'ACTION(REPLACE) REPLVER(',TRAIL=C')'))
                                                               
  OUTFIL BUILD=(C'DSN SYSTEM(PROD)',/,                         
                001,80,/,081,80,/,161,80,/,241,80,/,321,80,/,   
                C'SQLERROR(NOPACKAGE) DEFER(PREPARE)  +',/,     
                C'VALIDATE(BIND) FLAG(I)              +',/,     
                C'ISOLATION(CS) CURRENTDATA(NO)       +',/,     
                C'DEGREE(ANY) RELEASE(DEALLOCATE)     +',/,     
                C'EXPLAIN(YES) DYNAMICRULES(BIND)     +',/,     
                C'NOREOPT(VARS) KEEPDYNAMIC(NO)       +',/,     
                C'ENCODING(37)                        +',/,     
                401,80,/,                                       
                C'END',/,                                       
                C'EXIT CODE(&LASTCC)',/,                       
                C'END',/,80:X)                                 
//*


This will produce the following Output
Code:

DSN SYSTEM(PROD)                                       
BIND PACKAGE(PRODEH) +                                 
MEMBER(CLMADJ) +                                       
LIBRARY(ABC.AA.XYZ.XXX) +                             
OWNER(SCOTT) +                                         
QUALIFIER(DB2T1A) +                                   
SQLERROR(NOPACKAGE) DEFER(PREPARE)  +                 
VALIDATE(BIND) FLAG(I)              +                 
ISOLATION(CS) CURRENTDATA(NO)       +                 
DEGREE(ANY) RELEASE(DEALLOCATE)     +                 
EXPLAIN(YES) DYNAMICRULES(BIND)     +                 
NOREOPT(VARS) KEEPDYNAMIC(NO)       +                 
ENCODING(37)                        +                 
ACTION(REPLACE) REPLVER(2011-01-01-12.34.56.123456)   
END                                                   
EXIT CODE(&LASTCC)                                     
END                                                   
                                                       
DSN SYSTEM(PROD)                                       
BIND PACKAGE(PRODEH) +                                 
MEMBER(CLMPAYBL) +                                     
LIBRARY(ABC.AA.XYZ.YYY) +                             
OWNER(WILSON) +                                       
QUALIFIER(DB2T1A) +                                   
SQLERROR(NOPACKAGE) DEFER(PREPARE)  +                 
VALIDATE(BIND) FLAG(I)              +                 
ISOLATION(CS) CURRENTDATA(NO)       +                 
DEGREE(ANY) RELEASE(DEALLOCATE)     +                 
EXPLAIN(YES) DYNAMICRULES(BIND)     +                 
NOREOPT(VARS) KEEPDYNAMIC(NO)       +                 
ENCODING(37)                        +                 
ACTION(REPLACE) REPLVER(2012-01-01-12.34.56.123456)   
END                                                   
EXIT CODE(&LASTCC)                                     
END                                                   
                                                       
Back to top
View user's profile Send private message
sarbamrit

New User


Joined: 15 Oct 2007
Posts: 12
Location: Kentucky

PostPosted: Mon Apr 09, 2012 3:23 pm
Reply with quote

Thank you Kolusu for the complete solution.
I would also like to say 'Thank you' to Enrico, Bill and Dick for putting their time in guiding and providing solutions.
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 To fetch records that has Ttamp value... DFSORT/ICETOOL 4
No new posts ICETOOL returns no records JCL & VSAM 1
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
Search our Forums:

Back to Top