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

COBOL OCCURS and SORT statements.


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
DB2 Guy

New User


Joined: 28 Oct 2008
Posts: 98
Location: Cubicle

PostPosted: Mon May 09, 2011 7:54 pm
Reply with quote

Hi,

Was looking at this thread and tryingto understand the logic from of control statements Frank has used in his post:
1. This
Code:
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,
This just copy the input to output and when the initail condition arises in INREC.
2.
Code:
 PARSE=(%01=(ABSPOS=5,
    STARTAFT=C'SALE',STARTAFT=C'MGMT',FIXLEN=6),
Create " file-1, %1"- in which the the value should be picked up from 5th position of input (ABSloute POSition=5). However, what if we don't give the ABSPOS, as we are anyways using "STARTAFT=C'SALE',STARTAFT=C'MGMT',FIXLEN=6)". I tried removing that and get a user abend.

3. Other %n files are just similar.

4. So, we've created 9 intermediate files, in such a way that we get all the amoutn fields at some-fixed-postions; so that we can add them up later,right?

5. With these:
Code:
  BUILD=(1,3,%01,X'FF',%02,X'FF',%03,X'FF',%04,X'FF', %05,X'FF',%06,X'FF',%07,X'FF',%08,X'FF',%09,X'FF')),
We create a file in which we rearrange the intermediate files.
6. I did not get this -- why do we need this.
Code:
IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=4,
    IN=X'404040404040FF',OUT=X'00000000000C00')),
I tried by removing it and did not get any change in the intermediate out put

7. I've used the example in the thread I was reffeerign as input - but with these I get a S0C7
Code:
  IFTHEN=(WHEN=INIT,
    BUILD=(1,3,4,6,PD,ADD,11,6,PD,ADD,18,6,PD,ADD,25,6,PD,ADD,
     32,6,PD,ADD,39,6,PD,ADD,46,6,PD,ADD,53,6,PD,ADD,60,6,PD,
     TO=PD,LENGTH=6))
/*


Can someone please help a bit more to understand this.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Mon May 09, 2011 9:12 pm
Reply with quote

Read about parsing here

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

New User


Joined: 28 Oct 2008
Posts: 98
Location: Cubicle

PostPosted: Tue May 10, 2011 2:33 pm
Reply with quote

Hi sqlcode1,

Thanks for your time and pointing to the manuals.

Actually, I did look at the manual before posting here and understand the parsing.

I'm looking forward to help from point 6 onwards.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue May 10, 2011 2:59 pm
Reply with quote

item 5:
lays x'ff's in 'strategic positions.

item 6:
the FINDREP creates a packed decimal area of zeroe where the x'40' followed by x'FF' was (from item 5).

item 7:
the packed-decimal add is to the columns that items 5 & 6 prepared as zeroe value PD areas.

if you left out 5 & 6, it is understandable the item 7 would S0C7.
you are adding to an unsigned area filled with X'40's
Back to top
View user's profile Send private message
DB2 Guy

New User


Joined: 28 Oct 2008
Posts: 98
Location: Cubicle

PostPosted: Tue May 10, 2011 4:12 pm
Reply with quote

Thanks Dick.

Quote:
if you left out 5 & 6, it is understandable the item 7 would S0C7.
you are adding to an unsigned area filled with X'40's
Yes, thsi is what I've also anticipated and tried removing the said steps. but, on ther other hand, the original example, using the Job as is, results in S0C7 -- and I'm not able to figure out the what position is not having numeric data.

I'll generate an intermediate file now (using BUILD=(1,3,%01,X'FF',%02,X'FF',%...) and execute verify command on that to see where is non-numeric value...
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 2
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts JCL sort card - get first day and las... JCL & VSAM 9
Search our Forums:

Back to Top