/*********************************************************************/
/*                                                                   */
/* (c) Copyright IBM Corp. 1998                                      */
/* All Rights Reserved                                               */
/* Licensed Materials - Property of IBM                              */
/*                                                                   */
/* DISCLAIMER OF WARRANTIES.                                         */
/*                                                                   */
/* The following [enclosed] code is generated by a software product  */
/* of IBM Corporation.                                               */
/* This generated code is provided to you solely for the purpose of  */
/* assisting you in the development of your applications.            */
/* The code is provided "AS IS." IBM MAKES NO WARRANTIES, EXPRESS    */
/* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES   */
/* OF NONINFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR  */
/* PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF THIS CODE.      */
/* IBM shall not be liable for any damages arising out of your use   */
/* of the generated code, even if it has been advised of the         */
/* possibility of such damages.                                      */
/*                                                                   */
/* DISTRIBUTION.                                                     */
/*                                                                   */
/* This generated code can be freely distributed, copied, altered,   */
/* and incorporated into other software, provided that:              */
/*   - It bears the above Copyright notice and DISCLAIMER intact     */
/*   - The software is not offered for resale                        */
/*                                                                   */
/*********************************************************************/

/************************************************************************/
/* Generated by IMS Web Studio 2.1.1     1998.252 10:18:13 */
/* Userid:  pglezen                                     */
/* Project: test5                                 */
/************************************************************************/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "hws.h"
#include "hwstran.hpp"
#include "hwsmfsf.hpp"
#include "hwsmsgf.hpp"
#include "hwslpgf.hpp"
#include "hwssegf.hpp"
#include "hwsfldf.hpp"
#include "hwsdlist.hpp"
#include "hwslnode.hpp"
#include "HWSLPG00.hpp"
#include "HWSLPG01.hpp"

/*********************************************************/
/*                                                       */
/*  IMS Web generated transaction input class.           */
/*                                                       */
/*  This class :                                         */
/*                                                       */
/*   - provides the execute method which compiles a      */
/*     list of all attribute values and calls the server */
/*     DLL for building and passing the message to IMS.  */
/*                                                       */
/*********************************************************/

// LifeCycle
HWSLPG01In::HWSLPG01In():
   HWSTranIn("CGItest5")
{

   HWSMFSFormat   *aFmt;
   HWSMsgFormat   *aMsg;
   HWSLPageFormat *aLpg;
   HWSSegFormat   *aSeg;
   HWSFldFormat   *aFld;
   Condition   *aCond;

   aFmt = new HWSMFSFormat();

   aFmt->verLevel = HWS211;

   aFmt->forLevel = HWSFMT1;

   aFmt->convType = USENGLISH;

   aFmt->tranType = NONCONV;

   aFmt->passDataType = PASSWORDTEXT;

   aFmt->syncLevel = NONE;

   aMsg = new HWSMsgFormat("IVTNOMI1",OPT1,HWSIN);
   aMsg->nextName = (char *)malloc(sizeof("IVTNO")+1);
   strcpy(aMsg->nextName,"IVTNO");
   aFmt->addMID(aMsg);

   aCond = (Condition *)malloc(sizeof(Condition));
   aCond->MFLDName = NULL;
   aCond->pp = 0;
   aCond->op = HWSGE;
   aCond->value = NULL;
   aLpg = new HWSLPageFormat("HWSLPG01",NOCOND,aCond);
   aMsg->addLPage(aLpg);

   aSeg = new HWSSegFormat("HWSSEG01");
   aLpg->addSeg(aSeg);

   setAttr("HWSMF008","IVTNO     ");

   aFld = new HWSFldFormat("HWSMF008",FLDLIT,10);

   aFld->pp = 0;
   aFld->justify = HWSLEFT;
   aFld->fillType = HWSCHAR;
   aFld->fill = ' ';
   aFld->A3270Attr = NO3270;
   aFld->eAttr = 0;
   aFld->literalLen = 10;
   aFld->literalVal = (char *) malloc (10+1);
   memcpy(aFld->literalVal,"IVTNO     ",10);
   memset(aFld->literalVal+10, '\0', 1);

   aSeg->addFld(aFld);

   setAttr("HWSMF009",NULL);

   aFld = new HWSFldFormat("HWSMF009",STANDARD,8);

   aFld->pp = 0;
   aFld->justify = HWSLEFT;
   aFld->fillType = HWSCHAR;
   aFld->fill = ' ';
   aFld->A3270Attr = NO3270;
   aFld->eAttr = 0;
   aFld->literalLen = 0;
   aFld->literalVal = NULL;

   aSeg->addFld(aFld);

   setAttr("HWSMF00A",NULL);

   aFld = new HWSFldFormat("HWSMF00A",STANDARD,10);

   aFld->pp = 0;
   aFld->justify = HWSLEFT;
   aFld->fillType = HWSCHAR;
   aFld->fill = ' ';
   aFld->A3270Attr = NO3270;
   aFld->eAttr = 0;
   aFld->literalLen = 0;
   aFld->literalVal = NULL;

   aSeg->addFld(aFld);

   setAttr("HWSMF00B",NULL);

   aFld = new HWSFldFormat("HWSMF00B",STANDARD,10);

   aFld->pp = 0;
   aFld->justify = HWSLEFT;
   aFld->fillType = HWSCHAR;
   aFld->fill = ' ';
   aFld->A3270Attr = NO3270;
   aFld->eAttr = 0;
   aFld->literalLen = 0;
   aFld->literalVal = NULL;

   aSeg->addFld(aFld);

   setAttr("HWSMF00C",NULL);

   aFld = new HWSFldFormat("HWSMF00C",STANDARD,10);

   aFld->pp = 0;
   aFld->justify = HWSLEFT;
   aFld->fillType = HWSCHAR;
   aFld->fill = ' ';
   aFld->A3270Attr = NO3270;
   aFld->eAttr = 0;
   aFld->literalLen = 0;
   aFld->literalVal = NULL;

   aSeg->addFld(aFld);

   setAttr("HWSMF00D",NULL);

   aFld = new HWSFldFormat("HWSMF00D",STANDARD,7);

   aFld->pp = 0;
   aFld->justify = HWSLEFT;
   aFld->fillType = HWSCHAR;
   aFld->fill = ' ';
   aFld->A3270Attr = NO3270;
   aFld->eAttr = 0;
   aFld->literalLen = 0;
   aFld->literalVal = NULL;

   aSeg->addFld(aFld);

   aMsg = new HWSMsgFormat("IVTNO",OPT1,HWSOUT);
   aMsg->nextName = (char *)malloc(sizeof("IVTNOMI1")+1);
   strcpy(aMsg->nextName,"IVTNOMI1");
   aFmt->addMOD(aMsg);

   aCond = (Condition *)malloc(sizeof(Condition));
   aCond->MFLDName = NULL;
   aCond->pp = 0;
   aCond->op = HWSGE;
   aCond->value = NULL;
   aLpg = new HWSLPageFormat("HWSLPG00",NOCOND,aCond);
   aMsg->addLPage(aLpg);

   aSeg = new HWSSegFormat("HWSSEG00");
   aLpg->addSeg(aSeg);

   aFld = new HWSFldFormat("HWSMF000",STANDARD,40);

   aFld->pp = 0;
   aFld->justify = HWSLEFT;
   aFld->fillType = HWSCHAR;
   aFld->fill = ' ';
   aFld->A3270Attr = NO3270;
   aFld->eAttr = 0;
   aFld->literalLen = 0;
   aFld->literalVal = NULL;

   aSeg->addFld(aFld);

   aFld = new HWSFldFormat("HWSMF001",STANDARD,8);

   aFld->pp = 0;
   aFld->justify = HWSLEFT;
   aFld->fillType = HWSCHAR;
   aFld->fill = ' ';
   aFld->A3270Attr = NO3270;
   aFld->eAttr = 0;
   aFld->literalLen = 0;
   aFld->literalVal = NULL;

   aSeg->addFld(aFld);

   aFld = new HWSFldFormat("HWSMF002",STANDARD,10);

   aFld->pp = 0;
   aFld->justify = HWSLEFT;
   aFld->fillType = HWSCHAR;
   aFld->fill = ' ';
   aFld->A3270Attr = NO3270;
   aFld->eAttr = 0;
   aFld->literalLen = 0;
   aFld->literalVal = NULL;

   aSeg->addFld(aFld);

   aFld = new HWSFldFormat("HWSMF003",STANDARD,10);

   aFld->pp = 0;
   aFld->justify = HWSLEFT;
   aFld->fillType = HWSCHAR;
   aFld->fill = ' ';
   aFld->A3270Attr = NO3270;
   aFld->eAttr = 0;
   aFld->literalLen = 0;
   aFld->literalVal = NULL;

   aSeg->addFld(aFld);

   aFld = new HWSFldFormat("HWSMF004",STANDARD,10);

   aFld->pp = 0;
   aFld->justify = HWSLEFT;
   aFld->fillType = HWSCHAR;
   aFld->fill = ' ';
   aFld->A3270Attr = NO3270;
   aFld->eAttr = 0;
   aFld->literalLen = 0;
   aFld->literalVal = NULL;

   aSeg->addFld(aFld);

   aFld = new HWSFldFormat("HWSMF005",STANDARD,7);

   aFld->pp = 0;
   aFld->justify = HWSLEFT;
   aFld->fillType = HWSCHAR;
   aFld->fill = ' ';
   aFld->A3270Attr = NO3270;
   aFld->eAttr = 0;
   aFld->literalLen = 0;
   aFld->literalVal = NULL;

   aSeg->addFld(aFld);

   aFld = new HWSFldFormat("HWSMF006",STANDARD,4);

   aFld->pp = 0;
   aFld->justify = HWSLEFT;
   aFld->fillType = HWSCHAR;
   aFld->fill = ' ';
   aFld->A3270Attr = NO3270;
   aFld->eAttr = 0;
   aFld->literalLen = 0;
   aFld->literalVal = NULL;

   aSeg->addFld(aFld);

   aFld = new HWSFldFormat("HWSMF007",SLITDAT2,8);

   aFld->pp = 0;
   aFld->justify = HWSLEFT;
   aFld->fillType = HWSCHAR;
   aFld->fill = ' ';
   aFld->A3270Attr = NO3270;
   aFld->eAttr = 0;
   aFld->literalLen = 8;

   aSeg->addFld(aFld);

   formatObj = aFmt;

}

HWSLPG01In::~HWSLPG01In()
{
}

// Overloaded Method
HWSTranOut * HWSLPG01In::execute()
{
   HWSTranOut * aMod = NULL;
   HWSTranOut * pMod = NULL;
   HWSTranOut * qMod = NULL;
   HWSTran    aTran(this);
   HWSDList   * pList;
   HWSDList   * qList;
   int errNum = 0;

   pList = aTran.doIMS(export(),formatObj);

   if (pList) {
      while (pList) {
         if (strcmp(pList->MDName,"HWSErrOut") == 0) {
            pMod = new HWSErrOut(pList);
         } else if (strcmp(pList->MDName,"IVTNO&HWSLPG00") == 0) {
            pMod = new HWSLPG00Out(pList);
            pMod->userName = userName;
            pMod->groupName = groupName;
            pMod->password = password;
            pMod->hostName = hostName;
            pMod->imsName = imsName;
            pMod->port = hostPort;
         } else if (strcmp(pList->MDName,"DFSMO1&HWSMO1") == 0) {
            pMod = new HWSMO1(pList);
         } else if (strcmp(pList->MDName,"DFSMO2&HWSMO2") == 0) {
            pMod = new HWSMO2(pList);
         } else if (strcmp(pList->MDName,"DFSMO3&HWSMO3") == 0) {
            pMod = new HWSMO3(pList);
         } else if (strcmp(pList->MDName,"DFSMO4&HWSMO4") == 0) {
            pMod = new HWSMO4(pList);
         } else if (strcmp(pList->MDName,"DFSMO5&HWSMO5") == 0) {
            pMod = new HWSMO5(pList);
         } else if (strcmp(pList->MDName,"DFSDSPO1&HWSDSPO1") == 0) {
            pMod = new HWSDSPO1(pList);
         } else {
            pMod = new HWSErrOut(1000,"AN UNKNOWN MOD RETURNED BY HOST");
         } /* end if */
         if (!aMod) aMod = pMod;
         if (qMod) qMod->setNext(pMod);
         qMod = pMod;
         qList = pList;
         pList = qList->getNextList();
      } /* end while */
   } else {
      pMod = new HWSErrOut(1001,"SEVERE ERROR NULL RETURNED FROM DLLs");
   } /* end if */

   return (aMod);

}

