The QPPD framework provides methods to TOE - Plausibility Check and Search Help (F) can also be used from external applications. In the QPPD framework all classes, programs, and functions are described with the Ident TOE (technical object for the element).

The methods are defined using the class /SCT/QP_CL_TOE with the interface /SCT/QP_IF_TOE callable. 

the report /sct/qp_toe_external_call is demonstrating the use of the methods.

Exporting Parameter IS_TOE

The parameter provides all information on the methods described below. Only the following fields are required.

  • ELEMENT, Name of the element stored in Customizing

  • OBJEKTTYP, Name of the tab used. For each tab page used, you can store alternative definitions for the context or plausibility check. If the object type is not set, the first usage of the element on tab pages is determined and used.

  • ELEMENTGRUPPE, Name of the element group for the object type used. If the element group is not set, the first usage is determined.

  • VALUE the value to be checked.

  • VALIDATE Date for determining the element values in the validity period

get_instance

Creates a singleton instance. 

TRY.
mo_toe = /sct/qp_cl_toe=>get_instance( ).
CATCH /sct/qp_cx_error.
ENDTRY.

add_context

If context elements are used in the plausibility check, they must be set beforehand. The context is valid for all subsequent method calls.  

DATA(lt_context) = VALUE /sct/qp_t_qvc_val_data( ( element = p_celem1 value = p_cval1 )
( element = p_celem2 value = p_cval2 )
( element = p_celem3 value = p_cval3 ) ).
mo_toe->add_context( lt_context ).

get_context

Determines the context elements stored in Customizing.

DATA(rt_element) = mo_toe->get_context_elements( is_toe = VALUE #( element = p_elem ) ).

free_context

If the context changes, the current context can be reset.

mo_toe->free_context( ).

check_value

Checks the validity of an element value depending on the context, validity period, and status.

The parameter: RV_VALID indicates the validity. You can specify the valid values using the constants class /SCT/QP_CL_CONST=>TOE-VALID can be queried.

  • 0 OK: Value is valid

  • 2 warning: Warnung

  • 4 out_of_validity_period: outside the validity period

  • 6 failed: invalid

  • 7 index_not_found: not found in the index

The parameter ES_MESSAGE outputs a differentiated error description.           

DATA ls_message TYPE /sct/qp_s_message.
DATA(rv_valid) = mo_toe->check_value( EXPORTING is_toe = VALUE #( element = p_elem value = p_value valid_date = sy-datum )
IMPORTING es_message = ls_message ).
case rv_valid:
when /sct/qp_cl_const=>toe-valid-ok.
when /sct/qp_cl_const=>toe-valid-warning.
when /sct/qp_cl_const=>toe-valid-out_of_validity_period.
when /sct/qp_cl_const=>toe-valid-failed.
when /sct/qp_cl_const=>toe-valid-index_not_found.
endcase.
 
ls_message-message = /sct/qp_cl_tools=>get_instance( )->get_msg_from_msgv( iv_id = ls_message-msgid
iv_number = ls_message-msgno
iv_msgv1 = ls_message-msgv1
iv_msgv2 = ls_message-msgv2
iv_msgv3 = ls_message-msgv3
iv_msgv4 = ls_message-msgv4 ).

get_value_list

Determines all valid values, taking into account the context and validity period. Multilingual texts are output for the valid values.

Parameter:

IV_TOEC_ACTIVE Specifies whether the validity of the values should be taken into account based on the context

IS_SELOPT Additional selection conditions for the fields of the element value

mo_toe->get_value_list( EXPORTING is_toe = VALUE #( element = p_elem valid_date = sy-datum )
iv_toec_active = abap_true
is_selopt = VALUE #( value = VALUE #( ( option = 'CP' sign = 'I' low = '*' ) )
maxamount = 50 )
IMPORTING et_value = DATA(lt_data) ).

get_value_text

Determines the multilingual texts for the element value.

Parameter:

ES_VALT Texts in the specified language

ET_VALT all multilingual texts

mo_toe->get_value_text( EXPORTING is_toe = VALUE #( element = p_elem value = p_value )
"iv_spras = SY-LANGU
IMPORTING es_valt = DATA(ls_valt) "text in IV_SPRAS
et_valt = DATA(lt_valt) ).
 
out->write( |DEFAULT LANGUAGE TEXT: { ls_valt-scrtext_l } | ).
LOOP AT lt_valt REFERENCE INTO DATA(lr_valt).
out->write( |LANGUAGE: { lr_valt->spras } TEXT: { lr_valt->scrtext_l } | ).
ENDLOOP.

f4_call

Call the search help for the element.

Parameter:

RT_RESULT Table of selected values

DATA(lt_result) = mo_toe->f4_call( is_toe = VALUE #( element = p_elem value = p_value ) iv_disponly = abap_false
CHECK lt_result IS NOT INITIAL.
p_value = lv_result[ 1 ]-value.

Try Catch Block

Errors are output via exceptions. A Try Catch block is used to catch the error messages.

TRY.
mo->toe->*
CATCH /sct/qp_cx_error INTO DATA(lo_err).
out->write( |---------- EXCEPTION: ' { lo_err->get_longtext( ) }| ).
ENDTRY.