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

Convert DATE & COUNT to packed decimal S(9) comp-3 in DF


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

Active User


Joined: 19 Mar 2009
Posts: 206
Location: Globe, India

PostPosted: Sat Aug 20, 2011 4:29 pm
Reply with quote

i am in need to convert the the system date created during runtime into the packed decimal of S(9) COMP-3 field.

i have control statement in my sort card as:

Code:
HEADER1=(1:'HDR',4:DATE=(MD4-))

TRAILER1=(1:'TLR',10:COUNT=(EDIT(IIIT)))


I want to rewrite these statements by getting PD format of date at position 4.

And number of records processed in input file except TLR and HDR, at 10th position in packed decimal of S9(09) COMP-3.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Mon Aug 22, 2011 8:23 pm
Reply with quote

rohanthengal,
Is it safe to assume that you want Packed decimal date in the header record only and not on all the records? If possible, please show an example of input record and expected output along with LRECL and RECFM for the input file. What is your Date format? YYYYMMDD or MMDDYYYY or what?

I see a post from you in the JCL section, do you have Syncsort or DFSort?

Thanks,
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Mon Aug 22, 2011 8:32 pm
Reply with quote

rohanthengal
Have you tried executing your sort card shown to us? It is not correct syntax...
Code:
10:COUNT=(EDIT(IIIT)))
Back to top
View user's profile Send private message
rohanthengal

Active User


Joined: 19 Mar 2009
Posts: 206
Location: Globe, India

PostPosted: Mon Aug 22, 2011 8:34 pm
Reply with quote

hi sqlcode1...
your solution to my previous query worked well.. thanks buddy !
actually i am away from my mainframe. working from personal station.
but as far as i remember and u reminded me, i think all the fields in the output file need to be mapped to s(9) comp-3 for which i have got the solution using outrec and converting to packed decimal..
but i am not able to convert the above mentioned fields to PD.

problem is i am using the functions like DATE and COUNT which give me output in numeric format but can i convert them to S9(9) comp-3 ?
Back to top
View user's profile Send private message
rohanthengal

Active User


Joined: 19 Mar 2009
Posts: 206
Location: Globe, India

PostPosted: Mon Aug 22, 2011 8:51 pm
Reply with quote

esacapa, yeah it was working..
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Mon Aug 22, 2011 9:05 pm
Reply with quote

rohanthengal wrote:
esacapa, yeah it was working..

It will only after you give comma after HEADER1 statement..
Back to top
View user's profile Send private message
rohanthengal

Active User


Joined: 19 Mar 2009
Posts: 206
Location: Globe, India

PostPosted: Mon Aug 22, 2011 9:15 pm
Reply with quote

you are right escapa..
actually i removed outrec statements in between and pasted only required those, as i wanted to convert them i.e. DATE and COUNT into PD of S9(9) COMP-3
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Mon Aug 22, 2011 9:32 pm
Reply with quote

rohanthengal,
Quote:
but as far as i remember and u reminded me, i think all the fields in the output file need to be mapped to s(9) comp-3 for which i have got the solution using outrec and converting to packed decimal..
but i am not able to convert the above mentioned fields to PD.


If you already have date populated in required format why not just use that in HEADER1? For example, if you have date populated in packed decimal format at nth position, you would just use HEADER1=(1:'HDR',N,5)). You can get count in TRAILER1 using 10:COUNT=(TO=PD,LENGTH=5)

So use something like below...(UNTESTED)
Code:
OUTFIL REMOVECC,HEADER1=(1:'HDR',4:N,5),     --> N is where you already have date populated in PD
TRAILER1=(1:'TRL',10:COUNT=(TO=PD,LENGTH=5)) --> Based on your original sort card,I am assuming you want count at 10th position

Thanks,
Back to top
View user's profile Send private message
rohanthengal

Active User


Joined: 19 Mar 2009
Posts: 206
Location: Globe, India

PostPosted: Mon Aug 22, 2011 11:02 pm
Reply with quote

thanks for letting me know about COUNT in trailer !

Also,, can you please let me know the technique in your mind to convert DATE also to PD of S9(9) comp-3 at 4th position in HEADER after 'HDR' ?
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Mon Aug 22, 2011 11:56 pm
Reply with quote

rohanthengal,
rohanthengal wrote:
thanks for letting me know about COUNT in trailer !

Also,, can you please let me know the technique in your mind to convert DATE also to PD of S9(9) comp-3 at 4th position in HEADER after 'HDR' ?
One method(which I already told you above) is to use already populated date from "detail" record and populate the same on HEADER record. Remember, if you already have Date populated in the input file in packed decimal format, you don't need INREC OVERLAY.

I am "guessing" that you don't have date populated in packed decimal format for "detail" records based on below comment...
Quote:
i think all the fields in the output file need to be mapped to s(9) comp-3

If that is the case,I would write something like below. If you need something specific please provide test records and expected output when you get to the mainframe.
Code:
//STEP0001 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD  *                                           
SQLCODE IS                                                 
TESTING                                                     
"DATE"                                                     
FOR HEADER                                                 
AND TRAILER                                                 
RECORDS                                                     
//SORTOUT  DD  SYSOUT=*                                     
//SYSIN    DD *                                             
 INREC OVERLAY=(15:DATE1P)                                 
 SORT FIELDS=COPY                                           
 OUTFIL REMOVECC,HEADER1=(C'HDR',15,5),                     
                 TRAILER1=(C'TRL',10:COUNT=(TO=PD,LENGTH=5))
/*                                                         


OUTPUT
Code:
000001 HDR   b               
       CCD00182444444444444444
       8492102C000000000000000
------------------------------
000002 SQLCODE IS       b     
       EDDCDCC4CE4444001824444
       283364509200002102C0000
------------------------------
000003 TESTING          b     
       ECEECDC4444444001824444
       352395700000002102C0000
------------------------------
000004 "DATE"           b     
       7CCEC744444444001824444
       F4135F000000002102C0000
------------------------------
000005 FOR HEADER       b     
       CDD4CCCCCD4444001824444
       669085145900002102C0000
------------------------------
000006 AND TRAILER      b     
       CDC4EDCCDCD444001824444
       154039193590002102C0000
------------------------------
000007 RECORDS          b     
       DCCDDCE4444444001824444
       953694200000002102C0000
------------------------------
000008 TRL          %         
       EDD44444400006444444444
       3930000000000C000000000
------------------------------


Thanks,
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: Tue Aug 23, 2011 1:13 am
Reply with quote

rohanthengal,

I'd suggest this is a better way to do what you want with DFSORT. It's sets up the PD date as a symbol and then uses it only in HEADER1.

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
RECORD
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
  OPTION COPY
  INREC IFOUTLEN=80,
   IFTHEN=(WHEN=INIT,BUILD=(DATE1P)),
   IFTHEN=(WHEN=INIT,BUILD=(C'PDATE,C''',1,5,C''''))
/*
//S2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SYMNOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN DD *
  OPTION COPY
  OUTFIL REMOVECC,HEADER1=(1:'HDR',4:PDATE),
  TRAILER1=(1:'TLR',10:COUNT=(TO=PD,LENGTH=5))
/*
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Aug 23, 2011 3:14 pm
Reply with quote

Hi Frank.. Just curiosity


Will below two have any performance difference...
Code:

//SYSIN DD *
  OPTION COPY
  INREC IFOUTLEN=80,
   IFTHEN=(WHEN=INIT,BUILD=(DATE1P)),
   IFTHEN=(WHEN=INIT,BUILD=(C'PDATE,C''',1,5,C''''))
/*

Code:

//SYSIN DD *                                               
  OPTION COPY                                               
  INREC IFOUTLEN=80,                                       
  IFTHEN=(WHEN=INIT,BUILD=(C'PDATE,C''',DATE1P,C''''))     
/*                                                         

Back to top
View user's profile Send private message
rohanthengal

Active User


Joined: 19 Mar 2009
Posts: 206
Location: Globe, India

PostPosted: Tue Aug 23, 2011 7:34 pm
Reply with quote

hi sqlcode1, i tested the things..
it is populating the date in yyyymmdd format as packed decimal in HEADER. Thanks a lot.

Also i am able to convert the count in trailer to PD.
but can you please clarify whether it will populate the date in deatil record as well ? also is it possible to convert the date in mmddyyyy format ?
i want the date only in HEADER.
Back to top
View user's profile Send private message
rohanthengal

Active User


Joined: 19 Mar 2009
Posts: 206
Location: Globe, India

PostPosted: Tue Aug 23, 2011 8:07 pm
Reply with quote

Frank, i got your point but my constraint is to use only one step.
So i used sqlcode1's SORT card but i am worried if it adds date at 15th position of each detailed record which i dont need. I want to populate in only HEADER.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Tue Aug 23, 2011 8:29 pm
Reply with quote

rohanthengal,
rohanthengal wrote:
Also i am able to convert the count in trailer to PD.
but can you please clarify whether it will populate the date in deatil record as well ?

Yes and you don't want to use the card, I provided for the same reason.
rohanthengal wrote:
also is it possible to convert the date in mmddyyyy format ?
i want the date only in HEADER.
you could have mentioned this yesterday!!!

Thanks,
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: Tue Aug 23, 2011 8:35 pm
Reply with quote

rohanthengal wrote:
[...]

my constraint is to use only one step.

[...]


Sorry, but that is absurd. One step is to generate a little itsy-bitsy piece of data to be on the SYMNAME in the next step, where your data is actually processed.

And you're not allowed to do it? Please, ask the placer of this constraint to provide you with an explanation as to why not, and then, if you like, pass that on to us.
Back to top
View user's profile Send private message
rohanthengal

Active User


Joined: 19 Mar 2009
Posts: 206
Location: Globe, India

PostPosted: Tue Aug 23, 2011 8:39 pm
Reply with quote

ok sqlcode1, sorry for the mistake..
my sort card has become something like this:
Code:
INREC OVERLAY = (15:DATE1P)
SORT FIELDS = COPY
HEADER1....
OUTREC.... used to map the input fields to the output fields.
TRAILER1..

As per my today's run, i could not see DATE populated in detailed records but in HEADER i could see DATE.

I think DATE populated in detailed records are overwritten by OUTREC statements specified between HEADER and TRAILER.

Am i on right track ?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Aug 23, 2011 9:03 pm
Reply with quote

Hello,

Quote:
i got your point but my constraint is to use only one step.
What business requirement does this support . . . icon_confused.gif

Why would it matter if a new process is run in one or two steps?
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Tue Aug 23, 2011 9:04 pm
Reply with quote

rohanthengal,
How do you expect anyone to make even an educated guess with such "constraint" and that too when you haven't really provided any test data.

INREC OVERLAY = (15:DATE1P). This statement overlays whatever data that is present on 15th position. So if you input is 14 byte LRECL, then you are fine otherwise you are accidently overlaying some fields.

If you are not selecting this date in the OUTFIL OUTREC, and if this looks correct to you, you may be right. I don't have access to your data or requirements, so I can't really say much.

However, this doesn't help you in getting date in correct format.

Thanks,
Back to top
View user's profile Send private message
rohanthengal

Active User


Joined: 19 Mar 2009
Posts: 206
Location: Globe, India

PostPosted: Tue Aug 23, 2011 10:31 pm
Reply with quote

thanks all for your inputs. Will surely try by negotiating with placer.

sample input
Code:
10001    JOHN BRIAN
10002    ASHLEY GILES
10008    STEFFY SHAW


sample output
Code:
HDR   08242011
10001    JOHN BRIAN
10002    ASHLEY GILES
10008    STEFFY SHAW
TLR    3


Now the only issue remains is DATE format which was populated in yyyymmdd format but shop needs mmddyyyy and that too in PD.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Aug 23, 2011 10:42 pm
Reply with quote

rohanthengal,

Assuming your input LRECL is 80 and recfm=fb, the following DFSORT JCL will give you the desired results. I assumed you want the count also in PD format in pos 4 for a length of 8 bytes.

Code:

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD *                                           
10001    JOHN BRIAN                                       
10002    ASHLEY GILES                                     
10008    STEFFY SHAW                                       
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                           
  SORT FIELDS=COPY                                         
  INREC OVERLAY=(81:DATENS=(MD4),81,8,ZD,PD,LENGTH=5)     
  OUTFIL REMOVECC,BUILD=(1,80),                           
  HEADER1=('HDR',7:89,5),                                 
  TRAILER1=('TLR',COUNT=(PD,LENGTH=8))                     
//*
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: Tue Aug 23, 2011 10:51 pm
Reply with quote

Quote:
Hi Frank.. Just curiosity


Will below two have any performance difference...
Code:

//SYSIN DD *
OPTION COPY
INREC IFOUTLEN=80,
IFTHEN=(WHEN=INIT,BUILD=(DATE1P)),
IFTHEN=(WHEN=INIT,BUILD=(C'PDATE,C''',1,5,C''''))
/*


Code:

//SYSIN DD *
OPTION COPY
INREC IFOUTLEN=80,
IFTHEN=(WHEN=INIT,BUILD=(C'PDATE,C''',DATE1P,C''''))
/*


Sambhaji,

The answer to any and all such questions is one or more of the following:

1) It depends.
2) Your mileage may vary.
3) Try it yourself with the "relevant data" and see for yourself.

3) is usually the best answer.
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: Tue Aug 23, 2011 10:53 pm
Reply with quote

rohanthengal,

If you had explained clearly in your first post exactly what you wanted, we could have answered this in one reply. Please try to state your requirements more clearly in the future!
Back to top
View user's profile Send private message
rohanthengal

Active User


Joined: 19 Mar 2009
Posts: 206
Location: Globe, India

PostPosted: Wed Aug 24, 2011 8:14 pm
Reply with quote

Thanks Frank, sqlcode1 ans Skolusu for your posts. It helped me a lot to write the datacard and get the results successfully. Hope it will run for future runs as well.

Thanks IBMMAINFRAMES, thanks a lot !

Also i regret for the troubles caused to you folks due to improper specification provided by me. I was also confused a lot due to changes in requirements stated at shop.

Sorry, now onwards will post the requirement only after it gets finalised.
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 Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:

Back to Top