/* ************************************************************************** */
/* DBG201CL: External to flat file .csv conversion                            */
/* Copyright (C) 2001  Martin Rowe  <martin@dbg400.net>                       */
/*                                                                            */
/* This program is free software; you can redistribute it and/or modify       */
/* it under the terms of the GNU General Public License as published by       */
/* the Free Software Foundation; either version 2 of the License, or          */
/* (at your option) any later version.                                        */
/*                                                                            */
/* This program is distributed in the hope that it will be useful,            */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of             */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              */
/* GNU General Public License for more details.                               */
/*                                                                            */
/* You should have received a copy of the GNU General Public License          */
/* along with this program; if not, write to the Free Software                */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307   USA */
/* ************************************************************************** */
PGM PARM(&QUALFROM &QUALTO &FROMMBR &TOMBR &MBROPT &COLHDG &FLDDEL &RPLFLDDEL +
               &STRDEL &RPLSTRDEL)
  DCL        VAR(&QUALFROM) TYPE(*CHAR) LEN(20)
  DCL        VAR(&FROMFILE) TYPE(*CHAR) LEN(10)
  DCL        VAR(&FROMLIB) TYPE(*CHAR) LEN(10)
  DCL        VAR(&FROMMBR) TYPE(*CHAR) LEN(10)
  DCL        VAR(&QUALTO) TYPE(*CHAR) LEN(20)
  DCL        VAR(&TOFILE) TYPE(*CHAR) LEN(10)
  DCL        VAR(&TOLIB) TYPE(*CHAR) LEN(10)
  DCL        VAR(&TOMBR) TYPE(*CHAR) LEN(10)
  DCL        VAR(&RTNLIB) TYPE(*CHAR) LEN(10)
  DCL        VAR(&MBROPT) TYPE(*CHAR) LEN(8)
  DCL        VAR(&COLHDG) TYPE(*CHAR) LEN(7)
  DCL        VAR(&FLDDEL) TYPE(*CHAR) LEN(1)
  DCL        VAR(&RPLFLDDEL) TYPE(*CHAR) LEN(1)
  DCL        VAR(&STRDEL) TYPE(*CHAR) LEN(1)
  DCL        VAR(&RPLSTRDEL) TYPE(*CHAR) LEN(1)

  CHGVAR     VAR(&FROMFILE) VALUE(%SST(&QUALFROM 1 10))
  CHGVAR     VAR(&FROMLIB) VALUE(%SST(&QUALFROM 11 10))
  CHGVAR     VAR(&TOFILE) VALUE(%SST(&QUALTO 1 10))
  CHGVAR     VAR(&TOLIB) VALUE(%SST(&QUALTO 11 10))
/* Create file to hold .csv data if not there (or add member if reqd)         */
  CHKOBJ     OBJ(&TOLIB/&TOFILE) OBJTYPE(*FILE) MBR(&TOMBR)
  MONMSG     MSGID(CPF9801) EXEC(CRTPF +
               FILE(&TOLIB/&TOFILE) RCDLEN(5000) +
               SIZE(*NOMAX))

  MONMSG     MSGID(CPF9815) EXEC(ADDPFM +
               FILE(&TOLIB/&TOFILE) MBR(&TOMBR))

  IF         COND(&MBROPT *EQ '*REPLACE') THEN(CLRPFM +
               FILE(&TOLIB/&TOFILE) MBR(&TOMBR))

/* Get the actual library of the from file if not specified                   */
  IF         COND(&FROMLIB *EQ '*LIBL') THEN(DO)
    RTVOBJD    OBJ(*LIBL/&FROMFILE) OBJTYPE(*FILE) +
                 RTNLIB(&RTNLIB)
    CHGVAR     VAR(&FROMLIB) VALUE(&RTNLIB)
  ENDDO

  OVRDBF     FILE(INFILE) TOFILE(&FROMLIB/&FROMFILE) +
               MBR(&FROMMBR)
  OVRDBF     FILE(DBGCSV00) TOFILE(&TOLIB/&TOFILE) +
               MBR(&TOMBR)
  CALL       PGM(DBG201R4) PARM(&FROMFILE &FROMLIB &COLHDG +
               &FLDDEL &RPLFLDDEL &STRDEL &RPLSTRDEL)
  DLTOVR     FILE(INFILE DBGCSV00)
ENDPGM:
  RETURN
ENDPGM

-- MartinRowe - 24 Jun 2005


This topic: DBG400 > SourceCodeList > ClSource > ClDBG201CL
Topic revision: r1 - 24 Jun 2005 - 05:18:06 - MartinRowe
 
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding DBG/400? Send feedback