Friday, 9 December 2016

Peoplesoft Meta Variables

%DateIn


When a date literal or a date bind variable is used within the WHERE clause of SELECT or UPDATE statements,
it can be specified within the %DateIn meta-SQL variable to get the platform-specific SQL syntax for the date.


%Datein  resolves to to_date('2013-06-10','YYYY-MM-DD')   

In short it converts the date literal / bind variable into the format which the DB uses.

INSERT INTO PS_SGK_REC (EMPLID, NAME, JOIN_DT, DEPTID)
VALUES (’001′, ‘John’, %DateIn(:1), ‘EAS’);


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


%DateOut  

%DateOut on the other hand converts a date column in the SELECT clause to the format that PeopleSoft uses.

SELECT EMPLID, NAME, %DateOut(JOIN_DT)
FROM PS_SGK_REC WHERE DEPTID = ‘EAS’;


%Dateout resolves to to_char(date,'YYYY-MM-DD')


Local Rowset &rs = Createrowset(Record.PERSON);

&rs.Fill("WHERE 1=0 UNION SELECT EMPLID, %DateOut(BIRTHDATE),BIRTHPLACE,BIRTHCOUNTRY,
BIRTHSTATE,%DateOut(DT_OF_DEATH),%DateTimeOut(LAST_CHILD_UPDDTM)
 FROM PS_PERSON WHERE EMPLID = :1", &emplid);


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

%SELECTALL

%SelectAll uses the underlying record definition to select the fields - so it will always return all fields from the underlying record, even if that record definition changes.

Local Record &REC ;
&REC = CreateRecord(Record.SF_ACCTG_LN);


&SQL = CreateSQL("%SELECTALL(:1) WHERE GL_DISTRIB_STATUS =:2 AND  ACCOUNTING_DT <=TO_DATE( :3 ,'YYYY-MM-DD') ", &REC, "N", IBT_GL_RUN_AET.END_DATE);
While &SQL.Fetch(&REC)
  

&Currency_cd =  &REC.CURRENCY_CD.Value ;
&account = &REC.ACCOUNT.Value


End-While

No comments:

Post a Comment