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:
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:
Before and After, voilà!
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:
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.
The final piece of our puzzle is the config. You can spot it lounging around in a part of SPRO.
And there you have it! With these steps, we've made correspondence generation process interactive
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
5 | |
3 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |