Friday, October 11, 2019

CODE Generation - Upgrade/Conversion Project - Part 2

CODE Generation - Upgrade/Conversion Project - Part 1

Continuing with Part 2:

From my LinkedIn Projects List:

PeopleSoft/SQR Dynamic Conversion Code Generation - Unilever/Best Foods - May 2001
Developed Dynamic SQR Conversion Code Generation Tool for Unilever/Best Foods Acquisition & Merger to single PeopleSoft HR/Benefits/Payroll System. Using PeopleTools Meta-Data the Code Generator accounts for structural differences between Best Foods Source/Unilever Target (Version/Customization Delta) & produces full ready-to-run conversion programs for each record (with sections for special data transformations if needed). *Original Project Requirement was to merge Best Foods 7.5 data to Unilever's Upgraded 8.0 database. When the upgrade was placed on hold the focus was then a 7.5 to 7.5 merger - the Code Generation Tool reproduced the full set of Conversions in less than an hour followed by immediate testing. A major project alteration was hardly a blip on the timeline due to this unique approach.


In Part 1 I highlighted the Source/Target Upgrade Analyzer which detects the deltas between the two databases - either due to 7.5 to 8.0 upgrade or client-derived customizations. This part will focus on the Dynamic Conversion Code Generation of all required tables.

As mentioned in Part 1 the Upgrade Analyzer (TDUPGREC.SQC) is the backbone of the process - it detects the differences between the Source & Target records & stores the characteristics of each. It provides the blueprint for the Code Generation module TD80GEN.SQC.

Each record to convert may require a different conversion method depending on the types of data fields it contains or data mapping requirements. For example, a record with a long character field cannot be inserted directly into the target - an additional update is required after the initial insert. So, for each record a specific type may be selected.

4 methods are available (A thru D) that may be selected within a prompt (below) or connected to each specific RECNAME contained in a file. Driver programs XX80UPX%.SQR are used to launch the Code Generation process (See Part 1).

!**********************************************************************
!*       GEN Method Prompt                                            *
!**********************************************************************
!*                                                                    *
!*        INPUT: n/a        - Prompt for Input                        *
!*       OUTPUT: n/a        - Set Global Variable $GENmethod          *
!*                                                                    *
!**********************************************************************

begin-procedure GEN-Method-Prompt LOCAL

let $RC_meth   = ''

while $RC_meth = ''

   display ' '
   display 'GENERATE Methods'
   display '================'
   display ' '
   display 'A - Select/Insert  (Row-By-Row)'
   display 'B - Direct Insert  (Source to Target)'
   display 'C - Create/Insert  (Source to TEMP to Target)'
   display 'D - Create/Mapping (Source to TEMP/Mapping to Target)'
   display ' '

   input $RC_meth maxlen=1 'Enter Method (A/B/C/D)'

   uppercase $RC_meth

   if instr('ABCD', $RC_meth, 1) = 0
      let $RC_meth               = ''
   end-if

end-while

display $RC_meth

let $_GENmethod = $RC_meth

end-procedure

!**********************************************************************


The different method selections determine the coding structure that is generated. Option C & D are the most complex - they create temp tables, adjust for long character fields & provide a means of adding some special mapping or custom routines to the generated code.

Below is a portion of the Prompt-Based Driver Module TD80UPXA.SQR - it prompts for a DBLink Method, Code Method (explained previously), DB Link Name and RECNAME then builds the code.

You can see it calls the Main Code Generation function GEN-Main() which in turn will call the Upgrade Analyzer function UPG-Main().  All the components are designed in a clear integrated fashion.

...
  let #O_no            = 1

  do IO-Func('O', #O_no, 'O', 'Y', $O_file, #O_stat)

  if  #O_stat          = 0

      open $O_file as #O_no for-writing record=500 status=#O_stat

      let $RC_log      = 'Y'        ! SubRecord Analyzer Log - ON
      let $RC_rpt      = 'BREAK'    ! Report - Break on Recname

      do UPG-Pull-Prompt($RC_pull)  ! Prompt for PUSH or PULL Method
      do UPG-Alias-Prompt           ! Prompt for Alias Conversion

      input $RC_link 'Enter Database Link (i.e. @HTRY)'
      input $RC_rec  'Enter RECNAME (i.e. JOB)'

      do GEN-Shell-Beg(#O_no, $O_file, $RC_link, $RC_pull)

      !   Process Record(s)

      while $RC_rec   <> ''

         uppercase $RC_rec

         input $RC_syn 'Enter SYNONYM (i.e. A, B, X, etc)'

         uppercase $RC_syn

         do GEN-Method-Prompt
         do GEN-Main($RC_link, $RC_pull, $RC_rec, $RC_syn, $RC_log, $RC_rpt, #O_no)

         input $RC_rec 'Enter RECNAME (i.e. JOB)'

      end-while

      do GEN-Func-End(#O_no)

      do GEN-Shell-End(#O_no)

      close #O_no

  end-if

...

And now the main Code Generation function - GEN-Main() which calls the UPG-Main() function for the Upgrade Analyzer Blueprint.

!**********************************************************************
!*       GEN Main                                                     *
!**********************************************************************
!*                                                                    *
!*        INPUT: $I_link    - Database Link (or null)                 *
!*               $I_pull    - DB Link Method: Y = PULL / N = PUSH.    *
!*               $I_rec     - Primary Recname                         *
!*               $I_syn     - Synonym Prefix                          *
!*               $I_log     - Subrecord Analyzer Log Option (Y/N)     *
!*               $I_rpt     - Report Option (NONE/BREAK/SKIP)         *
!*               #I_no      - Output File Handle                      *
!*       OUTPUT: n/a        - Launch Upgrade Code Generator           *
!*                                                                    *
!**********************************************************************

begin-procedure GEN-Main($I_link, $I_pull, $I_rec, $I_syn, $I_log, $I_rpt, #I_no)

!   GENERATE Method (Set default if missing)
if  $_GENmethod          = ''
    let $_GENmethod      = 'A'
end-if

!   GENERATE Long Data Type Indicator (column name)
let $_GENlong            = ''

!  Use PULL DB Link Method as Default
if $I_pull              <> 'N'
   let $I_pull           = 'Y'
end-if

!  Build Upgrade Matrix
do UPG-Main($I_link, $I_pull, $I_rec, $I_log, $I_rpt, #R_ctr, #U_ctr)

!  Initialize GEN Matrix    - Primary Source => UPGmtx
do GEN-Func-Ini($I_syn, #U_ctr)

!  Generate Code for Desired Method
evaluate $_GENmethod

   when = 'A'

      if #R_ctr          > 0

         !  Construct Source Routines - Primary Source => UPGmtx
         let #loop       = 1
         while #loop    <= 3
            let $loop    = to_char(#loop)
            do GEN-Func-Src($loop, $I_link, $I_pull, $I_rec, $I_syn, #I_no, #U_ctr)
            let #loop    = #loop + 1
         end-while

         !  Construct Target Routines - Primary Source => RECmtx
         let #loop       = 1
         while #loop    <= 4
            let $loop    = to_char(#loop)
            do GEN-Func-Tgt($loop, $I_link, $I_pull, $I_rec, #I_no, #R_ctr)
            let #loop    = #loop + 1
         end-while

         !  Push RECNAME onto Stack
         do GEN-Func-Rec($I_rec, 'Select')

      else

         let $text       = 'TARGET (' || $I_rec || ') does not exist'
         do GEN-Func-Box(#I_no, $text, 'N')

      end-if

   when = 'B'

      if #R_ctr          > 0

         !  Construct Direct Routines - Primary Source => RECmtx
         let #loop       = 1
         while #loop    <= 4
            let $loop    = to_char(#loop)
            do GEN-Func-Dir($loop, $I_link, $I_pull, $I_rec, $I_syn, #I_no, #R_ctr)
            let #loop    = #loop + 1
         end-while

         !  Push RECNAME onto Stack
         do GEN-Func-Rec($I_rec, 'Direct')

         !  Construct Long Data Type Adjustments (if applicable)
         if $_GENlong   <> ''
            let #loop    = 1
            while #loop <= 3
               let $loop = to_char(#loop)
               do GEN-Func-Adj($loop, $I_link, $I_pull, $I_rec, $I_syn, #I_no, #R_ctr)
               let #loop = #loop + 1
            end-while
         end-if

      else

         let $text       = 'TARGET (' || $I_rec || ') does not exist'
         do GEN-Func-Box(#I_no, $text, 'N')

      end-if

   when = 'C'
   when = 'D'

      if #R_ctr          > 0

         do GEN-Temp-Set($I_rec, #I_no)
         do GEN-Temp-Drp($I_link, $I_pull, $I_rec, #I_no)
         do GEN-Temp-Cre($I_link, $I_pull, $I_rec, #I_no, #R_ctr)

         !  Push RECNAME onto Stack
         do GEN-Func-Rec($I_rec, 'Set')
         !  Push RECNAME onto Stack
         do GEN-Func-Rec($I_rec, 'Drop')
         !  Push RECNAME onto Stack
         do GEN-Func-Rec($I_rec, 'Create')

         !  Construct Xfer Routines - Primary Source => RECmtx
         let #loop       = 1
         while #loop    <= 4
            let $loop    = to_char(#loop)
            do GEN-Func-Xfr($loop, $I_link, $I_pull, $I_rec, $I_syn, #I_no, #R_ctr)
            let #loop    = #loop + 1
         end-while

         !  Push RECNAME onto Stack
         do GEN-Func-Rec($I_rec, 'XfrDir')

         !  Construct Long Data Type Adjustments (if applicable)
         if $_GENlong   <> ''
            let #loop    = 1
            while #loop <= 3
               let $loop = to_char(#loop)
               do GEN-Func-XfL($loop, $I_link, $I_pull, $I_rec, $I_syn, #I_no, #R_ctr)
               let #loop = #loop + 1
            end-while
         end-if

         !  Construct Mapping Routine Shell
         if $_GENmethod  = 'D'
            do GEN-Func-Map($loop, $I_link, $I_pull, $I_rec, $I_syn, #I_no, #R_ctr)
            do GEN-Func-Rec($I_rec, 'Map')
         end-if

         !  Construct Merge Routines - Primary Source => RECmtx
         let #loop       = 1
         while #loop    <= 3
            let $loop    = to_char(#loop)
            do GEN-Func-Mrg($loop, $I_link, $I_pull, $I_rec, $I_syn, #I_no, #R_ctr)
            let #loop    = #loop + 1
         end-while

         !  Push RECNAME onto Stack
         do GEN-Func-Rec($I_rec, 'MrgDir')

         !  Construct Long Data Type Adjustments (if applicable)
         if $_GENlong   <> ''
            let #loop    = 1
            while #loop <= 3
               let $loop = to_char(#loop)
               do GEN-Func-MrL($loop, $I_link, $I_pull, $I_rec, $I_syn, #I_no, #R_ctr)
               let #loop = #loop + 1
            end-while
         end-if

         !  Push RECNAME onto Stack
         do GEN-Func-Rec($I_rec, 'Drop')

      else

         let $text       = 'TARGET (' || $I_rec || ') does not exist'
         show ' '
         show $text
         show ' '
         do GEN-Func-Box(#I_no, $text, 'N')

      end-if

end-evaluate

end-procedure

!**********************************************************************


The generated code must be of the highest quality - down to the smallest detail. Below is one of many functions in the process that formats the code - just a simple header box that appears before each procedure.

!**********************************************************************
!*       GEN Box - Create Generic Text Box                            *
!**********************************************************************
!*                                                                    *
!*        INPUT: #I_no      - Output File Handle                      *
!*               $I_text    - Text (to place in box)                  *
!*               $I_cred    - Add TD80GEN Credit (Y/N)                *
!*       OUTPUT: n/a        - Build Generic Text Box                  *
!*                                                                    *
!**********************************************************************

begin-procedure GEN-Func-Box(#I_no, $I_text, $I_cred)

uppercase $I_cred

let $x       = chr(33)             ! Exclamation Point

let $rec     = rpad($x, 71, '*')
write #I_no from $rec

let $rec     = $x || '*'
let $rec     = rpad($rec,9,' ')   || $I_text
if  $I_cred  = 'Y'
    let $rec = rpad($rec,46,' ')  || '/TD80GEN Code Generator/'
end-if
let $rec     = rpad($rec,70,' ')  || '*'
write #I_no from $rec

let $rec     = rpad($x, 71, '*')
write #I_no from $rec

end-procedure

!**********************************************************************


Now for a simple example of the generated code produced for the DISABILITY record. The author is set to <TD80GEN>. Of special note is the routine Convert-SOURCE-To-TARGET - this is placed at the end of the module & consists of the routines based on the selected Generation Method. 

The routine Drops the TEMP table if it exists, Re-Creates the TEMP table, Transfers Source Data to the TEMP table, Provides for Data Mapping & then Merges the data into the Target. It also performs the TEMP table drop once more.

!**********************************************************************
!*       Convert-SOURCE-To-TARGET             /TD80GEN Code Generator/*
!**********************************************************************

begin-procedure Convert-SOURCE-To-TARGET

show 'Executing: Drop-DISABILITY'
do Drop-DISABILITY

show 'Executing: Create-DISABILITY'
do Create-DISABILITY

show 'Executing: XfrDir-DISABILITY'
do XfrDir-DISABILITY

show 'Executing: Map-DISABILITY'
do Map-DISABILITY

show 'Executing: MrgDir-DISABILITY'
do MrgDir-DISABILITY

show 'Executing: Drop-DISABILITY'
do Drop-DISABILITY

end-procedure

!**********************************************************************


Below is the full generated source code for the ULCVD044.SQR Disability Record Conversion.

!**********************************************************************
!*                                                                    *
!*       MODULE: ULCVD044.SQR.                                        *
!*       AUTHOR: <TD80GEN>.                                           *
!*         DATE: 08/01/2001.                                          *
!*       SYSTEM: <PEOPLESOFT HR/BEN/PAY>.                             *
!*         DESC: CONVERSION - DISABILITY.                             *
!*                                                                    *
!**********************************************************************
!*           REVISIONS:                                               *
!**********************************************************************
!*                                                                    *
!*   DATE     PROGRAMMER      DESCRIPTION                             *
!* ---------- --------------- --------------------------------------- *
!*                                                                    *
!* 08/01/2001 <TD80GEN>       ORIGINAL CODING.                        *
!*                                                                    *
!* 08/01/2001 DELIA,TONY      ADDED BF TO UNL MAPPING.                *
!*                                                                    *
!**********************************************************************

!**********************************************************************
!*         NOTE: Source Code generated by TD80GEN.SQC                 *
!**********************************************************************

#include 'setenv.sqc'

!**********************************************************************
!*       Setup Procedure                                              *
!**********************************************************************

begin-setup

#include 'setup02a.sqc'      ! Printer/Pagesize Landscape

#ifndef SRClink              ! SETENV should have link definitions
#define SRClink @HQUA        ! Source  Database Link
#define TGTlink              ! Target  Database Link
#define MAPlink @HQUA        ! Mapping Database Link
#endif

#ifndef TMPspace
#define TMPspace pstable     ! Temp Tablespace
#endif

end-setup

!**********************************************************************
!*       Headings                                                     *
!**********************************************************************

begin-heading 08

#include 'stdhdg01.sqc'

print '='                              ( +1,  1,175 ) fill

print ' '                              ( +1,  1,  1 )
print 'Recname'                        (  0,  1, 15 )
print 'Routine'                        (  0, +5, 25 )
print '     Count'                     (  0, +5, 10 )

print '='                              ( +1,  1,175 ) fill

end-heading

!**********************************************************************
!*       Mainline Processing                                          *
!**********************************************************************

begin-program

do Init-DateTime
do Get-Current-DateTime
move $AsOfToday to $AsOfDate

let $ReportId    = 'ULCVD044'
let $ReportTitle = 'Conversion'

show ' '
show $ReportId ' - ' $ReportTitle
show ' '

let $tablename1 = 'TD_DISABILITY'
do Convert-SOURCE-To-TARGET

!  Have a Nice Day...

end-program

!**********************************************************************
!*       Drop-DISABILITY                      /TD80GEN Code Generator/*
!**********************************************************************

begin-procedure Drop-DISABILITY

let #CTR_DISABILITY              = #CTR_DISABILITY + 1

let #ERR_ctr                     = #CTR_DISABILITY
let $ERR_tbl                     = 'DISABILITY'
let $ERR_rtn                     = 'Drop-DISABILITY'

begin-sql On-Error=Error-DISABILITY

drop table TD_disability{TGTlink}

end-sql

let #CTR_DISABILITY              = #sql-count

print ' '                              ( +1,  1,  1 )
print 'DISABILITY'                     (  0,  1, 15 )
print 'Drop-DISABILITY'                (  0, +5, 25 )
print #CTR_DISABILITY                  (  0, +5, 10 ) edit 99,999,999

print ' '                              ( +1,  1,  1 )

let #CTR_DISABILITY              = 0

end-procedure

!**********************************************************************
!*       Create-DISABILITY                    /TD80GEN Code Generator/*
!**********************************************************************

begin-procedure Create-DISABILITY

let #CTR_DISABILITY              = #CTR_DISABILITY + 1

let #ERR_ctr                     = #CTR_DISABILITY
let $ERR_tbl                     = 'DISABILITY'
let $ERR_rtn                     = 'Create-DISABILITY'

begin-sql On-Error=Error-DISABILITY

create table [$tablename1]{TGTlink}
       (emplid                   varchar2(11)             not null,
        disabled                 varchar2(1)              not null,
        disabled_vet             varchar2(1)              not null,
        reg_disabled_nbr         varchar2(10)             not null,
        disability_cd_uk         varchar2(3)              not null,
        disability_cd_jpn        varchar2(3)              not null,
        handicap_pcent_nld       decimal(5,2)             not null,
        comments                 long varchar)
tablespace {TMPSPACE}
storage ( initial 16384 next 106496 maxextents 110 pctincrease 0)

end-sql

let #CTR_DISABILITY              = #sql-count

print ' '                              ( +1,  1,  1 )
print 'DISABILITY'                     (  0,  1, 15 )
print 'Create-DISABILITY'              (  0, +5, 25 )
print #CTR_DISABILITY                  (  0, +5, 10 ) edit 99,999,999

print ' '                              ( +1,  1,  1 )

let #CTR_DISABILITY              = 0

let #CTR_DISABILITY              = #CTR_DISABILITY + 1

let #ERR_ctr                     = #CTR_DISABILITY
let $ERR_tbl                     = 'DISABILITY'
let $ERR_rtn                     = 'Create-DISABILITY (IDX)'

begin-sql On-Error=Error-DISABILITY

create unique index td_DISABILITY{TGTlink} on td_DISABILITY{TGTlink}
(EMPLID)
tablespace psindex
storage ( initial 10000 next 100000 maxextents 110 pctincrease 0)

end-sql

let #CTR_DISABILITY              = #sql-count

print ' '                              ( +1,  1,  1 )
print 'DISABILITY'                     (  0,  1, 15 )
print 'Create-DISABILITY (IDX)'        (  0, +5, 25 )
print #CTR_DISABILITY                  (  0, +5, 10 ) edit 99,999,999

print ' '                              ( +1,  1,  1 )

let #CTR_DISABILITY              = 0

end-procedure

!**********************************************************************
!*       XfrDir-DISABILITY                    /TD80GEN Code Generator/*
!**********************************************************************

begin-procedure XfrDir-DISABILITY

let #CTR_DISABILITY              = #CTR_DISABILITY + 1

let #ERR_ctr                     = #CTR_DISABILITY
let $ERR_tbl                     = 'DISABILITY'
let $ERR_rtn                     = 'XfrDir-DISABILITY'

begin-sql On-Error=Error-DISABILITY

insert into [$tablename1]{TGTlink}
       (emplid,
        disabled,
        disabled_vet,
        reg_disabled_nbr,
        disability_cd_uk,
        disability_cd_jpn,
        comments,
        handicap_pcent_nld)
select  a1.emplid,                           !   EMPLID
        a1.disabled,                         !   DISABLED
        a1.disabled_vet,                     !   DISABLED_VET
        a1.reg_disabled_nbr,                 !   REG_DISABLED_NBR
        a1.disability_cd_uk,                 !   DISABILITY_CD_UK
        a1.disability_cd_jpn,                !   DISABILITY_CD_JPN
        '',                                  !   COMMENTS
        a1.handicap_pcent_nld                !   HANDICAP_PCENT_NLD
 from ps_disability{SRClink}       a1,
      ps_z_conversn_ee{SRClink}    zz
where zz.emplid                  = a1.emplid
  and zz.z_yes_no_flag           = 'Y'

end-sql


let #CTR_DISABILITY              = #sql-count 

begin-sql
commit
end-sql

print ' '                              ( +1,  1,  1 )
print 'DISABILITY'                     (  0,  1, 15 )
print 'XfrDir-DISABILITY'              (  0, +5, 25 )
print #CTR_DISABILITY                  (  0, +5, 10 ) edit 99,999,999

print ' '                              ( +1,  1,  1 )

let #CTR_DISABILITY              = 0

do XfrAdj-DISABILITY

end-procedure

!**********************************************************************
!*       Error-DISABILITY                     /TD80GEN Code Generator/*
!**********************************************************************

begin-procedure Error-DISABILITY

show ' '
show '*** ERROR ***'
show ' '

show ' Routine: ' $ERR_rtn
show '   Table: ' $ERR_tbl
show ' Counter: ' #ERR_ctr
show ' Message: ' $sql-error
show ' '

if $ERR_rtn  = 'Update-DISABILITY'
or $ERR_rtn  = 'MrgUpd-DISABILITY'

   show '<K>                   EMPLID: >>>' $A2_emplid                '<<<'
   show '                    COMMENTS: >>>' $A2_comments              '<<<'

end-if

if $ERR_rtn <> 'Drop-DISABILITY'
   stop
end-if

end-procedure

!**********************************************************************
!*       XfrAdj-DISABILITY                    /TD80GEN Code Generator/*
!**********************************************************************

begin-procedure XfrAdj-DISABILITY

begin-select

a1.emplid
a1.comments

  let $A2_emplid                 = &a1.emplid
  let $A2_comments               = &a1.comments

  do Update-DISABILITY

 from ps_disability{SRClink}       a1
where a1.comments           is not null

end-select

print ' '                              ( +1,  1,  1 )
print 'DISABILITY'                     (  0,  1, 15 )
print 'XfrAdj-DISABILITY'              (  0, +5, 25 )
print #CTR_DISABILITY                  (  0, +5, 10 ) edit 99,999,999

print ' '                              ( +1,  1,  1 )

let #CTR_DISABILITY              = 0

end-procedure

!**********************************************************************
!*       Update-DISABILITY                    /TD80GEN Code Generator/*
!**********************************************************************

begin-procedure Update-DISABILITY

let #CTR_DISABILITY              = #CTR_DISABILITY + 1

let #ERR_ctr                     = #CTR_DISABILITY
let $ERR_tbl                     = 'DISABILITY'
let $ERR_rtn                     = 'Update-DISABILITY'

begin-sql On-Error=Error-DISABILITY

update [$tablename1]{TGTlink}      a2
   set a2.comments               = $A2_comments
 where a2.emplid                 = $A2_emplid

end-sql

begin-sql
commit
end-sql

end-procedure

!**********************************************************************
!*       Map-DISABILITY                       /TD80GEN Code Generator/*
!**********************************************************************

begin-procedure Map-DISABILITY

! Repeat code below for each set of Map Updates.

let #CTR_DISABILITY              = #CTR_DISABILITY + 1

let #ERR_ctr                     = #CTR_DISABILITY
let $ERR_tbl                     = 'DISABILITY'
let $ERR_rtn                     = 'Map-DISABILITY'

begin-sql On-Error=Error-DISABILITY

update [$tablename1]{TGTlink}  u
   set u.emplid        =  lpad(u.emplid,7,'0');

end-sql

let #CTR_DISABILITY              = #sql-count

print ' '                              ( +1,  1,  1 )
print 'DISABILITY'                     (  0,  1, 15 )
print 'Map-DISABILITY'                 (  0, +5, 25 )
print #CTR_DISABILITY                  (  0, +5, 10 ) edit 99,999,999

print ' '                              ( +1,  1,  1 )

let #CTR_DISABILITY              = 0

begin-sql
commit
end-sql

end-procedure

!**********************************************************************
!*       MrgDir-DISABILITY                    /TD80GEN Code Generator/*
!**********************************************************************

begin-procedure MrgDir-DISABILITY

let #CTR_DISABILITY              = #CTR_DISABILITY + 1

let #ERR_ctr                     = #CTR_DISABILITY
let $ERR_tbl                     = 'DISABILITY'
let $ERR_rtn                     = 'MrgDir-DISABILITY'

begin-sql On-Error=Error-DISABILITY

insert into ps_disability{TGTlink}
       (emplid,
        disabled,
        disabled_vet,
        reg_disabled_nbr,
        disability_cd_uk,
        disability_cd_jpn,
        comments,
        handicap_pcent_nld)
select  a2.emplid,                           !   EMPLID
        a2.disabled,                         !   DISABLED
        a2.disabled_vet,                     !   DISABLED_VET
        a2.reg_disabled_nbr,                 !   REG_DISABLED_NBR
        a2.disability_cd_uk,                 !   DISABILITY_CD_UK
        a2.disability_cd_jpn,                !   DISABILITY_CD_JPN
        '',                                  !   COMMENTS
        a2.handicap_pcent_nld                !   HANDICAP_PCENT_NLD
 from [$tablename1]{TGTlink}       a2
!where a2.emplid                 = < CHAR >

end-sql


let #CTR_DISABILITY              = #sql-count

begin-sql
commit
end-sql

print ' '                              ( +1,  1,  1 )
print 'DISABILITY'                     (  0,  1, 15 )
print 'MrgDir-DISABILITY'              (  0, +5, 25 )
print #CTR_DISABILITY                  (  0, +5, 10 ) edit 99,999,999

print ' '                              ( +1,  1,  1 )

let #CTR_DISABILITY              = 0

do MrgAdj-DISABILITY

end-procedure

!**********************************************************************
!*       MrgAdj-DISABILITY                    /TD80GEN Code Generator/*
!**********************************************************************

begin-procedure MrgAdj-DISABILITY

let $DYN_tbl = 'td_disability{TGTlink} a2'

begin-select

a2.emplid
a2.comments

  let $A2_emplid                 = &a2.emplid
  let $A2_comments               = &a2.comments

  do MrgUpd-DISABILITY

 from [ps_disability a2:$DYN_tbl]
where a2.comments           is not null

end-select

print ' '                              ( +1,  1,  1 )
print 'DISABILITY'                     (  0,  1, 15 )
print 'MrgAdj-DISABILITY'              (  0, +5, 25 )
print #CTR_DISABILITY                  (  0, +5, 10 ) edit 99,999,999

print ' '                              ( +1,  1,  1 )

let #CTR_DISABILITY              = 0

end-procedure

!**********************************************************************
!*       MrgUpd-DISABILITY                    /TD80GEN Code Generator/*
!**********************************************************************

begin-procedure MrgUpd-DISABILITY

let #CTR_DISABILITY              = #CTR_DISABILITY + 1

let #ERR_ctr                     = #CTR_DISABILITY
let $ERR_tbl                     = 'DISABILITY'
let $ERR_rtn                     = 'MrgUpd-DISABILITY'

begin-sql On-Error=Error-DISABILITY

update ps_disability{TGTlink}      a2
   set a2.comments               = $A2_comments
 where a2.emplid                 = $A2_emplid

end-sql

begin-sql
commit
end-sql

end-procedure

!**********************************************************************
!*       Convert-SOURCE-To-TARGET             /TD80GEN Code Generator/*
!**********************************************************************

begin-procedure Convert-SOURCE-To-TARGET

show 'Executing: Drop-DISABILITY'
do Drop-DISABILITY

show 'Executing: Create-DISABILITY'
do Create-DISABILITY

show 'Executing: XfrDir-DISABILITY'
do XfrDir-DISABILITY

show 'Executing: Map-DISABILITY'
do Map-DISABILITY

show 'Executing: MrgDir-DISABILITY'
do MrgDir-DISABILITY

show 'Executing: Drop-DISABILITY'
do Drop-DISABILITY

end-procedure

!**********************************************************************
!*       Include Members:                                             *
!**********************************************************************

#include 'curdttim.sqc'  ! Get-Current-DateTime Proc
#include 'datetime.sqc'  ! Date/Time Formatting

!**********************************************************************
!*       End of Program                                               *
!**********************************************************************


This concludes another TDXBITS Post.