Q. I have an interactive program that allows the user to search through the database. I would like to give the user the capability to search on a date field. The field is stored in the database as YYMMDD, but I need to provide search capabilities in the format DDmonth abbreviationYY (e.g., 04JUN96). For example, the user may search on *JU* and I need to return records for the months of June and July.
I'm using Open Query File (OPNQRYF) to query the database inside an RPG III program. I would like to avoid creating another file with the appropriately formatted date because this is an interactive program.
- Aau Urtubia
A. You have to convert the date field in the database to DDmonth abbreviationYY format to compare it to the wildcard search value. In 7, you can see how I accomplished this feat.
A. You have to convert the date field in the database to DDmonth abbreviationYY format to compare it to the wildcard search value. In Figure 7, you can see how I accomplished this feat.
The passed-in value (&SEARCH) is what you're searching for, such as *JU*. The power is in the MAPFLD parameter.
Here's what each mapped field does.
o MONTHLIST: a list of three character abbreviations. Notice that the value in this variable begins with three blank spaces.
o CHARDATE: the database date field (SDTRDJ) converted to character. If the database date is in character format, skip this step and use the database field
name instead of CHARDATE in the mapped field definitions that follow.
o MONTH: the month portion of the data-base date as a zoned decimal number.
o OFFSET: the position in the MONTH
LIST where the abbreviation for the month starts. January starts at position 4, February at position 7, and so on.
o SLTDATE: the database date reformatted as DDmonth abbreviationYY. It gets compared to the search string in the QRYSLT parameter.
- Ted Holt
TechTalk: Programming--This solution allows the user to search using a text month name in a numeric date.
Figure 7: Sample Source to Search Database Based on Month Name
PGM PARM(&SEARCH) DCL VAR(&SEARCH) TYPE(*CHAR) LEN(7) DCL VAR(&QRYSLT) TYPE(*CHAR) LEN(256) CHGVAR VAR(&QRYSLT) VALUE('SLTDATE *EQ %WLDCRD("' + *CAT &SEARCH *TCAT '")') OVRDBF FILE(TESTPF2) SHARE(*YES) OPNQRYF FILE((TESTPF2)) QRYSLT(&QRYSLT) + MAPFLD((MONTHLIST '" + JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC"') + (CHARDATE '%DIGITS(SDTRDJ)' *CHAR 6) + (MONTH '%SST(CHARDATE 3 2)' *ZONED 2 0) + (OFFSET 'MONTH * 3 + 1') (SLTDATE + '%SST(CHARDATE 5 2) *CAT %SST(MONTHLIST + OFFSET 3) *CAT %SST(CHARDATE 1 2)')) CALL PGM(LISTPGM) CLOF OPNID(TESTPF2) ENDPGM
Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.
IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn:
LATEST COMMENTS
MC Press Online