Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capturing Info from Input File Name

Status
Not open for further replies.

supra94red

Programmer
Nov 27, 2002
11
0
0
US
Hello,
I trying to capture a portion of the input file name
and write it to the output record. How would I go
about doing this? For example, my Select Filein statement
refers to filename TEST.DM123456.PROD.TXT and I want
to capture DM123456 to store in a variable for my
output.

Thanks
Dan.
 
Hi supra94red,

The system you are using should have callable APIs you can use to do this.

Most COBOL compilers will let you 'CALL' or 'ENTER' system routines that manipulate the file system.

Check your COBOL manual for the system call syntax, and your system manual for the appropriate API to use.

If this does not help, post your COBOL compiler name and your system name. Someone here will surely have a solution.

Dimandja
 
if the statement is set up like
select filein assign to disk "TEST.DM123456.PROD.TXT".
Then just use DM123456 as a constant.
If it is set up to key in the file name with display accept.
select filein assign to disk somefilename.

01 somefilename.
05 filler pic x(80) value spaces.

then you couLd move somefilename(6:8) to a variable.
or you could unstring the filename if the format is always the same.
01 storage-areas.
05 AA PIC X(20) VALUE SPACES.
05 A PIC 9(6) VALUE ZEROES.
05 BB PIC X(20) VALUE SPACES.
05 B PIC 9(6) VALUE ZEROES.
UNSTRING SOMEFILENAME DELIMITED BY "."
INTO AA COUNT IN A BB COUNT IN B.
THEN BB(1:B) IS YOUR VARIABLE

Enjoy Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top