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

Reading input files which contains in a dataset.....


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

New User


Joined: 12 Jan 2010
Posts: 66
Location: US

PostPosted: Sat Jul 17, 2010 12:11 pm
Reply with 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 ?

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
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Sat Jul 17, 2010 12:19 pm
Reply with quote

Hi Naresh,

Keyword : BPXWDYN

Do a search for BPXWDYN in this forum and you will know how to proceed further... icon_biggrin.gif
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Sat Jul 17, 2010 1:14 pm
Reply with quote

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
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Sat Jul 17, 2010 2:11 pm
Reply with quote

Amen to that, expat.
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: Sat Jul 17, 2010 10:13 pm
Reply with quote

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
View user's profile Send private message
icemanroh

New User


Joined: 23 Aug 2008
Posts: 25
Location: Mumbai

PostPosted: Wed Jul 21, 2010 1:05 pm
Reply with quote

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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed Jul 21, 2010 1:13 pm
Reply with quote

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 icon_evil.gif
Back to top
View user's profile Send private message
icemanroh

New User


Joined: 23 Aug 2008
Posts: 25
Location: Mumbai

PostPosted: Wed Jul 21, 2010 1:22 pm
Reply with quote

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
View user's profile Send private message
nareshdacha

New User


Joined: 12 Jan 2010
Posts: 66
Location: US

PostPosted: Wed Jul 21, 2010 1:22 pm
Reply with quote

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
View user's profile Send private message
nareshdacha

New User


Joined: 12 Jan 2010
Posts: 66
Location: US

PostPosted: Wed Jul 21, 2010 1:24 pm
Reply with quote

Hi Rohit,

Could you please share with us.. so that it will be helpful for me
Back to top
View user's profile Send private message
icemanroh

New User


Joined: 23 Aug 2008
Posts: 25
Location: Mumbai

PostPosted: Wed Jul 21, 2010 2:03 pm
Reply with quote

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
View user's profile Send private message
nareshdacha

New User


Joined: 12 Jan 2010
Posts: 66
Location: US

PostPosted: Thu Jul 22, 2010 12:40 pm
Reply with quote

Can anyone correct the errors in the above code.. so that it will be helpful for me...........
Back to top
View user's profile Send private message
icemanroh

New User


Joined: 23 Aug 2008
Posts: 25
Location: Mumbai

PostPosted: Thu Jul 22, 2010 12:48 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Thu Jul 22, 2010 7:14 pm
Reply with quote

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
View user's profile Send private message
nareshdacha

New User


Joined: 12 Jan 2010
Posts: 66
Location: US

PostPosted: Fri Jul 23, 2010 10:49 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Fri Jul 23, 2010 7:32 pm
Reply with quote

Hello,

Quote:
As i already mentioned above, this question was asked in interview..
Ahhh, ummm, errr. . . Not in this topic icon_confused.gif

Anyway it is good if you have an answer you can use icon_smile.gif
Back to top
View user's profile Send private message
nileshyp

New User


Joined: 22 Jun 2005
Posts: 65
Location: Mumbai

PostPosted: Fri Jul 30, 2010 3:02 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Jul 30, 2010 4:33 pm
Reply with quote

What does your SELECT look like? What does the OPEN statement look like?
Back to top
View user's profile Send private message
nileshyp

New User


Joined: 22 Jun 2005
Posts: 65
Location: Mumbai

PostPosted: Fri Jul 30, 2010 5:15 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Jul 30, 2010 6:23 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Jul 30, 2010 7:31 pm
Reply with quote

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

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
Search our Forums:

Back to Top