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

comparing fields with occurs clause


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

New User


Joined: 25 Jun 2006
Posts: 10
Location: Bangalore

PostPosted: Wed Aug 30, 2006 6:25 pm
Reply with quote

Hi,
Can anybody help me out of this???
The below declarations are from the copy book CLM_DATA.
The same copy book is used for both input and output files so I used

HS-SVC-CD OF CLM_DATA as i need to filter the records from the input.





10 HIDDEN-RMC PIC X(2).
10 RPT-LN-ITEM-CNT PIC S9(3) COMP-3.
05 LINE-DATA-OCCURS OCCURS 1 TO 65 TIMES
DEPENDING ON RPT-LN-ITEM-CNT
INDEXED BY LN-INDX.

10 HS-SVC-CD PIC X(3).

10 RPT-HML-PRCG-SVC-CD PIC X(03).



HOW CAN I CHECK THE CONDITIONS THAT ARE BELOW.



IF ((HS-SVC-CD OF CLM_DATA = 'PHO' OR 'PRV') AND
(HS-PROC-SVC-CLS-CD OF CLM-DATA = '01C'
OR '07B' OR '07C'
OR '07D' OR '01I' OR '07F' OR '07I' OR '07K'
OR '07L' OR '07M' OR '07T'))
WS-WRITE = 'T'
END-IF

can anybody specify the code for this?

Thanq Very Much in advance.


Mercy.
Back to top
View user's profile Send private message
vicky10001
Warnings : 1

Active User


Joined: 13 Jul 2005
Posts: 136

PostPosted: Wed Aug 30, 2006 7:00 pm
Reply with quote

Please explain cleary your requirement
Back to top
View user's profile Send private message
cobolunni

Active User


Joined: 07 Aug 2006
Posts: 127
Location: kerala,india

PostPosted: Wed Aug 30, 2006 10:41 pm
Reply with quote

you can use COPY as

COPY TEXTNAME IN LIBNAME

This will replace the copy with content of text file and all in text file will be inseted in to the source code all rules for programming are applicable to content of text file
Back to top
View user's profile Send private message
mercy
Warnings : 1

New User


Joined: 25 Jun 2006
Posts: 10
Location: Bangalore

PostPosted: Thu Aug 31, 2006 9:33 am
Reply with quote

10 HIDDEN-RMC PIC X(2).
10 RPT-LN-ITEM-CNT PIC S9(3) COMP-3.
05 LINE-DATA-OCCURS OCCURS 1 TO 65 TIMES
DEPENDING ON RPT-LN-ITEM-CNT
INDEXED BY LN-INDX.

10 HS-SVC-CD PIC X(3).
10 RPT-HML-PRCG-SVC-CD PIC X(03).



HOW CAN I CHECK THE CONDITIONS THAT ARE BELOW.

IF ((HS-SVC-CD OF CLM_DATA = 'PHO' OR 'PRV') AND
(HS-PROC-SVC-CLS-CD OF CLM-DATA = '01C'
OR '07B' OR '07C'
OR '07D' OR '01I' OR '07F' OR '07I' OR '07K'
OR '07L' OR '07M' OR '07T'))
WS-WRITE = 'T'
END-IF



In the above if stmt HS-SVC-CD is a field which is present inside OCCURS clause.So for every value of HS-SVC-CD I need to check the condition.Similarly for every value of HS-PROC-SVC-CLS-CD.So how can i do this.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Aug 31, 2006 2:21 pm
Reply with quote

From the example, I see that there is no level 01 in the COPY itself.
You can declare:
Code:
01  CLM-DATA-INP.
    COPY CLM_DATA.
01  CLM-DATA-OUT.
    COPY CML_DATA.
Then you can use HS-SVC-CD OF CLM-DATA-INP and HS-SVC-CD OF CLM-DATA-OUT

On the other hand, if you had a level 01 inside the COPY, you could declare:
Code:
    COPY CLM_DATA REPLACING ==Level01Name== BY ==NewName1==.
    COPY CLM_DATA REPLACING ==Level01Name== BY ==NewName2==.
Then you could use HS-SVC-CD OF NewName1 and HS-SVC-CD OF NewName2
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Aug 31, 2006 2:29 pm
Reply with quote

Quote:
10 HIDDEN-RMC PIC X(2).
10 RPT-LN-ITEM-CNT PIC S9(3) COMP-3.
05 LINE-DATA-OCCURS OCCURS 1 TO 65 TIMES
DEPENDING ON RPT-LN-ITEM-CNT
INDEXED BY LN-INDX.

10 HS-SVC-CD PIC X(3).
10 RPT-HML-PRCG-SVC-CD PIC X(03).


By the way, mixing levels as you do in the CLM_DATA is not healthy.
It works (I think it works) only by chance. I strongly recommend modifying the copy like this:
Code:
05 HIDDEN-RMC PIC X(2).
05 RPT-LN-ITEM-CNT PIC S9(3) COMP-3.
05 LINE-DATA-OCCURS OCCURS 1 TO 65 TIMES
     DEPENDING ON RPT-LN-ITEM-CNT
     INDEXED BY LN-INDX.
    10 HS-SVC-CD PIC X(3).
    10 RPT-HML-PRCG-SVC-CD PIC X(03).

or like that:
Code:
10 HIDDEN-RMC PIC X(2).
10 RPT-LN-ITEM-CNT PIC S9(3) COMP-3.
10 LINE-DATA-OCCURS OCCURS 1 TO 65 TIMES
     DEPENDING ON RPT-LN-ITEM-CNT
     INDEXED BY LN-INDX.
    12 HS-SVC-CD PIC X(3).
    12 RPT-HML-PRCG-SVC-CD PIC X(03).
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Fri Sep 01, 2006 4:15 am
Reply with quote

Mercy,

Your ques is incomplete. You must tell us the 01 levels that the copybook appears in or is the 01 level in the copybook?

The ans you want depends on us knowing this fact. Show us as much as you can if you want us to be of any help.
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 To search DB2 table based on Conditio... DB2 1
No new posts Comparing Header and Trailer. DFSORT/ICETOOL 7
No new posts Updating a 1 byte thats in occurs mul... DFSORT/ICETOOL 6
No new posts Concatenate 2 fields (usage national)... COBOL Programming 2
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
Search our Forums:

Back to Top