Domanda

I want to do a small RPG program but am very rusty. It's similar to the SQL recently.

I want to read a logical file, and select only those records with todays date. The field is defined as NUmeric 8 0. YYYYMMDD IS this the way to do this? I want to read only those records = todays date. (job date is ok ).

F Filename etc.

 D   Data structure for date     *** not sure how to code this,
   DS Datein
   D  year4in
       D Cent2
       D YR2
   D  month2in
   D day2in
****

D DS Dateout
D  month2out
D day2out
D  yr2out

C   Read loop 

     Read Filename until EOF.


              Move Ordhdt to Datemanip

              If Ordhdt not equal udate 

                  Leave

                       else

                            Write record to work file
                       iter
              End read loop.
È stato utile?

Soluzione

fmylf   if    e              k disk

d             ds
d  now                  1   20  0
d  date                 1    8  0
d  time                 9   14  0
d  zzzzzz              15   20  0

c/free
    now = %dec(%timestamp());
    setll date mylf;
    reade date mylf;
    dow not %eof(mylf);
       // Do your processing here.
       reade date mylf;
    enddo;
    *inlr = *on;
c/end-free

And here's a version you may be more comfortable with:

FMYLF     IF   E              K DISK

DYYYYMMDD        S               8  0
D                DS
D TIME                      1    6  0
D DATE                      7   12  0
D MM                        7    8  0
D DD                        9   10  0
D YYYY                     11   14  0
D TIMEDATE                  1   14  0

C                   TIME      TIMEDATE
C                   EVAL      YYYYMMDD = (YYYY*10000) + (MM*100) + DD
C      YYYYMMDD     SETLL     MYLF
C      YYYYMMDD     READE     MYLF                                 99
C                   DOW       *IN99 = *OFF
C* Do your processing here
C      YYYYMMDD     READE     MYLF                                 99
C                   ENDDO
C                   EVAL      *INLR = *ON

Altri suggerimenti

You could do the same logic with SQL using an HLL (SQLRPGLE) or RUNSQLSTM:

CREATE TABLE WORKFILE AS (
    SELECT *
    FROM Filename
    WHERE ORDHDT = YEAR(NOW()) * 10000 + MONTH(NOW()) * 100 + DAY(NOW())
) WITH DATA
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top