cim load for36.4.17.5 Label Detail Maintenance


{mfdeclre.i}
DEFINE VARIABLE m_file_path         AS CHARACTER FORMAT "x(50)" NO-UNDO INITIAL "/home/mfg/" .
DEFINE VARIABLE m_csv_file          AS CHARACTER FORMAT "x(50)" NO-UNDO INITIAL "Demo2.csv".
DEFINE VARIABLE m_cim_file          AS CHARACTER FORMAT "x(40)" NO-UNDO.
DEFINE VARIABLE m_out_file          AS CHARACTER FORMAT "x(40)" NO-UNDO.
DEFINE VARIABLE m_cim_errline       AS CHARACTER FORMAT "x(75)".
DEFINE VARIABLE m_cim_err           AS CHARACTER NO-UNDO INITIAL NO.
DEFINE VARIABLE m_cim_errdesc       AS CHARACTER NO-UNDO FORMAT "x(85)".

DEFINE TEMP-TABLE tt_label
    FIELD tt_field      AS  CHARACTER FORMAT "x(80)"
    FIELD tt_program    AS  CHARACTER FORMAT "x(80)"
    FIELD tt_term       AS  CHARACTER FORMAT "x(80)"
   /* FIELD tt_long       AS  CHARACTER FORMAT "x(80)"
    FIELD tt_short      AS  CHARACTER FORMAT "x(80)"
    FIELD tt_small      AS  CHARACTER FORMAT "x(80)"
    FIELD tt_stack      AS  CHARACTER FORMAT "x(80)"*/
    FIELD tt_err        AS  CHARACTER FORMAT "x(50)"
    FIELD tt_errdesc    AS  CHARACTER FORMAT "x(50)" .


FORM
    m_file_path     COLON 25    LABEL "Input/Output Path"
    m_csv_file      COLON 25    LABEL "CSV File Name"
    WITH FRAME a SIDE-LABELS.

EMPTY TEMP-TABLE tt_label.
REPEAT:
    UPDATE
        m_file_path        
        m_csv_file        
    WITH FRAME a.

    FOR EACH tt_label:
        DELETE tt_label.
    END.

    INPUT FROM VALUE (m_file_path + m_csv_file).
    REPEAT:
            CREATE tt_label.
            IMPORT DELIMITER "," tt_label.
    END.
    INPUT CLOSE.

    FOR EACH tt_label :
        m_cim_file = tt_field + tt_term + ".cim".               /*SG1*/ /* Add tt_term */
        m_out_file = REPLACE(m_cim_file,"cim","out") NO-ERROR.
        OUTPUT TO VALUE(m_file_path +  m_cim_file).

        PUT UNFORMATTED
            string('"' + tt_field + '"') SPACE
            string('"' + tt_program + '"') SPACE .
        PUT SKIP.
        PUT
            string('"' + tt_term + '"')  FORMAT "x(80)" SPACE
           /* string('"' + tt_long + '"')  FORMAT "x(80)" SPACE
            string('"' + tt_short + '"') SPACE
            string('"' + tt_small + '"')  SPACE
            string('"' + tt_stack + '"') FORMAT "x(80)" SPACE*/
            "." SKIP.


       OUTPUT CLOSE.
       cimloop:
           DO TRANSACTION ON ERROR UNDO cimloop, LEAVE cimloop:
             
               OUTPUT TO  VALUE(m_file_path  + m_out_file).    
             
               INPUT FROM VALUE(m_file_path  + m_cim_file).
         
               {gprun.i ""gplbldmt.p""}
                 
               INPUT  CLOSE.                              
               OUTPUT CLOSE.
               INPUT FROM VALUE(m_file_path  + m_out_file).    
               REPEAT:                                    
                   ASSIGN                                
                       m_cim_errline = "".                

                   IMPORT UNFORMATTED m_cim_errline.      
                   IF INDEX(m_cim_errline,"**")    <> 0 OR
                   INDEX(m_cim_errline,"ERROR")    <> 0 THEN
                   DO:
                       OUTPUT TO  VALUE(m_file_path + "error.err") APPEND.
                       PUT tt_field tt_program tt_term m_cim_errline SKIP.              /*SG1*/ /* Add m_cim_errline*/
                       OUTPUT CLOSE.
                       ASSIGN                            
                           m_cim_err = "YES"              
                           m_cim_errdesc = m_cim_errline  NO-ERROR.
                           LEAVE.                      
                   END.  /* end of index */
               END.      /* End of Repeat*/                    
               INPUT  CLOSE.
               IF m_cim_err = "YES" THEN UNDO cimloop, LEAVE cimloop.
               ELSE                                          
               DO:
                   m_cim_err = "NO".
                    OS-DELETE VALUE(m_file_path + m_cim_file).
                   OS-DELETE VALUE(m_file_path  + m_out_file).
                 END.  /* m_cim_err */    
           END. /*DO*/
           ASSIGN
                  tt_err       =   m_cim_err
                  tt_errdesc   =   m_cim_errdesc.
     

    END. /*For each*/
    MESSAGE "Procedure complete" .
END. /*repeat*/

Comments

Popular posts from this blog

Progress 4GL interview questions for QAD technology

QAD interview questions for SE and Eb2 version

Use of API in QAD EE