/* ************************************************************************** */
/* DBG203CL: Create .csv Streamfile                                           */
/* 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(&SOURCE &MEMBER &TARGET &COLHDG &FLDDEL +
         &RPLFLDDEL &STRDEL &RPLSTRDEL &STMFOPT +
         &STMFCODPAG &ENDLINFMT)
  DCL        VAR(&FROMFILE) TYPE(*CHAR) LEN(10)
  DCL        VAR(&LIBRARY) TYPE(*CHAR) LEN(10)
  DCL        VAR(&MEMBER) TYPE(*CHAR) LEN(10)
  DCL        VAR(&MEMBERPATH) TYPE(*CHAR) LEN(63)
  DCL        VAR(&SOURCE) TYPE(*CHAR) LEN(20)
  DCL        VAR(&TARGET) TYPE(*CHAR) LEN(250)
  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)
  DCL        VAR(&STMFCODPAG) TYPE(*CHAR) LEN(9)
  DCL        VAR(&STMFOPT) TYPE(*CHAR) LEN(8)
  DCL        VAR(&ENDLINFMT) TYPE(*CHAR) LEN(6)
/* ************************************************************************** */
/*  GLOBAL MESSAGE MONITOR                                                    */
/* ************************************************************************** */
  MONMSG     MSGID(CPF0000 RPG0000 QRG0000 RSF0000 +
               MCH0000) EXEC(GOTO CMDLBL(zzERROR))
  GOTO       CMDLBL(zzNOERROR)
zzERROR:
  MOVDIAGMSG
  MONMSG     MSGID(CPF0000)
  RSNESCMSG
  MONMSG     MSGID(CPF0000)
  RETURN
zzNOERROR:
/* ************************************************************************** */
/*  START OF MAINLINE CODE                                                    */
/* ************************************************************************** */
/* Extract the file & library names from the qualified name passed in */
  CHGVAR     VAR(&FROMFILE) VALUE(%SST(&SOURCE 1 10))
  CHGVAR     VAR(&LIBRARY) VALUE(%SST(&SOURCE 11 10))
/* Build the PC style path to the temporary AS/400 file */
  CHGVAR     VAR(&MEMBERPATH) +
               VALUE('/QSYS.LIB/QTEMP.LIB/CSV.FILE/CSV.MBR')
/* Create the .csv data in an AS/400 file to start with */
  CRTCSVDTA  FROMFILE(&LIBRARY/&FROMFILE) +
               TOFILE(QTEMP/CSV) FROMMBR(&MEMBER) +
               COLHDG(&COLHDG) FLDDEL(&FLDDEL) +
               RPLFLDDEL(&RPLFLDDEL) STRDEL(&STRDEL) +
               RPLSTRDEL(&RPLSTRDEL)
/* Copy the .csv file data to specified file & location on the IFS */
  CPYTOSTMF  FROMMBR(&MEMBERPATH) TOSTMF(&TARGET) +
               STMFOPT(&STMFOPT) CVTDTA(*AUTO) +
               DBFCCSID(*FILE) STMFCODPAG(&STMFCODPAG) +
               ENDLINFMT(&ENDLINFMT)
/* Delete the temporary file */
  DLTF       FILE(QTEMP/CSV)
ENDPGM:
  RETURN
ENDPGM

-- MartinRowe - 24 Jun 2005
Topic revision: r2 - 01 Oct 2014 - 19:37:00 - UnknownUser
 
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