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

Customize Write


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

New User


Joined: 11 Jun 2009
Posts: 60
Location: Chennai

PostPosted: Mon Oct 05, 2009 3:21 pm
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Mon Oct 05, 2009 3:49 pm
Reply with quote

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
View user's profile Send private message
sakthisiga
Warnings : 1

New User


Joined: 11 Jun 2009
Posts: 60
Location: Chennai

PostPosted: Mon Oct 05, 2009 3:55 pm
Reply with quote

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
View user's profile Send private message
sakthisiga
Warnings : 1

New User


Joined: 11 Jun 2009
Posts: 60
Location: Chennai

PostPosted: Mon Oct 05, 2009 3:56 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Mon Oct 05, 2009 4:12 pm
Reply with quote

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
View user's profile Send private message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 213
Location: Cochin/Kerala/India

PostPosted: Mon Oct 05, 2009 4:43 pm
Reply with quote

I think u can use RENAMES usage in cobol here.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Mon Oct 05, 2009 4:49 pm
Reply with quote

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
View user's profile Send private message
jctgf
Currently Banned

Active User


Joined: 04 Nov 2006
Posts: 109

PostPosted: Mon Oct 05, 2009 8:31 pm
Reply with quote

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
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 Write line by line from two files DFSORT/ICETOOL 7
This topic is locked: you cannot edit posts or make replies. How To Write, Compile and Execute Cob... COBOL Programming 5
No new posts Compare two files with a key and writ... SYNCSORT 3
No new posts JCL to write the log on to a PDS file JCL & VSAM 10
No new posts COBOL - create and write to output fi... COBOL Programming 0
Search our Forums:

Back to Top