How to Run a Report through a Form

 

 

 

 

 

--To Start Report Server

rwserver server=rep10g_sa batch=yes autostart=yes

 

--To Stop Report Server

rwserver server=rep10g_sa shutdown=normal authid=asp/asp

rwserver server=rep10g_sa shutdown=immediate authid=asp/asp

 

--To Check the Reports Log

http://shams:8889/reports/rwservlet/showjobs?server=rep10g_sa

 

--To run Report from URL

http://shams:8889/reports/rwservlet?server=rep10g_sa&report=c:\work\source\employees.rdf&desformat=htmlcss&destype=cache&userid=hmslive/hmslive@hms

 

--To run from form

Change C:\oracle\ids10g\reports\conf\rep10g_sa file for Report's source directory :

 

<engine id="rwEng" class="oracle.reports.engine.EngineImpl" initEngine="1" maxEngine="1" minEngine="0" engLife="50" maxIdle="30" callbackTimeOut="90000">

          <property name="sourceDir" value="D:\MyData\ORACLE\Shams_Docs\WORK_SHOP\source"/>

          <property name="tempDir" value="D:\MyData\ORACLE\Shams_Docs\WORK_SHOP\source"/>

          <property name="keepConnection" value="yes"/>

          </engine>

 

--Now you can run report without path.

http://shams:8889/reports/rwservlet?server=rep10g_sa&report=employees.rdf&desformat=htmlcss&destype=cache&userid=hmslive/hmslive@hms

 

See REPORT_LOG.fmb

 

 

----------------------------------------------

 

 

FORM                            :   REPORT_LOG.fmb

TRIGGER(Form Level)  :   WHEN-NEW-FORM-INSTANCE

 

DECLARE    

                   timer_id Timer;     

                   five_sec NUMBER(5) := 7000;

                   USRID VARCHAR2(30);

                   PDF CHAR(1);

                   cParamForm CHAR;

                   v_DummyCount number;---not used just dummy

                   v_message_level  number;

         

         

BEGIN

-------------by shams hcl----------(1)

                                        

          :global.job_id:=:global.rep_id;---Returns Unique Report Id,running on Local or Remote Report Server.(Prefixed with Rep Server name)

                                                                                                                                                           ---[value returned from run_report_object_async funtion ]

-------------by shams hcl----------(1)

 

           if :global.job_id is not null then

                    timer_id := CREATE_TIMER('rep_timer', five_sec, REPEAT);

            end if;

                   

-------------by shams hcl----------(2)

  --Delete from job_control where status in('TERMINATED_WITH_ERROR','PURGED');

 ---The Update_Reort_status was called to remove any record with Report Id being equal to '0' Zero,

 ---or Report status ='Terminated or Purged',

 ---coz it gives error of Invalid Job status when Report container runs.

                   

                    Update_Report_Status(:global.gusername,v_DummyCount);

          v_message_level       := :system.message_level;

          :system.message_level := 20;

          commit;

          :system.message_level := v_message_level;

         

-------------by shams hcl----------(2)

 

                   go_block('JOB_CTRL');

                   Execute_Query;

 

           

           

          ----------------------------------by shams hcl--------------------------------------- (3)

           

           

          SET_ITEM_PROPERTY('CTRL_REPORT.GETPDF',ENABLED,PROPERTY_FALSE);

           SET_ITEM_PROPERTY('CTRL_REPORT.CREATE_PDF',ENABLED,PROPERTY_FALSE);

          SET_ITEM_PROPERTY('CTRL_REPORT.SAVE',ENABLED,PROPERTY_FALSE);

           SET_ITEM_PROPERTY('CTRL_REPORT.EDIT_FORUSER',ENABLED,PROPERTY_FALSE);

          SELECT HUM_USER_ID,HUM_CREATE_PDF INTO USRID,PDF FROM H_USER_MASTER WHERE HUM_USER_ID=:GLOBAL.GUSERNAME;

          IF SQL%FOUND THEN

                   IF USRID='MAH' THEN-------------For Super user---------------------

                             --SET_ITEM_PROPERTY('CTRL_REPORT.SAVE',ENABLED,PROPERTY_TRUE);

                      SET_ITEM_PROPERTY('CTRL_REPORT.EDIT_FORUSER',ENABLED,PROPERTY_TRUE);      

                             SET_ITEM_PROPERTY('CTRL_REPORT.GETPDF',ENABLED,PROPERTY_TRUE);

                             SET_ITEM_PROPERTY('CTRL_REPORT.CREATE_PDF',ENABLED,PROPERTY_TRUE);

                   ELSE

                            

                             IF PDF='C' THEN

                                      --SET_ITEM_PROPERTY('CTRL_REPORT.GETPDF',VISIBLE,PROPERTY_TRUE);

                                                SET_ITEM_PROPERTY('CTRL_REPORT.GETPDF',ENABLED,PROPERTY_TRUE);

                                                SET_ITEM_PROPERTY('CTRL_REPORT.CREATE_PDF',ENABLED,PROPERTY_TRUE);

                            

                             ELSIF PDF='V' THEN

                                                SET_ITEM_PROPERTY('CTRL_REPORT.GETPDF',ENABLED,PROPERTY_TRUE);

                  

                             ELSIF PDF='N' THEN

                                       SET_ITEM_PROPERTY('CTRL_REPORT.GETPDF',ENABLED,PROPERTY_FALSE);

                               SET_ITEM_PROPERTY('CTRL_REPORT.CREATE_PDF',ENABLED,PROPERTY_FALSE);

                             END IF;

                                               

                   END IF;

          END IF;

          EXCEPTION

                             WHEN NO_DATA_FOUND THEN

                             MESSAGE('User Not Found');

                             MESSAGE('User Not Found');

           

           

----------------------------------------by shams hcl---------------------------------------(3)     

           

END;

 

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

 

FORM                            :   REPORT_LOG.fmb

TRIGGER(Form Level)  :   WHEN-TIMER-EXPIRED

 

declare

          timer_id  TIMER;

          five_sec NUMBER(5) := 7000;

begin

                             timer_id := FIND_TIMER('rep_timer');

                             Set_Timer(timer_id, five_sec, NO_CHANGE);

                             go_item('btn_refresh');

                             execute_trigger('WHEN-BUTTON-PRESSED');

                             IF :GLOBAL.job_ID is not null THEN

                              

                                      if :job_ctrl.status='FINISHED' then

                                                --hms_report.display_report(:GLOBAL.Job_ID);

                                                ---------------------------------------Modified bY SHAMS HCL

                                                          SHOW_PRINT('1');

                                                          --SHOW_REPORT(:GLOBAL.rep_ID);---Now SHOW_REPORT_OLD(not in use)

                                          --SHOW_REPORT(:job_ctrl.job_id);

                                        ---------------------------------------Modified bY SHAMS HCL

                                                :GLOBAL.job_ID:=NULL;

                                      end if;

                             END IF;

end;

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

 

FORM                            :   REPORT_LOG.fmb

TRIGGER(Form Level)  :   WHEN-WINDOW-CLOSED

 

exit_form;

 

 

----------------------------

 1.

FORM                            :   REPORT_LOG.fmb

BLOCK (of Buttons)       :   CTRL_REPORT

ITEM                             :   BTN_GET(Get Report)

TRIGGER(Form Level)  :   (WHEN-BUTTON-PRESSED)

 

 

declare

                   v_rep_job_id number(12);

                   rep_job_status varchar2(2000);

                   rep_msg varchar2(2000);

                   v_message_level number;

begin

                   if  :job_ctrl.object_type = 'REPORTS'  then

                                      begin

                                                  select REPORT_JOB_ID into v_rep_job_id from job_control

                                                    where job_id = :job_ctrl.job_id;

                                                  exception

                                                           when others then

                                                           null;

                                      end;                      

                                 rep_job_status := REPORT_OBJECT_STATUS(get_param_val('REPORT_SERVER_NAME')||'_'||v_rep_job_id );

                                 --rep_job_status := REPORT_OBJECT_STATUS(hms_report.REPORT_SERVER||'_'||v_rep_job_id );

                                 rep_job_status := nvl(rep_job_status, 'PURGED');

                                                rep_job_status :='FINISHED';-------Did as Report Server not connecting in Laptop,Comment it on Desktop

                                                if rep_job_status='FINISHED' THEN

                                                         

                                                                             ---hms_report.display_report(:job_ctrl.job_id);

                                                                             -----SHOW_PRINT('1');

                                                                             --:custom_button.status :=  'Report  ' || :job_ctrl.description || ' is available in another browser window.';

                                                                   -----------------------Modified By Shams HCL------------------------

                                                                        GET_REPORT(:job_ctrl.job_id);

                                                                   -----------------------Modified By Shams HCL-----------------------

                                                else

                                                                     message('Report Job ID ('||to_char(:job_ctrl.job_id)||') status is ' || rep_job_status || '.');

                                                                     message('Report Job ID ('||to_char(:job_ctrl.job_id)||') status is ' || rep_job_status || '.');

                                                                               if :job_ctrl.status <> rep_job_status then

                                                                                         :job_ctrl.status := rep_job_status;

                                                                                                update job_control

                                                                                                set      status = rep_job_status

                                                                                                where  job_id = :job_ctrl.job_id;

                                                                                                v_message_level       := :system.message_level;

                                                                                                :system.message_level := 20;

                                                                                                commit;

                                                                                                :system.message_level := v_message_level;

                                                                                      end if;

                         end if;------------         for rep_job_status='FINISHED'

                   end if;-----------for :job_ctrl.object_type         

end;

                  

                  

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

 

2.

FORM                            :   REPORT_LOG.fmb

BLOCK (of Buttons)       :   CTRL_REPORT

ITEM                             :   BTN_REFRESH(Refresh)

TRIGGER(Form Level)  :   (WHEN-BUTTON-PRESSED)

 

 

Declare

            v_message_level number;

            v_count         number;            

            timer_id                        TIMER;

Begin

                   Update_Report_Status(:global.gusername,v_count);

                   v_message_level       := :system.message_level;

                   :system.message_level := 20;

                   commit;

                   :system.message_level := v_message_level;

                   go_block('JOB_CTRL');

                   Execute_Query;

                             if v_count = 0 then

                                      timer_id := FIND_TIMER('rep_timer');

                                      Delete_Timer(timer_id);

                             end if;

End;

 

 

------------------------------ 

 

3.

FORM                            :   REPORT_LOG.fmb

BLOCK (of Buttons)       :   CTRL_REPORT

ITEM                             :   BTN_CLOSE(Close)

TRIGGER(Form Level)  :   (WHEN-BUTTON-PRESSED)

 

exit_form;

 

--------------------------------

 

4.

FORM                            :   REPORT_LOG.fmb

BLOCK (of Buttons)       :   CTRL_REPORT

ITEM                             :   CREATE_PDF

TRIGGER(Form Level)  :   (WHEN-BUTTON-PRESSED)

 

PROCEDURE CREATE_PDF( P_JOB_ID VARCHAR2 ) IS

    v_LOCAL_REP_id    varchar2(2000);

    V_OBJ_NAME VARCHAR2(20);

    src varchar2(100);

            dst varchar2(100);

            gf  boolean;

          fe  boolean;

          ALRT NUMBER;

          pdf_name varchar2(30);

Begin

         

           

 

            select LOCAL_REP_ID,object_name into v_LOCAL_REP_id,V_OBJ_NAME

            from job_control

            where job_id = p_job_id;

             src:=get_param_val('ALL_EXE_URL')||'Files2Print/'|| v_LOCAL_REP_id;

                    dst:=get_param_val('LOCAL_FILE_PATH')|| v_LOCAL_REP_id ;

                    

                    ----Deleting Pdf file already existing with the same name

                             fe := webutil_file.file_exists(get_param_val('LOCAL_FILE_PATH')||V_OBJ_NAME||substr(v_LOCAL_REP_id,1,instr(v_LOCAL_REP_id,'.')-1)||'.pdf');

                                while (fe) loop  ---Keep checking for Pdf file until its deleted.

                             client_Host('cmd /c del '||get_param_val('LOCAL_FILE_PATH')||V_OBJ_NAME||substr(v_LOCAL_REP_id,1,instr(v_LOCAL_REP_id,'.')-1)||'.pdf',no_screen);

                                 fe:=webutil_file.file_exists(get_param_val('LOCAL_FILE_PATH')||V_OBJ_NAME||substr(v_LOCAL_REP_id,1,instr(v_LOCAL_REP_id,'.')-1)||'.pdf');

                        end loop;

             ----

           alrt:=show_alert('pdf_alert');

           IF alrt=alert_button1 then

                                                call_form('PDF_PASSWORD',hide);

                                                DOWNLOAD_PDF_CONVERTER;------Pdf Converter File Transfer

                                                          gf := webutil_file_transfer.URL_To_Client(src,dst); -- Report Text File Transfer.

                             if gf then

                                                             fe := webutil_file.file_exists(dst);

                                                             while not(fe) loop

                                                                     fe := webutil_file.file_exists(dst);

                                                             end loop;

                                                            

                                                            

                                                                     -----Create Pdf File From Report Text File,with Password-------/////////////////////

                                                                    IF :GLOBAL.pdfpass IS NOT NULL THEN

                                                                   

                                                                              -----This webutil function used instead of Client_Host coz,

                                                                              -----The Computer control was coming out of the code after creating the pdf file        ,hence further lines of code were not executed.

                                                                              -----But with this funtion The computer control remains within the code,even after creating pdf file.

                                                  

                                                  webutil_host.nonblocking(get_param_val('LOCAL_FILE_PATH')||'txt2pdf.exe'||' '||get_param_val('LOCAL_FILE_PATH')||v_LOCAL_REP_id ||' '||get_param_val('LOCAL_FILE_PATH')||V_OBJ_NAME||substr(v_LOCAL_REP_id,1,instr(v_LOCAL_REP_id,'.')-1)||' -oao -ptc0 -pfs9 -pwa -epu:'||:GLOBAL.pdfpass);

                                                      END IF;

                                                                   else

                                                          message('Report file transfer failed from server to client.');

                                                          message('Report file transfer failed from server to client.');

                                                          Raise form_trigger_failure;

                                       end if;                  

                                     

                                     

                                                         

                                     

                    ELSE

                             DOWNLOAD_PDF_CONVERTER;------Pdf Converter File Transfer

                         gf := webutil_file_transfer.URL_To_Client(src,dst); -- Report Text File Transfered.

                             if gf then

                                                             fe := webutil_file.file_exists(dst);

                                                                    while not(fe) loop

                                                                             fe := webutil_file.file_exists(dst);

                                                                    end loop;

                                                                      -----Create Pdf File From Report Text File,without Password-------/////////////////////

                                                               webutil_host.nonblocking(get_param_val('LOCAL_FILE_PATH')||'txt2pdf.exe'||' '||get_param_val('LOCAL_FILE_PATH')||v_LOCAL_REP_id ||' '||get_param_val('LOCAL_FILE_PATH')||V_OBJ_NAME||substr(v_LOCAL_REP_id,1,instr(v_LOCAL_REP_id,'.')-1)||' -oao -ptc0 -pfs9 -pwa');--- earlier  -oao -ptc0 -pfs9 -pwa -epo:shams

                                                     else

                                                          message('Report file transfer failed from server to client.');

                                                          message('Report file transfer failed from server to client.');

                                                          Raise form_trigger_failure;

                                       end if;                    

                          

                   END IF;     

                             ----Delete Report file from client after making sure that Pdf file is completely created and exists----////////////////

                                                                   fe := webutil_file.file_exists(get_param_val('LOCAL_FILE_PATH')||V_OBJ_NAME||substr(v_LOCAL_REP_id,1,instr(v_LOCAL_REP_id,'.')-1)||'.pdf');

                                                                   while not(fe) loop

                                                                   fe := webutil_file.file_exists(get_param_val('LOCAL_FILE_PATH')||V_OBJ_NAME||substr(v_LOCAL_REP_id,1,instr(v_LOCAL_REP_id,'.')-1)||'.pdf');

                                                    end loop;

                                                         client_Host('cmd /c del '||dst,no_screen);--------Delete Report file from client computer

                             --client_Host('cmd /c del '||get_param_val('LOCAL_FILE_PATH')||'txt2pdf.exe',no_screen);---Delete txt2pdf.exe file.

                             fe:=webutil_file.file_exists(dst);

                             while (fe) loop  ---Keep checking for local report file until its deleted.

                                      client_Host('cmd /c del '||dst,no_screen);

                                      fe:=webutil_file.file_exists(dst);

                             end loop;

                            

                         

                            

                   :GLOBAL.pdfpass:='';

           

 end;

 

 

-------------------------------

 

5.

FORM                            :   REPORT_LOG.fmb

BLOCK (of Buttons)       :   CTRL_REPORT

ITEM                             :   GET_PDF

TRIGGER(Form Level)  :   (WHEN-BUTTON-PRESSED)

 

 

client_host(get_param_val('ADOBE_EXE_PATH')||' '||get_param_val('LOCAL_FILE_PATH')||:job_ctrl.object_name||substr(:job_ctrl.local_rep_id,1,instr(:job_ctrl.local_rep_id,'.')-1)||'.pdf');

 

 

--client_host(get_param_val('LOCAL_FILE_PATH')||:job_ctrl.object_name||substr(:job_ctrl.local_rep_id,1,instr(:job_ctrl.local_rep_id,'.')-1)||'.pdf');

 

IF NOT Form_Success THEN ----------------------Not working ..plz chk

          Message('Pdf File Not Available');

          Message('Pdf File Not Available');

--ELSE Message('Message Sent.');

end if;

 

------------------------------

 

6.

FORM                            :   REPORT_LOG.fmb

BLOCK (of Buttons)       :   CTRL_REPORT

ITEM                             :   SAVE

TRIGGER(Form Level)  :   (WHEN-BUTTON-PRESSED)

 

BEGIN

DO_KEY('COMMIT_FORM');

SET_ITEM_PROPERTY('CTRL_REPORT.SAVE',ENABLED,PROPERTY_FALSE);

END;

 

 

--------------------------------- 

 

7.

FORM                            :   REPORT_LOG.fmb

BLOCK (of Buttons)       :   CTRL_REPORT

ITEM                             :   EDIT_FORUSER

TRIGGER(Form Level)  :   (WHEN-BUTTON-PRESSED)

 

 

SET_ITEM_PROPERTY('CTRL_REPORT.SAVE',ENABLED,PROPERTY_TRUE);

Glsp_EnableItem('job_ctrl.for_user');

------------------------------------------ 

 

FORM                            :   REPORT_LOG.fmb

PROGRAM_UNIT          :   DOWNLOAD_PDF_CONVERTER

 

PROCEDURE DOWNLOAD_PDF_CONVERTER IS

  fp boolean;fex boolean;

BEGIN

                             client_Host('cmd /c IF NOT EXIST '||get_param_val('LOCAL_FILE_PATH')||' md '||get_param_val('LOCAL_FILE_PATH')); -- Directory created.

                             fex:=webutil_file.file_exists(get_param_val('LOCAL_FILE_PATH')||'txt2pdf.exe');----Weather Pdf converter exists locally?

                             if not fex then

                               fp := webutil_file_transfer.URL_To_Client(get_param_val('ALL_EXE_URL')||'txt2pdf.exe',get_param_val('LOCAL_FILE_PATH')||'txt2pdf.exe');

                                      if fp then

                                                fex:=webutil_file.file_exists(get_param_val('LOCAL_FILE_PATH')||'txt2pdf.exe');

                                                while not(fex) loop

                                                          fex:=webutil_file.file_exists(get_param_val('LOCAL_FILE_PATH')||'txt2pdf.exe');

                                                end loop;

                             else

                                                --ftp_flag := true;

                                                message('FTP failed in transfering file Pdf Converter from server.');

                                                message('FTP failed in transfering file Pdf Converter from server.');

                                                Raise Form_trigger_failure;

                                      end if;

                             end if;

 

END;

 

 

 

 

 

--------------------------------

 

 

FORM                            :   REPORT_LOG.fmb

PROGRAM_UNIT          :   GET_REPORT

 

PROCEDURE GET_REPORT(P_JOB_ID VARCHAR2) IS

  rep_status varchar2(200);

  fp boolean;fex boolean;

  ftp_flag boolean := false;

          src varchar2(100);

          dst varchar2(100);

          gf     boolean;

          fe     boolean;

          --REP_JOB_ID VARCHAR2(12);

          v_LOCAL_REP_id VARCHAR2(30);

BEGIN

          /*

           select REPORT_JOB_ID,LOCAL_REP_ID into REP_JOB_ID,v_LOCAL_REP_id 

            from job_control

            where job_id = p_job_id;

            --rep_status:=REPORT_OBJECT_STATUS(hms_report.REPORT_SERVER||'_'||REP_JOB_ID);

            rep_job_status := REPORT_OBJECT_STATUS(get_param_val('REPORT_SERVER_NAME')||'_'||v_rep_job_id );

                   WHILE rep_status in ('RUNNING','OPENING_REPORT','ENQUEUED', null) LOOP

                             rep_status:=REPORT_OBJECT_STATUS(REP_JOB_ID);

                   END LOOP;

             rep_status:='FINISHED';----Did as Server not running on laptop

                    IF rep_status='FINISHED' THEN

          */               

            select LOCAL_REP_ID into v_LOCAL_REP_id 

            from job_control

            where job_id = p_job_id;

                  

                                                client_Host('cmd /c IF NOT EXIST '||get_param_val('LOCAL_FILE_PATH')||' md '||get_param_val('LOCAL_FILE_PATH')); -- Directory created.

                                                --client_Host('cmd /c IF NOT EXIST C:\myfiles (md C:\myfiles)',no_screen); -- Directory created.

                                                fex:=webutil_file.file_exists( get_param_val('LOCAL_FILE_PATH')||'DosPad.exe');----

                                                          if not fex then

                                                          fp := webutil_file_transfer.URL_To_Client(get_param_val('ALL_EXE_URL')||'DosPad.exe',get_param_val('LOCAL_FILE_PATH')||'DosPad.exe');

                                                            if fp then

                                                                             fex:=webutil_file.file_exists( get_param_val('LOCAL_FILE_PATH')||'DosPad.exe');

                                                                             while not(fex) loop

                                                                                      fex:=webutil_file.file_exists( get_param_val('LOCAL_FILE_PATH')||'DosPad.exe');

                                                                             end loop;

                                                                   else

                                                                             ftp_flag := true;

                                                                             message('FTP failed in transfering file DosPad.exe from server.');

                                                                             message('FTP failed in transfering file DosPad.exe from server.');

                                                                   end if;

                                                          end if;

                                               

                                                fex:=webutil_file.file_exists( get_param_val('LOCAL_FILE_PATH')||'RICHTX32.OCX');

                                                if not fex then

                                                fp := webutil_file_transfer.URL_To_Client(get_param_val('ALL_EXE_URL')||'RICHTX32.OCX',get_param_val('LOCAL_FILE_PATH')||'RICHTX32.OCX');

                                                          if fp then

                                                                   fex:=webutil_file.file_exists( get_param_val('LOCAL_FILE_PATH')||'RICHTX32.OCX');

                                                                   while not(fex) loop

                                                                             fex:=webutil_file.file_exists( get_param_val('LOCAL_FILE_PATH')||'RICHTX32.OCX');

                                                                   end loop;

                                                          else

                                                                   ftp_flag := true;

                                                                   message('FTP failed in transfering file RICHTX32.OCX from server.');

                                                                   message('FTP failed in transfering file RICHTX32.OCX from server.');

                                                          end if;         

                                                end if;

                                               

                                                if not ftp_flag then

                                                          src:=get_param_val('ALL_EXE_URL')||'Files2Print/'||v_LOCAL_REP_id ;

                                                          dst:=get_param_val('LOCAL_FILE_PATH')||v_LOCAL_REP_id ;

                                                          gf := webutil_file_transfer.URL_To_Client(src,dst); -- Report Text File Transfered.

                                                          if gf then

                                                                             fe := webutil_file.file_exists(dst);

                                                                             while not(fe) loop

                                                                                      fe := webutil_file.file_exists(dst);

                                                                             end loop;

                                                                             -- Change Attributes of the input file

                                                                             --client_Host('cmd /c attrib +h +r '||dst,no_screen);----commented coz the file cudnt be deleted by the next command below

                                                                            

                                                                             -- Delete input file from Server

                                                                             --Host('del '||get_param_val('SERVER_FILE_PATH')||:global.ufile,no_screen);

                                                                      client_Host(get_param_val('LOCAL_FILE_PATH')||'dospad 1'||v_LOCAL_REP_id ,no_screen ); -- Preview & Print

                                                                    client_Host('cmd /c del '||dst,no_screen);--------Delete file from client computer

                                                                     --exit_form;

                                                          else

                                                                             message('Report file transfer failed from server to client.');

                                                                             message('Report file transfer failed from server to client.');

                                                          end if;

                                                end if;

                                               

                             /*               

                                      ELSE

                                                message('Report failed with error message '||rep_status);

                                                message('Report failed with error message '||rep_status);

                                      END IF;

                     */             

 

END;

 

------------------------------------------

 

FORM                            :   REPORT_LOG.fmb

PROGRAM_UNIT          :   SHOW_PRINT

 

 

PROCEDURE SHOW_PRINT(p_showprint varchar2) IS

          --pParam                         PARAMLIST;

  rep_status varchar2(200);

  fp boolean;fex boolean;

  ftp_flag boolean := false;

          src varchar2(100);

          dst varchar2(100);

          gf     boolean;

          fe     boolean;

BEGIN

  ---Destroy_Parameter_List('Param_List');

          rep_status:=REPORT_OBJECT_STATUS(:global.rep_id);--- used when (report_message) value returned from run_report_object_async.

          --rep_status:=REPORT_OBJECT_STATUS(hms_report.REPORT_SERVER||'_'||:global.rep_id );---used when (v_rep_job_id) value returned from run_report_object_async.

            WHILE rep_status in ('RUNNING','OPENING_REPORT','ENQUEUED', null)

                   LOOP

                             rep_status:=REPORT_OBJECT_STATUS(:global.rep_id);--- used when (report_message) value returned from run_report_object_async.

                    --rep_status:=REPORT_OBJECT_STATUS(hms_report.REPORT_SERVER||'_'||:global.rep_id );---used when (v_rep_job_id) value returned from run_report_object_async.

                   END LOOP;

                   IF rep_status='FINISHED' THEN

                  

                                      client_Host('cmd /c IF NOT EXIST '||get_param_val('LOCAL_FILE_PATH')||' md '||get_param_val('LOCAL_FILE_PATH')); -- Directory created.

                                      --client_Host('cmd /c IF NOT EXIST C:\myfiles (md C:\myfiles)',no_screen); -- Directory created.

                                       fex:=webutil_file.file_exists(get_param_val('LOCAL_FILE_PATH')||'DosPad.exe');----

                                      if not fex then

                                       fp := webutil_file_transfer.URL_To_Client(get_param_val('ALL_EXE_URL')||'DosPad.exe',get_param_val('LOCAL_FILE_PATH')||'DosPad.exe');

                                                if fp then

                                                          fex:=webutil_file.file_exists( get_param_val('LOCAL_FILE_PATH')||'DosPad.exe');

                                                          while not(fex) loop

                                                                   fex:=webutil_file.file_exists( get_param_val('LOCAL_FILE_PATH')||'DosPad.exe');

                                                          end loop;

                                                else

                                                          ftp_flag := true;

                                                          message('FTP failed in transfering file DosPad.exe from server.');

                                                          message('FTP failed in transfering file DosPad.exe from server.');

                                                end if;

                                      end if;

                                     

                                      fex:=webutil_file.file_exists( get_param_val('LOCAL_FILE_PATH')||'RICHTX32.OCX');

                                      if not fex then

                                        fp := webutil_file_transfer.URL_To_Client(get_param_val('ALL_EXE_URL')||'RICHTX32.OCX',get_param_val('LOCAL_FILE_PATH')||'RICHTX32.OCX');

                                                if fp then

                                                          fex:=webutil_file.file_exists( get_param_val('LOCAL_FILE_PATH')||'RICHTX32.OCX');

                                                          while not(fex) loop

                                                                    fex:=webutil_file.file_exists(get_param_val('LOCAL_FILE_PATH')||'RICHTX32.OCX');

                                                          end loop;

                                                else

                                                          ftp_flag := true;

                                                          message('FTP failed in transfering file RICHTX32.OCX from server.');

                                                          message('FTP failed in transfering file RICHTX32.OCX from server.');

                                                end if;         

                                      end if;

                                               

                                                if not ftp_flag then

                                                          src:=get_param_val('ALL_EXE_URL')||'Files2Print/'||:global.ufile;---[value returned from run_report_object_async funtion ]

                                                                                                                                                                                                                                                                                                                                                                              

                                                          dst:=get_param_val('LOCAL_FILE_PATH')||:global.ufile;

                                                          gf := webutil_file_transfer.URL_To_Client(src,dst); -- Report Text File Transfered.

                                                                   if gf then

                                                                             fe := webutil_file.file_exists(dst);

                                                                             while not(fe) loop

                                                                                      fe := webutil_file.file_exists(dst);

                                                                             end loop;

                                                                             -- Change Attributes of the input file

                                                                             --client_Host('cmd /c attrib +h +r '||dst,no_screen);

                                                                             -- Delete input file from Server

                                                                     --     Host('del D:\ids\j2ee\home\default-web-app\hms\Files2Print\'||:global.ufile,no_screen);

                                                                    --Host('del '||get_param_val('SERVER_FILE_PATH')||:global.ufile,no_screen);-----Dont Delete file from Server by commenting it

                                                                      client_Host(get_param_val('LOCAL_FILE_PATH')||'dospad '||p_showprint||:global.ufile,no_screen ); -- Preview & Print(Dospad 1/0<filename>)

                                                                             client_Host('cmd /c del '||dst,no_screen);--------Delete file from client computer

                                                                             --exit_form;

                                                                   else

                                                                             message('Report file transfer failed from server to client.');

                                                                             message('Report file transfer failed from server to client.');

                                                           end if;

                                       end if;

                             ELSE

                                      message('Report failed with error message '||rep_status);

                                      message('Report failed with error message '||rep_status);

                             END IF;

END;

 

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

 

B.

FORM                            :   REPORT_LOG.fmb

BLOCK                                   :   JOB_CTRL

TRIGGER(Block Level)  :   WHEN-MOUSE-DOUBLECLICK

 

BEGIN

  go_item('BTN_GET');

  Execute_Trigger('WHEN-BUTTON-PRESSED');

END;

 

 

------------------------- 

 

FORM                            :   REPORT_LOG.fmb

BLOCK                                    :   JOB_CTRL

TRIGGER(Block Level)  :   (POST-QUERY)

 

 

          declare

                   v_ID ITEM;

BEGIN

                   v_ID:=FIND_ITEM('JOB_CTRL.FLAG');

                  

    IF :STATUS='FINISHED' THEN

       set_item_instance_property(v_id,current_record,visual_attribute,'VA1');

    ELSIF :STATUS='ENQUED' THEN

       set_item_instance_property(v_id,current_record,visual_attribute,'VA4');

    ELSIF :STATUS='RUNNING' THEN

      set_item_instance_property(v_id,current_record,visual_attribute,'VA2'); 

          END IF;

end;

 

 

----------------------------------  

 

 

Form           : FGMMAIN.fmb

Block          : NBT_COMMON_BLOCK

Item             : BTN_REP_LOG (Report Log)

Trigger        : WHEN-BUTTON-PRESSED

 

 

begin

          :global.job_id := null;

          call_form('REPORT_LOG', no_hide, no_replace, query_only);

end;

 

 

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

 

Library : HMS.PLL

 

 

1.ENCODE

-------------- 

 

 

FUNCTION ENCODE (URL_PARAMS_IN Varchar2) RETURN VARCHAR2 IS

          v_url VARCHAR2(2000) := URL_PARAMS_IN; -- Url string

          v_url_temp VARCHAR2(4000) :=''; -- Temp URL string

          v_a VARCHAR2(10); -- conversion variable

          v_b VARCHAR2(10); -- conversion variable

          c CHAR;

          i NUMBER(10);

BEGIN

          FOR i IN 1..LENGTH(v_url) LOOP

                   c:= substr(v_url,i,1);

                   IF c in (';', '/','?',':','@','+','$',',',' ') THEN

                             v_a := ltrim(to_char(trunc(ascii(substr(v_url,i,1))/16)));

                             IF v_a = '10' THEN v_a := 'A';

                                      ELSIF v_a = '11' THEN v_a := 'B';

                                      ELSIF v_a = '12' THEN v_a := 'C';

                                      ELSIF v_a = '13' THEN v_a := 'D';

                                      ELSIF v_a = '14' THEN v_a := 'E';

                                      ELSIF v_a = '15' THEN v_a := 'F';

                             END IF;

 

                             v_b := ltrim(to_char(mod(ascii(substr(v_url,i,1)),16)));

                             IF v_b = '10' THEN v_b := 'A';

                                      ELSIF v_b = '11' THEN v_b := 'B';

                                      ELSIF v_b = '12' THEN v_b := 'C';

                                      ELSIF v_b = '13' THEN v_b := 'D';

                                      ELSIF v_b = '14' THEN v_b := 'E';

                                      ELSIF v_b = '15' THEN v_b := 'F';

                             END IF;

                             v_url_temp := v_url_temp||'%'||v_a||v_b;

                   ELSE

                             v_url_temp :=v_url_temp||c;

                   END IF;

          END LOOP;

return v_url_temp;

END;

 

 

---------------------------- 

 

 

2. HCL_SETTINGS (Procedure Body)

 

 

PROCEDURE HCL_Settings IS

          V_WIDTH NUMBER;

          V_INCR NUMBER;

          V_POS NUMBER;

          V_HEIGHT NUMBER;

          V_BT_HEIGHT NUMBER;

          x number;

          y number;

          xpos number;

          ypos number;

          h number;

          --DBNAME VARCHAR2(10);

 

         

BEGIN

---:global.cur_item:='';

    set_window_property('window1',window_size,750,465);

    set_window_property('window1',x_pos,2);

    set_window_property('window1',y_pos,2);

   

 

   

    V_INCR:=100;

          V_WIDTH:=GET_VIEW_PROPERTY('LCANVASTREE',WIDTH);

          SET_VIEW_PROPERTY('LCANVASTREE',WIDTH,V_WIDTH+V_INCR);

                   SET_VIEW_PROPERTY('LCANVASTREE',VIEWPORT_X_POS,0);

          SET_CANVAS_PROPERTY('LCANVASTREE',WIDTH,V_WIDTH+V_INCR+0);

          SET_CANVAS_PROPERTY('LCANVASTREE',HEIGHT,440);

          SET_VIEW_PROPERTY('LCANVASTREE',HEIGHT,440);

         

 

   

          V_WIDTH:=GET_item_property('LEFT_MENU_TREE.TREE',width);

    set_item_property('LEFT_MENU_TREE.TREE',WIDTH,V_WIDTH+V_INCR-0);

    set_item_property('LEFT_MENU_TREE.TREE',HEIGHT,440);

   

  

                   -- Main Canvas

    V_POS:=GET_VIEW_PROPERTY('MAINCANVAS',VIEWPORT_X_POS);

          SET_VIEW_PROPERTY('MAINCANVAS',VIEWPORT_X_POS,V_POS+V_INCR+3);

 

          V_POS:=GET_VIEW_PROPERTY('MAINCANVAS',VIEWPORT_Y_POS);

                   SET_VIEW_PROPERTY('MAINCANVAS',VIEWPORT_Y_POS,V_POS+10);

                  

                  

         

 

          SET_VIEW_PROPERTY('MAINCANVAS',WIDTH,565);

          SET_CANVAS_PROPERTY('MAINCANVAS',WIDTH,565);

          SET_VIEW_PROPERTY('MAINCANVAS',HEIGHT,415);

          SET_CANVAS_PROPERTY('MAINCANVAS',HEIGHT,415);

 

                   -- HCanvas

          V_POS:=GET_VIEW_PROPERTY('HCANVAS',VIEWPORT_X_POS);

                   SET_VIEW_PROPERTY('HCANVAS',VIEWPORT_X_POS,V_POS+V_INCR+0);

 

                   V_HEIGHT:=GET_VIEW_PROPERTY('HCANVAS',HEIGHT);

                   SET_VIEW_PROPERTY('HCANVAS',HEIGHT,V_HEIGHT+7);

                   SET_CANVAS_PROPERTY('HCANVAS',HEIGHT,V_HEIGHT+7);

                  

         

                            

                   SET_VIEW_PROPERTY('HCANVAS',WIDTH,565);

          SET_CANVAS_PROPERTY('HCANVAS',WIDTH,565);

 

                    V_HEIGHT:=GET_item_property('NBT_COMMON_BLOCK.BTN_MODULE',HEIGHT);

                    set_item_property('NBT_COMMON_BLOCK.BTN_MODULE',HEIGHT,V_HEIGHT+3);

                  

            --V_HEIGHT:=GET_item_property('NBT_COMMON_BLOCK.BTN_REP_LOG',HEIGHT);

                   --set_item_property('NBT_COMMON_BLOCK.BTN_REP_LOG',HEIGHT,V_HEIGHT+3);

 

          --set_item_property('nbt_common_block.btn_rep_log',Y_POS,3);

          set_item_property('nbt_common_block.btn_module',width,80);

          set_item_property('nbt_common_block.btn_module',Y_POS,3);

          set_item_property('nbt_common_block.nbt_user_name',Y_POS,7);

          set_item_property('nbt_common_block.nbt_module_desc',Y_POS,7);

         

          --set_item_property('nbt_common_block.BTN_COD_SEL',width,80);

    set_item_property('nbt_common_block.BTN_COD_SEL',x_POS,500);

          set_item_property('NBT_COMMON_BLOCK.BTN_COD_SEL',HEIGHT,V_HEIGHT+3);

          set_item_property('nbt_common_block.BTN_COD_SEL',Y_POS,3);

         

         

  

          --set_item_property('NBT_COMMON_BLOCK.BTN_COD_SEL',visible,property_true);

          --set_item_property('NBT_COMMON_BLOCK.BTN_COD_SEL',enabled,property_true);

             set_item_property('NBT_COMMON_BLOCK.NBT_COD_SEL_DESC',visible,property_false);

          --set_item_property('NBT_COMMON_BLOCK.BTN_REP_LOG',visible,property_false);

          --set_item_property('nbt_common_block.BTN_REP_LOG',x_POS,10);

          set_item_property('NBT_COMMON_BLOCK.BTN_REP_LOG',visible,property_true);

          set_item_property('NBT_COMMON_BLOCK.BTN_REP_LOG',enabled,property_true);

          V_HEIGHT:=GET_item_property('NBT_COMMON_BLOCK.BTN_REP_LOG',HEIGHT);

                    set_item_property('NBT_COMMON_BLOCK.BTN_REP_LOG',HEIGHT,V_HEIGHT+3);

                   set_item_property('nbt_common_block.BTN_REP_LOG',Y_POS,3);

                   Set_Item_Property('nbt_common_block.BTN_REP_LOG', NAVIGABLE, PROPERTY_TRUE);

                  

 

         

          /*

          if P_nbt_module_id NOT IN('ST','P') THEN

             SET_ITEM_PROPERTY('NBT_COMMON_BLOCK.BTN_COD_SEL',VISIBLE,PROPERTY_FALSE);

           ELSE

                     SET_ITEM_PROPERTY('NBT_COMMON_BLOCK.BTN_COD_SEL',VISIBLE,PROPERTY_TRUE);

                     SET_ITEM_PROPERTY('NBT_COMMON_BLOCK.BTN_COD_SEL',ENABLED,PROPERTY_TRUE);

          END IF;

         

          */

         

   --:global.cur_item:=:system.cursor_item;

  

  

   --SELECT NAME INTO DBNAME FROM V$DATABASE;

  

   --Set_Window_Property('WINDOW1',TITLE,P_WINDOWBAR||'    '||DBNAME);

  

         

END;

 

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

 

 

 

3a.HMS_REPORT (Package Spec) :

 

 

PACKAGE HMS_REPORT IS

  REPORT_ID                         REPORT_OBJECT;

  REPORT_SERVELET VARCHAR2(2000) := '../reports/rwservlet';

  REPORT_SERVER   VARCHAR2(2000) := 'REP10G_SA';

 

  PROCEDURE DISPLAY_REPORT ( P_JOB_ID VARCHAR2 );                                                                                                                                           

 

END HMS_REPORT;

 

------------------------------- 

 

 

 

 

3b.HMS_REPORT (Package Body) :

 

 

PACKAGE BODY HMS_REPORT IS

                                                                                                                                               

PROCEDURE DISPLAY_REPORT ( P_JOB_ID VARCHAR2 ) IS

    v_url                                    varchar2(2000);

    v_rpt_job_id     varchar2(2000);

    v_html                                  varchar2(2000);

Begin

            select parameter_value into v_rpt_job_id

            from job_parameters

            where job_id = p_job_id

                   and parameter_id = 'REPORT_JOB_ID';

                  

v_url := hms_report.report_servelet ||'/getjobid'||v_rpt_job_id || '?server='||hms_report.report_server;                  

v_html := 'javascript:self.close(); var OpenWindow=window.open("", "", "menubar=no,titlebar=no");';  v_html := v_html || 'OpenWindow.document.write(''<HTML><TITLE>HMS Reports</TITLE>';

v_html := v_html || '<BODY style="border-width:0px;" leftmargin=0 topmargin=0 rightmargin=0 bottommargin=0>';

v_html := v_html || '<iframe src="'||v_url||'" width="100%" height="100%"></iframe>';

 v_html := v_html || '</BODY>';

v_html := v_html || '</HTML>'');';

 

WEB.SHOW_DOCUMENT(v_html,'_blank');                

 

end;

 

END HMS_REPORT;

 

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

 

 

4.RUN_REPORT_OBJECT_ASYNC (Procedure Body)

 

PROCEDURE RUN_REPORT_OBJECT_ASYNC

(p_uFile out varchar2,p_job_id out varchar2,p_guname in varchar2,p_obj_name VARCHAR2,

p_description VARCHAR2,p_destype varchar2,p_desformat varchar2,p_plid in paramlist ) IS

          v_job_id                            number;

          v_rep_job_id                    VARCHAR2(4000):='';

          v_reports_servlet              varchar2(255);

          v_report_server               varchar2(55);

          v_file_name                    varchar2(1000);

          v_otherparam                  varchar2(1000);

          v_message_level               number;

          report_id                          REPORT_OBJECT;

          report_message                VARCHAR2(100) :='';

          hidden_action                  VARCHAR2(4000):='';

          v_uniqueFileName            varchar2(100);

          v_fpath                              varchar2(200);

BEGIN

          --v_uniqueFileName:=get_application_property(USERNAME)||TO_CHAR(SYSDATE,'YYYYMMDDHHMISS')||'.txt';

          v_uniqueFileName := p_guname ||TO_CHAR(SYSDATE,'YYYYMMDDHHMISS')||'.txt';

          --v_uniqueFileName := p_guname ||'.txt';

         

          p_uFile:=v_uniqueFileName;

          --v_fpath:='D:\ids\j2ee\home\default-web-app\hms\Files2Print\'||v_uniqueFileName;

          v_fpath:=get_param_val('SERVER_FILE_PATH')||v_uniqueFileName;

         

          report_id         := find_report_object('report10g');

          v_reports_servlet := hms_report.report_servelet;

          v_report_server   := get_param_val('REPORT_SERVER_NAME');

          --v_report_server   := hms_report.report_server;

          v_file_name                              := p_obj_name;

          SET_REPORT_OBJECT_PROPERTY ( report_id, REPORT_SERVER        , v_report_server );

          SET_REPORT_OBJECT_PROPERTY ( report_id, REPORT_FILENAME      , v_file_name);

          SET_REPORT_OBJECT_PROPERTY ( report_id, REPORT_EXECUTION_MODE, BATCH);

          SET_REPORT_OBJECT_PROPERTY ( report_id, REPORT_COMM_MODE     , ASYNCHRONOUS );

  if p_destype='CACHE' THEN

                   SET_REPORT_OBJECT_PROPERTY ( report_id, REPORT_DESFORMAT   , p_desformat); --(PDF), HTML,HTMLCSS,Printer Definitions etc.----BY SHAMS

                   SET_REPORT_OBJECT_PROPERTY ( report_id, REPORT_DESTYPE,CACHE);--(CACHE),FILE,PRINTER

            v_otherparam := v_otherparam||'SCHEDULE=NOW MODE=BITMAP';

            --v_otherparam := v_otherparam||'MODE=CHARACTER';

                   SAVE_JOB_PARAMS (p_guname,p_obj_name,p_description,v_job_id);

          ELSif p_destype='FILE' THEN

                   SET_REPORT_OBJECT_PROPERTY ( report_id, REPORT_DESFORMAT     , p_desformat); --PDF, HTML,HTMLCSS,(Printer Definitions) etc.

                   SET_REPORT_OBJECT_PROPERTY ( report_id, REPORT_DESTYPE,FILE);--CACHE,(FILE),PRINTER

            SET_REPORT_OBJECT_PROPERTY ( report_id, REPORT_DESNAME,v_fpath);-------Generated file path

            v_otherparam := v_otherparam||'MODE=CHARACTER';

            ----------------Modified by shams Hcl-----------------------(1)

            if p_desformat='wide180.prt' then  -----Report View thru Report log,not printing from button

            SAVE_JOB_PARAMS (p_guname,p_obj_name,p_description,v_job_id); --v_job_id(out)

            end if;

            ----------------Modified by shams Hcl-----------------------(1)

          END IF;

          hidden_action := hidden_action ||'&userid='   ||get_application_property(username)||'/'

                                                                                      ||get_application_property(password)||'@'

                                                                                      ||get_application_property(connect_string);

          hidden_action := v_reports_servlet||'?_hidden_server='|| v_report_server || encode(hidden_action);

          SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_OTHER,'pfaction='||hidden_action||' '||v_otherparam);

         

          report_message := run_report_object(report_id,p_plid);---Returns Unique Report Id,running on Local or Remote Report Server.(Prefixed with Rep Server name)

 

--http://devserver:8889/reports/rwservlet?server=rep10g_sa&report=opd1.rdf&paramform=yes&desformat=pdf&destype=cache&userid=hmslive/hmslive@orcl

 

 

                  

                   ------------------Modified by shams hcl-----------------------------------------------------------------------------------(2)

                  

                                     

                                     

                             if p_destype='FILE' THEN

                               v_rep_job_id :=substr(report_message,length(v_report_server)+2,length(report_message));--Returns Unique report Id(without report server name prefixed)

                               --insert into job_parameters (job_id,parameter_id,parameter_value) values (v_job_id, 'REPORT_JOB_ID', v_rep_job_id);

                               update job_control

                               set REPORT_JOB_ID = v_rep_job_id,LOCAL_REP_ID= v_uniqueFileName

                               where JOB_ID = v_job_id;

                             ELSIF p_destype='CACHE' THEN

                               v_rep_job_id :=substr(report_message,length(v_report_server)+2,length(report_message));

                               --insert into job_parameters (job_id,parameter_id,parameter_value) values (v_job_id, 'REPORT_JOB_ID', v_rep_job_id);

                               update job_control

                               set REPORT_JOB_ID = v_rep_job_id

                               where JOB_ID = v_job_id;

                             END IF;     

                            

                             p_job_id :=report_message; ------p_job_id(out)

                             --p_job_id := v_rep_job_id;

                  

                 ------------------Modified by shams hcl-----------------------------------------------------------------------------------(2)

                  

          END;

         

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

 

5.SAVE_JOB_PARAMS

 

 

PROCEDURE SAVE_JOB_PARAMS (p_guname in varchar2,p_obj_name varchar2,p_description varchar2,p_job_id out number) IS

    v_job_id              number;

BEGIN

    -- Create a record in the JOB_CONTROL table

    select job_id.nextval into v_job_id from   dual;

    p_job_id := v_job_id;

       

    begin

      insert into job_control

             (job_id

             ,username

             ,object_type

             ,object_name

             ,description

             ,status

             ,job_started

             ,comments)

      values (v_job_id

             ,p_guname

             ,'REPORTS'

             ,p_obj_name

             ,p_description

             ,'ENQUEUED'

             ,sysdate

             ,null);

     end; -- insert into job_control

END;

 

 

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

 

 

6.Update_Report_Status :

 

 

 

PROCEDURE Update_Report_Status(p_username varchar2, p_count out number) IS

          v_rep_job_id                  number(12);

          v_rep_status  job_control.status%type;

          v_job_id      job_control.job_id%type;

  v_message_level number;

  v_count number;

 

          rep_job_status       varchar2(2000);

 

          Cursor c1 is

                                                                    select job_id, REPORT_JOB_ID, status

                                                                    from job_control jc

               where     username = p_username

               and        status <> 'FINISHED'

               order by 1;

BEGIN

  v_count := 0;

          For rec1 in c1 Loop

                  

                    

              v_rep_job_id := rec1.REPORT_JOB_ID;

              v_rep_status := rec1.status;

              v_job_id     :=rec1.job_id;

             

                   

                    -------------Modified By shams HCL--------

                    ----This code deletes the report id which is equal to zero,or rep_status=Terminated or Purged,

                    ---which created error before as report job status was not fetched

                    ----for report id=0,or rep_staus=Terminated or Purged.

                    ---Therefore all pending reports always showed 'ENQUED' and

                    ---error message came ('No Job Id for this report') on screen

                    if  v_rep_job_id=0 or v_rep_status in('TERMINATED_WITH_ERROR','PURGED') then

                                                delete  from job_control where job_id=v_job_id ;

                                      else

                             --rep_job_status := REPORT_OBJECT_STATUS(hms_report.REPORT_SERVER||'_'||v_rep_job_id );

                             rep_job_status := REPORT_OBJECT_STATUS(get_param_val('REPORT_SERVER_NAME')||'_'||v_rep_job_id );

                                      --MESSAGE('Job Id:'||rec1.job_id||'  rep_job_status:'||rep_job_status);

                                                --MESSAGE('Job Id:'||rec1.job_id||'  rep_job_status:'||rep_job_status);

                                                update job_control

                             set      status = rep_job_status

                               where  job_id = v_job_id ;

                               v_count := v_count + 1; ---------counting no. of unfinished reports

                end if;

                    ------------------------------------------      

          End Loop;

          p_count := v_count;

         

END;

 

==============================================================*****

 

 

Form          : FGMMAIN.FMB

Block         : LEFT_MENU_TREE

ITEM         : TREE

TRIGGER  : (WHEN-TREE-NODE-ACTIVATED)

 

 

DECLARE

          pParam                           PARAMLIST;

  cParamForm  CHAR;

  svFormName  G_Form_Details.Gfd_Name%TYPE;

  v_desc      G_Form_Details.Gfd_Desc%TYPE;

  NODE_STATE1 NUMBER;

  CURRENT_NODE FTREE.NODE;

  FORM_TYPE VARCHAR2(1);

          v_message_level number;

          dtf  date;

          chr varchar2(30);

         

          gf     boolean;

          fe     boolean;

          src varchar2(100);

          dst varchar2(100);

  rep_status varchar2(200);

  fp boolean;fex boolean;

  ftp_flag boolean := false;

BEGIN

          -- Set Global variable to retain menu position

          :GLOBAL.nCatgCurrTopNo := 1;

          :GLOBAL.nCatgCurrRecNo := 1;

          current_node := ftree.get_tree_selection('LEFT_MENU_TREE.TREE',1);

          svFormName := Ftree.Get_Tree_Node_Property('LEFT_MENU_TREE.TREE',name_in('system.trigger_node'), Ftree.NODE_VALUE);

          :GLOBAL.OBJ_NAME:=svFormName;

          :GLOBAL.OBJ_DESC:='';

         

          NODE_STATE1 :=Ftree.Get_Tree_Node_Property('LEFT_MENU_TREE.TREE', current_node, Ftree.NODE_state);

          IF NODE_STATE1 = 0 AND :SYSTEM.TRIGGER_NODE_SELECTED ='FALSE' THEN

                   -- Set Default value to Global current block

                   IF (:NBT_COMMON_BLOCK.NbtCurrBlock IS NULL) THEN

                             :NBT_COMMON_BLOCK.NbtCurrBlock := Get_Form_Property(:SYSTEM.Current_Form, FIRST_NAVIGATION_BLOCK);

                   END IF;

                   -- Navigate to non-menu block

                   Go_Block(:NBT_COMMON_BLOCK.NbtCurrBlock);

            BEGIN

                     SELECT Gfd_Rep_Param_Flag,GFD_FORM_MODE,GFD_DESC

                             INTO cParamForm,FORM_TYPE,v_desc

                             FROM G_Form_Details

                              WHERE Gfd_Name = svFormName;

                   EXCEPTION

                             WHEN OTHERS THEN

                               cParamForm := 'Y';

                   END;

                                               

                   :GLOBAL.OBJ_DESC:=v_desc;

 

                   IF FORM_TYPE = 'F' THEN

                             -- Call the respective form

                             IF :SYSTEM.CURRENT_FORM='FGMMAIN' THEN

                                      Call_Form(svFormName);

                             ELSE                 

                                      NEW_Form(svFormName);

                             END IF;

                   ELSIF  FORM_TYPE= 'R' THEN

                             -- Find whether report parameter form need to be displayed or not

                     BEGIN

                                      SELECT Gfd_Rep_Param_Flag

                                       INTO cParamForm

                                       FROM G_Form_Details

                                        WHERE Gfd_Name = svFormName;

                             EXCEPTION

                                      WHEN OTHERS THEN

                                        cParamForm := 'Y';

                             END;

                            

                             ----------------------------------------------------------Modified By Shams HCL (for FGMMAIN)

                             call_form('PRMFORM',NO_HIDE);

                  

                             ----------------------------------------------------------Modified By Shams HCL (for FGMMAIN)

                   END IF; -- ELSIF  FORM_TYPE= 'R' THEN

          END IF; -- IF NODE_STATE1 = 0 . . .

END;

 

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

 

Form          : FATMERGE.FMB

Block         : A_REGISTRATION_DETAIL

ITEM         : BTN_OPSLIP (Registration Slip)

TRIGGER  : WHEN-BUTTON-PRESSED

 

 

DECLARE

  pl_id ParamList;

          v_message_level number;

BEGIN

          IF :A_REGISTRATION_DETAIL.ARD_MR_NUM IS NOT NULL THEN

                             pl_id := Create_Parameter_List('Param_List');

                             IF Id_Null(pl_id) THEN

                                      v_message_level:= Show_Alert('Error in report parameter list creation');

                                      RAISE Form_Trigger_Failure;

                             END IF;

 

                    --Add parameter(s) to list just created

              Add_Parameter(pl_id,'PARAMFORM', TEXT_PARAMETER, 'NO');

                             Add_Parameter(pl_id,'P_PAT_NUM',TEXT_PARAMETER,:A_REGISTRATION_DETAIL.ARD_PAT_NUM);

                             Add_Parameter(pl_id,'P_USER',TEXT_PARAMETER,:GLOBAL.GUSERNAME);

                            

                             -- Modified by Shams Hcl

                             RUN_REPORT_OBJECT_ASYNC(:global.ufile,:global.rep_id,:global.gusername,'REGISTRATIONSLIP','Registration Receipt','FILE','wideslip.prt',pl_id);

                             if get_param_val('SHOW_DOSPAD')='Y' then

                                      show_print('1');

                             else

                                      show_print('0');

                             end if;         

          ELSE

                     Pkg_TcsHms.Gsp_GetErrorMessage('ARD00011',:GLOBAL.gErrorText,:GLOBAL.gSeverity);

              :GLOBAL.gAlertButton := Glfn_DisplayAlert(:GLOBAL.gErrorText,:GLOBAL.gSeverity);

              Raise Form_Trigger_Failure;

          END IF;

          GO_ITEM('A_REGISTRATION_DETAIL.ARD_PAT_NUM');

END;

 

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

 

Form          : FATMERGE.FMB

Block         : A_REGISTRATION_DETAIL

ITEM         : BTN_RECEIPT (Reciept)

TRIGGER  : WHEN-BUTTON-PRESSED

 

 

DECLARE

  pl_id ParamList;

          v_message_level number;

BEGIN

          IF :A_REGISTRATION_DETAIL.ARD_MR_NUM IS NOT NULL THEN

                             pl_id := Create_Parameter_List('Param_List');

                             IF Id_Null(pl_id) THEN

                                      v_message_level:= Show_Alert('Error in report parameter list creation');

                                      RAISE Form_Trigger_Failure;

                             END IF;

 

                    --Add parameter(s) to list just created

              Add_Parameter(pl_id,'PARAMFORM', TEXT_PARAMETER, 'NO');

                             Add_Parameter(pl_id,'P_PAT_NUM',TEXT_PARAMETER,:A_REGISTRATION_DETAIL.ARD_PAT_NUM);

                             Add_Parameter(pl_id,'P_USER',TEXT_PARAMETER,:GLOBAL.GUSERNAME);

                            

          --run_report_object_async(:global.job_id,:global.gusername,'CASHOPSLIP','CashOPSlip Receipt','PRINTER','wideslip',pl_id);

                             -- Modified by Shams Hcl

                             RUN_REPORT_OBJECT_ASYNC(:global.ufile,:global.rep_id,:global.gusername,'CASHOPSLIP','CashOPSlip Receipt','FILE','wideslip.prt',pl_id);

      if get_param_val('SHOW_DOSPAD')='Y' then

                                      show_print('1');

                             else

                                      show_print('0');

                             end if;         

          ELSE

                     Pkg_TcsHms.Gsp_GetErrorMessage('ARD00011',:GLOBAL.gErrorText,:GLOBAL.gSeverity);

              :GLOBAL.gAlertButton := Glfn_DisplayAlert(:GLOBAL.gErrorText,:GLOBAL.gSeverity);

              Raise Form_Trigger_Failure;

          END IF;

          GO_ITEM('A_REGISTRATION_DETAIL.ARD_PAT_NUM');

END;

 

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

 

FORM                            :   FGMMAIN.fmb

PROGRAM UNIT           :   SHOW_PRINT    

 

 

PROCEDURE SHOW_PRINT(p_showprint varchar2) IS

          pParam                           PARAMLIST;

  rep_status varchar2(200);

  fp boolean;fex boolean;

  ftp_flag boolean := false;

          src varchar2(100);

          dst varchar2(100);

          gf     boolean;

          fe     boolean;

BEGIN

          ---/////////////////// THIS FUNCTION NOW USED ONLY BY BUTTON TRIGGERS IN FORMS TO PRINT THE SLIPS DIRECTLY WITHOUT VIEWING /////////------

         

          Destroy_Parameter_List('Param_List');

         

          rep_status:=REPORT_OBJECT_STATUS(:global.rep_id);--- used when (report_message) value returned from run_report_object_async.

            ---rep_status:=REPORT_OBJECT_STATUS(hms_report.REPORT_SERVER||'_'||:global.rep_id );---used when (v_rep_job_id) value returned from run_report_object_async.

            WHILE rep_status in ('RUNNING','OPENING_REPORT','ENQUEUED', null) LOOP

                   ---rep_status:=REPORT_OBJECT_STATUS(hms_report.REPORT_SERVER||'_'||:global.rep_id );---used when (v_rep_job_id) value returned from run_report_object_async.

                   rep_status:=REPORT_OBJECT_STATUS(:global.rep_id);--- used when (report_message) value returned from run_report_object_async.

                   END LOOP;

IF rep_status='FINISHED' THEN

                  

                                      client_Host('cmd /c IF NOT EXIST '||get_param_val('LOCAL_FILE_PATH')||' md '||get_param_val('LOCAL_FILE_PATH')); -- Directory created.

                                      --client_Host('cmd /c IF NOT EXIST C:\myfiles (md C:\myfiles)',no_screen); -- Directory created.

                                       fex:=webutil_file.file_exists(get_param_val('LOCAL_FILE_PATH')||'DosPad.exe');----

                                      if not fex then

                                       fp := webutil_file_transfer.URL_To_Client(get_param_val('ALL_EXE_URL')||'DosPad.exe',get_param_val('LOCAL_FILE_PATH')||'DosPad.exe');

                                                if fp then

                                                          fex:=webutil_file.file_exists( get_param_val('LOCAL_FILE_PATH')||'DosPad.exe');

                                                          while not(fex) loop

                                                                   fex:=webutil_file.file_exists( get_param_val('LOCAL_FILE_PATH')||'DosPad.exe');

                                                          end loop;

                                                else

                                                          ftp_flag := true;

                                                          message('FTP failed in transfering file DosPad.exe from server.');

                                                          message('FTP failed in transfering file DosPad.exe from server.');

                                                end if;

                                      end if;

                                     

                                      fex:=webutil_file.file_exists( get_param_val('LOCAL_FILE_PATH')||'RICHTX32.OCX');

                                      if not fex then

                                        fp := webutil_file_transfer.URL_To_Client(get_param_val('ALL_EXE_URL')||'RICHTX32.OCX',get_param_val('LOCAL_FILE_PATH')||'RICHTX32.OCX');

                                                if fp then

                                                          fex:=webutil_file.file_exists( get_param_val('LOCAL_FILE_PATH')||'RICHTX32.OCX');

                                                          while not(fex) loop

                                                                    fex:=webutil_file.file_exists(get_param_val('LOCAL_FILE_PATH')||'RICHTX32.OCX');

                                                          end loop;

                                                else

                                                          ftp_flag := true;

                                                          message('FTP failed in transfering file RICHTX32.OCX from server.');

                                                          message('FTP failed in transfering file RICHTX32.OCX from server.');

                                                end if;         

                                      end if;

                                               

                                                if not ftp_flag then

                                                          src:=get_param_val('ALL_EXE_URL')||'Files2Print/'||:global.ufile;

                                                          dst:=get_param_val('LOCAL_FILE_PATH')||:global.ufile;

                                                         gf := webutil_file_transfer.URL_To_Client(src,dst); -- Report Text File Transfered.

                                                                   if gf then

                                                                             fe := webutil_file.file_exists(dst);

                                                                             while not(fe) loop

                                                                                      fe := webutil_file.file_exists(dst);

                                                                             end loop;

                                                                             -- Change Attributes of the input file

                                                                             --client_Host('cmd /c attrib +h +r '||dst,no_screen);

                                                                             -- Delete input file from Server--------------------------////

                                                                     --     Host('del D:\ids\j2ee\home\default-web-app\hms\Files2Print\'||:global.ufile,no_screen);

                                                                    Host('del '||get_param_val('SERVER_FILE_PATH')||:global.ufile,no_screen);

                                                                      client_Host(get_param_val('LOCAL_FILE_PATH')||'dospad '||p_showprint||:global.ufile,no_screen ); -- Preview & Print

                                                                             client_Host('cmd /c del '||dst,no_screen);--------Delete file from client computer--////

                                                                             --exit_form;

                                                                   else

                                                                             message('Report file transfer failed from server to client.');

                                                                             message('Report file transfer failed from server to client.');

                                                           end if;

                                       end if;

                             ELSE

                                      message('Report failed with error message '||rep_status);

                                      message('Report failed with error message '||rep_status);

                             END IF;

END;

 

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

 

FORM                                                      :   PRMFORM.fmb

FORM LEVEL TRIGGER                        :   WHEN-NEW-FORM-INSTANCE

 

 

declare

         

          cParamForm char;

          pParam                           PARAMLIST;

          v_message_level number;

 

BEGIN

         

                   :global.rep_server_running:='';

         

          :global.rec_count:='';

         

          set_item_property('LOV',WIDTH,0);

          set_item_property('LOV',HEIGHT,0);

          set_window_property('WINDOW1',TITLE,'Report Parameters for '||:GLOBAL.OBJ_NAME||' :' ||:global.obj_desc);

         

 

                   ----------------Modified By Shams HCL-------------------------------------------------------------------------

         

                   SELECT Gfd_Rep_Param_Flag

                                       INTO cParamForm

                                       FROM G_Form_Details

                                        WHERE Gfd_Name = :global.obj_name;

                                               

                                          ------THESE LINES OF CODE USED TO RUN THE REPORT WHICH  HAS  PARAMETERS(i.e PARAMETER FORM TO SHOW)

                                        if cParamForm='Y' then

                                                           select count(*) into :global.rec_count

                                                                   from report_params

                                                                   where report_id = :global.obj_name;

                                                                  

                                                                   if :global.rec_count > 0 then

                                                                             go_block('report_params');

                                                                             execute_query;

                                                                   else

                                                                             message('Report parameters not defined.');

                                                message('Report parameters not defined.');

                                                Raise Form_Trigger_Failure;

                                               

                                       end if;

                                      else

                                                         

                                                ------THESE LINES OF CODE USED TO RUN THE REPORT WHICH HAS NO PARAMETERS(i.e NO PARAMETER FORM TO SHOW) 

 

                             pParam := Create_Parameter_List('Param_List');

                      Add_Parameter(pParam,'PARAMFORM',TEXT_PARAMETER,'NO');

                      Add_Parameter(pParam,'P_USER',TEXT_PARAMETER,:GLOBAL.GUSERNAME);

                                          

                                                                    RUN_REPORT_OBJECT_ASYNC(:global.ufile,:global.rep_id,:global.gusername,:GLOBAL.OBJ_NAME,:GLOBAL.OBJ_DESC,'FILE','wide180.prt',pParam);

                                                            --SHOW_PRINT('1'); --Show ------This function not called here but called in report_log.when-timer-expired trig.

                                                            

                                          Destroy_Parameter_List('Param_List');

                                       

                                                IF :GLOBAL.REP_ID IS NOT NULL THEN

                                                          v_message_level       := :system.message_level;

                                                          :system.message_level := 20;

                                                          commit;

                                                          :system.message_level := v_message_level;

                                                          Call_Form('REPORT_LOG', NO_HIDE);

                                                          END IF;

                                               

                   EXIT_FORM;

                   end if;

                                        

----------------Modified By Shams HCL---------------------------------------------------------------------------------------------

         

END;

 

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

 

FORM                            :   PRMFORM.fmb

BLOCK (of Buttons)       :   PARAM_BLK

ITEM                             :   RUN(Run Report)

TRIGGER(Block Level)  :   (WHEN-BUTTON-PRESSED)

 

 

          DECLARE

                             pParam                           PARAMLIST;

                             v_message_level number;

                             alrt number;

                     --rep_status varchar2(200);

                     --fp boolean;fex boolean;

                     --ftp_flag boolean := false;

                             --src varchar2(100);

                             --dst varchar2(100);

                             --gf     boolean;

                             --fe     boolean;

                            

                   BEGIN

                             --Data Validation

                             Go_Block('REPORT_PARAMS');

                             go_record(1);

                  

                             pParam := Create_Parameter_List('Param_List');

                             for i in 1..:global.rec_count Loop

                                                 Add_Parameter(pParam,:report_params.param_id,TEXT_PARAMETER,:report_params.param_value);

                                                if i != :global.rec_count then

                                                          next_record;

                                                end if;

                             end loop;

                             Add_Parameter(pParam,'PARAMFORM',TEXT_PARAMETER,'NO');

                             Add_Parameter(pParam,'P_USER',TEXT_PARAMETER,:GLOBAL.GUSERNAME);

                             --Add_Parameter(pParam,'P_OP_ID',TEXT_PARAMETER,:GLOBAL.GUSERNAME);

                  

                    ----------------------------MODIFIED by shams hcl-------------------//////////

                            

                                       RUN_REPORT_OBJECT_ASYNC(:global.ufile,:global.rep_id,:global.gusername,:GLOBAL.OBJ_NAME,:GLOBAL.OBJ_DESC,'FILE','wide180.prt',pParam);

                                        --SHOW_PRINT('1'); --Show ------This function not called here but called in report_log.when-timer-expired trig.

                                        if      :global.rep_server_running='N' then

                                               

                                                Set_Alert_Property('altError',ALERT_MESSAGE_TEXT,'The Report Server [ '||GET_PARAM_VAL('REPORT_SERVER_NAME')||' ] not runningt,Plz Start the Report Server');

            alrt:= Show_Alert('altError');

            exit_form;

          else

            ---------------------------------------------------------------------//////////    

                                                              Destroy_Parameter_List('Param_List');

                                                           

                                                                    IF :GLOBAL.REP_ID IS NOT NULL THEN

                                                                             v_message_level       := :system.message_level;

                                                                             :system.message_level := 20;

                                                                             commit;

                                                                             :system.message_level := v_message_level;

                                                                             Call_Form('REPORT_LOG', HIDE);---Hides the calling form(prmform)

                                                                             END IF;

                                                                            

                                                                             Exit_form;

                                     

                                        end if;

                            

                   END;

 

 

 

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

 

 

FORM                            :   PRMFORM.fmb

BLOCK (of Items)           :   REPORT_PARAMS

TRIGGER(Block Level)  :   (POST-QUERY)

 

BEGIN

                   if (:report_params.param_type = 'LOV') then

                             Set_Item_Instance_Property( 'REPORT_PARAMS.LOV_BTN', current_record,visual_attribute,'VA1');

                   end if;

 

                   if ((:report_params.param_datatype = 'DATE') and (upper(:report_params.param_default) = 'SYSDATE')) then

                             :report_params.param_value := to_char(sysdate,'dd/mm/yyyy');

                   else

                             :report_params.param_value := :report_params.param_default;

                   end if;

END;

 

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

 

FORM                            :   PRMFORM.fmb

BLOCK (of Items)           :   REPORT_PARAMS

ITEM                             :   PARAM_VALUE

TRIGGER(Item Level)    :   (KEY-LISTVAL)

 

declare

          i number;

BEGIN

if :global.rec_count > 0 then

          if :lov is null then

                   :lov := :report_params.param_default;

          else

                   :lov := :report_params.param_value;

          end if;

         

  if :report_params.param_type = 'TEXT' then

    message('Error: List of values unavailable for this field');

    raise form_trigger_failure;

  end if;

 

          i := POPULATE_GROUP_WITH_QUERY('LOV',:report_params.param_query);

          Set_LOV_Property('LOV',TITLE,:report_params.report_id);   

          Set_LOV_Column_Property('LOV',1,width,100);  

          Set_LOV_Column_Property('LOV',1,title,:report_params.param_desc);       

          Set_LOV_Column_Property('LOV',2,width,150);  

         

          go_item('LOV');

          do_key('LIST_VALUES');      

          :report_params.param_value := :lov;

          go_item('report_params.param_value');

end if;

END;

 

------------------------------------------ 

 

FORM                            :   PRMFORM.fmb

BLOCK (of Items)           :   REPORT_PARAMS

ITEM                             :   LOV_BTN

TRIGGER(Item Level)    :   (WHEN-BUTTON-PRESSED)

 

go_item('PARAM_VALUE');

do_key('LIST_VALUES');-----Executing the Key-Trigger(KEY-LISTVAL),IF SUPPOSE NO KEY-TRIGGER THERE,the specified built-in wd be executed .

 

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