FUNCTION z2_alv_output_fbl5n.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(I_R_BUKRS) TYPE Z2TT_BUKRS OPTIONAL
*" VALUE(I_KUNNR) TYPE KUNNR
*" EXPORTING
*" VALUE(ET_POS) TYPE /SAPPCE/RFPOSXEXT
*" EXCEPTIONS
*" CUSTOMER_NOT_FOUND
*" DATA_RETRIEVE_FAILED
*"----------------------------------------------------------------------
* Check if customer exists
PERFORM check_customer USING i_kunnr.
* Prepare catching ALV
cl_salv_bs_runtime_info=>clear_all( ).
* Set No Display/No Metadata and get ALV DATA
cl_salv_bs_runtime_info=>set( EXPORTING display = abap_false
metadata = abap_false
data = abap_true ).
* Init table items
CLEAR et_pos[].
* Submit report RFITEMAR ie transaction FBL5N
SUBMIT rfitemar AND RETURN
WITH dd_bukrs IN i_r_bukrs " Company
WITH dd_kunnr EQ i_kunnr " Customer
WITH x_opsel EQ abap_false " Only open items
WITH x_aisel EQ abap_true " All items
WITH x_clsel EQ abap_false " Cleared items
WITH pa_vari EQ '/AR'. " Layout
TRY.
* Get the output and store in local table
cl_salv_bs_runtime_info=>get_data_ref( IMPORTING r_data = lr_report ).
ASSIGN lr_report->* TO <lt_rfitem>.
* Errors detected ?
CATCH cx_root.
RAISE data_retrieve_failed.
ENDTRY.
* Clear ALV
cl_salv_bs_runtime_info=>clear_all( ).
* Output (items) available ?
CHECK <lt_rfitem> IS ASSIGNED.
* Export selected items
et_pos[] = <lt_rfitem>.
ENDFUNCTION.
METHOD supply_fbl5n .
** data declaration
DATA lt_alv TYPE wd_this->elements_alv.
DATA lo_el_selection TYPE REF TO if_wd_context_element.
DATA lv_kunnr TYPE wd_this->element_selection-kunnr.
* Get the value for the customer from the selection on the screen.
lo_el_selection = wd_context->get_child_node( name = wd_this->wdctx_selection )->get_element( ).
lo_el_selection->get_attribute( EXPORTING name = `KUNNR`
IMPORTING value = lv_kunnr ).
* Check if we have a value for the customer.
IF lv_kunnr IS INITIAL.
APPEND INITIAL LINE TO lt_alv.
EXIT.
ENDIF.
* Call the functionmodule that will retrieve the ALV info from FBL5N .
CALL FUNCTION 'Z2_GRAP_ALV_OUTPUT_FBL5N'
EXPORTING
i_kunnr = lv_kunnr
IMPORTING
et_pos = lt_alv
EXCEPTIONS
customer_not_found = 1
data_retrieve_failed = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here " TODO; generate nice error messages on screen.
APPEND INITIAL LINE TO lt_alv.
ENDIF.
* bind all the elements to the context
node->bind_table(
new_items = lt_alv
set_initial_elements = abap_true ).
ENDMETHOD.
METHOD onactionselect_kunnr .
* All we want to do is the start the supply function for the chosen customer.
wd_context->get_child_node( wd_this->wdctx_alv )->invalidate( ).
ENDMETHOD.
METHOD wddoinit .
DATA:
l_cmp_usage TYPE REF TO if_wd_component_usage,
l_intf_controller TYPE REF TO iwci_salv_wd_table.
IF wd_this->cmp_usage_group IS INITIAL.
wd_this->cmp_usage_group = wd_comp_controller->wd_get_api( )->create_cmp_usage_group(
name = 'ALV_USAGE_GROUP'
used_component = 'SALV_WD_TABLE' ).
l_cmp_usage = wd_this->cmp_usage_group->add_component_usage(
name = 'ALV_USAGE'
used_component = 'SALV_WD_TABLE').
l_cmp_usage->create_component( ).
wd_this->wd_get_api( )->do_dynamic_navigation(
source_window_name = 'W_MAIN'
source_vusage_name = 'V_MAIN_USAGE_0'
source_plug_name = 'TO_ALV'
target_component_name = 'SALV_WD_TABLE'
target_component_usage = 'ALV_USAGE'
target_view_name = 'TABLE'
target_plug_name = 'DEFAULT'
target_embedding_position = 'V_MAIN/CNT_ALV_CONTAINER' ).
l_intf_controller ?= l_cmp_usage->get_interface_controller( ).
l_intf_controller->set_data( wd_context->get_child_node( 'ALV' ) ).
ENDIF.
* Optional: add some nice features for the end-user.
l_intf_controller->get_model( )->if_salv_wd_std_functions~set_hierarchy_allowed( ).
l_intf_controller->get_model( )->if_salv_wd_std_functions~set_aggregation_allowed( abap_true ).
l_intf_controller->get_model( )->if_salv_wd_std_functions~set_hierarchy_allowed( abap_true ).
l_intf_controller->get_model( )->if_salv_wd_std_functions~set_count_records_allowed( abap_true ).
l_intf_controller->get_model( )->if_salv_wd_std_functions~set_group_aggregation_allowed( abap_true ).
ENDMETHOD.
METHOD wddoexit .
* And a nice clean-up after we're finished.
wd_this->wd_get_api( )->remove_dynamic_meta_data(
source_window_name = 'W_MAIN'
source_vusage_name = 'V_MAIN_USAGE_0'
source_plug_name = 'TO_ALV'
target_component_name = 'SALV_WD_TABLE'
target_component_usage = 'ALV_USAGE'
target_view_name = 'TABLE'
target_plug_name = 'DEFAULT'
target_embedding_position = 'V_MAIN/CNT_ALV_CONTAINER' ).
IF wd_this->cmp_usage_group IS BOUND.
wd_this->cmp_usage_group->remove_all_cmp_usages( ).
CLEAR wd_this->cmp_usage_group.
ENDIF.
wd_comp_controller->wd_get_api( )->remove_cmp_usage_group( 'ALV_USAGE_GROUP' ).
ENDMETHOD.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
9 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 |