npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@qwe8652591/abap-lib

v1.0.1

Published

ABAP 分析工具库 - 整合屏幕解析、流程追踪、PBO/PAI分析和CSV导出

Downloads

180

Readme

@qwe8652591/abap-lib

ABAP 分析工具库 - 整合屏幕解析、流程追踪、PBO/PAI分析和CSV导出的完整解决方案

📦 安装

npm install @qwe8652591/abap-lib

✨ 核心能力

1️⃣ 屏幕解析器 (Screen Parser)

解析 SAP 屏幕 XML,提取屏幕、字段、流程逻辑

2️⃣ 执行流程追踪器 (Flow Tracer)

追踪屏幕加载和执行流程,构建调用图

3️⃣ PBO/PAI 分析器 (PBO/PAI Analyzer)

分析 PBO/PAI 模块和控件级事件,提取调用链

4️⃣ CSV 导出器 (CSV Exporter)

导出屏幕总览、路径、调用链和控件清单为 CSV

🚀 快速开始

一键执行所有分析

import { ABAPAnalyzer } from '@qwe8652591/abap-lib';

const analyzer = new ABAPAnalyzer('./saplmegui.prog.xml');

// 一键执行:解析 + 分析 + 导出
await analyzer.analyzeAll('./output', {
  parser: {
    includeControlEvents: true,
    includeCallChains: true
  },
  analyzer: {
    traceDepth: 5
  },
  exporter: {
    filePrefix: 'my_'
  }
});

// 查看统计信息
const stats = analyzer.getStatistics();
console.log(`解析了 ${stats.totalScreens} 个屏幕`);

分步执行

import { ABAPAnalyzer } from '@qwe8652591/abap-lib';

const analyzer = new ABAPAnalyzer('./saplmegui.prog.xml');

// 步骤1: 解析屏幕
const screens = await analyzer.parseScreens();
console.log(`找到 ${screens.length} 个屏幕`);

// 步骤2: 生成屏幕路径
const paths = await analyzer.generateScreenPaths();
console.log(`生成 ${paths.length} 条路径`);

// 步骤3: 分析 PBO/PAI
const { moduleCallChains, controlEvents } = await analyzer.analyzePBOPAI();
console.log(`找到 ${moduleCallChains.length} 个模块`);

// 步骤4: 追踪执行流程
const flow = await analyzer.traceExecutionFlow('0014');
console.log(`追踪了 ${flow.steps.length} 个步骤`);

// 步骤5: 导出 CSV
await analyzer.exportAllCSV('./output');

📊 使用独立模块

屏幕解析器

import { ScreenParser } from '@qwe8652591/abap-lib';

const parser = new ScreenParser();
const screens = await parser.parse('./saplmegui.prog.xml', {
  screenNumberFilter: ['0014', '0010'] // 可选:只解析特定屏幕
});

执行流程追踪器

import { ExecutionFlowTracer } from '@qwe8652591/abap-lib';

const tracer = new ExecutionFlowTracer();
const flow = await tracer.trace('0014', screens, {
  traceDepth: 10,
  includeDynamicCalls: true
});

console.log('执行步骤:');
flow.steps.forEach(step => {
  console.log(`${step.stepNumber}. ${step.type}: ${step.description}`);
});

PBO/PAI 分析器

import { PBOPAIAnalyzer } from '@qwe8652591/abap-lib';

const analyzer = new PBOPAIAnalyzer();
const { moduleCallChains, controlEvents } = await analyzer.analyze(screens);

// 查看模块调用链
moduleCallChains.forEach(chain => {
  console.log(`${chain.moduleName}: ${chain.callChain}`);
});

// 查看控件级事件
controlEvents.forEach(event => {
  console.log(`${event.controlName}: ${event.moduleName} (${event.timing})`);
});

CSV 导出器

import { CSVExporter } from '@qwe8652591/abap-lib';

const exporter = new CSVExporter();

// 导出屏幕总览
await exporter.exportScreenOverview(screens, './屏幕总览.csv');

// 导出控件清单(含事件)
await exporter.exportControlsWithEvents(screens, controlEvents, './控件清单.csv');

📁 生成的 CSV 文件

执行 analyzeAll() 后会生成以下 CSV 文件:

  1. 屏幕总览.csv - 所有屏幕的基本信息
  2. 屏幕路径.csv - 屏幕层级关系和导航路径
  3. PBO-PAI方法调用链.csv - 每个模块的详细调用链
  4. 控件清单(含事件).csv - 所有控件及其事件信息

🔧 API 文档

ABAPAnalyzer

主分析器类,整合所有功能。

class ABAPAnalyzer {
  constructor(xmlFilePath: string)
  
  // 解析屏幕
  parseScreens(config?: ParserConfig): Promise<Screen[]>
  
  // 追踪执行流程
  traceExecutionFlow(entryScreen: string, config?: AnalyzerConfig): Promise<ExecutionFlow>
  
  // 分析 PBO/PAI
  analyzePBOPAI(config?: ParserConfig): Promise<{
    moduleCallChains: ModuleCallChain[];
    controlEvents: ControlEvent[];
  }>
  
  // 生成屏幕路径
  generateScreenPaths(): Promise<ScreenPath[]>
  
  // 导出所有 CSV
  exportAllCSV(outputDir: string, config?: ExporterConfig): Promise<void>
  
  // 一键执行所有
  analyzeAll(outputDir: string, config?: {...}): Promise<void>
  
  // 获取统计信息
  getStatistics(): Statistics
  
  // 获取数据
  getData(): { screens, screenPaths, moduleCallChains, controlEvents }
}

类型定义

interface ParserConfig {
  xmlFilePath?: string;
  screenNumberFilter?: string[];
  parseScreens?: boolean;
  parseFunctions?: boolean;
  parseClasses?: boolean;
  parseDictionary?: boolean;
  parseTables?: boolean;      // 🆕 独立解析表
  parseDomains?: boolean;     // 🆕 独立解析域
  parsePrograms?: boolean;
  parseInterfaces?: boolean;
  parseFunctionGroups?: boolean;
}

interface AnalyzerConfig {
  traceDepth?: number;
  includeDynamicCalls?: boolean;
  resolveVariables?: boolean;
}

interface ExporterConfig {
  outputDir?: string;
  filePrefix?: string;
  csvOptions?: CSVExportOptions;
}

interface Screen {
  screenNumber: string;
  type: string;
  description: string;
  pboModules: string[];
  paiModules: string[];
  fields: ScreenField[];
}

🆕 表解析功能

ABAPAnalyzer 现在支持独立的表定义解析。

基本用法

import { ABAPAnalyzer } from '@qwe8652591/abap-lib';

// 使用 abaplint 深度解析(推荐)
const analyzer = new ABAPAnalyzer(projectPath, true);

// 只解析表定义
await analyzer.analyzeAll({
  parseScreens: false,
  parseTables: true
});

// 获取表列表
const tables = analyzer.getTables();

// 获取特定表的详细信息
const tableDetail = analyzer.getTableDetails('VBAK');
console.log(`表 ${tableDetail.name} 有 ${tableDetail.fields.length} 个字段`);

配置选项

  • parseTables: boolean - 独立解析表定义
  • parseDomains: boolean - 独立解析域定义
  • parseDictionary: boolean - 同时解析表和域(兼容旧版)

详细文档

查看 表解析文档 了解更多信息。

🌟 示例项目

查看 examples/ 目录获取更多示例:

  • 01-screen-parser.ts - 屏幕解析示例
  • 02-flow-tracer.ts - 流程追踪示例
  • 03-pbo-pai-analyzer.ts - PBO/PAI 分析示例
  • 04-csv-exporter.ts - CSV 导出示例
  • 05-all-in-one.ts - 完整流程示例 ⭐
  • 08-table-parser-standalone.ts - 表解析示例 🆕

📝 开发指南

构建

npm run build

开发模式

npm run dev

运行示例

npm run example:all-in-one

🤝 贡献

欢迎提交 Issue 和 Pull Request!

📄 许可证

MIT

👤 作者

[email protected]

🔗 相关项目