I had a file 'ABC' and in that file i had various fields A1, A2, A3, A4, etc. How can i get the value of A2 (numeric) and A3 (character) from file 'ABC' using OPNQRY command ??
Announcement
Collapse
No announcement yet.
What will be the query to get the value of Specific field through OPNQRYF
Collapse
X
-
Havent used OPNQRYF in 100 years but
I found this out there.....I threw in a couple more examples for
the search engines
Once the OPNQRYF command has processed the data will be in the data type of the DDS for the Physical or Logical file.
Characters are defined using (") while decimals are not.
Code:OPNQRYF FILE((JPHLIB/QRYSLTPF)) + QRYSLT(' + (UPUPRF *EQ ''JPH'') + *AND + (UPUID *EQ 338) + ') + OPNID(BRUG)
You can use the keyword FORMAT to use another file as
the based on field type file
Code:OPNQRYF FILE(FILEA FILEB) FORMAT(JOINAB) + QRYSLT('FILEA/CUST *EQ FILEB/CUST') + MAPFLD((CUST 'FILEA/CUST'))
Code:OPNQRYF FILE((JPHLIB/QRYSLTPF)) + QRYSLT(' + (UPUPRF *EQ ''' *CAT &USER *CAT ''') + *AND + (%DIGITS(UPUID) *EQ ''' *CAT &NRALF *CAT ''') + ') + OPNID(BRUG)
You can also use the cpyfrmqryf command to copy data from a
OPNQRYF command
Code:CPYFRMQRYF FROMOPNID(BRUG) TOFILE(JPHLIB/BRUG) + MBROPT(*ADD)
Code:************************************************ * PHYSICAL FILE BRUG TO HOLD SELECTED RECORDS IN OPNQRYF ************************************************ A R SELECT A UPUPRF 10 TEXT('USER') A COLHDG('USER') A UPUID 10P 0 TEXT('ID') A COLHDG('ID')
hope something in there helps
All my answers were extracted from the "Big Dummy's Guide to the As400"
and I take no responsibility for any of them.
www.code400.com
-
Will OPNQRYF help me?
I do not have SQL package on AS400. I am using RPGLE program with 'QC2LE' as Bnddir. What i am upto is that in my CL program i am executing DSPFFD command over PRTF and now i want to have values provided by DSPFFD file (using C Dir). The 'C' provides field names as 'WHFLDE' etc. So i have the field name now i want to retrive the value of 'WHFLDE' in my RPG Code.
Will OPNQRYF help me?? and how.
Or I have to look for some other options.
Comment
-
This may send you in another direction but:
Check this program out....
It uses API QUSLFLD to list the fields.
Then it writes them to a dataqueue which then is read in
batch. There it creates a physical file with the selected fields.
You could mod this program(s) to work with your DDS of your print file. --Or-- Strip out what you need to get your program
running.
Which ever way you go:
Your program seems very interesting to me.
I would love to see it posted on the site under your name.
Let me know
Jimmy
All my answers were extracted from the "Big Dummy's Guide to the As400"
and I take no responsibility for any of them.
www.code400.com
Comment
Comment