View previous topic :: View next topic
|
Author |
Message |
sakthisiga Warnings : 1 New User
Joined: 11 Jun 2009 Posts: 60 Location: Chennai
|
|
|
|
Hi all,
I have a variable as:
Code: |
01 w01-var.
05 itm1 pic x(2).
05 itm2 pic x(2).
05 itm3 pic x(2).
|
....
...
when i try to write;
Code: |
WRITE PM-RECORD FROM W01-VAR.
It will write all sub items into the file.
|
My question is, i want customize write that, i want to write itm1 and itm3 instead of writing all.
Can anyone help to write the particular values to file? |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
1. Do you understand what does 01 level mean in a file-description?
2. Please show if you get the values of all the "inputs", what do you expect in the output?
The way you have posed your question, muliple 01 levels can be your choice or define other variable as
Code: |
01 w01-var-w.
05 itm1 pic x(2)
05 itm3 pic x(2). |
and WRITE FROM this new variable. |
|
Back to top |
|
|
sakthisiga Warnings : 1 New User
Joined: 11 Jun 2009 Posts: 60 Location: Chennai
|
|
|
|
my actual variable declaration is
Code: |
01 W02-RECORD-VALUE.
05 W02-OUT-POLN PIC X(10).
05 FILLER PIC X(02) VALUE SPACES.
05 W02-OUT-DATE.
10 W02-DD PIC 9(2).
10 FILLER PIC X(01) VALUE '-'.
10 W02-MM PIC 9(2).
10 FILLER PIC X(01) VALUE '-'.
10 W02-YY PIC 9(4).
05 FILLER PIC X(02) VALUE SPACES.
05 W02-PL-SUM PIC 9(07).
05 FILLER PIC X(02) VALUE SPACES.
05 W02-PL-PREMIUM PIC 9(07).
05 FILLER PIC X(02) VALUE SPACES.
05 W02-PL-AMTREFUND PIC 9(07).
05 FILLER PIC X(02) VALUE SPACES.
05 W02-PL-AMT PIC 9(07).
05 FILLER PIC X(22) VALUE SPACES.
|
My write code is
Code: |
WRITE PM-REC FROM W02-RECORD-VALUE
|
here,
PM-REC will write all 05 level variable to file, but i don't want to write all, but by using the W02-RECORD-VALUE i want the customize write.
I want to write
05 W02-OUT-POLN PIC X(10).
05 FILLER PIC X(02) VALUE SPACES.
05 W02-OUT-DATE.
10 W02-DD PIC 9(2).
10 FILLER PIC X(01) VALUE '-'.
10 W02-MM PIC 9(2).
10 FILLER PIC X(01) VALUE '-'.
10 W02-YY PIC 9(4).
05 FILLER PIC X(02) VALUE SPACES.
05 W02-PL-PREMIUM PIC 9(07).
05 FILLER PIC X(02) VALUE SPACES.
05 W02-PL-AMT PIC 9(07).
05 FILLER PIC X(22) VALUE SPACES.
Can you please tell how to do that.. |
|
Back to top |
|
|
sakthisiga Warnings : 1 New User
Joined: 11 Jun 2009 Posts: 60 Location: Chennai
|
|
|
|
my actual variable declaration is
Code: |
01 W02-RECORD-VALUE.
05 W02-OUT-POLN PIC X(10).
05 FILLER PIC X(02) VALUE SPACES.
05 W02-OUT-DATE.
10 W02-DD PIC 9(2).
10 FILLER PIC X(01) VALUE '-'.
10 W02-MM PIC 9(2).
10 FILLER PIC X(01) VALUE '-'.
10 W02-YY PIC 9(4).
05 FILLER PIC X(02) VALUE SPACES.
05 W02-PL-SUM PIC 9(07).
05 FILLER PIC X(02) VALUE SPACES.
05 W02-PL-PREMIUM PIC 9(07).
05 FILLER PIC X(02) VALUE SPACES.
05 W02-PL-AMTREFUND PIC 9(07).
05 FILLER PIC X(02) VALUE SPACES.
05 W02-PL-AMT PIC 9(07).
05 FILLER PIC X(22) VALUE SPACES.
|
My write code is
Code: |
WRITE PM-REC FROM W02-RECORD-VALUE
|
here,
PM-REC will write all 05 level variable to file, but i don't want to write all, but by using the W02-RECORD-VALUE i want the customize write.
I want to write
Code: |
05 W02-OUT-POLN PIC X(10).
05 FILLER PIC X(02) VALUE SPACES.
05 W02-OUT-DATE.
10 W02-DD PIC 9(2).
10 FILLER PIC X(01) VALUE '-'.
10 W02-MM PIC 9(2).
10 FILLER PIC X(01) VALUE '-'.
10 W02-YY PIC 9(4).
05 FILLER PIC X(02) VALUE SPACES.
05 W02-PL-PREMIUM PIC 9(07).
05 FILLER PIC X(02) VALUE SPACES.
05 W02-PL-AMT PIC 9(07).
05 FILLER PIC X(22) VALUE SPACES.
|
Can you please tell how to do that.. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
You must define a group level variable somewhere in your program that contains just the fields you want to write, or you can use reference modification to move the fields you want to the FD 01 then write it. |
|
Back to top |
|
|
bipinpeter
Active User
Joined: 18 Jun 2007 Posts: 213 Location: Cochin/Kerala/India
|
|
|
|
I think u can use RENAMES usage in cobol here. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
How is RENAMES (which allows existing variables to be renamed) going to get rid of fields in the middle of the group level -- which is what the requirement is? RENAMES won't remove variables -- just change their name. |
|
Back to top |
|
|
jctgf Currently Banned Active User
Joined: 04 Nov 2006 Posts: 109
|
|
|
|
Code: |
01 W02-RECORD-VALUE.
05 W02-OUT-POLN PIC X(10).
05 FILLER PIC X(02) VALUE SPACES.
05 W02-OUT-DATE.
10 W02-DD PIC 9(2).
10 FILLER PIC X(01) VALUE '-'.
10 W02-MM PIC 9(2).
10 FILLER PIC X(01) VALUE '-'.
10 W02-YY PIC 9(4).
05 FILLER PIC X(02) VALUE SPACES.
04 W02-VARIABLES.
05 W02-PL-SUM PIC 9(07).
05 FILLER PIC X(02) VALUE SPACES.
05 W02-PL-PREMIUM PIC 9(07).
05 FILLER PIC X(02) VALUE SPACES.
05 W02-PL-AMTREFUND PIC 9(07).
05 FILLER PIC X(02) VALUE SPACES.
05 W02-PL-AMT PIC 9(07).
05 FILLER PIC X(22) VALUE SPACES.
04 WX2-VARIABLES REDEFINES W02-VARIABLES.
05 WX2-PL-PREMIUM PIC 9(07).
05 FILLER PIC X(02).
05 WX2-PL-AMT PIC 9(07).
05 FILLER PIC X(__).
|
pls note the level 04 created for the WX2 variables.
move spaces to wx2-variables. then, just move pl-premium and pl-amt to WX2-PL-PREMIUM and WX2-PL-AMT (instead of W02). write the record the same way you are already doing. |
|
Back to top |
|
|
|