variable in write work file statement?



Software AG's platform-independent programming language with full support for open-source and Internet applications

variable in write work file statement?

Postby diptisaini » Tue Dec 14, 2010 4:34 pm

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 ?
diptisaini
 
Posts: 90
Joined: Sun Mar 14, 2010 5:12 pm
Has thanked: 0 time
Been thanked: 0 time

Re: variable in write work file statement?

Postby ats » Tue Dec 14, 2010 5:25 pm

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:

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
ats
 
Posts: 14
Joined: Mon Sep 06, 2010 12:27 pm
Has thanked: 0 time
Been thanked: 0 time

Re: variable in write work file statement?

Postby RGZbrog » Tue Dec 14, 2010 10:05 pm

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.
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
User avatar
RGZbrog
 
Posts: 101
Joined: Mon Nov 23, 2009 1:34 pm
Location: California, USA
Has thanked: 0 time
Been thanked: 0 time

Re: variable in write work file statement?

Postby diptisaini » Wed Dec 15, 2010 11:05 am

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 ?
diptisaini
 
Posts: 90
Joined: Sun Mar 14, 2010 5:12 pm
Has thanked: 0 time
Been thanked: 0 time

Re: variable in write work file statement?

Postby RGZbrog » Wed Dec 15, 2010 11:36 am

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.
User avatar
RGZbrog
 
Posts: 101
Joined: Mon Nov 23, 2009 1:34 pm
Location: California, USA
Has thanked: 0 time
Been thanked: 0 time

Re: variable in write work file statement?

Postby ats » Wed Dec 15, 2010 1:33 pm

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
ats
 
Posts: 14
Joined: Mon Sep 06, 2010 12:27 pm
Has thanked: 0 time
Been thanked: 0 time

Re: variable in write work file statement?

Postby RGZbrog » Wed Dec 15, 2010 10:08 pm

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
User avatar
RGZbrog
 
Posts: 101
Joined: Mon Nov 23, 2009 1:34 pm
Location: California, USA
Has thanked: 0 time
Been thanked: 0 time

Re: variable in write work file statement?

Postby ats » Thu Dec 16, 2010 11:41 am

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 :D

Regards,
Ats
ats
 
Posts: 14
Joined: Mon Sep 06, 2010 12:27 pm
Has thanked: 0 time
Been thanked: 0 time

Re: variable in write work file statement?

Postby fidelis » Fri Dec 17, 2010 5:14 pm

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.
fidelis
 
Posts: 7
Joined: Thu Dec 16, 2010 1:01 am
Location: Brazil
Has thanked: 0 time
Been thanked: 0 time


Return to Natural

 


  • Related topics
    Replies
    Views
    Last post