SMARTFORM X-System Comparer

Nützliche Abap Codes und Code Fragmente

SMARTFORM X-System Comparer

Postby Tron » Tue Mar 08, 2022 11:36 am

Moin.
Auf der Suche nach einer geeigneten Möglichkeit Smartform Formularversionen über die Systemgrenzen hinaus zu vergleichen, bin ich leider nirgends fündig geworden.
Der Bedarf an einem solchen Tools scheint mir jedoch sehr groß zu sein , deshalb .....

smart3.png
smart3.png (30.82 KiB) Viewed 270 times


smart2.png
smart2.png (16.92 KiB) Viewed 272 times


Der Smartformvergleicher besteht aus:
1.) einem RFC-fähigen Funktionsbaustein der eine Smartform Formular Definition als XML einliest und
via Tabellenparameter über die Schnittstelle bereitstellt. Dieser Funktionsbaustein sollte in alle verbundenen Systeme transportiert werden.

2.) Einem Report, welcher die Definitionen vergleicht (was einfacher klingt, als es ist.)
Wenn man genau wissen möchte was unterschiedlich ist, kann man die Ergebnistabelle (lt_xx) des Bausteins RS_CMP_COMPUTE_DELTA auf einem ALV ausgeben.
Die Differenzen sind gekennzeichnet (oder was er dafür hält) . Alle Tags eines Smartform formulars, welche generell unterschiedlich sind, wie FORMNAME LASTDATE ..
werden über ein Range Objekt abgefangen, da sonst jeder Vergleich zu Differenzen führen würde. (Also falls noch jemand etwas entdecken sollte...)
Mein Tipp wäre hier noch, die Liste ab der Differenz, Richtung Anfang zu gehen, bis zum Element INAME , das Element kann man dann in Smartforms suchen ! :wink:
Der Vergleich reagiert auf Übersetzungen und funktioniert sogar mit nicht aktivierten Formularen.
Der Report kann im Entwicklungssystem bleiben, solange man nicht von den angeschlossenen Systemen aus vergleichen möchte.

Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
  1. *&---------------------------------------------------------------------*
  2. *& Report  ZTEST_SF_COMP_ALV
  3. *&
  4. *&---------------------------------------------------------------------*
  5. *&
  6. *&
  7. *&---------------------------------------------------------------------*
  8. REPORT ztest_sf_comp_alv.
  9. TABLES: sscrfields.
  10.  
  11. TYPE-POOLS:ctslg,icon,slis.
  12.  
  13. CONSTANTS indx_id TYPE indx_srtfd VALUE 'RSEDCRESUL'.
  14.  
  15. TYPES: BEGIN OF ty_output,
  16.          line1  TYPE eddispline,
  17.          line2  TYPE  eddispline,
  18.          text1  TYPE  rsline,
  19.          text2  TYPE  rsline,
  20.          flag1  TYPE sedflgdelt,
  21.          flag2  TYPE  sedflgdelt,
  22.          iname1 TYPE rsline,
  23.          iname2 TYPE rsline,
  24.        END OF ty_output.
  25.  
  26.  
  27. TYPES : t_tr TYPE TABLE OF rsedcresul.
  28.  
  29. * Grid Parameter
  30. DATA: ok_code            LIKE sy-ucomm,
  31.       g_container        TYPE scrfname VALUE 'GRID1',
  32.       grid1              TYPE REF TO cl_gui_alv_grid,
  33.       g_custom_container TYPE REF TO cl_gui_custom_container,
  34.       g_dock_container   TYPE REF TO cl_gui_docking_container,
  35.       is_variant         TYPE disvariant.
  36. *--- Field catalog table
  37. DATA gt_fieldcat TYPE lvc_t_fcat WITH HEADER LINE.
  38. *--- Layout structure
  39. DATA gs_layout TYPE lvc_s_layo .
  40.  
  41. * LT_EXCLUDE => Tabelle zum Ausschliessen von Funktionen innerhalb
  42. * der Toolbar des ALV-Grid
  43. DATA: lt_exclude TYPE ui_functions,
  44.       ls_exclude TYPE ui_func.
  45.  
  46. DATA it_data TYPE TABLE OF ty_output .
  47. DATA gv_title(80) VALUE 'Comparing..'.
  48. *---------------------------------------------------------------------*
  49. *       CLASS lcl_event_handler DEFINITION
  50. *---------------------------------------------------------------------*
  51. *
  52. *---------------------------------------------------------------------*
  53. CLASS lcl_event_handler DEFINITION .
  54.   PUBLIC SECTION .
  55.     METHODS:
  56. *--To add new functional buttons to the ALV toolbar
  57.       handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
  58.         IMPORTING e_object e_interactive ,
  59.  
  60. *--To implement user commands
  61.       handle_user_command
  62.                     FOR EVENT user_command OF cl_gui_alv_grid
  63.         IMPORTING e_ucomm .
  64.  
  65.  
  66.   PRIVATE SECTION.
  67. ENDCLASS.                    "lcl_event_handler DEFINITION
  68.  
  69.  
  70.  
  71. *---------------------------------------------------------------------*
  72. *       CLASS lcl_event_handler IMPLEMENTATION
  73. *---------------------------------------------------------------------*
  74. *
  75. *---------------------------------------------------------------------*
  76. CLASS lcl_event_handler IMPLEMENTATION .
  77.  
  78. *--Handle Toolbar
  79.   METHOD handle_toolbar.
  80.     PERFORM handle_toolbar USING e_object e_interactive .
  81.   ENDMETHOD .                    "handle_toolbar
  82.  
  83. *--Handle User Command
  84.   METHOD handle_user_command .
  85.     PERFORM handle_user_command USING e_ucomm .
  86.   ENDMETHOD.                    "handle_user_command
  87.  
  88.  
  89. ENDCLASS.                    "lcl_event_handler IMPLEMENTATION
  90.  
  91. DATA gr_event_handler TYPE REF TO lcl_event_handler .
  92.  
  93. * Info Destinationen
  94. DATA: des1_info TYPE rfcsi,
  95.       des2_info TYPE rfcsi.
  96. *DATA lv_mandt1(3).
  97. *DATA lv_mandt2(3).
  98.  
  99. DATA rt_exc TYPE smum_xmltb-cname.
  100. RANGES gr_excl FOR rt_exc.
  101.  
  102.  
  103.  
  104.     p_form1 TYPE tdsfname OBLIGATORY MATCHCODE OBJECT sh_stxfadm,
  105.     p_form2 TYPE tdsfname OBLIGATORY MATCHCODE OBJECT sh_stxfadm.
  106.  
  107.   SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-001.
  108.   PARAMETERS p_des1 TYPE rfcdes-rfcdest OBLIGATORY DEFAULT 'NONE'.
  109.   SELECTION-SCREEN END OF BLOCK b.
  110.  
  111.   SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-002.
  112.   PARAMETERS p_des2 TYPE rfcdes-rfcdest OBLIGATORY DEFAULT 'NONE'.
  113.   SELECTION-SCREEN END OF BLOCK a.
  114.  
  115.  
  116.   PERFORM check_avail.
  117.   IF des1_info IS INITIAL.
  118.     MESSAGE s368(00) DISPLAY LIKE 'E' WITH p_des1 ':RFC-Destination not reachable.' .
  119.    return.
  120.   ENDIF.
  121.  
  122.   IF des2_info IS INITIAL.
  123.     MESSAGE s368(00) DISPLAY LIKE 'E' WITH p_des2 ':RFC-Destination not reachable.' .
  124.     return.
  125.   ENDIF.
  126.  
  127.   PERFORM fill_exclude_range.
  128.  
  129.  
  130.   PERFORM compare_sf.
  131. *&---------------------------------------------------------------------*
  132. *&      Form  Check_avail
  133. *&---------------------------------------------------------------------*
  134. *       text
  135. *----------------------------------------------------------------------*
  136. *      -->DEST       text
  137. *----------------------------------------------------------------------*
  138. FORM check_avail.
  139.   DATA:
  140. "  info LIKE rfcsi,
  141.   msg_text(80) TYPE c. "Message text
  142.  
  143.   CALL FUNCTION 'RFC_SYSTEM_INFO'
  144.     DESTINATION p_des1
  145.     IMPORTING
  146.       rfcsi_export          = des1_info
  147.     EXCEPTIONS
  148.       communication_failure = 1 MESSAGE msg_text
  149.       system_failure        = 2 MESSAGE msg_text.
  150.  
  151.   CALL FUNCTION 'RFC_SYSTEM_INFO'
  152.     DESTINATION p_des2
  153.     IMPORTING
  154.       rfcsi_export          = des2_info
  155.     EXCEPTIONS
  156.       communication_failure = 1 MESSAGE msg_text
  157.       system_failure        = 2 MESSAGE msg_text.
  158.  
  159. ENDFORM.                    "Check_avail
  160. *&---------------------------------------------------------------------*
  161. *&      Form  write_for_display
  162. *&---------------------------------------------------------------------*
  163. *       text
  164. *----------------------------------------------------------------------*
  165. FORM write_for_display.
  166.   DATA: t1(80),t2(80).
  167.   DATA: info         LIKE rfcsi,
  168.         msg_text(80) TYPE c. "Message text
  169.  
  170.   FORMAT COLOR COL_HEADING.
  171.   WRITE: / '*** STATUS RFC-connectivity ***' , AT sy-linsz space.
  172.   ULINE.
  173.   FORMAT COLOR OFF.
  174.  
  175.   CLEAR msg_text.
  176.   CALL FUNCTION 'RFC_PING'
  177.     DESTINATION p_des2
  178.     EXCEPTIONS
  179.       communication_failure = 1 MESSAGE msg_text
  180.       system_failure        = 2 MESSAGE msg_text.
  181.  
  182.  
  183.   t1 = p_des2.
  184.   CONDENSE t1.
  185.  
  186.   IF msg_text IS INITIAL.
  187.     CONCATENATE 'Destination :' t1 'reachable.' INTO t2 SEPARATED BY space.
  188.     FORMAT INTENSIFIED OFF.
  189.  
  190.     WRITE: / icon_led_green AS ICON,
  191.                 t2 COLOR COL_POSITIVE.
  192.  
  193.   ELSE.
  194.     CONCATENATE 'Destination :' t1 'not reachable.' INTO t2 SEPARATED BY space.
  195.     FORMAT INTENSIFIED OFF.
  196.  
  197.     WRITE: /      icon_led_red AS ICON,
  198.                   t2 COLOR COL_NEGATIVE.
  199.  
  200.   ENDIF.
  201.  
  202.   CLEAR msg_text.
  203.   CALL FUNCTION 'RFC_PING'
  204.     DESTINATION p_des1
  205.     EXCEPTIONS
  206.       communication_failure = 1 MESSAGE msg_text
  207.       system_failure        = 2 MESSAGE msg_text.
  208.  
  209.  
  210.   t1 = p_des1.
  211.   CONDENSE t1.
  212.  
  213.   IF msg_text IS INITIAL.
  214.     CONCATENATE 'Destination :' t1 'reachable.' INTO t2 SEPARATED BY space.
  215.     FORMAT INTENSIFIED OFF.
  216.  
  217.     WRITE: / icon_led_green AS ICON,
  218.                 t2 COLOR COL_POSITIVE.
  219.  
  220.   ELSE.
  221.     CONCATENATE 'Destination :' t1 'not reachable.' INTO t2 SEPARATED BY space.
  222.     FORMAT INTENSIFIED OFF.
  223.  
  224.     WRITE: /      icon_led_red AS ICON,
  225.                   t2 COLOR COL_NEGATIVE.
  226.  
  227.   ENDIF.
  228.  
  229. ENDFORM.                    "write_for_display
  230.  
  231. AT SELECTION-SCREEN.
  232.   IF sy-ucomm = 'FC01'." n = 1 up to 5
  233. * Teste Erreichbarkeit
  234.  
  235.     PERFORM write_for_display.
  236.  
  237.     CALL FUNCTION 'C14A_POPUP_LIST_DISPLAY'
  238.       EXPORTING
  239.         i_callback            = 'WRITE_FOR_DISPLAY'
  240.         i_callback_program    = sy-repid
  241.         i_title               = 'RFC-connections'
  242.         i_col                 = 4
  243.         i_row                 = 4
  244.         i_width               = 84
  245.         i_height              = 10
  246. *       I_TEXT_WIDTH          =
  247. *       I_FLG_SHOW_PRINT_BUTTON = ESP1_FALSE
  248.       EXCEPTIONS
  249.         no_callback_specified = 1
  250.         OTHERS                = 2.
  251.  
  252.     IF sy-subrc <> 0.
  253.       MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
  254.               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  255.     ENDIF.
  256.   ENDIF.
  257.  
  258.  
  259.   sscrfields-functxt_01 = '@FC@ Check RFC-Destinations'(003).
  260.  
  261. FORM compare_sf.
  262.  
  263.   DATA t_sftab1 TYPE TABLE OF smum_xmltb.
  264.   DATA t_sftab2 TYPE TABLE OF smum_xmltb.
  265.   FIELD-SYMBOLS <sft> TYPE smum_xmltb.
  266.   DATA lt_t1 TYPE rswsourcet.
  267.   DATA lt_t2 TYPE rswsourcet.
  268.   DATA lv_equal(1).
  269.   DATA lt_xx TYPE TABLE OF rsedcresul.
  270.   DATA lv_str TYPE string.
  271.   DATA msg_text(80).
  272.   DATA lv_lastname1(20).
  273.   DATA lv_lastname2(20).
  274.   DATA ls_data TYPE ty_output .
  275.  
  276.  
  277.  
  278.   DATA ls_xx TYPE rsedcresul.
  279.  
  280.   CALL FUNCTION 'Z_BC_READSFXML' DESTINATION p_des1
  281.     EXPORTING
  282.       i_form                  = p_form1
  283.       i_langu                 = ' '
  284.     TABLES
  285.       sftab                   = t_sftab1
  286. *     RETURN                  =
  287.     EXCEPTIONS
  288.       form_not_exist          = 1
  289.       wrong_access_to_archive = 2
  290.       communication_failure   = 3 MESSAGE msg_text
  291.       system_failure          = 4 MESSAGE msg_text
  292.       OTHERS                  = 5.
  293.  
  294.   IF NOT msg_text IS INITIAL.
  295.     MESSAGE s000(su) WITH msg_text 'under destination' p_des1 DISPLAY LIKE 'E'.
  296.     return.
  297.   ENDIF.
  298.  
  299.   IF sy-subrc EQ 1.
  300.     MESSAGE s000(su) WITH 'Form'  p_form1 'does not exist in' p_des1 DISPLAY LIKE 'E'.
  301.     return.
  302.   ENDIF.
  303.  
  304.   LOOP AT t_sftab1 ASSIGNING <sft> WHERE cname IN gr_excl AND type NE 'A' .
  305.     CONCATENATE  <sft>-cname '-' <sft>-cvalue INTO lv_str.
  306.     APPEND lv_str TO lt_t1.
  307.  
  308.   CALL FUNCTION 'Z_BC_READSFXML' DESTINATION p_des2
  309.     EXPORTING
  310.       i_form                  = p_form2
  311.       i_langu                 = ' '
  312.     TABLES
  313.       sftab                   = t_sftab2
  314. *     RETURN                  =
  315.     EXCEPTIONS
  316.       form_not_exist          = 1
  317.       wrong_access_to_archive = 2
  318.       communication_failure   = 3 MESSAGE msg_text
  319.       system_failure          = 4 MESSAGE msg_text
  320.       OTHERS                  = 5.
  321.  
  322.   IF NOT msg_text IS INITIAL.
  323.     MESSAGE s000(su) WITH msg_text 'under destination' p_des2 DISPLAY LIKE 'E'.
  324.     RETURN.
  325.   ENDIF.
  326.  
  327.   IF sy-subrc EQ 1.
  328.     MESSAGE s000(su) WITH 'Form'  p_form2 'does not exist in' p_des2 DISPLAY LIKE 'E'.
  329.     RETURN.
  330.   ENDIF.
  331.  
  332.   LOOP AT t_sftab2 ASSIGNING <sft> WHERE cname IN gr_excl AND type NE 'A' .
  333.     CONCATENATE <sft>-cname '-' <sft>-cvalue INTO lv_str.
  334.     APPEND lv_str TO lt_t2.
  335.  
  336.   CALL FUNCTION 'RS_CMP_COMPUTE_DELTA'
  337.     EXPORTING
  338. *     COMPARE_MODE            = '1'
  339. *     FLG_EXT_IGNORE          = ' '
  340.       ignore_case_differences = ' '
  341. *     FLG_WB99                = ' '
  342.     IMPORTING
  343.       flg_equal               = lv_equal
  344.     TABLES
  345.       text_tab1               = lt_t2
  346.       text_tab2               = lt_t1
  347.       text_tab_res            = lt_xx
  348.     EXCEPTIONS
  349.       parameter_invalid       = 1
  350.       difference_not_found    = 2
  351.       OTHERS                  = 3.
  352.  
  353.  
  354.   IF lv_equal IS INITIAL.
  355.  
  356.     LOOP AT lt_xx INTO ls_xx.
  357.       MOVE-CORRESPONDING ls_xx TO ls_data.
  358. *----------------------------------------------------------
  359.       IF strlen( ls_data-text1 ) > 5.
  360.         IF ls_data-text1(5) = 'INAME'.
  361.           lv_lastname1 = ls_data-text1+6.
  362.         ENDIF.
  363.       ENDIF.
  364.       IF NOT lv_lastname1 IS INITIAL.
  365.         ls_data-iname1 = lv_lastname1.
  366.       ENDIF.
  367.       IF ls_data-line1 = space.
  368.         CLEAR ls_data-iname1.
  369.       ENDIF.
  370. *----------------------------------------------------------
  371.       IF strlen( ls_data-text2 ) > 5.
  372.         IF ls_data-text2(5) = 'INAME'.
  373.           lv_lastname2 = ls_data-text2+6.
  374.         ENDIF.
  375.       ENDIF.
  376.       IF NOT lv_lastname2 IS INITIAL.
  377.         ls_data-iname2 = lv_lastname2.
  378.       ENDIF.
  379.       IF ls_data-line2 = space.
  380.         CLEAR ls_data-iname2.
  381.       ENDIF.
  382. *----------------------------------------------------------
  383.  
  384.       APPEND ls_data TO it_data.
  385.     ENDLOOP.
  386.  
  387.     CALL SCREEN 100.
  388.  
  389.     MESSAGE s000(su) WITH 'Forms are not equal !' DISPLAY LIKE 'E'.
  390.  
  391.   ELSE.
  392.     MESSAGE s000(su) WITH 'Forms are equal !'.
  393.   ENDIF.
  394.  
  395.  
  396. FORM fill_exclude_range.
  397.  
  398.   CLEAR   gr_excl .
  399.  
  400.   gr_excl-sign = 'E'.
  401.   gr_excl-option = 'EQ'.
  402.  
  403.   gr_excl-low = 'FORMNAME'. APPEND gr_excl.
  404.   gr_excl-low = 'FIRSTUSER'. APPEND gr_excl.
  405.   gr_excl-low = 'FIRSTDATE'. APPEND gr_excl.
  406.   gr_excl-low = 'FIRSTTIME'. APPEND gr_excl.
  407.   gr_excl-low = 'LASTUSER'. APPEND gr_excl.
  408.   gr_excl-low = 'LASTDATE'. APPEND gr_excl.
  409.   gr_excl-low = 'LASTTIME'. APPEND gr_excl.
  410.   gr_excl-low = 'CAPTION'. APPEND gr_excl.
  411. *  gr_excl-low = 'item'. APPEND gr_excl.
  412.   gr_excl-low = 'DEVCLASS'. APPEND gr_excl.
  413.   gr_excl-low = 'STATUS'. APPEND gr_excl.
  414.   gr_excl-low = 'LANGU'. APPEND gr_excl.
  415.  
  416.  
  417.  
  418. *&---------------------------------------------------------------------*
  419. *&      Module  PBO  OUTPUT
  420. *&---------------------------------------------------------------------*
  421. *       text
  422. *----------------------------------------------------------------------*
  423. MODULE pbo OUTPUT.
  424.  
  425.   IF g_custom_container IS INITIAL.
  426.  
  427.     IF cl_gui_alv_grid=>offline( ) IS INITIAL.
  428.       CREATE OBJECT g_custom_container
  429.         EXPORTING
  430.           container_name = g_container.
  431.       CREATE OBJECT grid1
  432.         EXPORTING
  433.           i_parent = g_custom_container.
  434.     ELSE.
  435.  
  436. *    Hintergrund
  437.       CREATE OBJECT grid1
  438.         EXPORTING
  439.           i_parent = g_dock_container.
  440.  
  441.     ENDIF.
  442.  
  443. *    CREATE OBJECT g_custom_container
  444. *      EXPORTING
  445. *        container_name = g_container.
  446. *
  447. *    CREATE OBJECT grid1
  448. *      EXPORTING
  449. *        i_parent = g_custom_container.
  450.  
  451. *--Creating an instance for the event handler
  452.     CREATE OBJECT gr_event_handler .
  453.  
  454. *----Preparing field catalog.
  455.     PERFORM prepare_field_catalog TABLES gt_fieldcat[] .
  456. *----Preparing layout structure
  457.     PERFORM prepare_layout CHANGING gs_layout .
  458. *----Preparing Disable Toolbar Buttons
  459.     PERFORM change_buttons .
  460.  
  461.     is_variant-report = sy-repid.
  462.     IF sy-batch IS INITIAL.
  463.       is_variant-variant = '/GLOB_DEF'.
  464.     ELSE.
  465.       is_variant-variant = '/GLOB_JOB'.
  466.     ENDIF.
  467.  
  468. *'X':  nur globales Speichern
  469. *'U':  nur benutzerspezifisches Speichern
  470. *'A':  entspricht 'X' und 'U'
  471. *SPACE:kein Speichern
  472.  
  473.     CALL METHOD grid1->set_table_for_first_display
  474.       EXPORTING
  475.         is_variant           = is_variant
  476.         i_save               = 'X'
  477.         is_layout            = gs_layout
  478.         it_toolbar_excluding = lt_exclude
  479.       CHANGING
  480.         it_outtab            = it_data[]
  481.         it_fieldcatalog      = gt_fieldcat[].
  482.  
  483.  
  484. *--Registering handler methods to handle ALV Grid events JG
  485.  
  486.     SET HANDLER gr_event_handler->handle_toolbar FOR grid1.
  487.     SET HANDLER gr_event_handler->handle_user_command FOR grid1.
  488.  
  489.     CALL METHOD grid1->set_toolbar_interactive.
  490.  
  491. * Der GRID1 wird noch refreshed
  492.     CALL METHOD grid1->refresh_table_display.
  493.  
  494.   ENDIF.
  495.  
  496.   SET PF-STATUS 'MAIN100'.
  497.   CONCATENATE 'Comparing' p_form1 'with' p_form2 INTO gv_title SEPARATED BY space.
  498.   SET TITLEBAR 'AUSW' WITH gv_title.
  499.  
  500. *&---------------------------------------------------------------------*
  501. *&      Module  PAI  INPUT
  502. *&---------------------------------------------------------------------*
  503. *       text
  504. *----------------------------------------------------------------------*
  505. MODULE pai INPUT.
  506. *   to react on oi_custom_events:
  507.   CALL METHOD cl_gui_cfw=>dispatch.
  508.   CASE ok_code.
  509.     WHEN 'EXIT'.
  510.       PERFORM exit_program.
  511.     WHEN OTHERS.
  512. *     do nothing
  513.   CLEAR ok_code.
  514.  
  515. *---------------------------------------------------------------------*
  516. *       FORM EXIT_PROGRAM                                             *
  517. *---------------------------------------------------------------------*
  518. FORM exit_program.
  519. *  CALL METHOD G_CUSTOM_CONTAINER->FREE.
  520. *  CALL METHOD CL_GUI_CFW=>FLUSH.
  521.   LEAVE TO SCREEN 0.
  522. ENDFORM.                    "EXIT_PROGRAM
  523. *&--------------------------------------------------------------------*
  524. *&      Form  Change_buttons
  525. *&--------------------------------------------------------------------*
  526. *       text
  527. *---------------------------------------------------------------------*
  528. FORM change_buttons .
  529. * Kein Symbol für Drucken / Graphik / Info
  530.   ls_exclude = cl_gui_alv_grid=>mc_fc_print_back.
  531.   APPEND ls_exclude TO lt_exclude.
  532.   ls_exclude = cl_gui_alv_grid=>mc_fc_graph.
  533.   APPEND ls_exclude TO lt_exclude.
  534.   ls_exclude = cl_gui_alv_grid=>mc_fc_info.
  535.   APPEND ls_exclude TO lt_exclude.
  536.  
  537. ENDFORM.                    "Change_buttons
  538.  
  539. *&--------------------------------------------------------------------*
  540. *&      Form  handle_toolbar
  541. *&--------------------------------------------------------------------*
  542. *       text
  543. *---------------------------------------------------------------------*
  544. *      -->I_OBJECT   text
  545. *---------------------------------------------------------------------*
  546. FORM handle_toolbar USING i_object TYPE REF TO cl_alv_event_toolbar_set
  547. e_interactive .
  548.  
  549.   DATA: ls_toolbar TYPE stb_button.
  550.  
  551. * Paltzhalter / Seperator
  552.   CLEAR ls_toolbar.
  553.   MOVE 3 TO ls_toolbar-butn_type.
  554.   APPEND ls_toolbar TO i_object->mt_toolbar.
  555.  
  556.  
  557. ** Button Show Differences
  558.   CLEAR ls_toolbar.
  559.   MOVE 'SET_FILTER' TO ls_toolbar-function.                 "#EC NOTEXT
  560.   MOVE icon_filter TO ls_toolbar-icon.
  561.   MOVE 'Filter Differences'(203) TO ls_toolbar-quickinfo.
  562.   MOVE ' Filter Differences'(203) TO ls_toolbar-text.
  563.   MOVE ' ' TO ls_toolbar-disabled.                          "#EC NOTEXT
  564.   APPEND ls_toolbar TO i_object->mt_toolbar.
  565.  
  566. ** Button Delete Filter Differences
  567.   CLEAR ls_toolbar.
  568.   MOVE 'DEL_FILTER' TO ls_toolbar-function.                 "#EC NOTEXT
  569.   MOVE icon_filter_undo TO ls_toolbar-icon.
  570.   MOVE 'Delete Filter Differences'(203) TO ls_toolbar-quickinfo.
  571.   MOVE ' Delete Filter Differences'(203) TO ls_toolbar-text.
  572.   MOVE ' ' TO ls_toolbar-disabled.                          "#EC NOTEXT
  573.   APPEND ls_toolbar TO i_object->mt_toolbar.
  574.  
  575. ** Paltzhalter / Seperator
  576. *  CLEAR ls_toolbar.
  577. *  MOVE 3 TO ls_toolbar-butn_type.
  578. *  APPEND ls_toolbar TO i_object->mt_toolbar.
  579.  
  580.  
  581.  
  582. ENDFORM .                    "handle_toolbar
  583. *&---------------------------------------------------------------------*
  584. *&      Form  handle_user_command
  585. *&---------------------------------------------------------------------*
  586. *       text
  587. *----------------------------------------------------------------------*
  588.  
  589. FORM handle_user_command USING i_ucomm TYPE syucomm .
  590.   DATA lt_selected_rows TYPE lvc_t_roid .
  591.   DATA ls_selected_row TYPE lvc_s_roid .
  592.   DATA lv_name TYPE epsfili-name.
  593.   DATA lv_flag(1).
  594.   DATA lv_stable TYPE lvc_s_stbl.
  595.   DATA ls_filter TYPE lvc_s_filt.
  596.   DATA lt_filter TYPE lvc_t_filt.
  597.  
  598.   CASE i_ucomm .
  599.  
  600.     WHEN 'SET_FILTER'.
  601.       ls_filter-fieldname = 'FLAG1'. "Field Name
  602.       ls_filter-sign = 'I'.
  603.       ls_filter-option = 'NE'.
  604.       ls_filter-low = ' '. "Filter Value
  605.       APPEND ls_filter TO lt_filter.
  606.  
  607.       ls_filter-fieldname = 'FLAG2'. "Field Name
  608.       ls_filter-sign = 'I'.
  609.       ls_filter-option = 'NE'.
  610.       ls_filter-low = ' '. "Filter Value
  611.       APPEND ls_filter TO lt_filter.
  612.  
  613.       CALL METHOD grid1->set_filter_criteria
  614.         EXPORTING
  615.           it_filter = lt_filter.
  616.  
  617.     WHEN 'DEL_FILTER'.
  618.       CALL METHOD grid1->get_filter_criteria
  619.         IMPORTING
  620.           et_filter = lt_filter.
  621.  
  622.       DELETE lt_filter WHERE fieldname = 'FLAG1' OR fieldname = 'FLAG2'.
  623.  
  624.       CALL METHOD grid1->set_filter_criteria
  625.         EXPORTING
  626.           it_filter = lt_filter.
  627.  
  628.     WHEN OTHERS.
  629.   ENDCASE .
  630.  
  631.   lv_stable-row = 'X'.
  632.   CALL METHOD grid1->refresh_table_display
  633.     EXPORTING
  634.       is_stable = lv_stable.
  635. *    EXCEPTIONS
  636. *      finished  = 1
  637. *      OTHERS    = 2.
  638.  
  639. ENDFORM.                    "handle_user_command
  640.  
  641. *&--------------------------------------------------------------------*
  642. *&      Form  prepare_field_catalog
  643. *&--------------------------------------------------------------------*
  644. *       text
  645. *---------------------------------------------------------------------*
  646. *      -->PT_FIELDCATtext
  647. *---------------------------------------------------------------------*
  648. FORM prepare_field_catalog TABLES pt_fieldcat TYPE lvc_t_fcat .
  649.  
  650. *  DATA ls_fcat TYPE lvc_s_fcat .
  651. *  DATA lv_depth TYPE i.
  652.  
  653.   DATA l_struc TYPE dd02l-tabname.
  654.   DATA: ls_fieldcat TYPE lvc_s_fcat.
  655.   FIELD-SYMBOLS: <p> TYPE lvc_s_fcat.
  656.  
  657.   l_struc = indx_id .
  658.   CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
  659.     EXPORTING
  660.       i_structure_name       = l_struc
  661.     CHANGING
  662.       ct_fieldcat            = pt_fieldcat[]
  663.     EXCEPTIONS
  664.       inconsistent_interface = 1
  665.       program_error          = 2
  666.       OTHERS                 = 3.
  667.  
  668.   IF sy-subrc <> 0.
  669. *--Exception handling
  670.   ENDIF.
  671.  
  672.   READ TABLE pt_fieldcat INTO ls_fieldcat WITH KEY fieldname = 'TEXT1'.
  673.   IF sy-subrc = 0.
  674.     ls_fieldcat-col_pos = 7.
  675.     ls_fieldcat-fieldname = 'INAME1'.
  676.     ls_fieldcat-ref_table = space.
  677.     ls_fieldcat-tabname = space.
  678.     APPEND ls_fieldcat TO pt_fieldcat.
  679.     ls_fieldcat-col_pos = 8.
  680.     ls_fieldcat-fieldname = 'INAME2'.
  681.     APPEND ls_fieldcat TO pt_fieldcat.
  682.   ENDIF.
  683.  
  684.   LOOP AT pt_fieldcat ASSIGNING <p>.
  685.  
  686.     CASE <p>-fieldname.
  687.       WHEN 'INAME1'.
  688.         <p>-scrtext_l = 'Element A'.
  689.         <p>-scrtext_m = 'Elem.A'.
  690.         <p>-scrtext_s = 'EA'.
  691.       WHEN 'INAME2'.
  692.         <p>-scrtext_l = 'Element B'.
  693.         <p>-scrtext_m = 'Elem.B'.
  694.         <p>-scrtext_s = 'EB'.
  695.       WHEN 'LINE1'.
  696.         <p>-scrtext_l = 'Line A'.
  697.         <p>-scrtext_m = 'Line A'.
  698.         <p>-scrtext_s = 'LA'.
  699.       WHEN 'LINE2'.
  700.         <p>-scrtext_l = 'Line B'.
  701.         <p>-scrtext_m = 'Line B'.
  702.         <p>-scrtext_s = 'LB'.
  703.       WHEN 'TEXT1'.
  704.         <p>-scrtext_l = 'Source A'.
  705.         <p>-scrtext_m = 'Src A'.
  706.         <p>-scrtext_s = 'A'.
  707.       WHEN 'TEXT2'.
  708.         <p>-scrtext_l = 'Source B'.
  709.         <p>-scrtext_m = 'Src B'.
  710.         <p>-scrtext_s = 'B'.
  711.       WHEN 'FLAG1'.
  712.         <p>-scrtext_l = 'Change A'.
  713.         <p>-scrtext_m = 'C-Flg A'.
  714.         <p>-scrtext_s = 'A'.
  715.       WHEN 'FLAG2'.
  716.         <p>-scrtext_l = 'Change B'.
  717.         <p>-scrtext_m = 'C-Flg B'.
  718.         <p>-scrtext_s = 'B'.
  719.  
  720.       WHEN OTHERS.
  721.     ENDCASE.
  722.  
  723. ENDFORM .                    "prepare_field_catalog
  724. *&--------------------------------------------------------------------*
  725. *&      Form  prepare_layout
  726. *&--------------------------------------------------------------------*
  727. *       text
  728. *---------------------------------------------------------------------*
  729. *      -->PS_LAYOUT  text
  730. *---------------------------------------------------------------------*
  731. FORM prepare_layout CHANGING ps_layout TYPE lvc_s_layo.
  732.  
  733.  
  734.   ps_layout-zebra = 'X' .
  735.   ps_layout-numc_total = ' '.
  736.   ps_layout-no_merging = 'X'.
  737.   ps_layout-no_rowmark = ' '.
  738.   ps_layout-sel_mode = 'A'.
  739.  
  740. ENDFORM.                    "prepare_layout
GeSHi ©


Der benötigte RFC-Enabled Funktionsbaustein.

Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
  1. FUNCTION Z_BC_READSFXML.
  2. *"----------------------------------------------------------------------
  3. *"*"Local Interface:
  4. *"  IMPORTING
  5. *"     VALUE(I_FORM) TYPE  TDSFNAME
  6. *"     VALUE(I_LANGU) TYPE  SPRAS DEFAULT 'E'
  7. *"  TABLES
  8. *"      SFTAB STRUCTURE  SMUM_XMLTB
  9. *"      RETURN STRUCTURE  BAPIRET2 OPTIONAL
  10. *"  EXCEPTIONS
  11. *"      FORM_NOT_EXIST
  12. *"----------------------------------------------------------------------
  13.   CONSTANTS: c_xml_ns_uri_sf(255)  TYPE c
  14.       VALUE 'urn:sap-com:SmartForms:2000:internal-structure', "#EC NOTEXT
  15.              c_xml_ns_uri_ifr(255) TYPE c
  16.                                      VALUE 'urn:sap-com:sdixml-ifr:2000'. "#EC NOTEXT
  17.  
  18.   TYPES tyt_tab_xml TYPE TABLE OF smum_xmltb.
  19.  
  20.  
  21.   TYPES: t_gnode  TYPE ssfgnode,
  22.          t_gnodes TYPE tsfgnode.
  23.  
  24.  
  25.   DATA: l_filename    TYPE string,
  26.         l_file_filter TYPE string,
  27.         l_user_action TYPE i.
  28.   DATA: l_element TYPE REF TO if_ixml_element.
  29.   DATA: l_language_str TYPE string,
  30.         l_language(2)  TYPE c.
  31.   DATA: l_lines             TYPE i,
  32.         l_splitted_name_tab TYPE TABLE OF string.
  33.   DATA: l_stylename  TYPE tdssname,
  34.         l_stylevari  TYPE tdvariant,
  35.         l_save_style TYPE tdssname.
  36.  
  37.  
  38.   DATA: g_ixml              TYPE REF TO if_ixml,
  39.         xml_document        TYPE REF TO if_ixml_document,
  40.         xml_element         TYPE REF TO if_ixml_element,
  41.         xml_ns_prefix_sf    TYPE string,
  42.         xml_ns_uri_sf       TYPE string,
  43.         xml_ns_uri_ifr      TYPE string,
  44.         xml_macro_name      TYPE string,
  45.         xml_macro_rc        TYPE i,
  46.         xml_macro_objt      TYPE stxfobjt,
  47.         xml_macro_text      TYPE stxftxt,
  48.         xml_macro_tline     TYPE tline,
  49.         xml_upload_language TYPE tdspras.
  50.  
  51.   TYPES: t_raw(250) TYPE x.
  52.  
  53.   DATA: xml_xtable        TYPE TABLE OF t_raw WITH HEADER LINE,
  54.         xml_document_size TYPE i.
  55.  
  56.  
  57.   DATA: sform             TYPE REF TO cl_ssf_fb_smart_form.
  58.  
  59. * Namen der aktuell bearbeiteten Objekte
  60.   DATA: formname    TYPE tdsfname,     " Name des Formulars
  61.         variant     TYPE tdvariant,    " Name der Formularvariante
  62.         language    TYPE sy-langu,     " Bearbeitungssprache
  63.         fmnumb      TYPE tdfmnumb,     " Nummer des zugeordneten Fb
  64.         fmnumb_test TYPE tdfmnumb.     " Fb zum Test der inaktiven Fassung
  65.  
  66.  
  67.   DATA: gv_xml_xstring TYPE          xstring,
  68.         gv_size        TYPE          sy-tabix.
  69.  
  70.   DATA ls_admin TYPE stxfadm.
  71.  
  72.   SELECT SINGLE * FROM stxfadm INTO ls_admin WHERE formname = i_form.
  73.  
  74.   IF ls_admin IS INITIAL.
  75.     RAISE form_not_exist.
  76.   ELSE.
  77.     formname = i_form.
  78.   ENDIF.
  79.  
  80.   IF i_langu IS INITIAL.
  81.     language =  ls_admin-masterlang.
  82.   ELSE.
  83.     language = i_langu.
  84.   ENDIF.
  85.  
  86. * create form object
  87.   CREATE OBJECT sform.
  88.  
  89.   CALL METHOD sform->load
  90.     EXPORTING
  91.       im_formname    = formname
  92.       im_language    = language
  93.       im_active      = space
  94.     IMPORTING
  95.       ex_fmnumb      = fmnumb
  96.       ex_fmnumb_test = fmnumb_test.
  97.  
  98.   IF g_ixml IS INITIAL.
  99.     g_ixml          = cl_ixml=>create( ).
  100.   ENDIF.
  101.  
  102.   xml_document      = g_ixml->create_document( ).
  103.   xml_ns_prefix_sf  = 'sf'.
  104.   xml_ns_uri_sf     = c_xml_ns_uri_sf.
  105.   xml_ns_uri_ifr    = c_xml_ns_uri_ifr.
  106.   CLEAR: xml_document_size, xml_xtable[].
  107.   sform->xml_init( ).
  108.  
  109. * create XML for the entire smart form
  110.   CALL METHOD sform->xml_download
  111.     EXPORTING
  112.       parent   = xml_document
  113.     CHANGING
  114.       document = xml_document.
  115.  
  116. * namespace
  117.   l_element  = xml_document->get_root_element( ).
  118.   l_element->set_attribute( name      = xml_ns_prefix_sf
  119.                             namespace = 'xmlns'
  120.                             value     = xml_ns_uri_sf ).
  121.   l_element->set_attribute( name  = 'xmlns'
  122.                             value = xml_ns_uri_ifr ).
  123.  
  124. * language
  125.   WRITE language TO l_language.
  126.   l_language_str = l_language.
  127.   xml_macro_rc = l_element->set_attribute(
  128.                       name      = 'language'
  129.                       namespace = xml_ns_prefix_sf
  130.                       value     = l_language_str ).
  131.  
  132.  
  133.   CALL FUNCTION 'SDIXML_DOM_TO_XML'
  134.     EXPORTING
  135.       document      = xml_document
  136. *     PRETTY_PRINT  = ' '
  137.     IMPORTING
  138.       xml_as_string = gv_xml_xstring
  139.       size          = gv_size
  140.     EXCEPTIONS
  141.       no_document   = 1
  142.       OTHERS        = 2.
  143.  
  144. *== Convert XML to itab
  145.   CALL FUNCTION 'SMUM_XML_PARSE'
  146.     EXPORTING
  147.       xml_input = gv_xml_xstring
  148.     TABLES
  149.       xml_table = sftab
  150.       return    = return.
  151.  
  152.  
GeSHi ©
Tron
.....
.....
 
Posts: 1112
Joined: Sat Aug 04, 2007 10:21 pm

Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 1 guest

cron