View previous topic :: View next topic
|
Author |
Message |
nareshdacha
New User
Joined: 12 Jan 2010 Posts: 66 Location: US
|
|
|
|
I have one input file which contains the only names of 25 files. These input files names will change on daily basis.
I want to read all these 25 input files using COBOL program. Is it possible or not ?
Input file just contain the 25 files names, first i should read this input file then i have to read 25 input files for processing.
Can anyone explain how to proceed further... |
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
Hi Naresh,
Keyword : BPXWDYN
Do a search for BPXWDYN in this forum and you will know how to proceed further... |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
One of the things that I question more and more and more is the thought and preparation that goes into building these applications.
Never in the past have I encountered this non knowledge of which files are to be processed by any particular job. Everything was static, and dare I say efficient. None of this extra processing to determine which files need processing.
Is it just me that thinks this way.
I just bet that the support people just love it when one of these jobs abends. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Amen to that, expat. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Expat,
Quote: |
Never in the past have I encountered this non knowledge of which files are to be processed by any particular job. |
In the past things were actually designed. . . Now, many are just thrown together and someone has to figure out how to use the pieces. . .
The most successful implementations of this type of process that i've worked with was to generate a new +1 for each file and then process the entire gdg as a single file. . . Rather simple actually. . .
@Naresh -
Quote: |
I have one input file which contains the only names of 25 files. These input files names will change on daily basis.
I want to read all these 25 input files using COBOL program. Is it possible or not ? |
If these files do not all have the same dcb info, you won't be able to read them with the "same" code. . . |
|
Back to top |
|
|
icemanroh
New User
Joined: 23 Aug 2008 Posts: 25 Location: Mumbai
|
|
|
|
BPXWDYN is used for Dynamic allocation of files within a COBOL program. But the utility requires all details in order to allocate a Dataset. Below is a sample command which needs to be used in order to allocate a dataset. U can allocate GDGs PS files using this utility.
ALLOC DD(OUTPUTFL) DSN(DOC.DYNAM.TEST) LRECL(00100) BLKSIZE(01000) RECFM(F,B) DATACLAS(LARGE) NEW CATALOG DSORG(PS)
CALL 'BPXWDYN' USING WS-COMMAND-STRING.
Once the allocation is complete u can open file in Input mode & start processing as u do in any program.
As mentioned by Dick if the file format of all files is going to change then it becomes a problem. If only the file names are changing then its very easy. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
icemanroh wrote: |
If only the file names are changing then its very easy. |
It may be easy for the programmer, but as stated above, it will not be easy for the people designated to support these types of applications.
But hey, why think about doing things properly when a hasty thrown together hotchpotch of crazy ideas will work |
|
Back to top |
|
|
icemanroh
New User
Joined: 23 Aug 2008 Posts: 25 Location: Mumbai
|
|
|
|
Some time back I had such a requirement so I created couple of generic copybooks which can be used to allocate files dynamically & Im willing to share if this thread starter wants it. |
|
Back to top |
|
|
nareshdacha
New User
Joined: 12 Jan 2010 Posts: 66 Location: US
|
|
|
|
All the files are of same format and same length.
I have coded as below, whether this procedure is correct or not ? Can anyone suggest me........Any errors please correct me...
DATA DIVISION.
FILE SECTION.
FD IN-FILE
RECORDING MODE IS F
LABEL RECORDS ARE STANDARD
BLOCK CONTAINS 0 RECORDS
DATA RECORD IS IN-REC.
01 IN-REC PIC X(80).
05 IN-FILE-NAME PIC X(80).
WORKING-STORAGE SECTION.
01 BPXWDYN PIC X(08) VALUE 'BPXWDYN'.
01 S-EOF-FILE PIC X(01) VALUE 'N'.
01 PDS-STRING.
05 PDS-LENGTH PIC S9(4) COMP VALUE 100.
05 PDS-TEXT PIC X(100) VALUE
'ALLOC DD(INFILE) DSN(''EMPLOYEE.INPUT.FILE)'') SHR'.
MOVE SPACES TO PDS-STRING
STRING 'FREE FI(INFILE) DSN(' IN-FILE-NAME ') SHR'
DELIMITED BY SIZE
INTO PDS-STRING
CALL BPXWDYN USING PDS-STRING
IF RETURN-CODE = ZERO
READ IN-FILE-NAME AT END MOVE '1' TO IN-EOF
DISPLAY DATA ...............
ELSE
GO TO 4000-ABEND-PARA
END-IF |
|
Back to top |
|
|
nareshdacha
New User
Joined: 12 Jan 2010 Posts: 66 Location: US
|
|
|
|
Hi Rohit,
Could you please share with us.. so that it will be helpful for me |
|
Back to top |
|
|
icemanroh
New User
Joined: 23 Aug 2008 Posts: 25 Location: Mumbai
|
|
|
|
Upload these three to mainframes & rename them to create copybook/pgm as below:
DYNAM.CODECPY.txt -> Code in copybook format (Rename: DYNAMAL)
DYNAM.CPY.txt -> Copybook for Filename & attribute details (Rename: DYNAMCPY)
DYNAM.CODE.txt -> A sample test program to show how to use the copybooks. |
|
Back to top |
|
|
nareshdacha
New User
Joined: 12 Jan 2010 Posts: 66 Location: US
|
|
|
|
Can anyone correct the errors in the above code.. so that it will be helpful for me........... |
|
Back to top |
|
|
icemanroh
New User
Joined: 23 Aug 2008 Posts: 25 Location: Mumbai
|
|
|
|
nareshdacha wrote: |
Can anyone correct the errors in the above code.. so that it will be helpful for me........... |
Ur command is wrong it should be something like below. Change DCB as per ur need.
ALLOC DD(INFILE) DSN(EMPLOYEE.INPUT.FILE) LRECL(00100) BLKSIZE(01000) RECFM(F,B) SHR
PDS-STRING should contain above. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Can anyone correct the errors in the above code.. so that it will be helpful for me........... |
Sorry to rain on the parade, but if you do not understand the code well enough to work with it, maybe it should not be implemented.
No organization wants code in use that the "author" (you) cannot support. . .
Possibly there is something i misunderstand. . . |
|
Back to top |
|
|
nareshdacha
New User
Joined: 12 Jan 2010 Posts: 66 Location: US
|
|
|
|
As i already mentioned above, this question was asked in interview..
Just i tried to implement that scenario in real-time......
Thanks to all .............. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
As i already mentioned above, this question was asked in interview.. |
Ahhh, ummm, errr. . . Not in this topic
Anyway it is good if you have an answer you can use |
|
Back to top |
|
|
nileshyp
New User
Joined: 22 Jun 2005 Posts: 65 Location: Mumbai
|
|
|
|
I downloaded the file given above and tried to run the given program but it failed with below error. the SPOOL sysout shows as below
Code: |
=== PGM DYNAMTST STARTED === ,,
DOC. .TEST DYNAM ....
***********************************************
ALLOCATING DATASET USING COMMAND : ALLOC DD(OUTPUTFL) DSN(DOC.DYNAM.TEST) LRECL(00100),BLKSIZE(01000) RECFM(F,B) DATA
CLAS(LARGE) NEW CATALOG DSORG(PS)
***********************************************
DYNAMALL : FILE ALLOCATION ¦ SUCCESS ¦
***********************************************
IGZ0035S There was an unsuccessful OPEN or CLOSE of file OUTPUTFL in program DYNAMTST at relative location X'0C28'.
Neither FILE STATUS nor an ERROR declarative were specified. The status code was 96.
From compile unit GCMDYNAM at entry point GCMDYNAM at unit offset +00000C28 at entry offset +00000C28
at address 2E300C28.
<> LEAID ENTERED (LEVEL 04/01/2008 AT 12.32)
<> LEAID PROCESSING COMPLETE. RC=0
|
and my run jcl looks as below
Code: |
//ASPUROHA JOB ('A'),'NIL',CLASS=G,
// MSGCLASS=Y,NOTIFY=ASPUROH,USER=ASPUROH
//**
//STEP01 EXEC PGM=GCMDYNAM
//STEPLIB DD DISP=SHR,DSN=SYSE.TE.MER1.ALL.LOADB
//INPUTFL DD DSNAME=TRTEGCM.TEST.FILE1,DISP=OLD
//
|
Please let me know if I need to add any step in my run JCL.
Regards,
Nilesh |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
What does your SELECT look like? What does the OPEN statement look like? |
|
Back to top |
|
|
nileshyp
New User
Joined: 22 Jun 2005 Posts: 65 Location: Mumbai
|
|
|
|
I am just running the program given by icemanroh in the same message thread given earlier. Just check previous replies and download link provided by Rohit. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
nileshyp wrote: |
I am just running the program given by icemanroh in the same message thread given earlier. Just check previous replies and download link provided by Rohit. |
**sigh** (or actually ROFL )
since the code in the other thread works and yours doesn't,
maybe something is wrong with your code,
which means for us to look at something that you do not have,
could be useless, as well as a waste of our time.
I personally would not hold my breath, if I were you, awaiting on helpful responses. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Potential problem 1: if your site does not have a DATACLASS named LARGE, your output data set will not be allocated.
Potential problem 2: if you did not customize the provided code to use a high level qualifier (HLQ) in use at your site, you could get an open error when attempting to update the master catalog with new data set DOC.DYNAM.TEST.
It took me half an hour to customize the code provided in the download link to work with our site standards -- and I am experienced in BPXWDYN and knowledgeable about our site. If you haven't spent at least that much time getting the provided code changed to your site standards, it's not going to work -- period. |
|
Back to top |
|
|
|