Learn the Useful Trick to Search “Text” in Smartforms/Text modules. You might dominate the new programming models utilizing Center Information Administrations. You might construct wonderful Fiori and UI5 applications which are smooth, quick and versatile. You may likewise compose SQLScript in your S/4HANA Task. Be that as it may, when an ABAP Software engineer, consistently an ABAP Developer. Clients will continuously have a few bizarre solicitations where you will in any case require your fundamental ABAP Programming abilities, troubleshooting, examining and solutioning sharpness. Useful Trick to Search “Text” in Smartforms/Text modules.
Foundation: As of late we got a necessity to supplant some hard-coded text written in Text Components of Savvy structures. In the SAP framework there were around 350 – 400 custom shrewd structures to find and supplant. Useful Trick to Search “Text” in Smartforms/Text modules!
For e.g: I was looking for text “Secret” in which and all smartforms/textmodule its composed.
Approaches/Attempts:
Approach 1:
In the same way as other, I figured there ought to be a table to hold this information and luckily (from scn local area) tracked down table STXFTXT. Field TDLINE holds brilliant structure content and I had a go at looking.
Results:
presto!! I found what I was searching for. Yet, … ..
The field TDLINE is case touchy. That is to say, you ought to know careful word with accurate capitalized and lower case blend. Any other way you can’t come by right outcomes in this table (I likewise read some place this table isn’t in any way shape or form dependable).
Check, presently I’m looking for all lower case “secret”. It gives different result.
So what next? Plan B
Approach 2:
Plan B was to download savvy structure as XML and look for text. This way you can track down the texts.
Solution Implementation:
There is a capability module called “FB_CONVERT_FORM_TO_XML” which will switch structure over completely to XML by taking Structure name and Structure type as info. This capability module acknowledges Text Module likewise as info, which is Reward.
Presently as each ABAPer does, select all structures, circle on each, get XML, convert XML to String and look through your Adoration/Agony stories strings and show all found structure names in ALV. Isn’t this the ordinary story of all ABAP engineers?
Advantage of this approach:
This search is Case Insensitive. It will search for all cases.
Code Snippet for your Reference
Appended program makes it happen. Go ahead and Attachment and Play . Extravagant word for duplicate glue.
The significant capabilities utilized in this example program are: FB_CONVERT_FORM_TO_XML, SSFH_XSTRINGUTF8_TO_STRING, FB_DISPLAY_FORM, DISPLAY_XML_DOCUMENT . Class utilized is CL_XML_DOCUMENT and strategy PARSE_STRING.
The whole code is likewise at the lower part of this article for your speedy reference.
In Determination screen, we can give Structure name and String for search.
Shows all Structure name/Text Module any place search string exists, with Area of interest tapping on this will open the Savvy structure/Text Module in XML design. Explore to your text component.
Please note: Inactive structures won’t be switched over completely to XML, yet Capability module is sufficiently shrewd to say its inert by raising Exemptions.
Presently the whole Savvy Structure properties are in your control. Do, anything you desire.
This is my most memorable article. Your real input is gladly received. If it’s not too much trouble, help me improve and give you better satisfied.
In the following article I will tell the best way to find (find) definite hub or component where search text lies in the Smartforms. If it’s not too much trouble, remain tuned.
Code Snippet
REPORT zsf_find_text.
*--------------------------------------------------------------------*
* Deferred statement CLASS is used to make the class class known,
* regardless of the location of the actual definition of the class
* in the program
CLASS lcl_event_handeler DEFINITION DEFERRED.
*--------------------------------------------------------------------*
DATA:lv_string TYPE tdsfname.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
SELECT-OPTIONS:s_form FOR lv_string.
PARAMETERS:p_forms TYPE string NO-DISPLAY,
find_dat TYPE string LOWER CASE OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
*--------------------------------------------------------------------*
INITIALIZATION.
s_form-low = 'Z*'.
APPEND s_form.
*--------------------------------------------------------------------*
DATA i_formname TYPE string.
DATA e_xml TYPE xstring.
*--------------------------------------------------------------------*
TYPES:BEGIN OF ty_sf,
formname TYPE tdsfname,
formtype TYPE tdsftype,
status TYPE char8,
e_xml TYPE string,
END OF ty_sf.
DATA:lt_forms TYPE STANDARD TABLE OF ty_sf.
*--------------------------------------------------------------------*
* Class Definition
CLASS lcl_event_handeler DEFINITION.
PUBLIC SECTION.
* Hotspot Handling
METHODS: handle_hotspot FOR EVENT link_click OF cl_salv_events_table
IMPORTING
row
column .
ENDCLASS.
*--------------------------------------------------------------------*
* Class Implementation
CLASS lcl_event_handeler IMPLEMENTATION.
* Handling Hotspot Click
METHOD handle_hotspot.
READ TABLE lt_forms INTO DATA(ls_forms) INDEX row.
IF sy-subrc = 0.
IF column = 'E_XML'.
DATA: gcl_xml TYPE REF TO cl_xml_document.
CREATE OBJECT gcl_xml.
*Parses XML String to DOM
CALL METHOD gcl_xml->parse_string
EXPORTING
stream = ls_forms-e_xml.
*Display XML
CALL METHOD gcl_xml->display.
ELSE.
CALL FUNCTION 'FB_DISPLAY_FORM'
EXPORTING
i_formname = ls_forms-formname
i_formtype = ls_forms-formtype
i_with_dialog = abap_false
EXCEPTIONS
no_name = 1
no_form = 2
no_access_permission = 3
illegal_language = 4
illegal_formtype = 5
OTHERS = 6.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDIF.
ENDIF.
ENDMETHOD.
ENDCLASS.
*--------------------------------------------------------------------*
START-OF-SELECTION.
SELECT formname formtype FROM stxfadm INTO TABLE lt_forms
WHERE formname IN s_form .
*--------------------------------------------------------------------*
LOOP AT lt_forms ASSIGNING FIELD-SYMBOL(<ls_forms>).
DATA(lv_tabix) = sy-tabix.
p_forms = <ls_forms>-formname.
* Convert to XML
CALL FUNCTION 'FB_CONVERT_FORM_TO_XML'
EXPORTING
i_formname = p_forms
IMPORTING
e_xml = e_xml
EXCEPTIONS
no_active_source = 3.
IF sy-subrc <> 0.
<ls_forms>-status = 'Inactive'.
CONTINUE.
ENDIF.
DATA ostr_output_data TYPE xstring.
DATA codepage TYPE cpcodepage.
DATA cstr_output_data TYPE string.
* Convert XML to String
CALL FUNCTION 'SSFH_XSTRINGUTF8_TO_STRING'
EXPORTING
ostr_output_data = e_xml
IMPORTING
cstr_output_data = <ls_forms>-e_xml
EXCEPTIONS
conversion_error = 1
internal_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
CONTINUE.
ENDIF.
* SEARCH Command
SEARCH <ls_forms>-e_xml FOR find_dat AND MARK.
IF sy-subrc NE 0.
DELETE lt_forms INDEX lv_tabix.
ENDIF.
ENDLOOP.
*--------------------------------------------------------------------*
DATA: o_alv TYPE REF TO cl_salv_table.
DATA: lx_msg TYPE REF TO cx_salv_msg.
DATA: lr_columns TYPE REF TO cl_salv_columns,
lr_column TYPE REF TO cl_salv_column_table,
lr_colums TYPE REF TO cl_salv_columns_table,
lr_display TYPE REF TO cl_salv_display_settings,
title TYPE lvc_title.
*--------------------------------------------------------------------*
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = o_alv
CHANGING
t_table = lt_forms ).
CATCH cx_salv_msg INTO lx_msg.
ENDTRY.
*--------------------------------------------------------------------*
lr_display = o_alv->get_display_settings( ).
title = 'Search Results for Text:'(001) && | " | && find_dat && | " |.
lr_display->set_list_header( title ).
lr_display->set_striped_pattern( if_salv_c_bool_sap=>true ).
lr_columns = o_alv->get_columns( ).
lr_columns->set_optimize( abap_true ).
DATA(gr_functions) = o_alv->get_functions( ).
gr_functions->set_all( abap_true ).
lr_colums = o_alv->get_columns( ).
lr_column ?= lr_colums->get_column( 'FORMNAME' ).
lr_column->set_cell_type( if_salv_c_cell_type=>hotspot ).
lr_column ?= lr_colums->get_column( 'STATUS' ).
lr_column->set_long_text( 'Status' ).
lr_column->set_short_text( 'Status' ).
lr_column->set_medium_text( 'Status' ).
lr_column ?= lr_colums->get_column( 'FORMTYPE' ).
lr_column->set_visible( if_salv_c_bool_sap=>false ).
lr_column ?= lr_colums->get_column( 'E_XML' ).
lr_column->set_cell_type( if_salv_c_cell_type=>hotspot ).
*--------------------------------------------------------------------*
DATA:co_report TYPE REF TO lcl_event_handeler.
DATA: lo_events TYPE REF TO cl_salv_events_table.
CREATE OBJECT co_report.
* All events
lo_events = o_alv->get_event( ).
*
* Event handler
SET HANDLER co_report->handle_hotspot FOR lo_events.
o_alv->display( ).
*--------------------------------------------------------------------*
YOU MAY LIKE THIS
ABAP on SAP HANA. Part III. Debugging in ADT
Building Cloud-Native ABAP Applications: A Guide to Modern SAP Development