跳转至

LN 4GL 代码库

Infor LN 4GL 开发代码示例集合,涵盖 DAL、Extension、User Exit、Public Interfaces 等常用代码片段。


💻 开发工具

工具名称 简介 适用版本 链接
Infor LN DevTools (VS Code) VS Code 扩展,浏览/选择/管理 LN ERP 构件(表、Session、脚本等) LN 10.7+ GitHub
LN Studio 官方应用开发工具,支持安装配置、基于活动的开发、调试工具 LN 10.4+ 官方文档
LN Development Tools Guide LN 开发工具开发者指南 LN 查看文档
LN Reporting (SSRS) SQL Server Reporting Services 报告开发工具 LN 10.7 查看文档

📝 代码示例(按主题分类)

DAL(Data Access Layer)示例

| DAL 示例:创建一个新的 DAL 函数
dal.define.table({
  table: "whinp001"
  lock: dal.LOCK.SHARED
})
dal.define.field({"whinp001.item", "whinp001.qty"})
dal.set.where("whinp001.item = :item")
dal.select.do({
  on.NOTFOUND: | 处理未找到记录 |
  on.SUCCESS: | 处理查询结果 |
})

Extension 开发示例

| Extension 示例:在 Standard Cost 计算前添加自定义逻辑
function extern short before.cost.standard.calculate()
{
  | 自定义逻辑:根据特定条件调整标准成本
  if tiitm001.oorg = "MANUFACTURING" then
    | 制造业特殊成本计算
    retval = 0  | 返回 0 表示成功,继续标准逻辑
  else
    retval = 1  | 返回 1 表示已处理,跳过标准逻辑
  endif

  return(retval)
}

Public Interfaces 示例

| PI 示例:调用外部 Web Service
function extern long call.external.service()
{
  string endpoint = "https://api.example.com/v1/data"
  string api.key = "your-api-key"

  | 使用 Http Client 调用外部 API
  long http.clnt = http.client.new()
  http.client.set.header(http.clnt, "Authorization", "Bearer " + api.key)
  long response = http.client.get(http.clnt, endpoint)

  if response.status == 200 then
    string response.body = http.client.get.response.body(http.clnt)
    | 解析响应...
  endif

  return(0)
}

数据库操作示例

| 数据库性能调优示例:使用索引优化查询
| 好的做法:使用索引字段作为查询条件
select ttiitm001.*
from ttiitm001
where ttiitm001._index1 = :item  | 使用主键索引
selectdo
  | 处理逻辑
endselect

| 避免的做法:全表扫描
select ttiitm001.*
from ttiitm001
where ttiitm001.dscp = :description  | 非索引字段,会全表扫描
selectdo
endselect

🔗 常用开发资源

资源名称 简介 链接
Infor LN 4GL 开发技巧 DAL2 / Extension / Public Interfaces 开发详解 查看
LN 二次开发实战集锦 实战案例集合 查看
我走的窄道(腾讯云) 15年 LN 经验,从 5.0c 到 10.3 升级历程 访问
CSDN LN 开发专栏 LN 二次开发详细教程 访问

📚 官方文档入口


🤝 贡献

欢迎提交更多 LN 4GL 代码示例!请查看 资源提交规范

最后更新:2026-05-11