Write work file 1 variable
I just need to know what is the exact use of variable in above statement. Can anyone please explain me with a example ?
variable in write work file statement?
-
- Posts: 90
- Joined: Sun Mar 14, 2010 5:12 pm
- Skillset: Natural,Adabas,jcl
- Referer: friend
Re: variable in write work file statement?
Hi Dipti,
We can write records with different fields to the same work file and need to use different WRITE WORK FILE statements. However, in this case, the VARIABLE clause must be specified in all WRITE WORK FILE statements. The records on the external file (assigned within JCL) will be written in variable format. Natural will write all output files as variable-blocked (unless you specify a record format and block size in the execution JCL).
Assuming you know the simple WRITE WORK FILE structure, below is an example with VARIABLE clause:
Thanks,
Ats
We can write records with different fields to the same work file and need to use different WRITE WORK FILE statements. However, in this case, the VARIABLE clause must be specified in all WRITE WORK FILE statements. The records on the external file (assigned within JCL) will be written in variable format. Natural will write all output files as variable-blocked (unless you specify a record format and block size in the execution JCL).
Assuming you know the simple WRITE WORK FILE structure, below is an example with VARIABLE clause:
Code: Select all
WRITE WORK FILE 1 VARIABLE #FIRST-NAME #LAST-NAME
........ (statements to be followed)
........
WRITE WORK FILE 1 VARIBALE #FIRST-NAME #LAST-NAME #ADDRESS-LINE-1 #PHONE-NUMBER
Thanks,
Ats
- RGZbrog
- Posts: 101
- Joined: Mon Nov 23, 2009 1:34 pm
- Skillset: Natural, Adabas, Predict, Natural Security, Construct, EntireX, SPoD, NaturalONE
- Referer: SAG Developer Forum
- Location: California, USA
- Contact:
Re: variable in write work file statement?
A minor adjustment to what Ats said:
It's not the different field lists that force the use of the VARIABLE clause, it's the difference in logical record lengths. You don't need to code VARIABLE if all the record lengths are the same.
Here's an example where both records are 15 bytes long.
It's not the different field lists that force the use of the VARIABLE clause, it's the difference in logical record lengths. You don't need to code VARIABLE if all the record lengths are the same.
Here's an example where both records are 15 bytes long.
Code: Select all
DEFINE DATA LOCAL
1 #A (A5)
1 #B (P11.2)
1 #C (N3)
1 #1 (L)
1 #2 (C)
1 #3 (D)
1 #4 (A8)
END-DEFINE
WRITE WORK 1 #A #B #C
WRITE WORK 1 #1 #2 #3 #4
END
-
- Posts: 90
- Joined: Sun Mar 14, 2010 5:12 pm
- Skillset: Natural,Adabas,jcl
- Referer: friend
Re: variable in write work file statement?
Hi,
Thanks for the clarification.
1 #2 (C)
I need to know in above statement what (c) repesent . As (c) is used as control variable in online maps so why we are using this in case of batch ?
Thanks for the clarification.
1 #2 (C)
I need to know in above statement what (c) repesent . As (c) is used as control variable in online maps so why we are using this in case of batch ?
- RGZbrog
- Posts: 101
- Joined: Mon Nov 23, 2009 1:34 pm
- Skillset: Natural, Adabas, Predict, Natural Security, Construct, EntireX, SPoD, NaturalONE
- Referer: SAG Developer Forum
- Location: California, USA
- Contact:
Re: variable in write work file statement?
Just a quick way of defining fields of various lengths for my example. (A control variable is 2 bytes in length.) I can't think of a good reason to write a CV to a work file, but there is no reason that you can't do it.
Re: variable in write work file statement?
To add to Ralph's note on CV, a variable defined with format C may be used to assign attributes dynamically to a field used in a DISPLAY, INPUT, PRINT, PROCESS PAGE or WRITE statement and attributes assigned will take effect in online mode. If they used in BATCH, it will STOW successfully but simply won't be effective (with their assignment).
Thanks,
Ats
Thanks,
Ats
- RGZbrog
- Posts: 101
- Joined: Mon Nov 23, 2009 1:34 pm
- Skillset: Natural, Adabas, Predict, Natural Security, Construct, EntireX, SPoD, NaturalONE
- Referer: SAG Developer Forum
- Location: California, USA
- Contact:
Re: variable in write work file statement?
Ats,
I hope that you're not saying that control variables are of no use in batch.
This thread is going a bit off-topic, so I'll submit my comments in a new one (Control Variables in batch):
posting.php?mode=post&f=11&sid=835d3fd32bc813723f1ba958285e139c#preview
I hope that you're not saying that control variables are of no use in batch.
This thread is going a bit off-topic, so I'll submit my comments in a new one (Control Variables in batch):
posting.php?mode=post&f=11&sid=835d3fd32bc813723f1ba958285e139c#preview
Re: variable in write work file statement?
Hi Ralph,
I saw your other example of CV in batch, in another post. As you hoped, I wasn't mean it's of no use in Batch. However, was limited to attributes such as AD, CD that won't be effective in batch mode (or they would be
, I really didn't come accross). Hope that clears the confusion
Regards,
Ats
I saw your other example of CV in batch, in another post. As you hoped, I wasn't mean it's of no use in Batch. However, was limited to attributes such as AD, CD that won't be effective in batch mode (or they would be


Regards,
Ats
-
- Posts: 7
- Joined: Thu Dec 16, 2010 1:01 am
- Skillset: Jcl; Natural; PL/I; Cobol
- Referer: website
- Location: Brazil
Re: variable in write work file statement?
Hi diptisaini,
When do you use WRITE WORK FILE statements, It is possible to write records with different fields to the same work file with different WRITE WORK FILE statements. In this case, the records on the external file will be written in variable format.
When the operand list includes a dynamic variable (that could change in size for different executions of the WRITE WORK FILE statement), the VARIABLE entry must be specified in all WRITE WORK FILE statements.
When do you use WRITE WORK FILE statements, It is possible to write records with different fields to the same work file with different WRITE WORK FILE statements. In this case, the records on the external file will be written in variable format.
When the operand list includes a dynamic variable (that could change in size for different executions of the WRITE WORK FILE statement), the VARIABLE entry must be specified in all WRITE WORK FILE statements.
-
- Similar Topics
- Replies
- Views
- Last post
-
- 3
- 6740
-
by sergeyken
View the latest post
Sun May 01, 2022 11:26 pm
-
-
regarding COBOL WRITE verb (VB File Handling)
by anonguy456 » Mon Jun 28, 2021 5:57 pm » in IBM Cobol - 6
- 3845
-
by Robert Sample
View the latest post
Tue Jun 29, 2021 11:33 pm
-
-
- 14
- 8184
-
by indianrajput
View the latest post
Wed Nov 24, 2021 11:33 pm
-
- 1
- 2164
-
by sandy427
View the latest post
Thu Oct 10, 2024 1:03 pm
-
- 0
- 1728
-
by CHMB1968
View the latest post
Mon Oct 31, 2022 2:18 am