You are on page 1of 49

*----------------------------------------------------------------------* Program to read in the inbound interface files and create * the IT9022 records * * 2 input files containing

CRO, SVU and ISD information are to be * uploaded (1 single applicant in 1 file) * * Upon successful creation of CRO, SVU & ISD records, Cat2 security * clearance of the applicant will be updated to completed * * Created by : Damon Peck * Created on : 23.09.2003 *----------------------------------------------------------------------* * Date Chg Id Changed By Description * 13.04.2004 Damon 1. Only perform creation of records * when an applicant has both F13 & * F13ra files available for upload * 2. Copy file to backup folder only * when uploading & creation of * record is successful * * 10.06.2004 Alice 1. To allow update of Trace info * regardless of trace indicator * * 25.11.2004 M01 Damon 1. Remove check on applicant's name * when validating data * 2. Add check on duplicate applicant * # found within files before * uploading * * 01.12.2004 M02 Damon 1. Additional trace results added * ('Y','N' or 'NA') * * 17.12.2004 M03 Damon 1. Add checking for null fields * (ie. Fieldname ^^) * * 12.04.2005 Alice 1. Include Date on report * * 15.07.2008 M04 Damon 1. Allow creation of OVU records * for re-applicants *----------------------------------------------------------------------* REPORT ZHRRC011 no standard page heading line-size 170 line-count 58 message-id zhr01. CONSTANTS: session like apqi-groupid value 'ZHRRC011'. tables: pb0001, pb0185, pb4000, pb4003, pb9022, t750j. "org assignment "personal id "applicant actions "applicant activities "inbound OVU information "applicant activity type

* temp internal table to merge multiple input files data: begin of itab_temp occurs 0, line(500), end of itab_temp.

* temp internal table to store F13 file contents data: begin of temp_ifile1 occurs 0, input(150), end of temp_ifile1. * internal table to store F13 file contents data: begin of ifile1 occurs 0, input(150), end of ifile1. * temp internal table to store F13ra file contents data: begin of temp_ifile2 occurs 0, input(450), end of temp_ifile2. * internal table to store F13ra file contents data: begin of ifile2 occurs 0, input(450), end of ifile2. * internal table to store CRO *+ M02 *data: begin of itab1 occurs 0, * SVUReplyRef(20), * DateReplied(10), * ARSNo(8), * Name(40), * NRIC(9), * CROTraced(1), * CROInfo(100), * error(1), * filename(100), * end of itab1. data: begin of itab1 occurs 0, SVUReplyRef(20), DateReplied(10), ARSNo(8), Name(40), NRIC(9), CROTraced(2), CROInfo(100), error(1), filename(100), end of itab1. *- M02 data: begin of CRO occurs 0, remark(72), end of CRO. data: begin of SVU occurs 0, remark(72), end of SVU. data: begin of ISD occurs 0, remark(72), end of ISD. * internal table to store SVU & ISD *+ M02

*data: begin of itab2 occurs 0, * SVUReplyRef(20), * DateReplied(10), * ARSNo(8), * Name(40), * NRIC(9), * SVUTraced(1), * SVUInfo(200), * ISDTraced(1), * ISDInfo(400), * error(1), * filename(100), * end of itab2. data: begin of itab2 occurs 0, SVUReplyRef(20), DateReplied(10), ARSNo(8), Name(40), NRIC(9), SVUTraced(2), SVUInfo(200), ISDTraced(2), ISDInfo(400), error(1), filename(100), end of itab2. *- M02 * internal table to store CRO, SVU & ISD together *+ M02 *data: begin of itab3 occurs 0, * SVUReplyRef1(20), * DateReplied1(10), * ARSNo(8), * Name(40), * NRIC(9), * CROTraced(1), * CROInfo(100), * SVUReplyRef2(20), * DateReplied2(10), * SVUTraced(1), * SVUInfo(200), * ISDTraced(1), * ISDInfo(400), * updated(1), * app_range like q0001-aptyp, "applicant range * f13 like rlgrap-filename, * f13ra like rlgrap-filename, * end of itab3. data: begin of itab3 occurs 0, SVUReplyRef1(20), DateReplied1(10), ARSNo(8), Name(40), NRIC(9), CROTraced(2), CROInfo(100), SVUReplyRef2(20), DateReplied2(10), SVUTraced(2),

** * * ** *-

SVUInfo(200), ISDTraced(2), ISDInfo(400), updated(1), app_range like q0001-aptyp, "applicant range Start Changes, Clila 20-Jun-06 Des: fname type changed to string ** f13 like rlgrap-filename, f13ra like rlgrap-filename, f13 type string, f13ra type string, End Changes, Clila 20-Jun-06 Des: fname type changed to string ** end of itab3. M02

* internal table to store MHQ applicants (for send mail) data: begin of itab_mhq occurs 0, ARSNo(10), NRIC(10), Name(40), Updated(13), Traced(13), end of itab_mhq. data: begin of mhq_txt occurs 0, txt(255), end of mhq_txt. * internal table to store CSIT applicants (for send mail) data: begin of itab_csit occurs 0, ARSNo(10), NRIC(10), Name(40), Updated(13), Traced(13), end of itab_csit. data: begin of csit_txt occurs 0, txt(255), end of csit_txt. * table to store error messages data: begin of errtab occurs 0, filename like rlgrap-filename, linenum(2), contents(100), message(80), end of errtab. * table for hr display main data: begin of datatabM occurs 0, ARSNo(8), NRIC(9), Name(40), Trace(3), SVUReplyRef(20), DateReplied(10), Traced(1), Info(80), end of datatabM.

types: begin of fieldtab, text(30), tabname(10), fieldname(10), typ, end of fieldtab. * table for headings data: fieldtabM type fieldtab occurs 0 with header line, fieldtabE type fieldtab occurs 0 with header line. * BDC table for processing data: begin of bdc_tab occurs 0. include structure bdcdata. data: end of bdc_tab. data: zsubrc like sy-subrc, zlen type i, zout_date type d, line1 type i, line2 type i, line3 type i, zline type i, counter type i, ztot_err type i, countchar(1), tempchar(3), fieldname(14), zmessage(72), button_code like sy-subrc, CROrc like sy-subrc, ISDrc like sy-subrc, SVUrc like sy-subrc, ztxt1(9) value 'failed - ', ztxt2(17) value ' Program aborted.'. data: pcmd(255), r_code like sy-subrc, dummy(355) occurs 100 with header line, zmail_rc1 like sy-subrc, "return code for MHQ send mail zmail_rc2 like sy-subrc. "return code for CSIT send mail * internal table to store names of f13 & f13ra files data: file_f13(355) occurs 100 with header line, file_f13ra(355) occurs 100 with header line. * data declaration for sending mails DATA: OBJCONT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE, OBJHEAD LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE, RECLIST LIKE SOMLRECI1 OCCURS 10 WITH HEADER LINE, DOC_CHNG LIKE SODOCCHGI1, objtxt like solisti1 occurs 10 with header line, PL LIKE SOPCKLSTI1 OCCURS 10 WITH HEADER LINE, ENTRIES LIKE SY-TABIX. data: tab_lines like sy-tabix. *----------------------------------------------------------------------* selection screen *----------------------------------------------------------------------SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

** Start Changes, Clila 20-Jun-06 Des: fname type changed to string ** *parameters: p_f13 like rlgrap-filename obligatory lower case, * p_f13ra like rlgrap-filename obligatory lower case, * p_backup as checkbox default 'X'. parameters: p_f13 type string obligatory lower case, p_f13ra type string obligatory lower case, p_backup as checkbox default 'X'. ** End Changes, Clila 20-Jun-06 Des: fname type changed to string ** SELECTION-SCREEN END OF BLOCK B1. SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-023. parameters: b_f13 like rlgrap-filename lower case, b_f13ra like rlgrap-filename lower case, ** Start Changes, Clila 20-Jun-06 Des: fname type changed to string ** * f13 like rlgrap-filename no-display, * f13ra like rlgrap-filename no-display. f13 type string no-display, f13ra type string no-display. ** End Changes, Clila 20-Jun-06 Des: fname type changed to string ** SELECTION-SCREEN END OF BLOCK B2. *SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-001. *parameters: f13 like rlgrap-filename default * 'c:\temp\f13_test.txt', * f13ra like rlgrap-filename default * 'c:\temp\f13ra_test.txt'. * mode as checkbox default 'X'. *SELECTION-SCREEN END OF BLOCK B3. *AT SELECTION-SCREEN ON VALUE-REQUEST FOR f13. * CALL FUNCTION 'WS_FILENAME_GET' * EXPORTING * DEF_FILENAME = f13 ** def_path = * MASK = ',Text Files,*.txt,All Files,*.*.' * MODE = 'O' * TITLE = 'Open Input File' * IMPORTING * FILENAME = f13 ** rc = * EXCEPTIONS * INV_WINSYS = 1 * NO_BATCH = 2 * SELECTION_CANCEL = 3 * SELECTION_ERROR = 4 * OTHERS = 5. *AT SELECTION-SCREEN ON VALUE-REQUEST FOR f13ra. * CALL FUNCTION 'WS_FILENAME_GET' * EXPORTING * DEF_FILENAME = f13ra ** def_path = * MASK = ',Text Files,*.txt,All Files,*.*.' * MODE = 'O' * TITLE = 'Open Input File' * IMPORTING * FILENAME = f13ra ** rc =

* * * * * *

EXCEPTIONS INV_WINSYS NO_BATCH SELECTION_CANCEL SELECTION_ERROR OTHERS

= = = = =

1 2 3 4 5.

*----------------------------------------------------------------------* start of program *----------------------------------------------------------------------start-of-selection. * perform populate_fieldtabM. * perform populate_fieldtabE. perform get_f13_files. perform extract_f13_data. perform get_f13ra_files. perform extract_f13ra_data. perform validate_f13. perform validate_f13ra. * check if applicant has both f13 & f13ra files perform check_files. perform check_IT9022. perform populate_itab3. perform update_records. * move files to backup folder and delete source perform delete_files. if itab3[] is initial and ztot_err = 0. message s002 with 'No record found'. exit. endif. if not itab3[] is initial. perform split_mhq_csit. if not itab_mhq[] is initial. perform populate_mhq_txt. perform send_mail_mhq. endif. if not itab_csit[] is initial. perform populate_csit_txt. perform send_mail_csit. endif. * perform write_report. endif. describe table errtab lines ztot_err. if ztot_err <> 0. sort errtab by filename linenum. perform write_errors. endif. * perform upload_data. * if zsubrc = 0. "upload successful * perform extract_f13. * perform extract_f13ra. * perform word_wrap_f13. * perform word_wrap_f13ra. * perform validate_f13.

* perform validate_f13ra. * perform check_IT9022. * perform message_error. * perform populate_datatabM. * endif. * perform check_errtab. end-of-selection. * handle push buttons click *describe table datatabM lines counter. *if counter > 0. * button_code = 1. *else. * button_code = 0. *endif. *if sy-batch is initial. * do. * case button_code. * when 1. * perform display_listM. * when 2. * perform display_listE. * when 3. * perform update_records. * if CRO, SVU & ISD records created, update * activity CAT2 clearance to completed * if CROrc = 0 and ISDrc = 0 * and SVUrc = 0. * perform update_cat2. * exit. * else. * message i002 with 'Cat2 Security Clearance not updated'. * perform display_listM. * endif. * when others. * exit. * endcase. * enddo. *---------------------------------------------------------------------* Form get_f13_files *---------------------------------------------------------------------FORM get_f13_files. data: zsource(255), zdestin(255), zline_f13 type i. * get contents of F13 directory clear: pcmd, file_f13[]. concatenate 'dir/b' p_f13 into pcmd separated by space. concatenate pcmd '*.txt' into pcmd. perform execute_command tables file_f13 using pcmd. * check if backup is selected and make a copy of F13 files *if p_backup = 'X'. * loop at file_f13. * clear: zsource, zdestin, pcmd. * concatenate p_f13 file_f13 into zsource. * concatenate b_f13 file_f13 into zdestin. * concatenate 'copy' zsource zdestin into pcmd separated by space.

* perform execute_command tables dummy using pcmd. * endloop. *endif. * append contents of F13 files into single internal table loop at file_f13. clear: zsource, temp_ifile1. refresh: temp_ifile1. concatenate p_f13 file_f13 into zsource. open dataset zsource in text mode. DO. READ DATASET zsource INTO temp_ifile1. IF sy-subrc <> 0. EXIT. ENDIF. append temp_ifile1. clear temp_ifile1. delete temp_ifile1 where input is initial. ENDDO. temp_ifile1-input = file_f13. append temp_ifile1. clear temp_ifile1. * check format of file by no. of lines describe table temp_ifile1 lines zline_f13. if zline_f13 = 10. append lines of temp_ifile1 to ifile1. else. errtab-filename = file_f13. errtab-linenum = '-'. errtab-contents = '-'. errtab-message = 'Format of file is incorrect: Contents should have 9 lines'. append errtab. clear errtab. endif. close dataset zsource. * delete dataset zsource. "delete file endloop. "at file_f13 ENDFORM. " get_f13_files *---------------------------------------------------------------------* Form extract_f13_data *---------------------------------------------------------------------* Each applicant has 9+1 lines of data in ifile1 *---------------------------------------------------------------------FORM extract_f13_data. data: ztemp(1), zlines type i, zcount type i. describe table ifile1 lines zlines. zlines = zlines / 10. "no. of applicants zcount = 2. "start from 2nd line do zlines times. read table ifile1 index zcount. split ifile1-input at '^' into ztemp itab1-SVUReplyRef. zlen = strlen( itab1-SVUReplyRef ). subtract 1 from zlen. *+ M03 * if itab1-SVUReplyRef+zlen(1) = '^'.

* itab1-SVUReplyRef = itab1-SVUReplyRef(zlen). * endif. if itab1-SVUReplyRef+zlen(1) = '^' and zlen > 0. itab1-SVUReplyRef = itab1-SVUReplyRef(zlen). elseif zlen <= 0. itab1-SVUReplyRef = ''. endif. *- M03 add 1 to zcount. read table ifile1 index zcount. split ifile1-input at '^' into ztemp itab1-DateReplied. zlen = strlen( itab1-DateReplied ). subtract 1 from zlen. *+ M03 * if itab1-DateReplied+zlen(1) = '^'. * itab1-DateReplied = itab1-DateReplied(zlen). * endif. if itab1-DateReplied+zlen(1) = '^' and zlen > 0. itab1-DateReplied = itab1-DateReplied(zlen). elseif zlen <= 0. itab1-DateReplied = ''. endif. *- M03 add 1 to zcount. read table ifile1 index zcount. split ifile1-input at '^' into ztemp itab1-ARSNo. zlen = strlen( itab1-ARSNo ). subtract 1 from zlen. *+ M03 * if itab1-ARSNo+zlen(1) = '^'. * itab1-ARSNo = itab1-ARSNo(zlen). * endif. if itab1-ARSNo+zlen(1) = '^' and zlen > 0. itab1-ARSNo = itab1-ARSNo(zlen). elseif zlen <= 0. itab1-ARSNo = ''. endif. *- M03 add 1 to zcount. read table ifile1 index zcount. split ifile1-input at '^' into ztemp itab1-Name. zlen = strlen( itab1-Name ). subtract 1 from zlen. *+ M03 * if itab1-Name+zlen(1) = '^'. * itab1-Name = itab1-Name(zlen). * endif. if itab1-Name+zlen(1) = '^' and zlen > 0. itab1-Name = itab1-Name(zlen). elseif zlen <= 0. itab1-Name = ''. endif. *- M03

add 1 to zcount. read table ifile1 index zcount. split ifile1-input at '^' into ztemp itab1-NRIC. zlen = strlen( itab1-NRIC ). subtract 1 from zlen. *+ M03 * if itab1-NRIC+zlen(1) = '^'. * itab1-NRIC = itab1-NRIC(zlen). * endif. if itab1-NRIC+zlen(1) = '^' and zlen > 0. itab1-NRIC = itab1-NRIC(zlen). elseif zlen <= 0. itab1-NRIC = ''. endif. *- M03 add 1 to zcount. read table ifile1 index zcount. split ifile1-input at '^' into ztemp itab1-CROTraced. zlen = strlen( itab1-CROTraced ). subtract 1 from zlen. *+ M03 * if itab1-CROTraced+zlen(1) = '^'. * itab1-CROTraced = itab1-CROTraced(zlen). * endif. if itab1-CROTraced+zlen(1) = '^' and zlen > 0. itab1-CROTraced = itab1-CROTraced(zlen). elseif zlen <= 0. itab1-CROTraced = ''. endif. *- M03 add 1 to zcount. read table ifile1 index zcount. split ifile1-input at '^' into ztemp itab1-CROInfo. zlen = strlen( itab1-CROInfo ). subtract 1 from zlen. if itab1-CROInfo+zlen(1) = '^' and zlen > 0. itab1-CROInfo = itab1-CROInfo(zlen). elseif zlen =< 0. itab1-CROInfo = ''. endif. add 2 to zcount. read table ifile1 index zcount. itab1-filename = ifile1-input. append itab1. clear itab1. add 2 to zcount. enddo. ENDFORM. " extract_f13_data *---------------------------------------------------------------------* Form get_f13ra_files

*---------------------------------------------------------------------FORM get_f13ra_files. data: zsource(255), zdestin(255), zline_f13ra type i. * get contents of F13ra directory clear: pcmd, file_f13ra[]. concatenate 'dir/b' p_f13ra into pcmd separated by space. concatenate pcmd '*.txt' into pcmd. perform execute_command tables file_f13ra using pcmd. * check if backup is selected and make a copy of F13ra files *if p_backup = 'X'. * loop at file_f13ra. * clear: zsource, zdestin, pcmd. * concatenate p_f13ra file_f13ra into zsource. * concatenate b_f13ra file_f13ra into zdestin. * concatenate 'copy' zsource zdestin into pcmd separated by space. * perform execute_command tables dummy using pcmd. * endloop. *endif. * append contents of F13ra files into single internal table loop at file_f13ra. clear: zsource, temp_ifile2. refresh: temp_ifile2. concatenate p_f13ra file_f13ra into zsource. open dataset zsource in text mode. DO. READ DATASET zsource INTO temp_ifile2. IF sy-subrc <> 0. EXIT. ENDIF. append temp_ifile2. clear temp_ifile2. delete temp_ifile2 where input is initial. ENDDO. temp_ifile2-input = file_f13ra. append temp_ifile2. clear temp_ifile2. * check format of file by no. of lines describe table temp_ifile2 lines zline_f13ra. if zline_f13ra = 12. append lines of temp_ifile2 to ifile2. else. errtab-filename = file_f13ra. errtab-linenum = '-'. errtab-contents = '-'. errtab-message = 'Format of file is incorrect: Contents should have 11 lines'. append errtab. clear errtab. endif. close dataset zsource. * delete dataset zsource. "delete file endloop. "at file_f13ra ENDFORM. " get_f13ra_files *---------------------------------------------------------------------* Form extract_f13ra_data

*---------------------------------------------------------------------* Each applicant has 11+1 lines of data in ifile2 *---------------------------------------------------------------------FORM extract_f13ra_data. data: ztemp(1), zlines type i, zcount type i. describe table ifile2 lines zlines. zlines = zlines / 12. "no. of applicants zcount = 2. "start from line 2 of ifile2 DO zlines times. read table ifile2 index zcount. split ifile2-input at '^' into ztemp itab2-SVUReplyRef. zlen = strlen( itab2-SVUReplyRef ). subtract 1 from zlen. *+ M03 * if itab2-SVUReplyRef+zlen(1) = '^'. * itab2-SVUReplyRef = itab2-SVUReplyRef(zlen). * endif. if itab2-SVUReplyRef+zlen(1) = '^' and zlen > 0. itab2-SVUReplyRef = itab2-SVUReplyRef(zlen). elseif zlen <= 0. itab2-SVUReplyRef = ''. endif. *- M03 add 1 to zcount. read table ifile2 index zcount. split ifile2-input at '^' into ztemp itab2-DateReplied. zlen = strlen( itab2-DateReplied ). subtract 1 from zlen. *+ M03 * if itab2-DateReplied+zlen(1) = '^'. * itab2-DateReplied = itab2-DateReplied(zlen). * endif. if itab2-DateReplied+zlen(1) = '^' and zlen > 0. itab2-DateReplied = itab2-DateReplied(zlen). elseif zlen <= 0. itab2-DateReplied = ''. endif. *- M03 add 1 to zcount. read table ifile2 index zcount. split ifile2-input at '^' into ztemp itab2-ARSNo. zlen = strlen( itab2-ARSNo ). subtract 1 from zlen. *+ M03 * if itab2-ARSNo+zlen(1) = '^'. * itab2-ARSNo = itab2-ARSNo(zlen). * endif. if itab2-ARSNo+zlen(1) = '^' and zlen > 0. itab2-ARSNo = itab2-ARSNo(zlen). elseif zlen <= 0.

itab2-ARSNo = ''. endif. *- M03 add 1 to zcount. read table ifile2 index zcount. split ifile2-input at '^' into ztemp itab2-Name. zlen = strlen( itab2-Name ). subtract 1 from zlen. *+ M03 * if itab2-Name+zlen(1) = '^'. * itab2-Name = itab2-Name(zlen). * endif. if itab2-Name+zlen(1) = '^' and zlen > 0. itab2-Name = itab2-Name(zlen). elseif zlen <= 0. itab2-Name = ''. endif. *-M03 add 1 to zcount. read table ifile2 index zcount. split ifile2-input at '^' into ztemp itab2-NRIC. zlen = strlen( itab2-NRIC ). subtract 1 from zlen. *+ M03 * if itab2-NRIC+zlen(1) = '^'. * itab2-NRIC = itab2-NRIC(zlen). * endif. if itab2-NRIC+zlen(1) = '^' and zlen > 0. itab2-NRIC = itab2-NRIC(zlen). elseif zlen <= 0. itab2-NRIC = ''. endif. *- M03 add 1 to zcount. read table ifile2 index zcount. split ifile2-input at '^' into ztemp itab2-SVUTraced. zlen = strlen( itab2-SVUTraced ). subtract 1 from zlen. *+ M03 * if itab2-SVUTraced+zlen(1) = '^'. * itab2-SVUTraced = itab2-SVUTraced(zlen). * endif. if itab2-SVUTraced+zlen(1) = '^' and zlen > 0. itab2-SVUTraced = itab2-SVUTraced(zlen). elseif zlen <= 0. itab2-SVUTraced = ''. endif. *- M03 add 1 to zcount. read table ifile2 index zcount. split ifile2-input at '^' into ztemp itab2-SVUInfo. zlen = strlen( itab2-SVUInfo ). subtract 1 from zlen.

if itab2-SVUInfo+zlen(1) = '^' and zlen > 0. itab2-SVUInfo = itab2-SVUInfo(zlen). elseif zlen =< 0. itab2-SVUInfo = ''. endif. add 1 to zcount. read table ifile2 index zcount. split ifile2-input at '^' into ztemp itab2-ISDTraced. zlen = strlen( itab2-ISDTraced ). subtract 1 from zlen. *+ M03 * if itab2-ISDTraced+zlen(1) = '^'. * itab2-ISDTraced = itab2-ISDTraced(zlen). * endif. if itab2-ISDTraced+zlen(1) = '^' and zlen > 0. itab2-ISDTraced = itab2-ISDTraced(zlen). elseif zlen <= 0. itab2-ISDTraced = ''. endif. *- M03 add 1 to zcount. read table ifile2 index zcount. split ifile2-input at '^' into ztemp itab2-ISDInfo. zlen = strlen( itab2-ISDInfo ). subtract 1 from zlen. if itab2-ISDInfo+zlen(1) = '^' and zlen > 0. itab2-ISDInfo = itab2-ISDInfo(zlen). elseif zlen =< 0. itab2-ISDInfo = ''. endif. add 2 to zcount. read table ifile2 index zcount. itab2-filename = ifile2-input. append itab2. clear itab2. add 2 to zcount. ENDDO. ENDFORM. " extract_f13ra_data *---------------------------------------------------------------------* Form upload_data *---------------------------------------------------------------------form upload_data. * upload F13.txt file ** Start Changes, Clila 20-Jun-06 Des: changed the WS_UPLOAD to GUI_UPLOAD ** * call function 'WS_UPLOAD' * EXPORTING * filename = f13 * filetype = 'DAT' * TABLES * data_tab = ifile1 * EXCEPTIONS * conversion_error = 1 * file_open_error = 2

* * * * * *

file_read_error invalid_type no_batch unknown_error invalid_table_width others

= = = = = =

3 4 5 6 7 10.

call function 'GUI_UPLOAD' EXPORTING filename = f13 filetype = 'ASC' TABLES data_tab = ifile1 EXCEPTIONS conversion_error = 1 file_open_error = 2 file_read_error = 3 invalid_type = 4 no_batch = 5 unknown_error = 6 invalid_table_width = 7 others = 10. ** End Changes, Clila 20-Jun-06 Des: changed the WS_UPLOAD to GUI_UPLOAD ** zsubrc = sy-subrc. if zsubrc ne 0. CASE ZSUBRC. WHEN 1. MESSAGE i001 WITH ztxt1 'File conversion error.' ztxt2. WHEN 2. MESSAGE i001 WITH ztxt1 'Unable to open file.' ztxt2. WHEN 3. MESSAGE i001 WITH ztxt1 'Unable to read file.' ztxt2. WHEN 4. MESSAGE i001 WITH ztxt1 'Invalid type.' ztxt2. WHEN 5. MESSAGE i001 WITH ztxt1 'No batch.' ztxt2. WHEN 6. MESSAGE i001 WITH ztxt1 'Unknown error' ztxt2. WHEN 7. MESSAGE i001 WITH ztxt1 'Invalid table width' ztxt2. WHEN 10. MESSAGE i001 WITH ztxt1 'Others' ztxt2. ENDCASE. else. message i001 with 'of CRO information successful'. endif. * upload F13RA.txt file ** Start Changes, Clila 20-Jun-06 call function 'WS_UPLOAD' EXPORTING filename = filetype = TABLES data_tab = EXCEPTIONS conversion_error = file_open_error = file_read_error = invalid_type = Des: changed the WS_UPLOAD to GUI_UPLOAD ** f13ra 'DAT' ifile2 1 2 3 4

no_batch unknown_error invalid_table_width others

= = = =

5 6 7 10.

call function 'GUI_UPLOAD' EXPORTING filename = f13ra filetype = 'ASC' TABLES data_tab = ifile2 EXCEPTIONS conversion_error = 1 file_open_error = 2 file_read_error = 3 invalid_type = 4 no_batch = 5 unknown_error = 6 invalid_table_width = 7 others = 10. ** End Changes, Clila 20-Jun-06 Des: changed the WS_UPLOAD to GUI_UPLOAD ** zsubrc = sy-subrc. if zsubrc ne 0. CASE ZSUBRC. WHEN 1. MESSAGE i001 WITH ztxt1 'File conversion error.' ztxt2. WHEN 2. MESSAGE i001 WITH ztxt1 'Unable to open file.' ztxt2. WHEN 3. MESSAGE i001 WITH ztxt1 'Unable to read file.' ztxt2. WHEN 4. MESSAGE i001 WITH ztxt1 'Invalid type.' ztxt2. WHEN 5. MESSAGE i001 WITH ztxt1 'No batch.' ztxt2. WHEN 6. MESSAGE i001 WITH ztxt1 'Unknown error' ztxt2. WHEN 7. MESSAGE i001 WITH ztxt1 'Invalid table width' ztxt2. WHEN 10. MESSAGE i001 WITH ztxt1 'Others' ztxt2. ENDCASE. else. message i001 with 'of SVU/ISD information successful'. endif. endform. "upload_data *---------------------------------------------------------------------* Form extract_f13 *---------------------------------------------------------------------* Extract data from ifile1 to itab1 *---------------------------------------------------------------------FORM extract_f13. data: ztemp(1). read table ifile1 index 2. split ifile1-input at '^' into ztemp itab1-SVUReplyRef. zlen = strlen( itab1-SVUReplyRef ). subtract 1 from zlen. if itab1-SVUReplyRef+zlen(1) = '^'. itab1-SVUReplyRef = itab1-SVUReplyRef(zlen). endif.

read table ifile1 index 3. split ifile1-input at '^' into ztemp itab1-DateReplied. zlen = strlen( itab1-DateReplied ). subtract 1 from zlen. if itab1-DateReplied+zlen(1) = '^'. itab1-DateReplied = itab1-DateReplied(zlen). endif. read table ifile1 index 4. split ifile1-input at '^' into ztemp itab1-ARSNo. zlen = strlen( itab1-ARSNo ). subtract 1 from zlen. if itab1-ARSNo+zlen(1) = '^'. itab1-ARSNo = itab1-ARSNo(zlen). endif. read table ifile1 index 5. split ifile1-input at '^' into ztemp itab1-Name. zlen = strlen( itab1-Name ). subtract 1 from zlen. if itab1-Name+zlen(1) = '^'. itab1-Name = itab1-Name(zlen). endif. read table ifile1 index 6. split ifile1-input at '^' into ztemp itab1-NRIC. zlen = strlen( itab1-NRIC ). subtract 1 from zlen. if itab1-NRIC+zlen(1) = '^'. itab1-NRIC = itab1-NRIC(zlen). endif. read table ifile1 index 7. split ifile1-input at '^' into ztemp itab1-CROTraced. zlen = strlen( itab1-CROTraced ). subtract 1 from zlen. if itab1-CROTraced+zlen(1) = '^'. itab1-CROTraced = itab1-CROTraced(zlen). endif. read table ifile1 index 8. split ifile1-input at '^' into ztemp itab1-CROInfo. zlen = strlen( itab1-CROInfo ). subtract 1 from zlen. if itab1-CROInfo+zlen(1) = '^'. itab1-CROInfo = itab1-CROInfo(zlen). endif. append itab1. clear itab1. ENDFORM. "extract_f13 *---------------------------------------------------------------------* Form extract_f13ra *---------------------------------------------------------------------* Extract data from ifile2 to itab2 *---------------------------------------------------------------------FORM extract_f13ra. data: ztemp(1).

read table ifile2 index 2. split ifile2-input at '^' into ztemp itab2-SVUReplyRef. zlen = strlen( itab2-SVUReplyRef ). subtract 1 from zlen. if itab2-SVUReplyRef+zlen(1) = '^'. itab2-SVUReplyRef = itab2-SVUReplyRef(zlen). endif. read table ifile2 index 3. split ifile2-input at '^' into ztemp itab2-DateReplied. zlen = strlen( itab2-DateReplied ). subtract 1 from zlen. if itab2-DateReplied+zlen(1) = '^'. itab2-DateReplied = itab2-DateReplied(zlen). endif. read table ifile2 index 4. split ifile2-input at '^' into ztemp itab2-ARSNo. zlen = strlen( itab2-ARSNo ). subtract 1 from zlen. if itab2-ARSNo+zlen(1) = '^'. itab2-ARSNo = itab2-ARSNo(zlen). endif. read table ifile2 index 5. split ifile2-input at '^' into ztemp itab2-Name. zlen = strlen( itab2-Name ). subtract 1 from zlen. if itab2-Name+zlen(1) = '^'. itab2-Name = itab2-Name(zlen). endif. read table ifile2 index 6. split ifile2-input at '^' into ztemp itab2-NRIC. zlen = strlen( itab2-NRIC ). subtract 1 from zlen. if itab2-NRIC+zlen(1) = '^'. itab2-NRIC = itab2-NRIC(zlen). endif. read table ifile2 index 7. split ifile2-input at '^' into ztemp itab2-SVUTraced. zlen = strlen( itab2-SVUTraced ). subtract 1 from zlen. if itab2-SVUTraced+zlen(1) = '^'. itab2-SVUTraced = itab2-SVUTraced(zlen). endif. read table ifile2 index 8. split ifile2-input at '^' into ztemp itab2-SVUInfo. zlen = strlen( itab2-SVUInfo ). subtract 1 from zlen. if itab2-SVUInfo+zlen(1) = '^'. itab2-SVUInfo = itab2-SVUInfo(zlen). endif. read table ifile2 index 9. split ifile2-input at '^' into ztemp itab2-ISDTraced. zlen = strlen( itab2-ISDTraced ). subtract 1 from zlen.

if itab2-ISDTraced+zlen(1) = '^'. itab2-ISDTraced = itab2-ISDTraced(zlen). endif. read table ifile2 index 10. split ifile2-input at '^' into ztemp itab2-ISDInfo. zlen = strlen( itab2-ISDInfo ). subtract 1 from zlen. if itab2-ISDInfo+zlen(1) = '^'. itab2-ISDInfo = itab2-ISDInfo(zlen). endif. append itab2. clear itab2. ENDFORM. "extract_f13ra *---------------------------------------------------------------------* Form word_wrap_f13 *---------------------------------------------------------------------FORM word_wrap_f13. clear: CRO[]. CALL FUNCTION 'RKD_WORD_WRAP' EXPORTING TEXTLINE = itab3-CROInfo OUTPUTLEN = 72 TABLES OUT_LINES = CRO. ENDFORM. "word_wrap_f13 *---------------------------------------------------------------------* Form word_wrap_f13ra *---------------------------------------------------------------------FORM word_wrap_f13ra. clear: SVU[], ISD[]. CALL FUNCTION EXPORTING TEXTLINE OUTPUTLEN TABLES OUT_LINES 'RKD_WORD_WRAP' = itab3-SVUInfo = 72 = SVU.

CALL FUNCTION 'RKD_WORD_WRAP' EXPORTING TEXTLINE = itab3-ISDInfo OUTPUTLEN = 72 TABLES OUT_LINES = ISD. ENDFORM. "word_wrap_f13ra *---------------------------------------------------------------------* Form validate_f13 *---------------------------------------------------------------------FORM validate_f13. data: dd(2), mm(2), yyyy(4). *+ M01 * check if applicant has another file in folder perform check_duplicate_f13. *- M01 loop at itab1.

* change date replied to ddmmyyyy dd = itab1-DateReplied(2). mm = itab1-DateReplied+3(2). yyyy = itab1-DateReplied+6(4). concatenate dd mm yyyy into itab1-DateReplied. modify itab1. * validate date replied clear zout_date. CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL' EXPORTING DATE_EXTERNAL = itab1-DateReplied IMPORTING DATE_INTERNAL = zout_date EXCEPTIONS DATE_EXTERNAL_IS_INVALID = 1 OTHERS = 2. if zout_date is initial. itab1-error = 'X'. "mark as an error record modify itab1. errtab-filename = itab1-filename. errtab-linenum = '3'. errtab-contents = itab1-DateReplied. errtab-message = text-002. append errtab. clear errtab. endif. * check applicant no. select single * from pb4000 where pernr = itab1-ARSNo. if sy-subrc <> 0. "applicant no. not found itab1-error = 'X'. modify itab1. errtab-filename = itab1-filename. errtab-linenum = '4'. errtab-contents = itab1-ARSNo. errtab-message = text-003. append errtab. clear errtab. endif. * check activity 'CAT2 clearance' is in planned status select single * from pb4003 where pernr = itab1-ARSNo and apact = '051'. if sy-subrc = 0. *+ M04 start clear pb4003. select single * from pb4003 where pernr = itab1-ARSNo and apact = '051' and indic = 'S'. *- M04 end if pb4003-indic <> 'S'. itab1-error = 'X'. modify itab1. errtab-filename = itab1-filename. errtab-linenum = '-'. errtab-contents = itab1-ARSNo. errtab-message = text-005.

append errtab. clear errtab. endif. else. itab1-error = 'X'. modify itab1. errtab-filename = itab1-filename. errtab-linenum = '-'. errtab-contents = itab1-ARSNo. errtab-message = text-004. append errtab. clear errtab. endif. *+ M01 * Removed check against applicant name * check input name against pb0001-ename * select single * from pb0001 where ename = itab1-Name * and pernr = itab1-ARSNo. * if sy-subrc <> 0. * itab1-error = 'X'. * modify itab1. * errtab-filename = itab1-filename. * errtab-linenum = '5'. * errtab-contents = itab1-Name. * errtab-message = text-006. * append errtab. * clear errtab. * endif. *- M01 * check input nric against pb0185-icnum select single * from pb0185 where pernr = itab1-ARSNo and icnum = itab1-NRIC. if sy-subrc <> 0. itab1-error = 'X'. modify itab1. errtab-filename = itab1-filename. errtab-linenum = '6'. errtab-contents = itab1-NRIC. errtab-message = text-007. append errtab. clear errtab. endif. * check CROTraced value *+ M02 * if not ( itab1-CROTraced = 'Y' * or itab1-CROTraced = 'N' ). * itab1-error = 'X'. * modify itab1. * errtab-filename = itab1-filename. * errtab-linenum = '7'. * errtab-contents = itab1-CROTraced. * errtab-message = text-008. * append errtab. * clear errtab. * endif. if not ( itab1-CROTraced = 'Y' or itab1-CROTraced = 'N'

or itab1-CROTraced = 'NA' ). itab1-error = 'X'. modify itab1. errtab-filename = itab1-filename. errtab-linenum = '7'. errtab-contents = itab1-CROTraced. errtab-message = text-008. append errtab. clear errtab. endif. *- M02 * commented by alice, to include trace info when avail * CRO info should be blank if indicator = N * if itab1-CROTraced = 'N'. * if not itab1-CROInfo is initial. * itab1-error = 'X'. * modify itab1. * errtab-filename = itab1-filename. * errtab-linenum = '8'. * errtab-contents = itab1-CROInfo. * errtab-message = text-009. * append errtab. * clear errtab. * endif. * endif. * * CRO info should not be blank if indicator = Y * if itab1-CROTraced = 'Y'. * if itab1-CROInfo is initial. * itab1-error = 'X'. * modify itab1. * errtab-filename = itab1-filename. * errtab-linenum = '7'. * errtab-contents = itab1-CROTraced. * errtab-message = text-020. * append errtab. * clear errtab. * endif. * endif. * ** end of comment endloop. "at itab1 ENDFORM. "validate_f13 *---------------------------------------------------------------------* Form validate_f13ra *---------------------------------------------------------------------FORM validate_f13ra. data: dd(2), mm(2), yyyy(4). *+ M01 * check if applicant has another file in folder perform check_duplicate_f13ra. *- M01 loop at itab2. * change date replied to ddmmyyyy dd = itab2-DateReplied(2). mm = itab2-DateReplied+3(2).

yyyy = itab2-DateReplied+6(4). concatenate dd mm yyyy into itab2-DateReplied. modify itab2. * validate date replied clear zout_date. CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL' EXPORTING DATE_EXTERNAL = itab2-DateReplied IMPORTING DATE_INTERNAL = zout_date EXCEPTIONS DATE_EXTERNAL_IS_INVALID = 1 OTHERS = 2. if zout_date is initial. itab2-error = 'X'. "mark as an error record modify itab2. errtab-filename = itab2-filename. errtab-linenum = '3'. errtab-contents = itab2-DateReplied. errtab-message = text-002. append errtab. clear errtab. endif. * check applicant no. select single * from pb4000 where pernr = itab2-ARSNo. if sy-subrc <> 0. "applicant no. not found itab2-error = 'X'. modify itab2. errtab-filename = itab2-filename. errtab-linenum = '4'. errtab-contents = itab2-ARSNo. errtab-message = text-003. append errtab. clear errtab. endif. * check activity 'CAT2 clearance' is in planned status select single * from pb4003 where pernr = itab2-ARSNo and apact = '051'. if sy-subrc = 0. *+ M04 start clear pb4003. select single * from pb4003 where pernr = itab2-ARSNo and apact = '051' and indic = 'S'. *- M04 end if pb4003-indic <> 'S'. itab2-error = 'X'. modify itab2. errtab-filename = itab2-filename. errtab-linenum = '-'. errtab-contents = itab2-ARSNo. errtab-message = text-005. append errtab. clear errtab. endif. else.

itab2-error = 'X'. modify itab2. errtab-filename = itab2-filename. errtab-linenum = '-'. errtab-contents = itab2-ARSNo. errtab-message = text-004. append errtab. clear errtab. endif. *+ M01 * Removed check against applicant name * check input name against pb0001-ename * select single * from pb0001 where ename = itab2-Name * and pernr = itab2-ARSNo. * if sy-subrc <> 0. * itab2-error = 'X'. * modify itab2. * errtab-filename = itab2-filename. * errtab-linenum = '5'. * errtab-contents = itab2-Name. * errtab-message = text-006. * append errtab. * clear errtab. * endif. *- M01 * check input nric against pb0185-icnum select single * from pb0185 where pernr = itab2-ARSNo and icnum = itab2-NRIC. if sy-subrc <> 0. itab2-error = 'X'. modify itab2. errtab-filename = itab2-filename. errtab-linenum = '6'. errtab-contents = itab2-NRIC. errtab-message = text-007. append errtab. clear errtab. endif. * check SVUTraced value *+ M02 * if not ( itab2-SVUTraced = 'Y' * or itab2-SVUTraced = 'N' ). * itab2-error = 'X'. * modify itab2. * errtab-filename = itab2-filename. * errtab-linenum = '7'. * errtab-contents = itab2-SVUTraced. * errtab-message = text-010. * append errtab. * clear errtab. * endif. if not ( itab2-SVUTraced = 'Y' or itab2-SVUTraced = 'N' or itab2-SVUTraced = 'NA' ). itab2-error = 'X'. modify itab2. errtab-filename = itab2-filename.

errtab-linenum = '7'. errtab-contents = itab2-SVUTraced. errtab-message = text-010. append errtab. clear errtab. endif. *- M02 * commented by Alice, to update trace info when avail ** SVU info should be blank if indicator = N * if itab2-SVUTraced = 'N'. * if not itab2-SVUInfo is initial. * itab2-error = 'X'. * modify itab2. * errtab-filename = itab2-filename. * errtab-linenum = '8'. * errtab-contents = itab2-SVUInfo. * errtab-message = text-011. * append errtab. * clear errtab. * endif. * endif. * * SVU info should not be blank if indicator = Y * if itab2-SVUTraced = 'Y'. * if itab2-SVUInfo is initial. * itab2-error = 'X'. * modify itab2. * errtab-filename = itab2-filename. * errtab-linenum = '7'. * errtab-contents = itab2-SVUTraced. * errtab-message = text-021. * append errtab. * clear errtab. * endif. * endif. * ** end of comment * check ISDTraced value *+ M02 * if not ( itab2-ISDTraced = 'Y' * or itab2-ISDTraced = 'N' ). * itab2-error = 'X'. * modify itab2. * errtab-filename = itab2-filename. * errtab-linenum = '9'. * errtab-contents = itab2-ISDTraced. * errtab-message = text-012. * append errtab. * clear errtab. * endif. if not ( itab2-ISDTraced = 'Y' or itab2-ISDTraced = 'N' or itab2-ISDTraced = 'NA' ). itab2-error = 'X'. modify itab2. errtab-filename = itab2-filename. errtab-linenum = '9'. errtab-contents = itab2-ISDTraced.

errtab-message = text-012. append errtab. clear errtab. endif. *- M02 * commented by Alice, to update trace info when avail * ISD info should be blank if indicator = N * if itab2-ISDTraced = 'N'. * if not itab2-ISDInfo is initial. * itab2-error = 'X'. * modify itab2. * errtab-filename = itab2-filename. * errtab-linenum = '10'. * errtab-contents = itab2-ISDInfo. * errtab-message = text-013. * append errtab. * clear errtab. * endif. * endif. * ** ISD info should not be blank if indicator = Y * if itab2-ISDTraced = 'Y'. * if itab2-ISDInfo is initial. * itab2-error = 'X'. * modify itab2. * errtab-filename = itab2-filename. * errtab-linenum = '9'. * errtab-contents = itab2-ISDTraced. * errtab-message = text-022. * append errtab. * clear errtab. * endif. * endif. * endloop. "at itab2 ENDFORM. "validate_f13ra *----------------------------------------------------------------------* Form check_IT9022 *----------------------------------------------------------------------* Check for any existing record in IT9022 (CRO,SVU,ISD) *----------------------------------------------------------------------FORM check_IT9022. loop at itab1. * if itab1-error <> 'X'. select single * from pb9022 where pernr = itab1-ARSNo and zsubty = '0001' "CRO and begda = sy-datum "M04 and zreplyref = itab1-SVUReplyRef. if sy-subrc = 0. "record already exists itab1-error = 'X'. modify itab1. errtab-filename = itab1-filename. errtab-linenum = '-'. errtab-contents = '-'. concatenate text-014 itab1-ARSNo into errtab-message separated by space. append errtab.

clear errtab. endif. * endif. "itab1-error <> 'X' endloop. "at itab1

loop at itab2. * if itab2-error <> 'X'. select single * from pb9022 where pernr = itab2-ARSNo and zsubty = '0002' "SVU and begda = sy-datum "M04 and zreplyref = itab2-SVUReplyRef. if sy-subrc = 0. "record already exists itab2-error = 'X'. modify itab2. errtab-filename = itab2-filename. errtab-linenum = '-'. errtab-contents = '-'. concatenate text-015 itab2-ARSNo into errtab-message separated by space. append errtab. clear errtab. endif. select single * from pb9022 where pernr = itab2-ARSNo and zsubty = '0003' "ISD and begda = sy-datum "M04 and zreplyref = itab2-SVUReplyRef. if sy-subrc = 0. "record already exists itab2-error = 'X'. modify itab2. errtab-filename = itab2-filename. errtab-linenum = '-'. errtab-contents = '-'. concatenate text-016 itab2-ARSNo into errtab-message separated by space. append errtab. clear errtab. endif. * endif. endloop. "itab2-error <> 'X' "at itab2

ENDFORM. "check_IT9022 *----------------------------------------------------------------------* Form populate_itab3 *----------------------------------------------------------------------FORM populate_itab3. * remove error records before proceed delete itab1 where error = 'X'. delete itab2 where error = 'X'. describe table errtab lines ztot_err. loop at itab1. itab3-SVUReplyRef1 = itab1-SVUReplyRef. itab3-DateReplied1 = itab1-DateReplied.

itab3-ARSNo = itab1-ARSNo. itab3-Name = itab1-Name. itab3-NRIC = itab1-NRIC. itab3-CROTraced = itab1-CROTraced. itab3-CROInfo = itab1-CROInfo. itab3-f13 = itab1-filename. * only append if applicant has all 3 records (w/o errors) read table itab2 with key ARSNo = itab1-ARSNo. if sy-subrc = 0. itab3-SVUReplyRef2 = itab2-SVUReplyRef. itab3-DateReplied2 = itab2-DateReplied. itab3-SVUTraced = itab2-SVUTraced. itab3-SVUInfo = itab2-SVUInfo. itab3-ISDTraced = itab2-ISDTraced. itab3-ISDInfo = itab2-ISDInfo. itab3-f13ra = itab2-filename. append itab3. clear itab3. else. clear itab3. * exit. "do not create record if applicant has incomplete info endif. endloop. ENDFORM. " populate_itab3 *----------------------------------------------------------------------* Form message_error *----------------------------------------------------------------------FORM message_error. describe table errtab lines counter. if counter <> 0. tempchar = counter. concatenate 'Total errors found:' tempchar into zmessage separated by space. message i002 with zmessage. endif. ENDFORM. "message_error *----------------------------------------------------------------------* Form populate_datatabM *----------------------------------------------------------------------FORM populate_datatabM. data: dd(2), mm(2), yyyy(4). loop at itab1. datatabM-ARSNo = itab1-ARSNo. datatabM-NRIC = itab1-NRIC. datatabM-Name = itab1-Name. datatabM-Trace = 'CRO'. datatabM-SVUReplyRef = itab1-SVUReplyRef. dd = itab1-DateReplied(2). mm = itab1-DateReplied+2(2). yyyy = itab1-DateReplied+4(4). concatenate dd '/' mm '/' yyyy into datatabM-DateReplied. datatabM-Traced = itab1-CROTraced. clear zline. describe table CRO lines zline. if itab1-CROTraced = 'Y' and zline > 0. * populate CRO trace info loop at CRO. datatabM-Info = CRO-remark. append datatabM. clear datatabM.

endloop. else. append datatabM. clear datatabM. endif. endloop. "at itab1 loop at itab2. datatabM-ARSNo = itab2-ARSNo. datatabM-NRIC = itab2-NRIC. datatabM-Name = itab2-Name. datatabM-Trace = 'SVU'. datatabM-SVUReplyRef = itab2-SVUReplyRef. dd = itab2-DateReplied(2). mm = itab2-DateReplied+2(2). yyyy = itab2-DateReplied+4(4). concatenate dd '/' mm '/' yyyy into datatabM-DateReplied. datatabM-Traced = itab2-SVUTraced. clear zline. describe table SVU lines zline. if itab2-SVUTraced = 'Y' and zline > 0. * populate SVU trace info loop at SVU. datatabM-Info = SVU-remark. append datatabM. clear datatabM. endloop. else. append datatabM. clear datatabM. endif. datatabM-ARSNo = itab2-ARSNo. datatabM-NRIC = itab2-NRIC. datatabM-Name = itab2-Name. datatabM-Trace = 'ISD'. datatabM-SVUReplyRef = itab2-SVUReplyRef. dd = itab2-DateReplied(2). mm = itab2-DateReplied+2(2). yyyy = itab2-DateReplied+4(4). concatenate dd '/' mm '/' yyyy into datatabM-DateReplied. datatabM-Traced = itab2-ISDTraced. clear zline. describe table ISD lines zline. if itab2-ISDTraced = 'Y' and zline > 0. * populate SVU trace info loop at ISD. datatabM-Info = ISD-remark. append datatabM. clear datatabM. endloop. else. append datatabM. clear datatabM. endif. endloop. "at itab2. ENDFORM. "populate_datatabM *----------------------------------------------------------------------* Form fill_fieldtab *-----------------------------------------------------------------------

FORM fill_fieldtab tables fieldX like fieldtabM[] using value(text) value(tabname) value(fieldname) value(type). clear fieldX. fieldX-text = text. fieldX-tabname = tabname. fieldX-fieldname = fieldname. fieldX-typ = type. append fieldX. ENDFORM. "fill_fieldtab *----------------------------------------------------------------------* Form populate_fieldtabM *----------------------------------------------------------------------* Populate headings into fieldtabM for main summary *----------------------------------------------------------------------FORM populate_fieldtabM. perform fill_fieldtab tables fieldtabM using 'Applicant No' '' '' ''. perform fill_fieldtab tables fieldtabM using 'NRIC' '' '' ''. perform fill_fieldtab tables fieldtabM using 'Name' '' '' ''. perform fill_fieldtab tables fieldtabM using 'Trace Type' '' '' ''. perform fill_fieldtab tables fieldtabM using 'SVUReplyRef' '' '' ''. perform fill_fieldtab tables fieldtabM using 'Date Replied' '' '' ''. perform fill_fieldtab tables fieldtabM using 'Trace?' '' '' ''. perform fill_fieldtab tables fieldtabM using 'Trace Info' '' '' ''. ENDFORM. "populate_fieldtabM *----------------------------------------------------------------------* Form populate_fieldtabE *----------------------------------------------------------------------* Populate headings into fieldtabE for errors screen *----------------------------------------------------------------------FORM populate_fieldtabE. perform fill_fieldtab tables fieldtabE using 'Filename' '' '' ''. perform fill_fieldtab tables fieldtabE using 'Line number' '' '' ''. perform fill_fieldtab tables fieldtabE using 'Contents' '' '' ''. perform fill_fieldtab tables fieldtabE using 'Message' '' '' ''. ENDFORM. "populate_fieldtabE *----------------------------------------------------------------------* Form display_listM *----------------------------------------------------------------------* Display list for main summary *----------------------------------------------------------------------FORM display_listM. data: upd_button(6). * if test mode selected, hide update button *if mode <> 'X'.

upd_button = 'Update'. *endif. CALL FUNCTION 'HR_DISPLAY_BASIC_LIST' EXPORTING * BASIC_LIST_TITLE = ' ' FILE_NAME = ' ' HEAD_LINE1 = 'Summary' * HEAD_LINE2 = ' ' * FOOT_NOTE1 = ' ' * FOOT_NOTE2 = ' ' * FOOT_NOTE3 = ' ' * LAY_OUT = 0 * DATA_STRUCTURE = ' ' * HEAD_LINE3 = ' ' * HEAD_LINE4 = ' ' CURRENT_REPORT = sy-repid LIST_LEVEL = '01' * DYN_PUSHBUTTON_TEXT1 = TEXT-017 "Summary DYN_PUSHBUTTON_TEXT2 = TEXT-018 "Errors DYN_PUSHBUTTON_TEXT3 = upd_button "Update * ADDITIONAL_OPTIONS = ' ' * WORD_DOCUMENT = * NO_ALV_GRID = 'X' * ALV_MARKER = 'X' IMPORTING RETURN_CODE = button_code TABLES DATA_TAB = datatabM FIELDNAME_TAB = fieldtabM. * SELECT_TAB = * ERROR_TAB = ENDFORM. "display_listM *----------------------------------------------------------------------* Form display_listE *----------------------------------------------------------------------* Display list for errors screen *----------------------------------------------------------------------FORM display_listE. CALL FUNCTION 'HR_DISPLAY_BASIC_LIST' EXPORTING * BASIC_LIST_TITLE = ' ' FILE_NAME = ' ' HEAD_LINE1 = 'Errors' * HEAD_LINE2 = ' ' * FOOT_NOTE1 = ' ' * FOOT_NOTE2 = ' ' * FOOT_NOTE3 = ' ' * LAY_OUT = 0 * DATA_STRUCTURE = ' ' * HEAD_LINE3 = ' ' * HEAD_LINE4 = ' ' CURRENT_REPORT = sy-repid LIST_LEVEL = '02' DYN_PUSHBUTTON_TEXT1 = TEXT-017 "Summary * DYN_PUSHBUTTON_TEXT2 = TEXT-018 "Errors * DYN_PUSHBUTTON_TEXT3 = TEXT-019 "Update * ADDITIONAL_OPTIONS = ' ' * WORD_DOCUMENT = * NO_ALV_GRID = 'X' * ALV_MARKER = 'X'

IMPORTING RETURN_CODE = button_code TABLES DATA_TAB = errtab FIELDNAME_TAB = fieldtabE. * SELECT_TAB = * ERROR_TAB = ENDFORM. "display_listE *----------------------------------------------------------------------* Form update_records *----------------------------------------------------------------------FORM update_records. describe table itab3 lines line3. * describe table errtab lines ztot_err. * initialize return codes for CRO,ISD,SVU records to 1. CROrc = 1. ISDrc = 1. SVUrc = 1. if line3 <> 0. * perform bdc_open_group. loop at itab3.

**** Create CRO record perform word_wrap_f13. PERFORM BDC_SCREEN tables PERFORM BDC_FIELD tables PERFORM BDC_FIELD tables PERFORM BDC_FIELD tables PERFORM BDC_FIELD tables PERFORM BDC_FIELD tables PERFORM PERFORM PERFORM PERFORM BDC_SCREEN BDC_FIELD BDC_FIELD BDC_FIELD tables tables tables tables

bdc_tab bdc_tab bdc_tab bdc_tab bdc_tab bdc_tab bdc_tab bdc_tab bdc_tab bdc_tab

USING USING USING USING USING USING USING USING USING USING

'SAPMP50A' '4000'. 'BDC_OKCODE' '=INS'. 'RPAPP-APLNO' itab3-ARSNo. 'RP50G-TIMR6' 'X'. 'RP50G-CHOIC' '9022'. 'RP50G-SUBTY' '0001'.

*+ * *+ * * *

*-

'MP902200' '2000'. 'BDC_OKCODE' '=UPD'. 'P9022-ZSUBTY' '0001'. 'P9022-ZREPLYREF' itab3-SVUReplyRef1. PERFORM BDC_FIELD tables bdc_tab USING 'P9022-ZUPDATE' itab3-DateReplied1. Amended by Damon: to update trace info when info exist regardless of Traced = Y or N M02 if itab3-CROTraced = 'Y'. PERFORM BDC_FIELD tables bdc_tab USING 'P9022-ZTRACE' 'X'. endif. CASE itab3-CROTraced. when 'Y'. PERFORM BDC_FIELD tables bdc_tab USING 'P9022-ZTRACERES' '01'. when 'N'. PERFORM BDC_FIELD tables bdc_tab USING 'P9022-ZTRACERES' '02'. when 'NA'. PERFORM BDC_FIELD tables bdc_tab USING 'P9022-ZTRACERES' '03'. ENDCASE. M02 if not CRO[] is initial. counter = 1. loop at CRO. countchar = counter.

concatenate 'P9022-ZREMARK' countchar into fieldname. PERFORM BDC_FIELD tables bdc_tab USING fieldname CRO-remark. add 1 to counter. endloop. "at CRO endif. *- End of amendment call transaction 'PB30' using bdc_tab mode 'E'. CROrc = sy-subrc. refresh bdc_tab. **** Create SVU record perform word_wrap_f13ra. PERFORM BDC_SCREEN tables PERFORM BDC_FIELD tables PERFORM BDC_FIELD tables PERFORM BDC_FIELD tables PERFORM BDC_FIELD tables PERFORM BDC_FIELD tables PERFORM PERFORM PERFORM PERFORM BDC_SCREEN BDC_FIELD BDC_FIELD BDC_FIELD tables tables tables tables

bdc_tab bdc_tab bdc_tab bdc_tab bdc_tab bdc_tab bdc_tab bdc_tab bdc_tab bdc_tab

USING USING USING USING USING USING USING USING USING USING

'SAPMP50A' '4000'. 'BDC_OKCODE' '=INS'. 'RPAPP-APLNO' itab3-ARSNo. 'RP50G-TIMR6' 'X'. 'RP50G-CHOIC' '9022'. 'RP50G-SUBTY' '0003'.

*+ * *+ * * *

*-

*-

'MP902200' '2000'. 'BDC_OKCODE' '=UPD'. 'P9022-ZSUBTY' '0003'. 'P9022-ZREPLYREF' itab3-SVUReplyRef2. PERFORM BDC_FIELD tables bdc_tab USING 'P9022-ZUPDATE' itab3-DateReplied2. Amended by Damon: to update trace info when info exist regardless of Traced = Y or N M02 if itab3-SVUTraced = 'Y'. PERFORM BDC_FIELD tables bdc_tab USING 'P9022-ZTRACE' 'X'. endif. CASE itab3-SVUTraced. when 'Y'. PERFORM BDC_FIELD tables bdc_tab USING 'P9022-ZTRACERES' '01'. when 'N'. PERFORM BDC_FIELD tables bdc_tab USING 'P9022-ZTRACERES' '02'. when 'NA'. PERFORM BDC_FIELD tables bdc_tab USING 'P9022-ZTRACERES' '03'. ENDCASE. M02 if not SVU[] is initial. counter = 1. loop at SVU. countchar = counter. concatenate 'P9022-ZREMARK' countchar into fieldname. PERFORM BDC_FIELD tables bdc_tab USING fieldname SVU-remark. add 1 to counter. endloop. "at SVU endif. End of amendment call transaction 'PB30' using bdc_tab mode 'E'. SVUrc = sy-subrc. refresh bdc_tab.

**** Create ISD record PERFORM BDC_SCREEN tables bdc_tab USING 'SAPMP50A' '4000'. PERFORM BDC_FIELD tables bdc_tab USING 'BDC_OKCODE' '=INS'.

PERFORM PERFORM PERFORM PERFORM PERFORM PERFORM PERFORM PERFORM

BDC_FIELD BDC_FIELD BDC_FIELD BDC_FIELD BDC_SCREEN BDC_FIELD BDC_FIELD BDC_FIELD

tables tables tables tables tables tables tables tables

bdc_tab bdc_tab bdc_tab bdc_tab bdc_tab bdc_tab bdc_tab bdc_tab

USING USING USING USING USING USING USING USING

'RPAPP-APLNO' 'RP50G-TIMR6' 'RP50G-CHOIC' 'RP50G-SUBTY'

itab3-ARSNo. 'X'. '9022'. '0002'.

*+ * *+ * * *

*-

*-

'MP902200' '2000'. 'BDC_OKCODE' '=UPD'. 'P9022-ZSUBTY' '0002'. 'P9022-ZREPLYREF' itab3-SVUReplyRef2. PERFORM BDC_FIELD tables bdc_tab USING 'P9022-ZUPDATE' itab3-DateReplied2. Amended by Damon: to update trace info when info exist regardless of Traced = Y or N M02 if itab3-ISDTraced = 'Y'. PERFORM BDC_FIELD tables bdc_tab USING 'P9022-ZTRACE' 'X'. endif. CASE itab3-ISDTraced. when 'Y'. PERFORM BDC_FIELD tables bdc_tab USING 'P9022-ZTRACERES' '01'. when 'N'. PERFORM BDC_FIELD tables bdc_tab USING 'P9022-ZTRACERES' '02'. when 'NA'. PERFORM BDC_FIELD tables bdc_tab USING 'P9022-ZTRACERES' '03'. ENDCASE. M02 if not ISD[] is initial. counter = 1. loop at ISD. countchar = counter. concatenate 'P9022-ZREMARK' countchar into fieldname. PERFORM BDC_FIELD tables bdc_tab USING fieldname ISD-remark. add 1 to counter. endloop. "at ISD endif. End of amendment call transaction 'PB30' using bdc_tab mode 'E'. ISDrc = sy-subrc. refresh bdc_tab.

**** update Cat2 security clearance when all 3 records are created if CROrc = 0 and SVUrc = 0 and ISDrc = 0. update pb4003 set indic = 'A' where pernr = itab3-ARSno and apact = '051' and indic = 'S'. if sy-subrc = 0. itab3-updated = 'Y'. modify itab3. else. itab3-updated = 'N'. "direct update error? modify itab3. endif. else. itab3-updated = 'N'. "BDC error? modify itab3. endif.

endloop. perform bdc_close_group. endif.

ENDFORM. "update_record *----------------------------------------------------------------------* Form update_cat2 *----------------------------------------------------------------------* Update applicant Cat2 security clearance to completed *----------------------------------------------------------------------FORM update_cat2. loop at itab1. update pb4003 set indic = 'A' where pernr = itab1-ARSno and apact = '051' and indic = 'S'. if sy-subrc = 0. message i002 with 'Cat2 Security Clearance has been completed'. endif. endloop. ENDFORM. "update_cat2 *----------------------------------------------------------------------* Form bdc_open_group *----------------------------------------------------------------------FORM bdc_open_group. call function 'BDC_OPEN_GROUP' EXPORTING client group keep user EXCEPTIONS client_invalid destination_invalid group_invalid group_is_locked holddate_invalid internal_error queue_error running system_lock_error user_invalid others

= = = = = = = = = = = = = = =

sy-mandt session 'X' sy-uname 1 2 3 4 5 6 7 8 9 10 11.

ENDFORM. "BDC_OPEN_GROUP *----------------------------------------------------------------------* Form bdc_screen *----------------------------------------------------------------------FORM bdc_screen tables p_bdc structure bdcdata using p_program p_screen. clear p_bdc. p_bdc-program = p_program. p_bdc-dynpro = p_screen. p_bdc-dynbegin = 'X'. append p_bdc. ENDFORM. "bdc_screen *----------------------------------------------------------------------* Form bdc_field *-----------------------------------------------------------------------

FORM bdc_field tables p_bdc structure bdcdata using p_name p_value. clear p_bdc. case p_value. when ' '. when others. p_bdc-fnam = p_name. p_bdc-fval = p_value. append p_bdc. endcase. ENDFORM. "bdc_field *----------------------------------------------------------------------* Form bdc_insert *----------------------------------------------------------------------FORM bdc_insert. call function 'BDC_INSERT' EXPORTING tcode = 'PB30' TABLES dynprotab = bdc_tab EXCEPTIONS internal_error = 1 not_open = 2 queue_error = 3 tcode_invalid = 4 others = 5. refresh bdc_tab. ENDFORM. "bdc_insert *----------------------------------------------------------------------* Form bdc_close_group *----------------------------------------------------------------------FORM bdc_close_group. call function 'BDC_CLOSE_GROUP' exceptions not_open = 1 queue_error = 2 others = 3. ENDFORM. "bdc_close_group *----------------------------------------------------------------------* Form check_errtab *----------------------------------------------------------------------FORM check_errtab. loop at errtab. write: /1 'Filename : ' ,errtab-filename. write: /1 'Line No. : ' ,errtab-linenum. write: /1 'Contents : ' ,errtab-contents. write: /1 'Message : ' ,errtab-message. skip 1. endloop. ENDFORM. "check_errtab *----------------------------------------------------------------------* Form execute_command *----------------------------------------------------------------------FORM execute_command tables in_result using in_cmd. CALL 'SYSTEM' ID 'COMMAND' FIELD in_cmd ID 'TAB' FIELD in_result-*sys*. r_code = sy-subrc.

ENDFORM. "execute_command *----------------------------------------------------------------------* * Form split_mhq_csit *----------------------------------------------------------------------* FORM split_mhq_csit. data: i0001 like p0001 occurs 0 with header line, aplno like p0001-pernr. sort itab3 by name. loop at itab3. clear: i0001, i0001[], aplno. aplno = itab3-ARSNo. CALL FUNCTION 'HR_READ_INFOTYPE' EXPORTING TCLAS = 'B' PERNR = aplno INFTY = '0001' BEGDA = '18000101' ENDDA = '99991231' TABLES INFTY_TAB = i0001 EXCEPTIONS INFTY_NOT_FOUND = 1 OTHERS = 2. IF SY-SUBRC = 0. sort i0001 by begda descending. read table i0001 index 1. itab3-app_range = i0001-persk. modify itab3. ENDIF. endloop. * populate itab_mhq (applicant range = '91') read table itab3 with key app_range = '91'. if sy-subrc = 0. "populate headings for file attachment itab_mhq-ARSNo = 'Appl No.'. itab_mhq-NRIC = 'NRIC'. itab_mhq-Name = 'Name'. itab_mhq-Updated = 'Updated (Y/N)'. itab_mhq-Traced = 'Traced (Y/N)'. append itab_mhq. clear itab_mhq. endif. clear itab3. loop at itab3 where app_range = '91'. move-corresponding itab3 to itab_mhq. if itab3-CROTraced = 'Y' or itab3-ISDTraced = 'Y' or itab3-SVUTraced = 'Y'. itab_mhq-Traced = 'Y'. else. itab_mhq-Traced = 'N'. endif. append itab_mhq. clear itab_mhq. endloop.

* populate itab_csit (applicant range = '92') read table itab3 with key app_range = '92'. if sy-subrc = 0. "populate headings for file attachment itab_csit-ARSNo = 'Appl No.'. itab_csit-NRIC = 'NRIC'. itab_csit-Name = 'Name'. itab_csit-Updated = 'Updated (Y/N)'. itab_csit-Traced = 'Traced (Y/N)'. append itab_csit. clear itab_csit. endif. clear itab3. loop at itab3 where app_range = '92'. move-corresponding itab3 to itab_csit. if itab3-CROTraced = 'N' and itab3-ISDTraced = 'N' and itab3-SVUTraced = 'N'. itab_csit-Traced = 'N'. else. itab_csit-Traced = 'Y'. endif. append itab_csit. clear itab_csit. endloop. ENDFORM. " split_mhq_csit *----------------------------------------------------------------------* * Form write_report *----------------------------------------------------------------------* FORM write_report. write: /2 'Creation of OVU Records'. write: /2 sy-uline(23). write: / sy-uline(85). format intensified color 1. write: / sy-vline, 02 'Applicant No.', 16 sy-vline, 17 'NRIC', 30 sy-vline, 31 'Name', 70 sy-vline, 71 'Updated (Y/N)', 85 sy-vline. write: / sy-uline(85). loop at itab3. format color 2. write: / sy-vline, 02 itab3-ARSNo, 16 sy-vline, 17 itab3-NRIC, 30 sy-vline, 31 itab3-Name, 70 sy-vline, 77 itab3-updated, 85 sy-vline. format color off. at last. write: / sy-uline(85).

endat. endloop. ENDFORM. " write_report *----------------------------------------------------------------------* * Form write_errors *----------------------------------------------------------------------* FORM write_errors. new-page. write: /2 'Errors'. write: /2 sy-uline(7). write: / sy-uline(116). format intensified color 1. write: / sy-vline, 02 'Filename', 32 sy-vline, 33 'Line number', 45 sy-vline, 46 'Error Message', 116 sy-vline. write: / sy-uline(116). format color off. loop at errtab. format color 2. write: / sy-vline, 02 errtab-filename, 32 sy-vline, 33 errtab-linenum, 45 sy-vline, 46 errtab-message, 116 sy-vline. format color off. write: 117(13)' '. at last. write: / sy-uline(116). endat. endloop. ENDFORM. " write_errors *----------------------------------------------------------------------* * Form send_mail_mhq *----------------------------------------------------------------------* FORM send_mail_mhq. clear: objcont[], objhead[], reclist[], pl[], objtxt[], objcont, objhead, reclist, pl, objtxt, entries, tab_lines, doc_chng. DOC_CHNG-OBJ_NAME = 'OVU Inbound Report'. DOC_CHNG-OBJ_DESCR = 'OVU Screening Results'. DOC_CHNG-SENSITIVTY = 'P'. objtxt = 'OVU Inbound Report'. append objtxt. describe table objtxt lines tab_lines. read table objtxt index tab_lines.

doc_chng-doc_size = ( tab_lines - 1 ) * 255 + strlen( objtxt ). *** clear PL-transf_bin. PL-head_start = 1. PL-head_num = 0. PL-body_start = 1. PL-body_num = 0. PL-doc_type = 'RAW'. append PL. **** describe table mhq_txt lines tab_lines. * objhead = 'OVU_RPT_HQ'. append objhead. objhead = 'OVU_RPT_HQ.TXT'. append objhead. * Creation of the entry for the compressed attachment pl-transf_bin = 'X'. pl-head_start = 1. pl-head_num = 1. pl-body_start = 1. pl-body_num = tab_lines. * pl-doc_type = 'TXT'. "damon 20050401 pl-doc_type = 'RAW'. "damon 20050401 pl-obj_name = 'OVUScreen_HQ'. * pl-obj_descr = 'OVU_RPT_HQ'. pl-obj_descr = 'OVU_RPT_HQ.TXT'. pl-doc_size = tab_lines * 255. append pl. * * * * * * receive party reclist-receiver = 'OVU_SCREEN'. reclist-rec_type = 'C'. RECLIST-EXPRESS = ' '. APPEND RECLIST. CLEAR RECLIST.

* reclist-receiver = 'OVU_IN_HQ'. * reclist-rec_type = 'C'. reclist-receiver = 'OVU_IN_HQ'. reclist-rec_type = 'C'. RECLIST-EXPRESS = ' '. APPEND RECLIST. CLEAR RECLIST. call function 'SO_NEW_DOCUMENT_ATT_SEND_API1' EXPORTING document_data = doc_chng put_in_outbox = 'X' TABLES packing_list = pl object_header = objhead contents_bin = mhq_txt contents_txt = objtxt receivers = reclist EXCEPTIONS too_many_receivers = 1

document_not_sent = 2 operation_no_authorization = 4 others = 99. zmail_rc1 = sy-subrc. case sy-subrc. when 0. commit work. message s002 with 'OVU Inbound Report (MIDHQ) Sent'. when 1. message s002 with 'No authorization for sending to the specified recipients(MIDHQ)' . when 2. message s002 with 'Document could not be sent to any recipient(MIDHQ)'. when 4. message s002 with 'No send authorization(MIDHQ)'. when others. message s002 with 'Error occurred while sending(MIDHQ)'. endcase. ENDFORM. " send_mail_mhq *----------------------------------------------------------------------* * Form send_mail_csit *----------------------------------------------------------------------* FORM send_mail_csit. clear: objcont[], objhead[], reclist[], pl[], objtxt[], objcont, objhead, reclist, pl, objtxt, entries, tab_lines, doc_chng. DOC_CHNG-OBJ_NAME = 'OVU Inbound Report'. DOC_CHNG-OBJ_DESCR = 'OVU Screening Results'. DOC_CHNG-SENSITIVTY = 'P'. objtxt = 'OVU Inbound Report'. append objtxt. describe table objtxt lines tab_lines. read table objtxt index tab_lines. doc_chng-doc_size = ( tab_lines - 1 ) * 255 + strlen( objtxt ). *** clear PL-transf_bin. PL-head_start = 1. PL-head_num = 0. PL-body_start = 1. PL-body_num = 0. PL-doc_type = 'RAW'. append PL. **** describe table csit_txt lines tab_lines. * objhead = 'OVU_RPT_CSIT'. append objhead. objhead = 'OVU_RPT_CSIT.TXT'. append objhead.

* Creation of the entry for the compressed attachment pl-transf_bin = 'X'. pl-head_start = 1. pl-head_num = 1. pl-body_start = 1. pl-body_num = tab_lines. * pl-doc_type = 'TXT'. "damon 20050401 pl-doc_type = 'RAW'. "damon 20050401 pl-obj_name = 'OVUScreen'. * pl-obj_descr = 'OVU_RPT'. pl-obj_descr = 'OVU_RPT.TXT'. pl-doc_size = tab_lines * 255. append pl. * * * * * * receive party reclist-receiver = 'OVU_SCREEN'. reclist-rec_type = 'C'. RECLIST-EXPRESS = ' '. APPEND RECLIST. CLEAR RECLIST.

reclist-receiver = 'OVU_IN_CSIT'. reclist-rec_type = 'C'. * reclist-receiver = sy-uname. * reclist-rec_type = 'B'. RECLIST-EXPRESS = ' '. APPEND RECLIST. CLEAR RECLIST. call function 'SO_NEW_DOCUMENT_ATT_SEND_API1' EXPORTING document_data = doc_chng put_in_outbox = 'X' TABLES packing_list = pl object_header = objhead contents_bin = csit_txt contents_txt = objtxt receivers = reclist EXCEPTIONS too_many_receivers = 1 document_not_sent = 2 operation_no_authorization = 4 others = 99. zmail_rc1 = sy-subrc. case sy-subrc. when 0. commit work. message s002 with 'OVU Inbound Report (CSIT) Sent'. when 1. message s002 with 'No authorization for sending to the specified recipients.(CSIT)' . when 2. message s002 with 'Document could not be sent (CSIT)'. when 4.

message s002 with 'No send authorization (CSIT)'. when others. message s002 with 'Error occurred while sending (CSIT)'. endcase. ENDFORM. " send_mail_csit *----------------------------------------------------------------------* * Form populate_mhq_txt *----------------------------------------------------------------------* FORM populate_mhq_txt. data: zstring(40), zlen type i, zdiff type i, zblank(40), zspace(100). data: dd(2), mm(2), yyyy(4). ** Added by Alice dd 12.04.2005 * change sy-datum to ddmmyyyy dd = sy-datum+6(2). mm = sy-datum+4(2). yyyy = sy-datum(4). concatenate 'Date Printed: ' dd '.' mm '.' yyyy into mhq_txt. append mhq_txt. clear mhq_txt. ** *sort itab_mhq by name. loop at itab_mhq. clear mhq_txt. * draw a line do 92 times. concatenate mhq_txt-txt '-' into mhq_txt-txt. enddo. append mhq_txt. clear mhq_txt. * populate Applicant No. zstring = itab_mhq-ARSNo. zlen = strlen( zstring ). zdiff = 10 - zlen. do zdiff times. concatenate zblank '^' into zblank. enddo. concatenate ' ' zstring zblank ' ' into mhq_txt-txt. clear: zstring, zlen, zdiff, zblank. * populate NRIC zstring = itab_mhq-NRIC. zlen = strlen( zstring ). zdiff = 10 - zlen. do zdiff times. concatenate zblank '^' into zblank. enddo. concatenate mhq_txt-txt zstring zblank ' ' into mhq_txt-txt. clear: zstring, zlen, zdiff, zblank. * populate Name

zstring = itab_mhq-name. zlen = strlen( zstring ). zdiff = 40 - zlen. do zdiff times. concatenate zblank '^' into zblank. enddo. concatenate mhq_txt-txt zstring zblank ' ' into mhq_txt-txt. clear: zstring, zlen, zdiff, zblank. * populate Updated zstring = itab_mhq-updated. zlen = strlen( zstring ). zdiff = 13 - zlen. do zdiff times. concatenate zblank '^' into zblank. enddo. concatenate mhq_txt-txt zstring zblank ' ' into mhq_txt-txt. clear: zstring, zlen, zdiff, zblank. * populate Traced zstring = itab_mhq-Traced. zlen = strlen( zstring ). zdiff = 13 - zlen. do zdiff times. concatenate zblank '^' into zblank. enddo. concatenate mhq_txt-txt zstring zblank ' ' into mhq_txt-txt. clear: zstring, zlen, zdiff, zblank. overlay mhq_txt-txt with zspace only '^'. append mhq_txt. clear mhq_txt. * draw a line at last. do 92 times. concatenate mhq_txt-txt '-' into mhq_txt-txt. enddo. append mhq_txt. clear mhq_txt. endat. endloop. ENDFORM. " populate_mhq_txt *----------------------------------------------------------------------* * Form populate_csit_txt *----------------------------------------------------------------------* FORM populate_csit_txt. data: zstring(40), zlen type i, zdiff type i, zblank(40), zspace(100). data: dd(2), mm(2), yyyy(4). ** Added * change dd = mm = yyyy = by Alice dd 12.04.2005 sy-datum to ddmmyyyy sy-datum+6(2). sy-datum+4(2). sy-datum(4).

concatenate 'Date Printed: ' dd '.' mm '.' yyyy into csit_txt. append csit_txt. clear csit_txt. ** *sort itab_csit by name. loop at itab_csit. clear csit_txt. * draw a line do 92 times. concatenate csit_txt-txt '-' into csit_txt-txt. enddo. append csit_txt. clear csit_txt. * populate Applicant No. zstring = itab_csit-ARSNo. zlen = strlen( zstring ). zdiff = 10 - zlen. do zdiff times. concatenate zblank '^' into zblank. enddo. concatenate ' ' zstring zblank ' ' into csit_txt-txt. clear: zstring, zlen, zdiff, zblank. * populate NRIC zstring = itab_csit-NRIC. zlen = strlen( zstring ). zdiff = 10 - zlen. do zdiff times. concatenate zblank '^' into zblank. enddo. concatenate csit_txt-txt zstring zblank ' ' into csit_txt-txt. clear: zstring, zlen, zdiff, zblank. * populate Name zstring = itab_csit-name. zlen = strlen( zstring ). zdiff = 40 - zlen. do zdiff times. concatenate zblank '^' into zblank. enddo. concatenate csit_txt-txt zstring zblank ' ' into csit_txt-txt. clear: zstring, zlen, zdiff, zblank. * populate Updated zstring = itab_csit-updated. zlen = strlen( zstring ). zdiff = 13 - zlen. do zdiff times. concatenate zblank '^' into zblank. enddo. concatenate csit_txt-txt zstring zblank ' ' into csit_txt-txt. clear: zstring, zlen, zdiff, zblank. * populate Traced zstring = itab_csit-Traced. zlen = strlen( zstring ). zdiff = 13 - zlen.

do zdiff times. concatenate zblank '^' into zblank. enddo. concatenate csit_txt-txt zstring zblank ' ' into csit_txt-txt. clear: zstring, zlen, zdiff, zblank. overlay csit_txt-txt with zspace only '^'. append csit_txt. clear csit_txt. * draw a line at last. do 92 times. concatenate csit_txt-txt '-' into csit_txt-txt. enddo. append csit_txt. clear csit_txt. endat. endloop. ENDFORM. " populate_csit_txt *----------------------------------------------------------------------* * Form check_files *----------------------------------------------------------------------* * If applicant has both f13 & f13ra files, itab1 & itab2 * should consist the same applicant no. *----------------------------------------------------------------------* FORM check_files. loop at itab1. read table itab2 with key ARSNo = itab1-ARSNo. if sy-subrc <> 0. itab1-error = 'X'. "mark as an error record modify itab1. errtab-filename = itab1-filename. errtab-linenum = '-'. errtab-contents = '-'. concatenate 'F13ra file not found for applicant' itab1-ARSNo into errtab-message separated by space. append errtab. clear errtab. endif. endloop. loop at itab2. read table itab1 with key ARSNo = itab2-ARSNo. if sy-subrc <> 0. itab2-error = 'X'. "mark as an error record modify itab2. errtab-filename = itab2-filename. errtab-linenum = '-'. errtab-contents = '-'. concatenate 'F13 file not found for applicant' itab2-ARSNo into errtab-message separated by space. append errtab. clear errtab. endif. endloop. ENDFORM. " check_files

*----------------------------------------------------------------------* * Form delete_files *----------------------------------------------------------------------* * Only perform backup & delete if record is updated successfully *----------------------------------------------------------------------* FORM delete_files. data: zsource(255), zdestin(255). loop at itab3 where updated = 'Y'. * check if backup is selected and make a copy of F13/F13ra files if p_backup = 'X'. * copy F13 file clear: zsource, zdestin, pcmd. concatenate p_f13 itab3-f13 into zsource. concatenate b_f13 itab3-f13 into zdestin. concatenate 'copy' zsource zdestin into pcmd separated by space. perform execute_command tables dummy using pcmd. * copy F13ra file clear: zsource, zdestin, pcmd. concatenate p_f13ra itab3-f13ra into zsource. concatenate b_f13ra itab3-f13ra into zdestin. concatenate 'copy' zsource zdestin into pcmd separated by space. perform execute_command tables dummy using pcmd. endif. * delete F13 file concatenate p_f13 itab3-f13 into zsource. delete dataset zsource. * delete F13ra file concatenate p_f13ra itab3-f13ra into zsource. delete dataset zsource. endloop. ENDFORM. " delete_files *&---------------------------------------------------------------------* *& Form check_duplicate_f13 *&---------------------------------------------------------------------* * Check duplicates based on applicant no. *----------------------------------------------------------------------* FORM check_duplicate_f13. data: err_msg(72), counter type i, itab1_cmp like itab1 occurs 0 with header line. itab1_cmp[] = itab1[]. loop at itab1. clear: counter, err_msg. loop at itab1_cmp where ARSNo = itab1-ARSNo. add 1 to counter. if counter > 1. "duplicate found itab1-error = 'X'. "mark as an error record modify itab1. errtab-filename = itab1-filename. errtab-linenum = '4'.

errtab-contents = itab1-ARSNo. concatenate text-024 itab1-ARSNo into err_msg separated by space. errtab-message = err_msg. append errtab. clear errtab. exit. endif. endloop. endloop. ENDFORM. " check_duplicate_f13 *&---------------------------------------------------------------------* *& Form check_duplicate_f13ra *&---------------------------------------------------------------------* * Check duplicates based on applicant no. *----------------------------------------------------------------------* FORM check_duplicate_f13ra. data: err_msg(72), counter type i, itab2_cmp like itab1 occurs 0 with header line. itab2_cmp[] = itab2[]. loop at itab2. clear: counter, err_msg. loop at itab2_cmp where ARSNo = itab2-ARSNo. add 1 to counter. if counter > 1. "duplicate found itab2-error = 'X'. "mark as an error record modify itab2. errtab-filename = itab2-filename. errtab-linenum = '4'. errtab-contents = itab2-ARSNo. concatenate text-024 itab2-ARSNo into err_msg separated by space. errtab-message = err_msg. append errtab. clear errtab. exit. endif. endloop. endloop. ENDFORM. " check_duplicate_f13ra

You might also like