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 

occurs clause Question

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


Joined: 26 Dec 2002
Posts: 23
Topics: 7

PostPosted: Thu Jan 02, 2003 3:56 pm    Post subject: occurs clause Question Reply with quote

Hi All,

I have occurs clause used with indexed in my input file ,The occurs having five fields ,but i need only one occurs of one filed in my ouput file but remaining fields should be same as in input file.

Thanks
Valla
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Jan 02, 2003 4:21 pm    Post subject: Reply with quote

Vallabhaneni,

Please be descriptive when asking a question. With the limited information you gave I assumed that you have a layout like this

Code:

01 W-INPUT-LAYOUT.
  05 W-INP1             PIC X(20).
  ....
 
  05 W-GROUP-KEY       OCCURS   5 TIMES     
                       INDEXED BY W-IDX1.
     10 W-IN-FIELD1        PIC X(10).
     10 W-IN-FIELD2        PIC X(05).
     10 W-IN-FIELD3        PIC X(20).
     10 W-IN-FIELD4        PIC S9(4) COMP.
     10 W-IN-FIELD5        PIC S9(5)V9(2) COMP-3


If you want only one occurance of w-field2 in the output file , then you can define it as follows.
Code:

01 W-OUTPUT-LAYOUT.
   05 W-OUT1                PIC X(20).
   ...
   05 W-OUT-FIELD2          PIC X(05).


In procedure division you can code

Code:


   MOVE W-IN-FIELD2(1)         TO     W-OUT-FIELD2



Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vallabhaneni
Beginner


Joined: 26 Dec 2002
Posts: 23
Topics: 7

PostPosted: Thu Jan 02, 2003 4:37 pm    Post subject: Reply with quote

Sure,Thank you very much Kolusu.

Vallabhaneni
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
vallabhaneni
Beginner


Joined: 26 Dec 2002
Posts: 23
Topics: 7

PostPosted: Thu Jan 02, 2003 4:50 pm    Post subject: Reply with quote

Hi Kolusu,

You declared W-GROUP-KEY.Thats is Correct but I need only first occurance of w-in-field2 and I need same occurs for rest of the fields in w-group-key file for output.

Thanks
Vallabhaneni
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Jan 02, 2003 6:23 pm    Post subject: Reply with quote

Vallabhaneni,


Code:

01 W-INPUT-LAYOUT.
  05 W-INP1                PIC X(20).
  ....
 
  05 W-IN-GROUP-KEY       OCCURS   5 TIMES     
                          INDEXED BY W-IDX1.
     10 W-IN-FIELD1        PIC X(10).
     10 W-IN-FIELD2        PIC X(05).
     10 W-IN-FIELD3        PIC X(20).
     10 W-IN-FIELD4        PIC S9(4) COMP.
     10 W-IN-FIELD5        PIC S9(5)V9(2) COMP-3




Code:

01 W-INPUT-LAYOUT.
  05 W-OUT                 PIC X(20).
  ....
 
  05 W-OUT-GROUP-KEY.
     10 W-OUT-FIELD1        PIC X(10).
     10 W-OUT-FIELD2        PIC X(05).
     10 W-OUT-FIELD3        PIC X(20).
     10 W-OUT-FIELD4        PIC S9(4) COMP.
     10 W-OUT-FIELD5        PIC S9(5)V9(2) COMP-3




In procedure division you can code

Code:

MOVE W-IN-GROUP-KEY(1)         TO     W-OUT-GROUP-KEY


Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
MY4114
Beginner


Joined: 18 Dec 2002
Posts: 8
Topics: 2

PostPosted: Fri Jan 10, 2003 3:05 pm    Post subject: Reply with quote

Hi,
I think what Vallabhaneni meant was to have all the fields, except for one, in the output as they appear in the input.
Let us take the same example that Mr. Kolusu has used. So only field 2 would occur once and rest of the 4 fields would occur 5 times. I am just giving a sample structure for the output. The actual structure depends on the order of the fields that you need for the output file.
Code:
01 W-INPUT-LAYOUT.                         
  05 W-INP1                PIC X(05).       
  05 W-IN-GROUP-KEY       OCCURS   5 TIMES.
     10 W-IN-FIELD1        PIC X(01).       
     10 W-IN-FIELD2        PIC X(01).       
     10 W-IN-FIELD3        PIC X(01).       
     10 W-IN-FIELD4        PIC X(01).       
     10 W-IN-FIELD5        PIC X(01).       
  05 W-INP2                PIC X(50).

Code:

01 W-OUTPUT-LAYOUT.                               
  05 W-OUT1                PIC X(05).             
  05 W-O-GROUP-KEY1      OCCURS   5 TIMES.       
     10 W-O-FIELD1        PIC X(01).             
  05 W-O-FIELD2        PIC X(01).                 
  05 W-O-GROUP-KEY2      OCCURS   5 TIMES.       
     10 W-O-FIELD3        PIC X(01).             
     10 W-O-FIELD4        PIC X(01).             
     10 W-O-FIELD5        PIC X(01).             
  05 W-OUT2                PIC X(50).             
  05 W-OUT3                PIC X(04) VALUE SPACES.

Code:

01  W-CNT                 PIC 9(01) VALUE ZERO.

Code:

MOVE W-INP1 TO W-OUT1                           
MOVE W-INP2 TO W-OUT2                           
MOVE W-IN-FIELD2 (1) TO W-O-FIELD2               
PERFORM VARYING W-CNT FROM 1 BY 1 UNTIL         
       W-CNT > 5                                 
   MOVE W-IN-FIELD1 (W-CNT) TO W-O-FIELD1 (W-CNT)
   MOVE W-IN-FIELD3 (W-CNT) TO W-O-FIELD3 (W-CNT)
   MOVE W-IN-FIELD4 (W-CNT) TO W-O-FIELD4 (W-CNT)
   MOVE W-IN-FIELD5 (W-CNT) TO W-O-FIELD5 (W-CNT)
END-PERFORM                                     


Let us say the input record is: XXXXX1111122222333334444455555XXXXX
Then output record would be : XXXXX123451111222333444555XXXXX

It is just a matter of defining your structure in the way you want with a combination of Occurs and non-Occurs field declarations.

Please correct me if I am wrong.

Regards,
Madhuri
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming 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