简体   繁体   English

如何在 SapScript 或 SmartForm 中查找标准文本?

[英]How to find a standard text within a SapScript or SmartForm?

I need to track down where within a large number of custom sapscripts and smartforms a specific standard text (SO10) is being used.我需要追踪在大量自定义 sapscripts 和 smartforms 中使用特定标准文本 (SO10) 的位置。

Apart from the equivalent of "check the code for each print script", I've not found a workable solution online.除了相当于“检查每个打印脚本的代码”之外,我还没有在网上找到可行的解决方案。 Any suggestions?有什么建议?

After posting, I found a partial solution.发布后,我找到了部分解决方案。 The code below will search for a standard text within sapscripts, but not smartforms.下面的代码将在 sapscripts 中搜索标准文本,但不会在 smartforms 中搜索。

PARAMETERS: p_sttxt LIKE stxh-tdname.

DATA: BEGIN OF t_stxh OCCURS 0,
        tdname LIKE stxh-tdname,
        tdspras LIKE stxh-tdspras,
      END OF t_stxh.

DATA t_lines LIKE tline OCCURS 0 WITH HEADER LINE.

SELECT tdname tdspras FROM stxh INTO TABLE t_stxh
                         WHERE tdobject = 'FORM'
                         AND tdid = 'TXT'
                         AND tdspras = 'E'.

LOOP AT t_stxh.
  REFRESH t_lines.
  CALL FUNCTION 'READ_TEXT'
    EXPORTING
*       CLIENT                        = SY-MANDT
      id                            = 'TXT'
      language                      = t_stxh-tdspras
      name                          = t_stxh-tdname
      object                        = 'FORM'
    TABLES
      lines                         = t_lines
   EXCEPTIONS
     id                            = 0
     language                      = 0
     name                          = 0
     not_found                     = 0
     object                        = 0
     reference_check               = 0
     wrong_access_to_archive       = 0
     OTHERS                        = 0 .

  SEARCH t_lines FOR p_sttxt.
  IF sy-subrc EQ 0.
    WRITE:/ t_stxh-tdname, t_stxh-tdspras.
  ENDIF.

ENDLOOP.

This is a (fixed) version of the code found here: http://scn.sap.com/thread/179142这是此处找到的代码的(固定)版本: http : //scn.sap.com/thread/179142

What concerns SmartForms, you cannot.关于 SmartForms,您不能。 You cannot just find it like you want it.你不能随心所欲地找到它。

Unfortunately, in such ̶g̶o̶o̶d̶ ̶o̶l̶'̶ legacy technology as SmartForms everything is working legacy way, and standard texts are simply hard-coded .不幸的是,在像 SmartForms 这样的 ̶g̶o̶o̶d̶ ̶o̶l̶'̶ 遗留技术中,一切都以遗留方式工作,标准文本只是硬编码 Yes, it looks awkward but they are really hard-coded, and these names are written out to SmartForm FM code every time it is re-generated.是的,它看起来很笨拙,但它们确实是硬编码的,每次重新生成 SmartForm FM 代码时,这些名称都会写出。

在此处输入图片说明

So the only workaround here is to analyze the code.所以这里唯一的解决方法是分析代码。

  1. Find all FMs for existing Smart Forms in system查找系统中现有智能表单的所有 FM

There is a D010INC table containing all forms with their includes.有一个D010INC表,其中包含所有包含它们的表单。 The main point here is that all SmartForm FMs start with /1BCDWB/ prefix.这里的要点是所有 SmartForm FM 都以/1BCDWB/前缀开头。

The main logic is in the includes, so we need to find correspondent INCLUDE for the target form.主要逻辑在includes中,所以我们需要为目标表单找到对应的INCLUDE。

  1. Fetch SF include source code获取SF包括源代码

It can be done in a several ways: via CL_RECA_RS_SERVICES class, via table REPOSRC , but the simplest way is ABAP statement READ REPORT .它可以通过多种方式完成:通过CL_RECA_RS_SERVICES类,通过表REPOSRC ,但最简单的方法是 ABAP 语句READ REPORT

  1. Search SO10 text element name in the source code在源代码中搜索SO10文本元素名称
  2. Get Smart Form names for the FMs from hit list.从命中列表中获取 FM 的智能表单名称。 It can be done via STXFADMI table, like in below snippet, but the more correct way is SSF_FUNCTION_MODULE_NAME FM它可以通过STXFADMI表完成,就像下面的代码片段一样,但更正确的方法是SSF_FUNCTION_MODULE_NAME FM
  3. Bingo!答对了!

    Sample solution could look like this:示例解决方案可能如下所示:

     DATA: lt_source TYPE TABLE OF string, lt_smartforms TYPE TABLE OF d010inc, so_text TYPE char50, fs_form TYPE string, used_in TYPE TABLE OF string, len TYPE i. * populating the list of SmartForm FMs SELECT * FROM d010inc AS d INTO TABLE lt_smartforms WHERE master LIKE '/1BCDWB/%' AND include LIKE '/1BCDWB/%'. so_text = '85XX_FOOTER'. " <- our SO10 text element name LOOP AT lt_smartforms ASSIGNING FIELD-SYMBOL(<fs_fm_name>). * reading FM source code READ REPORT <fs_fm_name>-include INTO lt_source. * checking if SO11 exists in source code FIND FIRST OCCURRENCE OF so_text IN TABLE lt_source. IF sy-subrc = 0. len = strlen( <fs_fm_name>-include ) - 7. * searching for SmartForm related to the target FM SELECT SINGLE formname FROM stxfadmi INTO fs_form WHERE fmnumb = <fs_fm_name>-include+len(4). IF sy-subrc = 0. APPEND fs_form TO used_in. ENDIF. ENDIF. ENDLOOP.

Yes, it is junky, not elegant and awkward, but who said it should be so?是的,它是垃圾,不优雅和笨拙,但谁说它应该如此?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM