CRM and CX Blog Posts by SAP
Stay up-to-date on the latest developments and product news about intelligent customer experience and CRM technologies through blog posts from SAP experts.
cancel
Showing results for 
Search instead for 
Did you mean: 
JerryWang
Product and Topic Expert
Product and Topic Expert
0 Kudos
1,041
Today I was assigned with a task to generate a list of all request objects used in each WHEN statement in include LCRM_ORDER_OWF03.




Since this include has 608 lines and I am too lazy to populate the list manually, I decide to write a report to create the list.

The basic idea is to use keyword SCAN ABAP-SOURCE to split the include source code into tokens, and I only care about the tokens which come directly after "WHEN". Once all such words are extracted, I export the list into clipboard with markdown format, so that I can just press ctrl+c in markdown editor and send the result to my colleague.

Here is the report:


REPORT zread_report.
INCLUDE: crm_object_names_con.

TYPES:
BEGIN OF ty_clipdata,
data TYPE c LENGTH 100,
END OF ty_clipdata .
TYPES:
tt_formatted TYPE STANDARD TABLE OF ty_clipdata .

DATA: lt_source TYPE string_table,
lv_ret TYPE int4,
lt_token TYPE TABLE OF stokes,
lt_statement TYPE TABLE OF sstmnt,
lt_export TYPE tt_formatted.

CONSTANTS: gc_variable TYPE char20 VALUE 'Variable',
gc_value TYPE char20 VALUE 'Value'.
READ REPORT 'LCRM_ORDER_OWF03' INTO lt_source .

SCAN ABAP-SOURCE lt_source TOKENS INTO lt_token
STATEMENTS INTO lt_statement.

WRITE: 10 gc_variable COLOR COL_NEGATIVE, 40 gc_value COLOR COL_POSITIVE.

APPEND |{ gc_variable } \| { gc_value } | TO lt_export.
APPEND '-----|-----' TO lt_export.
LOOP AT lt_token ASSIGNING FIELD-SYMBOL(<when>) WHERE str = 'WHEN'.
DATA(lv_name) = lt_token[ sy-tabix + 1 ]-str.
ASSIGN (lv_name) TO FIELD-SYMBOL(<name>).
WRITE:/ lv_name UNDER gc_variable, <name> UNDER gc_value.
APPEND |{ lv_name } \| { <name> }| TO lt_export.
ENDLOOP.

cl_gui_frontend_services=>clipboard_export(
EXPORTING
no_auth_check = abap_true
IMPORTING
data = lt_export
CHANGING
rc = lv_ret
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
).

Here is report output:



And then I go to a markdown editor for example github issue:



And here is the final generated list:





2 Comments