I work for a travel company whose Inventory file uses a unique field for each day of the month, e.g. LGRA1 is the first, LGRA2 is the second etc. The month and the year are single fields.
Is there a way of converting these fields to concatenate the date to be able to link easily to other files? Not sure why they chose to do it this way, maybe someone has experience of this.
Software/Hardware used:
AS400
ASKED:
August 2, 2011 9:20 PM
UPDATED:
March 31, 2012 7:20 PM
Hi,
You can try creating a LF with CONCAT.
From DDS manual :
Example 1
MTH, DAY, and YEAR are fields in the physical file that are concatenated into one field DATE in the logical file, as shown in the following example.
|…+….1….+….2….+….3….+….4….+….5….+….6….+….7….+….8
00010A R RECORD1 PFILE(PF1)
00020A DATE CONCAT(MTH DAY YEAR)
A
Regards,
Wilson
…e.g. LGRA1 is the first, LGRA2 is the second etc.
Is that meaning that there is no DAY field? I.e., you only know a value for ‘day’ by looking to see which of the LGRAn columns have values?
Tom
That’s correct, any row of results will have at least 30 columns to sift through.
I would guess that a view could be made. Assuming that Year and Month are character then someting like this????
Create View Myview as
Select Year || Month || ’01′ , LGRA01
union
Select Year || Month || ’02′ , LGRA02
union
Select Year || Month || ’03′ , LGRA03
etc.
You could also make a multi-format logical this way.
Phil
Thanks for the answers. Is there a way of doing this in Define Results Fields of AS400 query? I don’t have access to a command line unfortunately.
Phil’s suggestion might be about as good as it gets, given the questionable design of the file records. It might be modified a little:
That is, each sub-SELECT might only contribute rows for day numbers when the corresponding LGRAn field has a non-zero value. But that would be a decision you’d have to make. By selecting only non-zero values, the result table could definitely be much smaller, especialy if early in a month when no days had had values set yet.
Whether it can be done with WRKQRY will have to be answered by someone very familiar with the product. I haven’t used that product much since it went nearly obsolete many years ago. Nothing simple in WRKQRY comes to mind. If Query Manager is available as well, though, it’s easy to do.
Tom
If the file is not too large, it might be worth writing a program to duplicate the records to a new file for query purposes and add a field for a single date in the format you need.