× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Externally define the data structure as EXTNAME(recordformat) 

Define a standalone field as LIKE(DATASRUCTURE)

Use the standalone field and the data structure for the compare.

Use some key, any key, to at least group the records in some small way.
 
Clear your array when the keys change.

Use select instead of ifs.
 
 
---------------------------------------------------------
Booth Martin   http://www.MartinVT.com
Booth@xxxxxxxxxxxx
---------------------------------------------------------
 
-------Original Message-------
 
From: RPG programming on the AS400 / iSeries
Date: 01/19/04 16:25:52
To: RPG400-L@xxxxxxxxxxxx
Subject: Store Record Format in an Array
 
Hello:
 
I would like my program to delete duplicate records in a file.  I'm trying
to:
 
1) READ A RECORD
 
2) STORE THAT RECORD IN A DATA STRUCTURE
 
3) COMPARE DATA STRUCTURE AGAINST ARRAY THAT HOLDS RECORDS ALREADY READ
FROM FILE
      -Delete any matches found
      -Add Array Element if no matches found
 
If there is any easier way to program this, I'd like to hear it.  Any ideas
or help would be appreciated.
 
Thanks,
 
Frank
 
      * ----------
      * Files Used
      * ----------
     FUSERTIME  UF   E           K DISK
 
      *
FWK5 D Z               S              4S 0
FWK5 D Y               S              4S 0
 
      *
      * ---------
      * RECORD_DS
      * ---------
     D RECORD_DS       DS
     D  DSCMPLNT#                          LIKE(CMPLNT#)
     D  DSOT                               LIKE(OT)
     D  DSPRO                              LIKE(PRO)
     D  DSCMPLNTCD                         LIKE(CMPLNTCD)
     D  DSCUSTRESP                         LIKE(CUSTRESP)
     D  DSCUSTNAM                          LIKE(CUSTNAM)
     D  DSRESPVIA                          LIKE(RESPVIA)
     D  DSINVSTBY                          LIKE(INVSTBY)
     D  DSSUB_UNSUB                        LIKE(SUB_UNSUB)
     D  DSROOT1                            LIKE(ROOT1)
     D  DSROOT1DESC                        LIKE(ROOT1DESC)
     D  DSROOT2                            LIKE(ROOT2)
     D  DSROOT2DESC                        LIKE(ROOT2DESC)
     D  DSROOT3                            LIKE(ROOT3)
     D  DSROOT3DESC                        LIKE(ROOT3DESC)
     D  DSROOT4                            LIKE(ROOT4)
     D  DSROOT4DESC                        LIKE(ROOT4DESC)
     D  DSROOT5                            LIKE(ROOT5)
     D  DSROOT5DESC                        LIKE(ROOT5DESC)
     D  DSOTHER_ROOT                       LIKE(OTHER_ROOT)
     D  DSSUPP_CORP                        LIKE(SUPP_CORP)
     D  DSSUPPCORPD1                       LIKE(SUPPCORPD1)
     D  DSSUPPCORPD2                       LIKE(SUPPCORPD2)
     D  DSOTHERCONT1                       LIKE(OTHERCONT1)
     D  DSOTHERCONT2                       LIKE(OTHERCONT2)
     D  DSACTTAKE                          LIKE(ACTTAKE)
     D  DSCUSTCONT                         LIKE(CUSTCONT)
     D  DSCLOSECMP                         LIKE(CLOSECMP)
     D  DSEMAILSVC                         LIKE(EMAILSVC)
     D  DSCLOSED_BY                        LIKE(CLOSED_BY)
     D  DSCLOSED_DT                        LIKE(CLOSED_DT)
     D  DSCLOSED_TM                        LIKE(CLOSED_TM)
     D  DSRESO_VERI                        LIKE(RESO_VERI)
     D  DSLNGTRMRESO                       LIKE(LNGTRMRESO)
     D  DSCSTPHN                           LIKE(CSTPHN)
     D  DSCSTPHX                           LIKE(CSTPHX)
     D  DSCALLBK                           LIKE(CALLBK)
     D  DSISSDTL                           LIKE(ISSDTL)
     D  DSCODAMT                           LIKE(CODAMT)
     D  DSINQCOD                           LIKE(INQCOD)
     D  DSDSPCOD                           LIKE(DSPCOD)
     D  DSDSPAMT                           LIKE(DSPAMT)
     D  DSDSPFND                           LIKE(DSPFND)
     D  DSFNDAMT                           LIKE(FNDAMT)
     D  DSOTHCOD                           LIKE(OTHCOD)
     D  DSOTHEXP                           LIKE(OTHEXP)
     D  DSOT2                              LIKE(OT2)
     D  DSPRO2                             LIKE(PRO2)
     D  DSNUMPCS                           LIKE(NUMPCS)
     D  DSLABDS1                           LIKE(LABDS1)
     D  DSLABDS2                           LIKE(LABDS2)
     D  DSFRTDES                           LIKE(FRTDES)
     D  DSSHPSHT                           LIKE(SHPSHT)
     D  DSCSTFAX                           LIKE(CSTFAX)
 
      *
      * ---------
      * RECORD_AR
      * ---------
     D RECORD_AR                           DIM(9999) OVERLAY(RECORD_DS)
 
      *
      * --------
      * BLANK_DS
      * --------
     D BLANK_DS        DS
     D  BDCMPLNT#                          LIKE(CMPLNT#)    INZ(0)
     D  BDOT                               LIKE(OT)         INZ(0)
     D  BDPRO                              LIKE(PRO)        INZ(0)
     D  BDCMPLNTCD                         LIKE(CMPLNTCD)   INZ(*BLANKS)
     D  BDCUSTRESP                         LIKE(CUSTRESP)   INZ(*BLANKS)
     D  BDCUSTNAM                          LIKE(CUSTNAM)    INZ(*BLANKS)
     D  BDRESPVIA                          LIKE(RESPVIA)    INZ(*BLANKS)
     D  BDINVSTBY                          LIKE(INVSTBY)    INZ(*BLANKS)
     D  BDSUB_UNSUB                        LIKE(SUB_UNSUB)  INZ(*BLANKS)
     D  BDROOT1                            LIKE(ROOT1)      INZ(*BLANKS)
     D  BDROOT1DESC                        LIKE(ROOT1DESC)  INZ(*BLANKS)
     D  BDROOT2                            LIKE(ROOT2)      INZ(*BLANKS)
     D  BDROOT2DESC                        LIKE(ROOT2DESC)  INZ(*BLANKS)
     D  BDROOT3                            LIKE(ROOT3)      INZ(*BLANKS)
     D  BDROOT3DESC                        LIKE(ROOT3DESC)  INZ(*BLANKS)
     D  BDROOT4                            LIKE(ROOT4)      INZ(*BLANKS)
     D  BDROOT4DESC                        LIKE(ROOT4DESC)  INZ(*BLANKS)
     D  BDROOT5                            LIKE(ROOT5)      INZ(*BLANKS)
     D  BDROOT5DESC                        LIKE(ROOT5DESC)  INZ(*BLANKS)
     D  BDOTHER_ROOT                       LIKE(OTHER_ROOT) INZ(*BLANKS)
     D  BDSUPP_CORP                        LIKE(SUPP_CORP)  INZ(*BLANKS)
     D  BDSUPPCORPD1                       LIKE(SUPPCORPD1) INZ(*BLANKS)
     D  BDSUPPCORPD2                       LIKE(SUPPCORPD2) INZ(*BLANKS)
     D  BDOTHERCONT1                       LIKE(OTHERCONT1) INZ(*BLANKS)
     D  BDOTHERCONT2                       LIKE(OTHERCONT2) INZ(*BLANKS)
     D  BDACTTAKE                          LIKE(ACTTAKE)    INZ(*BLANKS)
     D  BDCUSTCONT                         LIKE(CUSTCONT)   INZ(*BLANKS)
     D  BDCLOSECMP                         LIKE(CLOSECMP)   INZ(*BLANKS)
     D  BDEMAILSVC                         LIKE(EMAILSVC)   INZ(*BLANKS)
     D  BDCLOSED_BY                        LIKE(CLOSED_BY)  INZ(*BLANKS)
     D  BDCLOSED_DT                        LIKE(CLOSED_DT)  INZ(0)
     D  BDCLOSED_TM                        LIKE(CLOSED_TM)  INZ(0)
     D  BDRESO_VERI                        LIKE(RESO_VERI)  INZ(*BLANKS)
     D  BDLNGTRMRESO                       LIKE(LNGTRMRESO) INZ(*BLANKS)
     D  BDCSTPHN                           LIKE(CSTPHN)     INZ(*BLANKS)
     D  BDCSTPHX                           LIKE(CSTPHX)     INZ(*BLANKS)
     D  BDCALLBK                           LIKE(CALLBK)     INZ(*BLANKS)
     D  BDISSDTL                           LIKE(ISSDTL)     INZ(*BLANKS)
     D  BDCODAMT                           LIKE(CODAMT)     INZ(0)
     D  BDINQCOD                           LIKE(INQCOD)     INZ(*BLANKS)
     D  BDDSPCOD                           LIKE(DSPCOD)     INZ(*BLANKS)
     D  BDDSPAMT                           LIKE(DSPAMT)     INZ(0)
     D  BDDSPFND                           LIKE(DSPFND)     INZ(*BLANKS)
     D  BDFNDAMT                           LIKE(FNDAMT)     INZ(*BLANKS)
     D  BDOTHCOD                           LIKE(OTHCOD)     INZ(*BLANKS)
     D  BDOTHEXP                           LIKE(OTHEXP)     INZ(*BLANKS)
     D  BDOT2                              LIKE(OT2)        INZ(0)
     D  BDPRO2                             LIKE(PRO2)       INZ(0)
     D  BDNUMPCS                           LIKE(NUMPCS)     INZ(0)
     D  BDLABDS1                           LIKE(LABDS1)     INZ(*BLANKS)
     D  BDLABDS2                           LIKE(LABDS2)     INZ(*BLANKS)
     D  BDFRTDES                           LIKE(FRTDES)     INZ(*BLANKS)
     D  BDSHPSHT                           LIKE(SHPSHT)     INZ(*BLANKS)
     D  BDCSTFAX                           LIKE(CSTFAX)     INZ(*BLANKS)
 
      *
      * --------------------------------------------------
      * Find and Delete Duplicate Records in USERTIME file
      * --------------------------------------------------
FWK5 C     *LOVAL        SETLL     USERTIME
 |   C                   DOU       %EOF(USERTIME)
 |   C                   READ      USERTIME
 |   C                   IF        %EOF(USERTIME)
 |   C                   LEAVE
 |   C                   ENDIF
 |    *
 |    * Move Record into Data Structure
 |   C                   MOVE      RUSERTIM      RECORD_DS
 |    *
 |    * Find out if Record Already Exists
 |   C     1             DO        999           Z
 |    *
 |    * Last Array Element Processing
 |   C                   IF        Z = 999 AND (RECORD_AR(Z) <> RECORD_DS)
 |   C     1             DO        999           Y
 |    *
 |    * Store Record in First Blank Array Element
 |    * Array Element Isn't Blank; Get Next Array Element
 |   C                   IF        RECORD_AR(Y) <> BLANK_DS
 |   C                   ITER
 |   C                   ENDIF
 |    * Blank Array Element; Store Record in Array; Leave Loop
 |   C                   IF        RECORD_AR(Y) = BLANK_DS
 |   C                   EVAL      RECORD_AR(Y) = RECORD_DS
 |   C                   LEAVE
 |   C                   ENDIF
 |   C                   ENDDO
 |   C                   ENDIF
 |    *
 |    * Record NOT-Equal to Array Element; Get next Array Element
 |   C                   IF        RECORD_AR(Z) <> RECORD_DS
 |   C                   ITER
 |   C                   ENDIF
 |    *
 |    * Record Equal to Array Element; Delete Record; Leave Loop
 |   C                   IF        RECORD_AR(Z) = RECORD_DS
 |   C                   DELETE    RUSERTIM
 |   C                   LEAVE
 |   C                   ENDIF
 |    *
 |   C                   ENDDO
 |    * 1 DO 999 Z
 |    *
FWK5 C                   ENDDO
      * DOU %EOF(USERTIME)
 

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.