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

LRECL parameter in Dynamic Allocation routine.


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

New User


Joined: 15 Jun 2009
Posts: 17
Location: India

PostPosted: Thu Jun 25, 2009 5:42 am
Reply with quote

Hello All -

Can someone help me out by saying how to give the LRECL parameter in the Dynamic allocation routine.

I am passing the below parameter in my dynamic allocation routine, but it allocating the files with default LRECL of 80 whereas I need to allocate the files only with LRECL of 50. I tried by giving the LRECL value as,
10 PIC X(12) VALUE ' LRECL(50) ' , but I was getting error saying the invalid parameter. So, I just wanted to know the correct format for it.

Your response is greatly appreciated.

01 WS-DYNAMIC-ALLOC-STORAGE.
05 ENV-VAR-PARM-PASSED.
10 DDNAME PIC X(08) VALUE SPACES.
10 PIC X(05) VALUE '=DSN('.
10 DSNAME PIC X(50) VALUE SPACE.
10 PIC X(14) VALUE ' NEW CATALOG '.
10 PIC X(23) VALUE ' SPACE(10,5) TRACKS '.
10 PIC X(17) VALUE ' UNIT(SYSDA) '.
10 PIC X(01) VALUE X'00'.
05 PUTVAR-PARM-PTR POINTER.
05 RC PIC S9(9) BINARY VALUE +0.

Regards!
Arun
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Thu Jun 25, 2009 6:18 am
Reply with quote

Are you using the BPXWDYN routine or a standard TSO ALLOCATE command?
Back to top
View user's profile Send private message
ArunAnbu

New User


Joined: 15 Jun 2009
Posts: 17
Location: India

PostPosted: Thu Jun 25, 2009 6:30 am
Reply with quote

Hi -
I am using 'PUTENV' to pass the ENV-VAR-PARM-PASSED. I didnt try by using BPXWDYN.

Your response in any form in terms of giving the LRECL in the passed parameter would be appreciated. Thanks!
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jun 25, 2009 7:28 am
Reply with quote

Hello,

Once you have called PUTENV to identify the DD, you then issue an OPEN for the file (FD)?

If so, the lrecl would be taken from the FD. . .?
Back to top
View user's profile Send private message
ArunAnbu

New User


Joined: 15 Jun 2009
Posts: 17
Location: India

PostPosted: Fri Jun 26, 2009 12:39 am
Reply with quote

Hi Dick!

Even I presumed that way i.e. the LRECL would be taken from FD but, when I tried by giving the LRECL as 50 in my FD, my job was getting failed with error code of 39 [discrepany in the LRECL] and the error says that there is discrepany between the LRECL in the program( it is 50) and in the dynamic allocation(defaults allocation with LRECL 80).

Thatz where I got stuck and not able to proceed further. I tried couple of different methods of giving the LRECL in the Dynamic allocation routine, but everytime I was getting "Invalid keyword".

Would be great if someone could share their experience if you have already faced such a situation. Thanks a lot!
Back to top
View user's profile Send private message
Douglas Wilder

Active User


Joined: 28 Nov 2006
Posts: 305
Location: Deerfield IL

PostPosted: Sat Jun 27, 2009 2:39 am
Reply with quote

I had only tried dynamic allocation for my input files. I am getting the same result you have for a dynamically allocated output file. Have you tried using IKJTSOEV and IKJEFTSR? They should work (but I have not tried it yet).
Back to top
View user's profile Send private message
ArunAnbu

New User


Joined: 15 Jun 2009
Posts: 17
Location: India

PostPosted: Thu Jul 02, 2009 5:01 pm
Reply with quote

Hi Doug! No I didn't try using IKJTSOEV and IKJEFTSR as I have no clue how to go about that...

Any other response from other folks would be greatly appreciated. I gave a good search in this forum and happen to find out one of the user ('adiovanni ') had given some solution to similar request. I tried that by changing the RECORDIND MODE, BLOCK CONTAINS.......but nothing paid me. :-( :(

Hi adiovanni - Would be great if you could throw some light on my request. All I want is to pass the LRECL of 50 from Dynamic routine because in my pgm i have my FD with 50. Its taking the system default LRELC of 80 which is causing my pgm to get abend with status code 39.

I am totally stuck on this. Any response in any form is greatly appreciated.

Thanks a lot!
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jul 02, 2009 5:19 pm
Reply with quote

80 char is a minimum for a lot of things. Maybe, here also.
Back to top
View user's profile Send private message
ArunAnbu

New User


Joined: 15 Jun 2009
Posts: 17
Location: India

PostPosted: Thu Jul 02, 2009 5:52 pm
Reply with quote

Yep thatz true!....but in my case I wanted the LRECL to be 50.... I am not able to override the system provided LRECL with my value....so, trying out the different possibilities.....any other suggestions from other folks?......Thanks!
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: Thu Jul 02, 2009 6:03 pm
Reply with quote

From what I can tell, the PUTENV method does not support LRECL -- so if you're defining a new file, PUTENV probably is not the way to go. Using BPXWDYN allows you to specify the LRECL as part of the allocation.
Back to top
View user's profile Send private message
ArunAnbu

New User


Joined: 15 Jun 2009
Posts: 17
Location: India

PostPosted: Thu Jul 02, 2009 6:12 pm
Reply with quote

Thanks for your comments Robert! Yes I am going to give a try by using BPXWDYN routine.

In the meanwhile, if any of the other forum folks have the sample of BPXWDYN routine, could you please pass it across???

Your response is greatly appreciated. Thanks a ton!
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: Thu Jul 02, 2009 8:43 pm
Reply with quote

Code:
       FILE-CONTROL.
           SELECT OUT-FILE             ASSIGN TO OUTFILE
                                       FILE STATUS IS OUT-FILE-FS
                                       .
       DATA DIVISION.
       FILE SECTION.
       FD  OUT-FILE
           BLOCK 0
           RECORDING F
           LABEL RECORDS STANDARD.
       01  OUT-FILE-REC PIC X(50).

       WORKING-STORAGE SECTION.
       01  WS-VARIABLES.
           05  BPXWDYN-ALLOC.
               10  FILLER              PIC X(42) VALUE
               'ALLOC FI(OUTFILE) DA(TTSSRS0.BPXWDYN.TEXT)'.
               10  FILLER              PIC X(12) VALUE
               ' NEW CATALOG'.
               10  FILLER              PIC X(46) VALUE
               ' SPACE(1,1) CYL LRECL(50) BLKSIZE(0) RECFM(FB)'.
               10  FILLER              PIC X(12) VALUE
               ' UNIT(SYSDA)'.

       01  BPXWDYN-RC                  PIC S9(08) COMP-5.

       01  OUT-FILE-FS                 PIC 9(02) VALUE 00.

       01  WS-SUB-PROG                 PIC X(08) VALUE 'BPXWDYN '.
      /
       PROCEDURE DIVISION.
       S1000-MAIN       SECTION.
           CALL WS-SUB-PROG
               USING WS-VARIABLES
               RETURNING BPXWDYN-RC.
           DISPLAY 'BPXWDYN RC = ' BPXWDYN-RC.
           OPEN OUTPUT OUT-FILE.
           DISPLAY 'OPEN  FILE STATUS = ' OUT-FILE-FS.
           MOVE ALL 'ABCDE0001'        TO  OUT-FILE-REC.
           WRITE OUT-FILE-REC.
           DISPLAY 'WRITE FILE STATUS = ' OUT-FILE-FS.
           MOVE ALL 'ZYXWV9999'        TO  OUT-FILE-REC.
           WRITE OUT-FILE-REC.
           DISPLAY 'WRITE FILE STATUS = ' OUT-FILE-FS.
           CLOSE OUT-FILE.
           DISPLAY 'CLOSE FILE STATUS = ' OUT-FILE-FS.
           STOP RUN.
allocates the file
Code:
Data Set Name . . . . : TTSSRS0.BPXWDYN.TEXT

General Data                           Current Allocation
 Management class . . : MCSTRG          Allocated cylinders : 1
 Storage class  . . . : SCSTRG          Allocated extents . : 1
  Volume serial . . . : STRS13
  Device type . . . . : 3390
 Data class . . . . . : DCNOORG        Current Utilization
  Organization  . . . : PS              Used cylinders  . . : 1
  Record format . . . : F               Used extents  . . . : 1
  Record length . . . : 50
  Block size  . . . . : 50
  1st extent cylinders: 1
  Secondary cylinders : 1
  Data set name type  :                 SMS Compressible  :   NO

  Creation date . . . : 2009/07/02      Referenced date . . : 2009/07/02
  Expiration date . . : ***None***
with contents
Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
ABCDE0001ABCDE0001ABCDE0001ABCDE0001ABCDE0001ABCDE
ZYXWV9999ZYXWV9999ZYXWV9999ZYXWV9999ZYXWV9999ZYXWV
and the JCL that executed was
Code:
//STEP1     EXEC PGM=MF0084
//STEPLIB   DD   DISP=SHR,DSN=TTSSRS0.COMPILES.LOADLIB
//

Notes:
1. The data set name does not have tic marks around it but is fully qualified. I ran one without my TSO user id and got the data set cataloged in the master catalog (not what I wanted) since my user id can do that; most users would get abends at that point.
2. Checking the return code is highly recommended -- and the BPXWDYN return code is a COMP-5 (4-byte binary) field.
3. The passed parameter is not a null-terminated string as with C code.
Back to top
View user's profile Send private message
ArunAnbu

New User


Joined: 15 Jun 2009
Posts: 17
Location: India

PostPosted: Fri Jul 03, 2009 6:30 pm
Reply with quote

Thanks for your post Robert! Yes I am trying out the dynamic allocation using BPXWDYN routine. Would keep you posted. Thanks again!
Back to top
View user's profile Send private message
ArunAnbu

New User


Joined: 15 Jun 2009
Posts: 17
Location: India

PostPosted: Fri Jul 03, 2009 7:50 pm
Reply with quote

Hi Robert!

Yeah i tried your code by hard coding the output dataset, its working fine and allocating the DS with LRECL 50.

But for my requirement I need to read the data from another input file and pass the DSN and also write into the dynamically allocated file. When I tried so, i was getting different RC from the BPXWDYN call.

I tried different methods, but nothing paid me. So, I just wanted to know whether BPXWDYN will work when the DSN comes from a different means?.....if so, the could you please tell me how to handle it in the pgm?...

Below is the error msg from the spool.
BPXWDYN RC = 176082124Q
OPEN FILE STATUS = 96
CEE3204S The system detected a protection exception (System Completion Code=0C4
From compile unit DYNALLTS at entry point DYNALLTS at statement 123 at
entry offset +000007C0 at address 16101718.

Below is my two select [input and output file]:
SELECT IN-FILE ASSIGN TO INFILE
FILE STATUS IS IN-FILE-FS.

SELECT OUT-FILE ASSIGN TO OUTFILE
FILE STATUS IS OUT-FILE-FS.

Thanks for your response!
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: Sat Jul 04, 2009 2:58 am
Reply with quote

You are probably not allowing for the different lengths of the data set name in the correct way. I have tested this code and it works:
Code:
           SELECT IN-FILE              ASSIGN TO INFILE
                                       FILE STATUS IS IN-FILE-FS
                                       .
           SELECT OUT-FILE             ASSIGN TO OUTFILE
                                       FILE STATUS IS OUT-FILE-FS
                                       .
       DATA DIVISION.
       FILE SECTION.
       FD  IN-FILE
           BLOCK 0
           RECORDING F
           LABEL RECORDS STANDARD.
       01  IN-RECORD.
           05  IN-DSN                  PIC X(44).
           05  FILLER                  PIC X(36).

       FD  OUT-FILE
           BLOCK 0
           RECORDING F
           LABEL RECORDS STANDARD.
       01  OUT-FILE-REC PIC X(50).

       WORKING-STORAGE SECTION.
       01  WS-VARIABLES.
           05  BPXWDYN-ALLOC.
               10  BPXWDYN-1           PIC X(21) VALUE
               'ALLOC FI(OUTFILE) DA('.
               10  BPXWDYN-2           PIC X(14) VALUE
               ')  NEW CATALOG'.
               10  BPXWDYN-3           PIC X(46) VALUE
               ' SPACE(1,1) CYL LRECL(50) BLKSIZE(0) RECFM(FB)'.
               10  BPXWDYN-4           PIC X(12) VALUE
               ' UNIT(SYSDA)'.
       01  BPXWDYN-RC                  PIC S9(08) COMP-5.

       01  OUT-FILE-FS                 PIC 9(02) VALUE 00.

       01  IN-FILE-FS                  PIC 9(02) VALUE 00.

       01  WS-SUB-PROG                 PIC X(08) VALUE 'BPXWDYN '.

       01  WS-BPXWDYN-STRING           PIC X(255) VALUE SPACES.
      /
       PROCEDURE DIVISION.
       S1000-MAIN       SECTION.
           OPEN INPUT IN-FILE.
           DISPLAY 'OPEN IN-FILE FS = ' IN-FILE-FS.
           READ IN-FILE.
           DISPLAY 'READ IN-FILE FS = ' IN-FILE-FS.
           STRING BPXWDYN-1 DELIMITED BY SIZE
                  IN-DSN    DELIMITED BY SPACE
                  BPXWDYN-2 DELIMITED BY SIZE
                  BPXWDYN-3 DELIMITED BY SIZE
                  BPXWDYN-4 DELIMITED BY SIZE
             INTO WS-BPXWDYN-STRING.
           CLOSE IN-FILE.
           DISPLAY WS-BPXWDYN-STRING.
           CALL WS-SUB-PROG
               USING WS-BPXWDYN-STRING
               RETURNING BPXWDYN-RC.
           DISPLAY 'BPXWDYN RC = ' BPXWDYN-RC.
           OPEN OUTPUT OUT-FILE.
           DISPLAY 'OPEN  FILE STATUS = ' OUT-FILE-FS.
           MOVE ALL 'ABCDE0001'        TO  OUT-FILE-REC.
           WRITE OUT-FILE-REC.
           DISPLAY 'WRITE FILE STATUS = ' OUT-FILE-FS.
           MOVE ALL 'ZYXWV9999'        TO  OUT-FILE-REC.
           WRITE OUT-FILE-REC.
           DISPLAY 'WRITE FILE STATUS = ' OUT-FILE-FS.
           CLOSE OUT-FILE.
           DISPLAY 'CLOSE FILE STATUS = ' OUT-FILE-FS.
           STOP RUN.
In the execution JCL I gave earlier, I added
Code:
//INFILE   DD   *
TTSSRS0.BPXWDYN.TEXT
/*
You could make the amount of space allocated variable by using a string function on it as well (trivial modification to this code). The BPXWDYN allocation string has spaces between keywords but cannot have any spaces within a keyword or you'll get an error.
Back to top
View user's profile Send private message
ArunAnbu

New User


Joined: 15 Jun 2009
Posts: 17
Location: India

PostPosted: Mon Jul 06, 2009 3:48 pm
Reply with quote

This is just awesome Rob! I think I am just an inch away from my solution. Now Im able to allocate the output file with LRECL 50!! But, with one issue. :-( :-(

Before that I would like to put my requirment briefly:
1. I have one huge input file(2.5 lakhs of recs) with the delimiter of '**' in the first 2 pos followed by the file name
**abcd.defg.hijk.f0001

2. Based on the delimiter I'll have to allocate the file and write the rest of the recs till it finds the next delimiter.
If the delimiter is found, then close the current file and allocate the new file and write into the new file. Perform this process till the input file EOF.

i.e.
**abcd.defg.hijk.f0001
Rec1
Rec2
.
.
Rec 100000
**abcd.defg.hijk.f0002
Rec11
Rec22.
.
Rec 100000
**abcd.defg.hijk.f0003
Rec111
Rec222.
.
Rec 50000

Per your suggestion I've framed out the logic and the pgm flow is working perfectly! But the real issue is,
my output file contains only the last set of recs BUT under the first file name.
i.e.
abcd.defg.hijk.f0001
Rec111
Rec222
.
.
Rec 50000

So, when i checked the BPXWDYN-RC, only for the first file it was 0 and for the f0002 & f0003 file, the
BPXWDYN-RC is showing as 0068157440. Which means, only the f0001 allocation had happen.

I have put some display stmt to find out the flow and could find that the read and write had happened till the EOF of the input file but it had overlaid the recs of f0002 & f0003 files and wrote the recs only for the last set in the output file.

I tried couple of different ways, but it took me no where. Could you please throw some of your suggestion to get rid off this.

Does pointer needs to be used as itz used in 'PUTENV' routine?

Definitely your response is highly appreciated. Thanks a lot!
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 Jul 06, 2009 4:48 pm
Reply with quote

You need to close and deallocate your input file when you hit the second (and third ...) ** which will write the last data buffer to the file, catalog it, and so forth. The non-zero dynamic allocation code probably (I haven't looked it up to confirm) means the DD name is already allocated to an open file. Once the file is closed, then you can use BPXWDYN to open the file again with the new name.

The close can be the usual COBOL CLOSE verb, but the deallocate needs to be a BPXWDYN FREE command, so you'll need another string for it.
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 Jul 06, 2009 6:30 pm
Reply with quote

Your code 0068157440 translates to hex '04100000' which is interpreted in the MVS Authorized Assembler Services Guide as
Quote:
0410




(1040)




Meaning: Specified ddname unavailable. (dsname
allocation, ddname allocation)

Application Programmer Action: Change ddname.

Corresponding Message: IKJ56246I
Back to top
View user's profile Send private message
ArunAnbu

New User


Joined: 15 Jun 2009
Posts: 17
Location: India

PostPosted: Mon Jul 06, 2009 7:23 pm
Reply with quote

Hi Rob -

Hip Hip Hurray!....Yes I have used another string to FREE the current output file and called the BPXWDYN routine to allocate the new file.
The logic went fine and I was able to create the output file as per my requirement!!! [i.e. dynamically allocating multiple output files with LRECL 50].

I dont think I would've completed this without your posts and valuable suggestions Rob. I really appreciate your support on this thread.
You have very good acumen on the BPXWDYN routine. Thank a tons!
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 Jul 06, 2009 7:24 pm
Reply with quote

I'm very glad to hear you've got it running. Although, if you'd given the full requirements in your first post it might have taken less time to get to the end result ... but we did get there eventually! icon_smile.gif
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 Jul 06, 2009 7:43 pm
Reply with quote

This thread is added in "Set a bookmark for this topic" for me... icon_smile.gif. Thanks Robert. icon_smile.gif
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 Jul 06, 2009 7:48 pm
Reply with quote

Hope it helps, Anuj! The code I posted was tested and is known to work, although I did not add the CLOSE and BPXWDYN FREE commands. On the other hand, reading the BPXWDYN documentation should make the FREE command fairly obvious. And at least the dynamic file was fixed length in this case, which simplified processing somewhat.
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 Jul 06, 2009 7:57 pm
Reply with quote

Yes it does help. Actually, I was never in such a need to dynamically allocate files using COBOL/BPXWDYN so never used that. I'll experiment with that in my "free time" or over the weekend to explore more, though I've seen code using that but I was a "passer by"...

Have a good one icon_smile.gif

Regards,
Anuj
Back to top
View user's profile Send private message
grabeva

New User


Joined: 07 Sep 2006
Posts: 23

PostPosted: Mon Oct 26, 2009 11:07 pm
Reply with quote

Hello,

i do a cobol program how invoke at BPXWDYN,
i need to alloc dynamic GDGs with LRECLs variable.....

but give me un error.....can somebody help me....thanks...Gra

2000-PROCESO
2200-VER-CONTROL
3000-ABRIR-ARCHIVO
SVCALLOC-I-DSN TSBA.XT.DI.REGIMEN.SISCEN(+1)
SVCALLOC-I-LRECL 00168
BPXWDYN --- SALIDA POR ERROR
BPXWDYN CODIGO ERROR: 000000002}
BPXWDYN PARAMETROS ENVIADOS: ALLOC FI(SALIDA) DA(TSBA.XT.DI.REGIMEN.SISCEN(+1)) NEW CATALOG SPACE(1,1) CYL BLKSIZE(0) RECFM(FB)LRECL=00168

FIN
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: Tue Oct 27, 2009 12:14 am
Reply with quote

1. LRECL(168) instead of LRECL=00168
2. You must add GDGNT to your allocation string or the (+1) will be taken as a member name and the allocation failed.
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 Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts VB to FB - Finding LRECL SYNCSORT 4
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
No new posts Using the Jobname parameter in a Qual... ABENDS & Debugging 1
No new posts JCL Dynamic System Symbols JCL & VSAM 3
Search our Forums:

Back to Top