Skip to Content
Author's profile photo Eitan Rosenberg

Basic Smart form “source” scan

Hi,

 

Some times there is a need to do a source scan of smart forms .

 

The recent needs that triggers this blog entry is here: How to remove hardcoded values in smartforms

 

Program Y_R_EITAN_TEST_31_08 (attached) is my attempt .

 

The program goes through the selected smart forms based on table stxfadm ,

 

For each form it extract xml document representing the form .

 

The XML document is iterated and each node is checked against the selection screen parameters.

 

The filtered nodes are presented using cl_salv_table .

 

(I did said it is basic…. 😉 )

 

/wp-content/uploads/2014/09/screenshot_01_535445.png

 

/wp-content/uploads/2014/09/screenshot_02_535446.png

 

Enjoy.

 

Update 2014/09/10

 

This morning (While shaving…) I got an idea that might help a little .

 

Since if_ixml_node has get_parent() I can get them all .

 

I want to know where are the styles used ?

 

The source was updated .

 

/wp-content/uploads/2014/09/screenshot_01_535445.png

 

/wp-content/uploads/2014/09/screenshot_02_535446.png

Assigned Tags

      14 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Thanks for your help.

      I will check and let you know the results.

      Regards,

      Ravi Shankar.L

      Author's profile photo Former Member
      Former Member

      Hi,

      I want the name of the standard include alone that is used in the smartforms.

      Can you please share that how to acheive this.

      Thanks in advance for your help.

      Retgards,

      Ravi Shankar.L

      Author's profile photo Eitan Rosenberg
      Eitan Rosenberg
      Blog Post Author

      Hi,

      "name of the standard include" I do not understand what you mean .

      Example please .(Screen shots)

      Regards.

      Author's profile photo Former Member
      Former Member

      Hi,

      Generally  if we create text in smart form,We are allowed to choose type of the text,

      1. Include Text

      2.Text Element

      3.Text Module

      4.Dynamic Text,

      I that I need to find out what all are the texts created with Include text addition to that need  window and node details of it.

      In Some cases Include text name will be determined in the program and passed by

      &STXH-CTDNAME& /wp-content/uploads/2014/09/1_536715.png

      /wp-content/uploads/2014/09/1_536715.png

      Author's profile photo Former Member
      Former Member

      Only need the full details about include text creation.

      Your program works fine for text elements.

      But it not adding additional information like window name,Node and page number.

      Thanks for understanding.

      Regards,

      Ravi Shankar.L

      Author's profile photo Eitan Rosenberg
      Eitan Rosenberg
      Blog Post Author

      Hi,

      If you use the program without any filter do you see your Include Texts ?

      I am afraid that I do not have the time to do any more work on this program .

      It is basic but feel free to modify it to your needs.

      Regards.

      Author's profile photo Former Member
      Former Member

      Ok than I will check and modify the code once I got the result I keep you update.

      Thanks for your kind support. 🙂

      Regards,

      Ravi Shankar.L

      Author's profile photo Eitan Rosenberg
      Eitan Rosenberg
      Blog Post Author

      Hi,

      Ravi Shankar

      See update.

      Author's profile photo Former Member
      Former Member

      Hi,

      Please have a look into the post Search Hard Codes In Smart Form And Smart Styles Used In The Form.

      Thanks for your great help.

      Regards,

      Ravi Shankar.L

      Author's profile photo Jānis B
      Jānis B

      Excellent stuff, thank you very much Eitan!

      In this particular case I'd have found Forms I was looking for due to generation errors in mass generation, but your program was faster and it works for text modules as well! 🙂

      Author's profile photo Eitan Rosenberg
      Eitan Rosenberg
      Blog Post Author

      Hi,

      You are most welcome !!

      You remember that The case of sending mail with graphs .  is your brain child so I guess we are even now  🙂

      Have a nice weekend.

      Regards.

      Author's profile photo Former Member
      Former Member

      Hello Eitan,

      Attachment is missing in this blog, can you please add it for further reference.

      Thanks.

       

      Regards,

      Sampath

      Author's profile photo Former Member
      Former Member

      HI Eitan,

      Attachment is missing. Can you please add it for my reference ?

      Author's profile photo Eitan Rosenberg
      Eitan Rosenberg
      Blog Post Author

      Hi,

      Some code:

      REPORT y_r_eitan_test_31_08 .

      TYPE-POOLS: abap .
      TABLES: ssfscreen .

      DATA: text255 TYPE text255 .

      *----------------------------------------------------------------------*
      TYPES: BEGIN OF tp_tech_1 .
      TYPES: it_styl TYPE salv_t_int4_column .
      TYPES: END OF tp_tech_1 .
      *----------------------------------------------------------------------*
      TYPES: BEGIN OF tp_stxf_1 .
      TYPES: formname TYPE stxfadm-formname .
      TYPES: END OF tp_stxf_1 .
      *----------------------------------------------------------------------*
      TYPES: BEGIN OF tp_node_1 .
      TYPES: name TYPE ssfscreen-iname ,
      value TYPE text255 .
      TYPES: ob_ixml_node TYPE REF TO if_ixml_node .
      TYPES: END OF tp_node_1 .
      *----------------------------------------------------------------------*
      TYPES: BEGIN OF tp_alv_data_1 .
      INCLUDE TYPE tp_tech_1 AS tech_1 RENAMING WITH SUFFIX _tech_1 .
      INCLUDE TYPE tp_stxf_1 AS stxf_1 RENAMING WITH SUFFIX _stxf_1 .
      INCLUDE TYPE tp_node_1 AS node_1 RENAMING WITH SUFFIX _node_1 .
      TYPES: END OF tp_alv_data_1 .

      TYPES: tp_alv_data_1_tab TYPE TABLE OF tp_alv_data_1 .

      DATA: it_alv_data_1 TYPE tp_alv_data_1_tab .

      *----------------------------------------------------------------------*
      TYPES: BEGIN OF tp_alv_data_2 .
      INCLUDE TYPE tp_node_1 AS node_1 RENAMING WITH SUFFIX _node_1 .
      TYPES: END OF tp_alv_data_2 .

      TYPES: tp_alv_data_2_tab TYPE TABLE OF tp_alv_data_2 .

      *----------------------------------------------------------------------*
      *----------------------------------------------------------------------*
      CLASS cl_event_receiver DEFINITION .

      PUBLIC SECTION.

      METHODS: link_click FOR EVENT link_click OF cl_salv_events_table
      IMPORTING row column.

      PRIVATE SECTION.

      METHODS: show_parents
      IMPORTING ob_ixml_node_1 TYPE REF TO if_ixml_node .

      METHODS: popup
      IMPORTING
      start_line TYPE i DEFAULT 2
      end_line TYPE i DEFAULT 15
      start_column TYPE i DEFAULT 25
      end_column TYPE i DEFAULT 150
      value(t_table) TYPE table .

      ENDCLASS . "cl_event_receiver DEFINITION
      *----------------------------------------------------------------------*
      *----------------------------------------------------------------------*
      CLASS cl_event_receiver IMPLEMENTATION.
      *----------------------------------------------------------------------*
      METHOD: link_click .

      FIELD-SYMBOLS: <st_alv_data_1> TYPE tp_alv_data_1 .
      FIELD-SYMBOLS: <cell> TYPE ANY .

      READ TABLE it_alv_data_1 INDEX row ASSIGNING <st_alv_data_1> .

      ASSIGN COMPONENT column OF STRUCTURE <st_alv_data_1> TO <cell> .

      CASE column .
      WHEN 'NAME_NODE_1' .
      me->show_parents( <st_alv_data_1>-node_1-ob_ixml_node ) .
      ENDCASE .

      ENDMETHOD . "on_link_click
      *----------------------------------------------------------------------*
      METHOD: show_parents .

      DATA: ob_ixml_node_t TYPE REF TO if_ixml_node .

      ob_ixml_node_t = ob_ixml_node_1->get_parent( ) .

      DATA: it_alv_data_2 TYPE tp_alv_data_2_tab .
      DATA: st_alv_data_2 LIKE LINE OF it_alv_data_2 .

      WHILE ob_ixml_node_t IS NOT INITIAL .

      st_alv_data_2-node_1-name = ob_ixml_node_t->get_name( ) .
      st_alv_data_2-node_1-value = ob_ixml_node_t->get_value( ) .

      APPEND st_alv_data_2 TO it_alv_data_2 .

      ob_ixml_node_t = ob_ixml_node_t->get_parent( ) .

      ENDWHILE .

      me->popup( EXPORTING t_table = it_alv_data_2 ) .

      ENDMETHOD . "show_parents
      *----------------------------------------------------------------------*
      METHOD: popup .

      IF t_table IS INITIAL .
      MESSAGE s801(dh).
      RETURN .
      ENDIF .

      DATA: ob_salv_table TYPE REF TO cl_salv_table.

      TRY.
      cl_salv_table=>factory(
      IMPORTING
      r_salv_table = ob_salv_table
      CHANGING
      t_table = t_table ).

      CATCH cx_salv_msg.
      ENDTRY.

      CHECK ob_salv_table IS BOUND.

      ob_salv_table->set_screen_popup(
      start_column = start_column
      end_column = end_column
      start_line = start_line
      end_line = end_line ).

      ob_salv_table->display( ) .

      ENDMETHOD . "popup
      *----------------------------------------------------------------------*
      ENDCLASS . "cl_event_receiver IMPLEMENTATION
      *----------------------------------------------------------------------*
      *----------------------------------------------------------------------*

      SELECTION-SCREEN BEGIN OF BLOCK block04 WITH FRAME.

      SELECT-OPTIONS: s_fname FOR ssfscreen-fname NO INTERVALS OBLIGATORY .
      SELECT-OPTIONS: s_devcl FOR ssfscreen-devclass NO INTERVALS .

      SELECTION-SCREEN SKIP .

      SELECT-OPTIONS: s_name FOR ssfscreen-iname .
      SELECT-OPTIONS: s_value FOR text255 NO INTERVALS.

      SELECTION-SCREEN END OF BLOCK block04.
      *----------------------------------------------------------------------*
      *----------------------------------------------------------------------*

      INITIALIZATION .
      PERFORM at_initialization .

      START-OF-SELECTION.
      PERFORM at_start_of_selection .

      *----------------------------------------------------------------------*
      *----------------------------------------------------------------------*
      FORM at_initialization .

      * APPEND 'IEQSF_EXAMPLE_01' TO s_fname .
      * APPEND 'IEQSF_EXAMPLE_02' TO s_fname .
      APPEND 'IEQSF_EXAMPLE_03' TO s_fname .

      APPEND 'IEQSTDSTYLE' TO s_name .

      DATA: it_seltexts TYPE TABLE OF rsseltexts .
      DATA: st_seltexts LIKE LINE OF it_seltexts .

      st_seltexts-name = 'S_NAME' .
      st_seltexts-kind = 'S' .
      st_seltexts-text = 'Node name' .
      APPEND st_seltexts TO it_seltexts .

      st_seltexts-name = 'S_VALUE' .
      st_seltexts-kind = 'S' .
      st_seltexts-text = 'Node value' .
      APPEND st_seltexts TO it_seltexts .

      CALL FUNCTION 'SELECTION_TEXTS_MODIFY'
      EXPORTING
      program = sy-cprog
      TABLES
      seltexts = it_seltexts
      EXCEPTIONS
      program_not_found = 1
      program_cannot_be_generated = 2
      OTHERS = 3.

      ENDFORM . "at_initialization
      *----------------------------------------------------------------------*
      FORM at_start_of_selection .

      CLEAR it_alv_data_1 .

      DATA: it_stxfadm TYPE TABLE OF stxfadm .

      SELECT * INTO TABLE it_stxfadm
      FROM stxfadm
      WHERE
      formname IN s_fname AND
      devclass IN s_devcl.

      FIELD-SYMBOLS: <st_stxfadm> LIKE LINE OF it_stxfadm .

      LOOP AT it_stxfadm ASSIGNING <st_stxfadm> .

      PERFORM scan_form
      USING
      <st_stxfadm>
      CHANGING
      it_alv_data_1 .

      ENDLOOP.

      PERFORM display_results
      CHANGING
      it_alv_data_1 .

      ENDFORM . "at_start_of_selection
      *----------------------------------------------------------------------*
      FORM scan_form
      USING
      st_stxfadm TYPE stxfadm
      CHANGING
      it_alv_data_1 TYPE tp_alv_data_1_tab .

      DATA: ob_smart_form TYPE REF TO cl_ssf_fb_smart_form .

      CREATE OBJECT ob_smart_form .

      CALL METHOD ob_smart_form->load
      EXPORTING
      im_active = space
      im_formname = st_stxfadm-formname
      im_language = 'E'.

      DATA: ob_ixml TYPE REF TO if_ixml .
      DATA: ob_ixml_document TYPE REF TO if_ixml_document .

      ob_ixml = cl_ixml=>create( ).
      ob_ixml_document = ob_ixml->create_document( ) .

      ob_smart_form->xml_init( ) .

      CALL METHOD ob_smart_form->xml_download
      EXPORTING
      parent = ob_ixml_document
      CHANGING
      document = ob_ixml_document.

      * DATA: ob_ixml_stream_factory TYPE REF TO if_ixml_stream_factory.
      * DATA: ob_ostream TYPE REF TO if_ixml_ostream .

      * DATA: debug TYPE string.
      *
      * ob_ixml_stream_factory = ob_ixml->create_stream_factory( ).
      * ob_ostream = ob_ixml_stream_factory->create_ostream_cstring( debug ).
      * ob_ixml_document->render( ostream = ob_ostream ) .

      DATA: ob_ixml_node TYPE REF TO if_ixml_node .

      ob_ixml_node = ob_ixml_document .

      DATA: ob_ixml_node_iterator TYPE REF TO if_ixml_node_iterator .

      ob_ixml_node_iterator = ob_ixml_node->create_iterator( ) .

      DATA: st_alv_data_1 LIKE LINE OF it_alv_data_1 .
      DATA: st_styl LIKE LINE OF st_alv_data_1-tech_1-it_styl .

      WHILE NOT ob_ixml_node IS INITIAL .

      CLEAR st_alv_data_1 .

      st_alv_data_1-stxf_1-formname = st_stxfadm-formname .

      st_alv_data_1-node_1-ob_ixml_node = ob_ixml_node .

      st_alv_data_1-node_1-name = ob_ixml_node->get_name( ) .

      IF st_alv_data_1-node_1-name NOT IN s_name .
      ob_ixml_node = ob_ixml_node_iterator->get_next( ).
      CONTINUE .
      ENDIF .

      st_alv_data_1-node_1-value = ob_ixml_node->get_value( ) .

      IF st_alv_data_1-node_1-value NOT IN s_value .
      ob_ixml_node = ob_ixml_node_iterator->get_next( ).
      CONTINUE .
      ENDIF .

      APPEND st_alv_data_1 TO it_alv_data_1 .

      ob_ixml_node = ob_ixml_node_iterator->get_next( ).

      ENDWHILE .

      ENDFORM. "scan_form
      *----------------------------------------------------------------------*
      FORM display_results
      CHANGING
      t_table TYPE table .

      DATA: ob_salv_table TYPE REF TO cl_salv_table .

      TRY.
      cl_salv_table=>factory(
      IMPORTING
      r_salv_table = ob_salv_table
      CHANGING
      t_table = t_table ).
      CATCH cx_salv_msg.
      ENDTRY.

      DATA: ob_salv_functions_list TYPE REF TO cl_salv_functions_list.

      ob_salv_functions_list = ob_salv_table->get_functions( ).
      ob_salv_functions_list->set_default( ) .

      DATA: st_fcat TYPE lvc_s_fcat .

      DATA: ob_salv_columns TYPE REF TO cl_salv_columns_table .

      ob_salv_columns = ob_salv_table->get_columns( ) .

      ob_salv_columns->set_cell_type_column( 'IT_STYL_TECH_1' ) .

      DATA: it_column_ref TYPE salv_t_column_ref .
      FIELD-SYMBOLS: <st_column_ref> LIKE LINE OF it_column_ref .

      it_column_ref = ob_salv_columns->get( ) .

      DATA: ob_salv_column TYPE REF TO cl_salv_column_table .

      LOOP AT it_column_ref ASSIGNING <st_column_ref> .

      CASE <st_column_ref>-columnname .
      WHEN 'NAME_NODE_1' .
      st_fcat-scrtext_s = st_fcat-scrtext_m = st_fcat-scrtext_l = 'Node Name'(011) .
      <st_column_ref>-r_column->set_short_text( value = st_fcat-scrtext_s ) .
      <st_column_ref>-r_column->set_medium_text( value = st_fcat-scrtext_m ) .
      <st_column_ref>-r_column->set_long_text( value = st_fcat-scrtext_l ) .

      ob_salv_column ?= ob_salv_columns->get_column( <st_column_ref>-columnname ) .
      ob_salv_column->set_cell_type( if_salv_c_cell_type=>hotspot ).

      WHEN 'VALUE_NODE_1' .
      st_fcat-scrtext_s = st_fcat-scrtext_m = st_fcat-scrtext_l = 'Node Value'(012) .
      <st_column_ref>-r_column->set_short_text( value = st_fcat-scrtext_s ) .
      <st_column_ref>-r_column->set_medium_text( value = st_fcat-scrtext_m ) .
      <st_column_ref>-r_column->set_long_text( value = st_fcat-scrtext_l ) .
      ENDCASE.

      ENDLOOP .

      DATA: ob_salv_events TYPE REF TO cl_salv_events_table.
      DATA: ob_event_receiver TYPE REF TO cl_event_receiver .

      ob_salv_events = ob_salv_table->get_event( ).

      CREATE OBJECT ob_event_receiver .

      SET HANDLER ob_event_receiver->link_click FOR ob_salv_events .

      ob_salv_table->display( ).

      ENDFORM. "display_results