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 

Convert from PD to Character using sort

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


Joined: 05 Jun 2004
Posts: 46
Topics: 18

PostPosted: Tue Apr 04, 2006 1:33 am    Post subject: Convert from PD to Character using sort Reply with quote

Hi,
I have file having following structure -
Code:

Name   start   length  datatype
------   ------   -------   ---------
field1    1          4        9(6)
field2    7          5        S9(7)v9(2) Comp-3


I want a output file having following structure (using SORT)-
Code:

Name   start   length  datatype
------   ------   -------   ---------
field1     1         4        9(6)
field2     7        10       X(10)


e.g. Field2 in input file has value -1234567.56 in PD format, the field2 in o/p file should show the value as '-1234567.56'.

I tried the EDIT option in OUTREC, but ended up in SOC7 abend. Also, didn't get much help after searching the forum too.
Can anybody help with this? Thanks.
_________________
Regards,
Mangsk
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
pzmohanty
Beginner


Joined: 20 May 2004
Posts: 97
Topics: 43
Location: hyderabad, India

PostPosted: Tue Apr 04, 2006 2:35 am    Post subject: Reply with quote

Hi mangsk,

Here is the SORT step which will solve your problem :

Code:

//STEP1    EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//******************************************************************
//* INPUT FILE COPY-BOOK                                             
//*    01  TEST-RECORD.                                             
//*        05  FIELD1                  PIC 9(06).                   
//*        05  FIELD2                  PIC S9(7)V9(2) COMP-3.       
//******************************************************************
//SORTIN   DD DSN=VENV31.PRIYA.TST.SRT,DISP=SHR                     
//SORTOUT  DD DSN=VENV31.PRIYA.TST.SRT.OUT,DISP=(NEW,CATLG,DELETE), 
//            LIKE=VENV31.PRIYA.TST.SRT,LRECL=17                     
//SYSIN    DD *                                                     
   SORT FIELDS=COPY                                                 
   OUTREC FIELDS=(1,6,7,5,PD,EDIT=(SIIIIIIT.TT),SIGNS=(-),LENGTH=11)



One more thing , you said :
Code:
Name   start   length  datatype
------   ------   -------   ---------
field1    1          4        9(6)

How come your definition of field1 is 9(6) but length is 4.

Cheers
_________________
Priya Ranjan Mohanty
Consultant
Kanbay Software (I) pvt. Ltd.
Hyderabad
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
pzmohanty
Beginner


Joined: 20 May 2004
Posts: 97
Topics: 43
Location: hyderabad, India

PostPosted: Tue Apr 04, 2006 2:41 am    Post subject: Reply with quote

Hi mangsk,

One more thing your Output File structure has to be
Code:
Name   start   length  datatype
------   ------   -------   ---------
field1     1         6        9(6)
field2     7        11       X(11)


The Field2 of output file has to be X(11) as it will contain :
1 byte sign
7 byte number before decimal point
1 byte decimal point
2 byte number after decimal point
======================
11 byte character
_________________
Priya Ranjan Mohanty
Consultant
Kanbay Software (I) pvt. Ltd.
Hyderabad
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
mangsk
Beginner


Joined: 05 Jun 2004
Posts: 46
Topics: 18

PostPosted: Tue Apr 04, 2006 2:46 am    Post subject: Reply with quote

Hi pzmohanty,

Thanks for your respnse.
The output and input file structure should be as you've pointed out.
But as I already said -
Quote:

I tried the EDIT option in OUTREC, but ended up in SOC7 abend.


Don't we have any other method to achieve this?

Thanks!
_________________
Regards,
Mangsk
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
pzmohanty
Beginner


Joined: 20 May 2004
Posts: 97
Topics: 43
Location: hyderabad, India

PostPosted: Tue Apr 04, 2006 3:13 am    Post subject: Reply with quote

Hi mangsk,

Did you tried the above SORT ....

I had tested it , its working fine.

Check , what you had given for the datatype of Field2 in OUTREC , if you had given ZD , then you will end up with S0C 7 , it should be PD.
_________________
Priya Ranjan Mohanty
Consultant
Kanbay Software (I) pvt. Ltd.
Hyderabad
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
mangsk
Beginner


Joined: 05 Jun 2004
Posts: 46
Topics: 18

PostPosted: Tue Apr 04, 2006 4:43 am    Post subject: Reply with quote

Thanks pzmohanty for your replies.
I apologize for the mistake. Here is my input file fields structure. Please note that the field2 datatype is COMP and not COMP-3 -

Code:

Name   start   length  datatype
------   ------   -------   ---------
field1    1          6        9(6)
field2    7          4        S9(9) Comp


and this is how I want in the output file -

Code:

Name   start   length  datatype
------   ------   -------   ---------
field1     1         6        9(6)
field2     7        10       X(10)


Length of field2 here doesn't make much difference, any convinient length would do.

Now this is what I tried and got S0C7 abend -

Quote:

SORT FIELDS=COPY
OUTREC FIELDS=(1,6,7,4,PD,EDIT=(SIIIIIIIT),SIGNS=(-),LENGTH=10)


Can anybody help me out in this?
_________________
Regards,
Mangsk
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


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

PostPosted: Tue Apr 04, 2006 4:56 am    Post subject: Reply with quote

Mangsk,

PD Stands for Packed Decimal - which is equivalent of cobol COMP-3 variable. A field in cobol with a declaration of COMP refers to a Binary variable. So, you should actually use BI instead of PD. Change your sort card as shown below.

Code:

  SORT FIELDS=COPY
  OUTREC FIELDS=(1,6,
                 7,4,BI,EDIT=(SIIIIIIIIT),SIGNS=(,-,,))


for information on equivalent Sort formats for various COBOL data types, see the "What are the equivalent DFSORT formats for various COBOL data types?" Ask Professor Sort item at:

http://www.ibm.com/servers/storage/support/software/sort/mvs/professor_sort/


Hope this helps,

Cheers,
Phantom
Back to top
View user's profile Send private message
mangsk
Beginner


Joined: 05 Jun 2004
Posts: 46
Topics: 18

PostPosted: Tue Apr 04, 2006 5:14 am    Post subject: Reply with quote

Hi,

The problem is solved now. Thanks for everybody's inputs. See the changed control card below.
Code:

  SORT FIELDS=COPY
  OUTREC FIELDS=(1,6,7,4,FI,EDIT=(SIIIIIIIT),SIGNS=(' ','-'),LENGTH=10)


Note the changes from PD to FI and the SIGNS parameter.

Thanks!
_________________
Regards,
Mangsk
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Apr 04, 2006 10:30 am    Post subject: Reply with quote

Mangsk,

Just a few minor comments on your control statements.

The minimum value for a 4-byte FI field is -2147483648 and the maximum value is 2147483647. In each case, that's 10 digits, so your EDIT pattern of SIIIIIIIT with only 8 digits is not the best choice as digits and the sign may be lost. I'd suggest the following instead:

Code:

  OUTREC FIELDS=(1,6,7,4,FI,EDIT=(SIIIIIIIIIT),SIGNS=(,-))


Note that you could use DFSORT's M25 edit mask to do the same thing:

Code:

  OUTREC FIELDS=(1,6,7,4,FI,M25,LENGTH=11)

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mangsk
Beginner


Joined: 05 Jun 2004
Posts: 46
Topics: 18

PostPosted: Thu Apr 06, 2006 2:11 am    Post subject: Reply with quote

Thanks Frank. I'll take care of it.
_________________
Regards,
Mangsk
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
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