PeopleSoft 开发 - 01 People Code 语法基础

PeopleCode 语言结构

数据类型
常规数据类型包括 number,date,string.可以进行基本计算。
Object 数据类型用于实例化。

在使用变量前要先声明。

常规数据类型:
  • Any   没有声明类型的默认为   ANY 类型,由系统自动判断类型
  • Boolean
  • Date
  • DateTime
  • Float
  • Integer   
     -2,147,483,648 到 2,147,483,647
  • Number
  • Object
  • String
  • Time


注释
  • /* This is commont */ 
  • REM (remark)
  • <*  /*   This is commont  */     *>      可以嵌套别的注释符号

语句
以分号( ;)结尾

赋值语句
根据数据类型,判断是传值还是传引用,
基本类型数据一般是传值,对象类型是传引用。
Local array of number &AN, &AN2; 
Local number &NUM; 
 
&AN = CreateArray(100, 200, 300); 
&AN2 = &AN; 
&NUM = &AN[1];
上面代码中 &AN和&AN2指向同一个对象

分支语句
If condition Then 
   [statement_list_1] 
[Else 
   [statement_list_2]] 
End-if;
evaluate &USE_FREQUENCY
when = "never" 
   PROD_USE_FREQ = 0;
   Break;
when = "sometimes" 
   PROD_USE_FREQ = 1;
   Break;
when = "frequently" 
   PROD_USE_FREQ = 2;
   Break;
when-other
   Error "Unexpected value assigned to &USE_FREQUENCY."
end-evaluate;

For 语句
&MAX = 10;
for &COUNT = 1 to &MAX;
   WinMessage("Executing statement list, count = " | &COUNT);
end-for;

Repeat
statement_list
Until logical_expression;
反复运行直到   logical_expression 返回 TRUE

While logical_expression
statement_ list
End-while;
反复运行直到   logical_expression 返回 FALSE


常量
Constant &Start_New_Instance = True; 
Constant &Display_Mode = 0; 
Constant &AddMode = "A": 
Local Field &Start_Date; 
. . . 
MyFunction(&Start_New_Instance, &Display_Mode, &Add_Mode);

meta-SQL
特殊的SQL对象,用%表示。

变量
以   &  开头。
Local Number &AGE; 
Global String &OPER_NICKNAME; 
Component Rowset &MY_ROWSET; 
Local Any &SOME_FIELD; 
Local ApiObject &MYTREE; 
Local Boolean &Compare = True;
通常不使用Global范围的变量,因为很难维护。
在使用 TransferPage, DoModal, or DoModalComponent 方法后 Component 范围变量可以保持使用,但是在调用 Transfer 方法后,Component 范围变量就无效了。

下面类型的变量只能声明为Local:
  • JavaObject

  • Interlink

    Note. Interlink objects can be declared as type Global in an Application Engine program.

  • TransformData

  • XmlNode

下面ApiObject 类型的变量只能声明为Global:
  • Session

  • PSMessages collection

  • PSMessage

  • All tree classes (trees, tree structures, nodes, levels, and so on.)

  • Query classes

All other ApiObject data type objects (such as all the PortalRegistry classes) must be declared as Local.


操作符
  • +

  • -

  • *

  • /

  • **

Time + number of seconds

Time

Resulting time

Date + number of days

Date

Resulting date

Date - date

Number

Difference in days

Time - time

Number

Difference in seconds

Date + time

DateTime

Date and time combined


字符串之间用 | 符号链接。
&RETORT = "I can't do that, " | &OPER_NICKNAME |  "."

@ 操作符(类似指针)
使用 @操作符,可以达到类似指针的效果:
&STR1 = "RECORD.BUS_EXPENSE_PER"; 
&STR2 = "BUS_EXPENSE_DTL.EMPLID"; 
&STR3 = FetchValue(@(&STR1), CurrentRowNumber(1), @(&STR2), 1); 
WinMessage(&STR3, 64); 

=

Equal

!=

Not equal

<>

Not equal

<

Less than

<=

Less than or equal to

>

Greater than

>=

Greater than or equal to



版权声明:本文为yanliang1原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。