Thursday, April 3, 2014

PeopleSoft :: Record data to file conversion using Peoplecode

Local SQL &MYSQL; 
Local string &EFFDT1; 

SQLExec("SELECT COUNT(*) FROM PS_YOUR_TABLE", &COUNT); 
&MYSQL = CreateSQL("SELECT EMPLID,NAME,to_char(EFFDT,'YYYY-MM-DD HH:MI'),to_char(BIRTHDATE,'YYYY-MM-DD HH:MI')
,SUPERVISOR_NAME,DEPT_DESC,LOCATION FROM PS_PPSFT_ATST_EMP"); 
&fileLog = GetFile("Output_Report.csv", "w", "a", %FilePath_Relative); 
If &COUNT = 0 Then 
&fileLog.WriteLine("No data found"); 
Else/*Write Heading for the file columns 
&fileLog.WriteLine("EMPLID" | "," | "NAME" | "," | "EFFDT" | "," | " 
BIRTHDATE" | "," | "SUPERVISOR_NAME" | "," | "DEPT_DESC" | "," | "LOCATION"); 
End-If; 
While &fileLog.WriteLine(&EMPLID,&NAME ,&EFFDT,&BIRTHDATE,,&SUPERVISOR_NAME,&DEPT_DESC,& 
LOCATION) 
&EMPLID | "," | &NAME | "," | &EFFDT | "," | &BIRTHDATE" | "," | & SUPERVISOR_NAME | 
"," | &DEPT_DESC | "," | &LOCATION) 
End-While; 


where  PS_PPSFT_ATST_EMP is the staging table

No comments:

Post a Comment