Financial Management Blogs by SAP
Get financial management insights from blog posts by SAP experts. Find and share tips on how to increase efficiency, reduce risk, and optimize working capital.
cancel
Showing results for 
Search instead for 
Did you mean: 
morzech
Advisor
Advisor
0 Kudos

Let's jazz up your user experience during manual correspondence creation with the superpower of WD addon components. This nifty tool also lets us shift selection from Adobe Form, which is a must when the form decides to take a non-interactive nap, right onto the WD layer.

We'll dive into a mini-example where we'll boost an existing process (ISR Scenario STL3) with the selection of long text (you get the freedom to type or choose from predefined options). We'll also throw in free selection of BRF+ messages. Ready for the upgrade? Here's how we'll do it:

 

1. Adobe Form Makeover

We'll start by creating a clone of the existing Adobe Form ISR_FORM_STL3, and we'll dub it ZISR_FORM_STL3. Here's what the new version will look like:

  • We'll bid adieu to the Drop Down List LONG_TEXT_SEL. We don't need text selection on the form anymore.
  • The table with BRF+ messages will get a minimalist makeover. We'll eliminate the "Select" column.


Before and After, voilà!

morzech_0-1706601090680.png

 morzech_1-1706601090683.png

2. Crafting the WD Addon

We'll replicate WD Component FMCA_CORRM_TR_ADDON to create our new version, ZFMCA_CORRM_TR_ADDON_STL3.

We'll then craft the following Data Definitions, Context, Layout, Actions and Methods:

2.1 Data Definitions

morzech_2-1706601090686.png

morzech_3-1706601090688.png

morzech_4-1706601090691.png

morzech_8-1706601090713.png

2.2 Context

morzech_9-1706601090722.png

morzech_10-1706601090733.png

morzech_11-1706601090742.png

morzech_12-1706601090751.png

morzech_13-1706601090761.png

2.3 Layout

morzech_14-1706601090778.png

morzech_15-1706601090782.png

morzech_16-1706601090797.png

morzech_17-1706601090802.png

morzech_18-1706601090827.png

morzech_19-1706601090831.png

morzech_20-1706601090838.png

morzech_21-1706601090842.png

morzech_22-1706601090847.png

morzech_23-1706601090852.png

morzech_24-1706601090859.png

morzech_25-1706601090863.png

morzech_26-1706601090868.png

2.4 Actions/Methods

morzech_27-1706601090869.png

morzech_28-1706601090872.png

morzech_29-1706601090881.png

Respective ABAP code:

 

 

METHOD wddoinit .
  set_predefined_texts( ).
  set_brf_messages( ).
ENDMETHOD.
METHOD set_brf_messages .

  DATA(lt_brf_msg_ctx) = VALUE wd_this->elements_brf_messages( ).

  SELECT * FROM dfmca_brf_msg
    INTO TABLE @DATA(lt_brf_msg)
   WHERE return_id EQ @wd_comp_controller->ms_header-appobj_id.

  CHECK sy-subrc EQ 0.

  DATA(lt_dd07) = VALUE dd07v_t( ).

  CALL FUNCTION 'DD_DOMVALUES_GET'
    EXPORTING
      domname        = 'MSGTY_CO'
      text           = abap_true
    TABLES
      dd07v_tab      = lt_dd07
    EXCEPTIONS
      wrong_textflag = 1
      OTHERS         = 2.

  LOOP AT lt_brf_msg ASSIGNING FIELD-SYMBOL(<brf_msg>).

    APPEND INITIAL LINE TO lt_brf_msg_ctx ASSIGNING FIELD-SYMBOL(<brf_msg_ctx>).
    <brf_msg_ctx> = CORRESPONDING #( <brf_msg> ).

    MESSAGE
      ID <brf_msg>-msgid
      TYPE <brf_msg>-msgty
      NUMBER <brf_msg>-msgno
      WITH
        <brf_msg>-msgv1
        <brf_msg>-msgv2
        <brf_msg>-msgv3
        <brf_msg>-msgv4
      INTO <brf_msg_ctx>-message_text.

    TRY.
        <brf_msg_ctx>-msg_type_desc = lt_dd07[ domvalue_l = <brf_msg>-msgty ]-ddtext.
      CATCH cx_sy_itab_duplicate_key.
    ENDTRY.

  ENDLOOP.

  wd_context->path_get_node( path = `SELECTION.BRF_MESSAGES` )->bind_table(
    new_items = lt_brf_msg_ctx set_initial_elements = abap_true ).

ENDMETHOD.
METHOD set_predefined_texts .

  SELECT id, text
    FROM ztcorr_long_txtt
    INTO TABLE @DATA(lt_text)
   WHERE spras EQ -langu.

  CHECK sy-subrc EQ 0.

  DATA(lo_formdata_ni) = wd_context->get_child_node( name = wd_this->wdctx_selection )->get_node_info( ).

  DATA(lt_valueset) = VALUE wdr_context_attr_value_list( FOR <line> IN lt_text ( value = <line>-id text = <line>-text ) ).

  lo_formdata_ni->set_attribute_value_set( name = 'CORR_TEXT_ID' value_set = lt_valueset ).

ENDMETHOD.
METHOD onactionselect .

  DATA(lt_sel_brf_msg) = VALUE wdr_context_element_set( ).
  DATA(lv_index) = VALUE i( ).
  DATA(ls_brf_msg_ctx) = VALUE wd_this->element_brf_messages( ).
  DATA(lt_form_data) = VALUE qisrtspecial_param( ).

  wd_comp_controller->mr_form_data_context_node->get_static_attributes_table( IMPORTING table = lt_form_data ).

  DELETE lt_form_data WHERE fieldname EQ 'SELECTED' OR
                            fieldname EQ 'MSG_STR' OR
                            fieldname EQ 'TYPE_TEXT' OR
                            fieldname EQ 'STATUS_TEXT' OR
                            fieldname EQ 'LONG_TEXT'.

  DATA(lt_dd07) = VALUE dd07v_t( ).

  CALL FUNCTION 'DD_DOMVALUES_GET'
    EXPORTING
      domname        = 'MSGSTATUS_PS'
      text           = abap_true
    TABLES
      dd07v_tab      = lt_dd07
    EXCEPTIONS
      wrong_textflag = 1
      OTHERS         = 2.

  lt_sel_brf_msg = wd_context->path_get_node( path = `SELECTION.BRF_MESSAGES` )->get_selected_elements( ).

  LOOP AT lt_sel_brf_msg ASSIGNING FIELD-SYMBOL(<brf_msg>).

    ADD 1 TO lv_index.

    <brf_msg>->get_static_attributes( IMPORTING static_attributes = ls_brf_msg_ctx ).

    APPEND VALUE #( fieldindex = lv_index fieldname = :
      'SELECTED'    fieldvalue = abap_true )                    TO lt_form_data,
      'MSG_STR'     fieldvalue = ls_brf_msg_ctx-message_text )  TO lt_form_data,
      'TYPE_TEXT'   fieldvalue = ls_brf_msg_ctx-msg_type_desc ) TO lt_form_data.

    TRY.
        APPEND VALUE #( fieldindex = lv_index fieldname = 'STATUS_TEXT' fieldvalue = lt_dd07[ domvalue_l = ls_brf_msg_ctx-status ]-ddtext ) TO lt_form_data.
      CATCH cx_sy_itab_line_not_found.
        APPEND VALUE #( fieldindex = lv_index fieldname = 'STATUS_TEXT' fieldvalue = ls_brf_msg_ctx-status ) TO lt_form_data.
    ENDTRY.

  ENDLOOP.

  APPEND VALUE #( fieldindex = 1 fieldname = 'LONG_TEXT' ) TO lt_form_data ASSIGNING FIELD-SYMBOL(<long_text>).

  DATA(ls_selection) = VALUE wd_this->element_selection( ).

  wd_context->get_child_node( name = wd_this->wdctx_selection )->get_element( )->get_static_attributes(
    IMPORTING
      static_attributes = ls_selection ).

  IF ls_selection-corr_predefined_text EQ abap_true.
    SELECT SINGLE text FROM ztcorr_long_txtt INTO <long_text>-fieldvalue WHERE spras EQ sy-langu AND id EQ ls_selection-corr_text_id.
  ELSE.
    <long_text>-fieldvalue = ls_selection-corr_text.
  ENDIF.

  wd_comp_controller->mt_update_form_data = lt_form_data.
  wd_comp_controller->fire_event( ).

ENDMETHOD.

 

 

3. Configuration Calibration

The final piece of our puzzle is the config. You can spot it lounging around in a part of SPRO.

morzech_30-1706601090891.png

morzech_31-1706601090893.png

And there you have it! With these steps, we've made correspondence generation process interactive

Short Demo