SQR Code

Your rating: None Average: 4.3 (3 votes)

Some times requirement comes to genrate the output file (csv or any other) at the default output directory so that it can be accesible from the Process Monitor's 'View Log/Trace' page.
To achive this below code will be helpful-

begin-procedure Init-Report

  do Stdapi-Init

  if $prcs_process_instance = ''
        !No Prompt
    do Ask-As-Of-Date
  else
    display 'Going to select-parameters'
    do Select-Parameters
  end-if
  do Init_Printer
  do Init_Report_Translation ($ReportID, $Language_cd)

  if $language_cd = 'JPN'
     let $qualifier = 'NAME_AC'
  else
     let $qualifier = 'NAME'
  end-if
  
  do Get-Filename
  let $filename1 = '{HRSDIR_OUT}'||'Age-Wage-Distribution.csv'			
  open $filename   as 100 for-writing record=1000:vary status=#filestat
  open $filename1  as 101 for-writing record=1000:vary status=#filestat

  Let $Report_Title = 'Age and Wage Distribution Report'
  WRITE 100 FROM $Report_Title  
  WRITE 100 FROM ''  
  WRITE 101 FROM $Report_Title  
  WRITE 101 FROM '' 	
 
end-procedure


!**************************************************************************
begin-procedure Get-Filename
!**************************************************************************

begin-select 
R.PRCSOUTPUTDIR &R.PRCSOUTPUTDIR 
	let $OutputDirectory = &R.PRCSOUTPUTDIR 
FROM PSPRCSPARMS R 
WHERE R.PRCSINSTANCE = $prcs_process_instance 
end-select 

!show 'Creating File'
#ifdef UNIX
	let $FileName = $OutputDirectory || '/Age-Wage-Distribution.csv'
	!show $FileName
#ELSE
	let $FileName = $OutputDirectory || '\Age-Wage-Distribution.csv'
	!show $FileName
#END-IF

END-PROCEDURE

Regards,
Ganesh Pawar,
Pune

Please try to help out with unanswered topics on the forum. Chances are you have had the same issue/question some time in your IT career!

Comments

Have a question? Please ask it on the forum instead.
rahulkhandelw's picture
User offline. Last seen 6 years 27 weeks ago. Offline
Joined: 10/16/2009
Posts: 34
Re: SQR Code

To my knowledge , if we use {FILEPREFIX} variable, process direclty creates file in Log output folder and created file is available in process schedular.

Sample code
let $FileName = '{FILEPREFIX}'||xxx.csv

SQR engine is intelligent enough to assign correct value to FILEPREFIX variable.

Post new comment

CAPTCHA
The question below is to prevent automated spam submissions.
10 + 5 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.