H DFTACTGRP(*NO) BNDDIR('ERPGSDK')                                                             
      **********************************************************************                        
     FCATLNK2   IF   E           K DISK    USROPN                                                   
     FITEMPF    IF   E           K DISK    USROPN                                                   
      ****************************************************************                              
      * Prototypes                                                   *                              
      ****************************************************************                              
      /COPY QCOPYSRC,P.ERPGSDK                                                                      
      /COPY QCOPYSRC,P.STRING                                                                       
      ****************************************************************                              
     D DftPath         S             64    INZ('/www/erpgsdk/catalog+                               
     D                                          /templates/')                                       
      *                                                                                             
      * Data read in from Web Page                                                                  
     D cat             S                   Like(CLCAT)                                              
      *                                                                                             
      * Work variables                                                                              
     D CatArr          S              5  0 DIM(9999)                                                
      *                                                                                             
     D CatCount        S             10i 0                                                          
     D LastCat         S              5  0                                                          
     D i               S             10i 0                                                          
     D DidWrite        S               N                                                            
      **********************************************************************                        
     C                   callp     #startup                                                         
      *                                                                                             
     C                   EXSR      $Input                                                           
      *                                                                                             
     C                   callp     #setPath(DftPath)                                                
     C                   callp     #loadTemplate('cat0002.erpg')                                    
     C                   callp     #writeThisSec('first')                                           
     C                   EXSR      $ListProds                                                       
     C                   callp     #cleanup                                                         
      *                                                                                             
     C                   SETON                                        LR                            
      ****************************************************************                              
      * List Products for Catalog                                    *                              
      ****************************************************************                              
     C     $ListProds    BEGSR                                                                      
      *                                                                                             
     C                   OPEN      CATLNK2                              99                          
     C                   OPEN      ITEMPF                               98                          
      *                                                                                             
     C                   if        (not *IN99) and (not *IN98)                                      
     C                   callp     #loadSection('prods')                                            
      *                                                                                             
     C     LastCat       SETLL     CATLNK2                                                          
     C     LastCat       READE     CATLNK2                                                          
      *                                                                                             
     C                   dow       (not %eof(CATLNK2))                                              
      *                                                                                             
     C                   if        (not DidWrite)                                                   
     C                   callp     #writeThisSec('prodfirst')                                       
     C                   endif                                                                      
      *                                                                                             
     C     CLPROD        CHAIN     ITEMPF                                                           
      *                                                                                             
     C                   if        (not %found(ITEMPF))                                             
     C                   CLEAR     *ALL          RITEM                                              
     C                   eval      ITITEM = CLPROD                                                  
     C                   eval      ITIDESC = 'Not Found!'                                           
     C                   endif                                                                      
      *                                                                                             
     C                   callp     #replaceData('/%prod%/':ITITEM)                                  
     C                   callp     #replaceData('/%proddesc%/':ITIDESC)                             
     C                   callp     #replaceData('/%longdesc%/':ITLONGD)                             
     C                   callp     #replaceData('/%price%/':                                        
     C                                          %editc(ITPRICE:'L'))                                
     C                   callp     #replaceData('/%imgpath%/':ITIMGLOC)                             
     C                   callp     #writeSection                                                    
      *                                                                                             
     C                   eval      DidWrite = *ON                                                   
     C     LastCat       READE     CATLNK2                                                          
     C                   enddo                                                                      
      *                                                                                             
     C                   if        (DidWrite)                                                       
     C                   callp     #writeThisSec('prodlast')                                        
     C                   endif                                                                      
      *                                                                                             
     C                   CLOSE     CATLNK2                                                          
     C                   CLOSE     ITEMPF                                                           
     C                   else                                                                       
     C                   callp     #writeThisSec('fileerror')                                       
     C                   endif                                                                      
      *                                                                                             
     C                   ENDSR                                                                      
      ****************************************************************                              
      * Read Input from web page                                     *                              
      ****************************************************************                              
     C     $Input        BEGSR                                                                      
      *                                                                                             
     C                   eval      i = 1                                                            
     C                   eval      cat = #CtoN(#getData('cat':i))                                   
      *                                                                                             
     C                   dow       (cat <> 0)                                                       
     C                   eval      CatCount = (CatCount + 1)                                        
     C                   eval      CatArr(CatCount) = cat                                           
     C                   eval      LastCat = cat                                                    
     C                   eval      i = (i + 1)                                                      
     C                   eval      cat = #CtoN(#getData('cat':i))                                   
     C                   enddo                                                                      
      *                                                                                             
     C                   ENDSR