60 pts.
Q:
how to copy column-headings from a PF
how to get column-heading names copied along with data from a PF to a flat-file?
- OR -
how to copy column-headings from a PF to another PF?

Software/Hardware used:
AS/400
ASKED: Nov 19 2009  10:52 AM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
95 pts.
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • Bookmark and Share
If I understand you correctly, you want the file field description copied and written to a file.

In a CL do a DSPFFD to an outfile and then call a pgm (RPG etc) read in that file extracting the description as required.

Neil.
Last Answered: Nov 19 2009  10:59 AM GMT by NeilD   95 pts.
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

DanTheDane   530 pts.  |   Nov 19 2009  2:52PM GMT

Query the systemfile QSYS/QADBIFLD.
Maybe this sample code can help you:

SELECT dbilib, dbifil, dbifmt, dbifld, dbitxt, dbihdg
FROM qadbifld
WHERE dbilib = ‘[myownlib]‘ and dbifil = ‘[myownfile]‘  

Replace the squared brackets and content with your own library and filname.

You may find other interesting info in the other sytem database files. Use command

wrkobj qadb* 

to find these files.

You may use Query/400 also.
Warning: DO NOT try to update these files.

Good luck
DanTheDane

 

Teandy   4495 pts.  |   Nov 19 2009  5:40PM GMT

If we knew more on why you want to do this, we may be able to come up with better answers.

The only reason I can think of for a flat file to contain column headings is so it can be converted to a .CSV. If this is the case then google for a command called CVTPFXLS. This will take the file and convert it to an excel spread sheet complete with column headings. You can then save the file as a .CSV

 

TomLiotta   15455 pts.  |   Nov 19 2009  9:08PM GMT

If at all possible, don’t query QSYS/QADBIFLD. Better would be to use the views provided over it rather than the PF itself. Query QSYS2/SYSCOLUMNS instead.

Consider a specific function that can create a single row for any list of columns from any table. If you’re going to need to do this once, you’ll probably need it again. If you can generate a single row for column headings, you can always append additional rows for column data.

Tom