Skip to main content

Physical filename from within Cobol

  • February 11, 2025
  • 3 replies
  • 0 views

I need to find out how to, if possible, access the physical name of a file, eg; ACCOUNTS20250211 please.



------------------------------
Peter OFlanagan
Consultant
Rocket Forum Shared Account
------------------------------

3 replies

Chris Glazier
Forum|alt.badge.img+2
  • Moderator
  • 3697 replies
  • February 11, 2025

I need to find out how to, if possible, access the physical name of a file, eg; ACCOUNTS20250211 please.



------------------------------
Peter OFlanagan
Consultant
Rocket Forum Shared Account
------------------------------

Hi Peter,

I am not really sure what you are asking for.

Can you please provide some more detail on exactly what you need to do?

Thanks



------------------------------
Chris Glazier
Principal Technical Support Specialist
Rocket Forum Shared Account
------------------------------

  • Author
  • New Participant
  • 1 reply
  • February 12, 2025

Hi Peter,

I am not really sure what you are asking for.

Can you please provide some more detail on exactly what you need to do?

Thanks



------------------------------
Chris Glazier
Principal Technical Support Specialist
Rocket Forum Shared Account
------------------------------

Hi Chris, Thanks for getting back to me so quickly.  I have been asked to see if it is possible to create a string within my program to contain the physical name of the file. So for arguments sake if I have a file ACCOUNTS20250211.txt is there a way to populate a PIC X(20) string as "ACCOUNTS20250211.txt  "



------------------------------
Peter OFlanagan
Consultant
Rocket Forum Shared Account
------------------------------

Chris Glazier
Forum|alt.badge.img+2
  • Moderator
  • 3697 replies
  • February 12, 2025

Hi Chris, Thanks for getting back to me so quickly.  I have been asked to see if it is possible to create a string within my program to contain the physical name of the file. So for arguments sake if I have a file ACCOUNTS20250211.txt is there a way to populate a PIC X(20) string as "ACCOUNTS20250211.txt  "



------------------------------
Peter OFlanagan
Consultant
Rocket Forum Shared Account
------------------------------

Hi Peter,

Sure, you can use dynamic assignment in your select statement to assign the file to a data-item in working-storage.

       identification division.
       program-id. Program1.

       environment division.
       configuration section.
           select test-file assign to my-file-name.
       data division.
       file section.
       fd test-file.
       01 test-rec  pic x(10).
       working-storage section.
       01 my-file-name  pic x(20) value spaces.
       procedure division.
           move "ACCOUNTS20250211.txt" to my-file-name
           open output test-file

           goback.



------------------------------
Chris Glazier
Principal Technical Support Specialist
Rocket Forum Shared Account
------------------------------