问题
I need to track down where within a large number of custom sapscripts and smartforms a specific standard text (SO10) is being used.
Apart from the equivalent of "check the code for each print script", I've not found a workable solution online. Any suggestions?
回答1:
After posting, I found a partial solution. The code below will search for a standard text within sapscripts, but not 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
回答2:
What concerns SmartForms, you cannot. 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. 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.
So the only workaround here is to analyze the code.
- Find all FMs for existing Smart Forms in system
There is a D010INC
table containing all forms with their includes. The main point here is that all SmartForm FMs start with /1BCDWB/
prefix.
The main logic is in the includes, so we need to find correspondent INCLUDE for the target form.
- Fetch SF include source code
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
.
- Search
SO10
text element name in the source code - Get Smart Form names for the FMs from hit list. It can be done via
STXFADMI
table, like in below snippet, but the more correct way isSSF_FUNCTION_MODULE_NAME
FM 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?
来源:https://stackoverflow.com/questions/34268377/how-to-find-a-standard-text-within-a-sapscript-smartform