!***********************************************************************
! Outbound.sqr - this program will print employee data
! Checks the employee Id exist or not
! Returns the number of rows printed in file
! Returns file open success or not
!***********************************************************************
#include 'setenv.sqc' !set environment
#include 'setup32.sqc' !printer and page-size initialization
#include 'stdapi.sqc' !update process api
begin-report
do stdapi-init
if $prcs_process_instance=''
do get-params-from-cmd
else
do get-params-from-pia
end-if
do open-files
do close-file
do stdapi-term
end-report
!***************************************************************************
!Closing the file
!*****************************************************************
begin-procedure close-file
! close files
close 20
! write out to log how many records written
show ' '
show ' '
show 'Total records written to file: ' #total edit 999
end-procedure close-file
!***************************************************************************
!Getting I/P Parameters from cmd
!***************************************************************************
begin-procedure get-params-from-cmd
input $emplid 'enter employee id'
end-procedure get-params-from-cmd
!***************************************************************************
!Getting I/P Parameters from PIA
!***************************************************************************
begin-procedure get-params-from-pia
begin-SELECT
EMPLID
let $emplid=&emplid
FROM PS_MY1_PRCSRUNCNTL WHERE OPRID=$prcs_oprid and RUN_CNTL_ID=$prcs_run_cntl_id
END-SELECT
end-procedure get-params-from-pia
!***************************************************************************
!open file and check status
!***************************************************************************
begin-procedure open-files
open 'C:\Documents and Settings\Administrator\Desktop\DATA4.txt' as 20 for-writing record=400:fixed
status = #open20
if #open20 <> 0
display 'could not open file C:\Documents and Settings\Administrator\Desktop\DATA4.txt'
stop quiet
else
display 'file opened success C:\Documents and Settings\Administrator\Desktop\DATA4.txt'
do select-data
end-if
end-procedure open-files
!***************************************************************************
!select the data from db
!***************************************************************************
begin-procedure select-data
let $found= 'N'
BEGIN-SELECT
COUNTRY_NM_FORMAT &COUNTRY_NM_FORMAT
NAME &NAME
let $found= 'Y'
FROM PS_PERSONAL_DATA WHERE EMPLID=$EMPLID
END-SELECT
if $found= 'Y'
do write-file-out
else
show 'employee id not found' $emplid
end-if
end-procedure select-data
!***********************************************************************
! Write the data into flat file
!***********************************************************************
begin-procedure write-file-out
! create a comma delimited file for output.
let $output = $emplid || ', ' || &country_nm_format || ', ' || &name
write 20 from $output:400
add 1 to #total
end-procedure write-file-out
#include 'reset.sqc' !reset printer procedure
#include 'curdttim.sqc' !get-current-datetime procedure
#include 'datetime.sqc' !routines for date and time formatting
! Outbound.sqr - this program will print employee data
! Checks the employee Id exist or not
! Returns the number of rows printed in file
! Returns file open success or not
!***********************************************************************
#include 'setenv.sqc' !set environment
#include 'setup32.sqc' !printer and page-size initialization
#include 'stdapi.sqc' !update process api
begin-report
do stdapi-init
if $prcs_process_instance=''
do get-params-from-cmd
else
do get-params-from-pia
end-if
do open-files
do close-file
do stdapi-term
end-report
!***************************************************************************
!Closing the file
!*****************************************************************
begin-procedure close-file
! close files
close 20
! write out to log how many records written
show ' '
show ' '
show 'Total records written to file: ' #total edit 999
end-procedure close-file
!***************************************************************************
!Getting I/P Parameters from cmd
!***************************************************************************
begin-procedure get-params-from-cmd
input $emplid 'enter employee id'
end-procedure get-params-from-cmd
!***************************************************************************
!Getting I/P Parameters from PIA
!***************************************************************************
begin-procedure get-params-from-pia
begin-SELECT
EMPLID
let $emplid=&emplid
FROM PS_MY1_PRCSRUNCNTL WHERE OPRID=$prcs_oprid and RUN_CNTL_ID=$prcs_run_cntl_id
END-SELECT
end-procedure get-params-from-pia
!***************************************************************************
!open file and check status
!***************************************************************************
begin-procedure open-files
open 'C:\Documents and Settings\Administrator\Desktop\DATA4.txt' as 20 for-writing record=400:fixed
status = #open20
if #open20 <> 0
display 'could not open file C:\Documents and Settings\Administrator\Desktop\DATA4.txt'
stop quiet
else
display 'file opened success C:\Documents and Settings\Administrator\Desktop\DATA4.txt'
do select-data
end-if
end-procedure open-files
!***************************************************************************
!select the data from db
!***************************************************************************
begin-procedure select-data
let $found= 'N'
BEGIN-SELECT
COUNTRY_NM_FORMAT &COUNTRY_NM_FORMAT
NAME &NAME
let $found= 'Y'
FROM PS_PERSONAL_DATA WHERE EMPLID=$EMPLID
END-SELECT
if $found= 'Y'
do write-file-out
else
show 'employee id not found' $emplid
end-if
end-procedure select-data
!***********************************************************************
! Write the data into flat file
!***********************************************************************
begin-procedure write-file-out
! create a comma delimited file for output.
let $output = $emplid || ', ' || &country_nm_format || ', ' || &name
write 20 from $output:400
add 1 to #total
end-procedure write-file-out
#include 'reset.sqc' !reset printer procedure
#include 'curdttim.sqc' !get-current-datetime procedure
#include 'datetime.sqc' !routines for date and time formatting
No comments:
Post a Comment