a problem with WRITE WORK FILE

Hi,

i have a question about the statement DEFINE WORK FILE.
I have a solution for my problem, but I like to know, what’s the reason.
In my first Program I have a problem:


DEFINE WORK FILE 1 #DSNAME           
DEFINE WORK FILE 2 #DSNAME_NEU 
FIND CATALOG-VIEW WITH DSNAME = #DSNAME AND NODE = #NODE 
  IF NO RECORDS FOUND 
    WRITE 'Keine Emtex-Datei gefunden!' 
    ESCAPE BOTTOM 
  END-NOREC 
  READ WORK FILE 1 RECORD #EMTEXDATENSATZ 
    MOVE SUBSTR(#EMTEXDATENSATZ,1,50) TO #TEST
    WRITE WORK FILE 2 VARIABLE #TEST
  END-WORK
END-FIND 
CLOSE WORK FILE 1 
CLOSE WORK FILE 2
END

The problem is in the WRITE WORK FILE statment.
The systeme write: 1500 WORK-Datei 2 kann nicht geoeffnet werden , DMS ERROR: DD31.
My solution:


DEFINE WORK FILE 1 #DSNAME           
DEFINE WORK FILE 2 #DSNAME_NEU 
FIND CATALOG-VIEW WITH DSNAME = #DSNAME AND NODE = #NODE 
  IF NO RECORDS FOUND 
    WRITE 'Keine Emtex-Datei gefunden!' 
    ESCAPE BOTTOM 
  END-NOREC
  FETCH RETURN 'ACEMTX' 
END-FIND 
CLOSE WORK FILE 1 
CLOSE WORK FILE 2
END

and the program ‘ACEMTX’:


READ WORK FILE 1 RECORD #EMTEXDATENSATZ 
 MOVE SUBSTR(#EMTEXDATENSATZ,1,50) TO #TEST 
 WRITE WORK FILE 11 VARIABLE #EMTEXDATENSATZV 
END-WORK 
END 

Why?

write work file 2 #emtexdatensatz

Is work file 2 (CMWKF02) defined as a variable length RECFM in the DCB? Is it a sequential (QSAM) file? Does it work if you don’t specify the VARIABLE clause?

Is work file 2 (CMWKF02) defined as a variable length RECFM in the DCB?
Yes
Is it a sequential (QSAM) file?
It is a SAM-file.
Does it work if you don’t specify the VARIABLE clause?
It is the same problem with or without the VARIABLE clause.

The problem is:
Why I can’t write in the work file 2 in the same program, but I use a second program it is OK?
It is a time-problem?
I define a work file and can’t use it in the same program. Why?

You use work file 11 (instead of 2) in the subprogram… maybe that’s the reason why.

No, i have no right write in the first post.

It is WORK FILE 2.
(I have try witch WORK FILE 11, but the same)

Could you provide the entire error message ?

I start the program in Natural with run.

Then I can read the message in Natural:
==err> 0000 1500 WORK-Datei 2 kann nicht geoeffnet werden , DMS ERROR: DD31.

I start the program with a batch-job.
Then I can read in the outputfile the following massage:

39:ANEXT ACEMTER
40:AACEMTER NAT1500 WORK-Datei 2 kann nicht geoeffnet werden , DMS
ERROR: DD31
41:ANEXT FIN·

what do you have in “#DSNAME_NEU”?

Your error seems to indicate that the program is writing to //DD31. Is this defined? Is “DD31” the content of #DSNAME_NEU? What happens if you omit the DEFINE WORK FILE 2 #DSNAME_NEU in the first program (assuming you have the default file assignments, the output should go to //CMWKF02)?

Hi,

#dsname is the name of a file with a lot of data (BS2000-Accounting-data).
e.g. #dsname = sys.account.2011-03-23.e2
I need a part of this data e.g. the data with TASK. This part I will write in a new work file. (work file 2 #dsname_neu) .
#dsname_neu = acc.account.2011-03-23.e2

I will write in this file - not read.
I read from work file 1 - this is all right.
If I use the FETCH RETURN statment, I can write in work file 2.

But I don’t now, why I can’t write in work file 2 in the same program

Jörg

dd31 is a error-massage from BS2000 ( I think so)

If I write in the BS2000-console

help dd31

I can read the massege from BS2000

% DMS0D31 DATEINAME UNGUELTIG ODER FEHLERHAFT
% ? Der Benutzer-Dateiname folgt nicht den Konventionen.
% Moegliche Ursachen:
% 1) $USER-ID ungueltig bzw. der Benutzer hat kein Zugriffsrecht auf
% den angesprochenen Pubset;
% 2) Verlangte Funktion erlaubt keinen teilqualifizierten Dateinamen;
% Unter Meldung DMS0331 sind weitere moegliche Fehlerursachen aufgefuehrt.
% ! Das Programm verbessern und erneut versuchen.

But with the second program I can.

Just a wild guess…

  • and I am no expert in this area - my BS2000 knowledge is 15 years old :wink:

Could this be related to the AM=STD setting in the NTWORK macro in NATPARM ?
More specifically if the OPEN=… is set to ACC or INIT or ???
In other words if the file is open at session init or at first access ?
There is tons of different options described in the doc.
http://techcommunity.softwareag.com/ecosystem/documentation/natural/nat427mf/sm/definewo.htm

Finn