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

COBOL VS SORT Utility for file formatting


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Pradeepv

New User


Joined: 15 Nov 2020
Posts: 1
Location: India

PostPosted: Sun Nov 15, 2020 11:05 pm
Reply with quote

I have a requirement to re-format records if a PS file. I know that building a sort card is the easiest way. But, I do not want to create 500+ Sort cards for each file that I had to reformat. When I do not have to sort a file, but only re-format fields in a record where each record can have 3000+ fields, which one is effective? A COBOL PGM OR A SORT CARD?
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 932
Location: Maryland

PostPosted: Mon Nov 16, 2020 4:01 am
Reply with quote

Generally, the total amount of code to be created for SORT utility should be seriously less than verbose COBOL code.

1. Need to create the “record description” as SYMNAMES member for SORT. It is functionally equivalent to COBOL copybook for the same record. If copybooks already do exist, it’s not a big deal to create a REXX script converting them from COBOL format to SYMNAMES format.
Code:
* SYMNAMES COPYBOOK FOR XXXXXXX_RECORD
$RDWLEN,BI,*,2    record length if RECFM=VB
$RDWFLAG,BI,*,2     flag field if RECFM=VB
FIELDaaa,CH,*,30 from PIC X(30)
FIELDbbb,PD,*,5 from PIC S9(7)V99 COMP-3
FIELDccc,FI,*,2 from PIC S9(4) COMP-1
FIELDddd,ZD,*,9 from PIC S9(7)V99
. . . etc . . .


2. Need to use required conversion in any of BUILD parameters of SORT control statements
Code:
 INREC BUILD=($RDWLEN,$RDWFLAG,
          FIELDaaa,      no conversion
          FIELDbbb,CH,EDIT=(STTTTTTT.TT),SIGNS=(,-),   
          FIELDccc,CH,EDIT=(TTTTT), unpack binary
          FIELDddd,CH,EDIT=(STTTTTTT.TT),SIGNS=(,-),
 . . . . . etc . . . . .
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1100
Location: Dublin, Ireland

PostPosted: Mon Nov 16, 2020 1:54 pm
Reply with quote

Quote:
If copybooks already do exist, it’s not a big deal to create a REXX script converting them from COBOL format to SYMNAMES format.


See: ibmmainframes.com/about49973.html

Garry
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 932
Location: Maryland

PostPosted: Tue Nov 17, 2020 1:34 am
Reply with quote

While not using any tool daily a lot of syntax tricks are missing from my mind.

The correct syntax must be
1.
Code:
* SYMNAMES COPYBOOK FOR XXXXXXX_RECORD
$RDWLEN,*,2,BI   record length if RECFM=VB
$RDWFLAG,*,2,BI    flag field if RECFM=VB
FIELDaaa,*,30,CH   from PIC X(30)
FIELDbbb,*,5,PD   from PIC S9(7)V99 COMP-3
FIELDccc,*,2,FI     from PIC S9(4) COMP-1
FIELDddd,*,9,ZD    from PIC S9(7)V99
. . . etc . . .


2.
Code:
 INREC BUILD=($RDWLEN,$RDWFLAG,
          FIELDaaa,      no conversion
          FIELDbbb,PD,EDIT=(STTTTTTT.TT),SIGNS=(,-),     
          FIELDccc,FI,EDIT=(TTTTT), unpack binary
          FIELDddd,ZD,EDIT=(STTTTTTT.TT),SIGNS=(,-),
 . . . . . etc . . . . .


Sorry for mistakes
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2572
Location: NYC,USA

PostPosted: Tue Nov 17, 2020 6:41 pm
Reply with quote

Pradeepv wrote:
I have a requirement to re-format records if a PS file. I know that building a sort card is the easiest way. But, I do not want to create 500+ Sort cards for each file that I had to reformat. When I do not have to sort a file, but only re-format fields in a record where each record can have 3000+ fields, which one is effective? A COBOL PGM OR A SORT CARD?

How do you intend to write one program fits all 500+ formats ? It’s a less efforts if you do by SORT., use option copy if you don’t want to sort, that’s okay.
Back to top
View user's profile Send private message
prino
Warnings : 1

Senior Member


Joined: 07 Feb 2009
Posts: 1241
Location: Vilnius, Lithuania

PostPosted: Tue Nov 17, 2020 7:03 pm
Reply with quote

Two COBOL copybooks, one MOVE CORRESPONDING. How short do you want it?
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1015
Location: Richmond, Virginia

PostPosted: Wed Nov 18, 2020 3:42 am
Reply with quote

MOVE CORRESPONDING does not handle OCCURS's.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Very Large Sort failed - Seeking reco... DFSORT/ICETOOL 7
No new posts Date conversion using SORT SYNCSORT 4
No new posts Converting a file from PD to display ... SYNCSORT 4
No new posts Record count of RECFM=U tape file DFSORT/ICETOOL 17
No new posts Which SORT utility can improve the Pe... DFSORT/ICETOOL 16
Search our Forums:

Back to Top