Creating questionnaires for Risk Assessment
Using the Risk Assessment module in Trade Compliance Management you can create questionnaires automatically when checking your documents with export controls . To provide the required data, implement one or more of the following BAdIs accordingly.
For sales documents use BAdI /AEB/CMP_EC_ORDER_06.
For deliveries use BAdI /AEB/CMP_EC_DLV_03.
For purchase documents use BAdI /AEB/CMP_EC_PD_03.
For service orders use BAdI /AEB/CMP_EC_SO_03.
For service transactions (S4), use BAdI /AE1/CMP_EC_ST_02.
DATA:
quest_parm TYPE REF TO /aeb/if_cmp_pb_ec_cr_quest_do,
additional_info TYPE REF TO /aeb/cl_01_string_nv,
template_id TYPE REF TO /aeb/cl_01_string_nv,
department TYPE REF TO /aeb/cl_01_string_nv,
email TYPE REF TO /aeb/cl_01_string_nv,
user TYPE REF TO /aeb/cl_01_string_nv,
org_unit TYPE string,
org_unit_nv TYPE REF TO /aeb/cl_01_string_nv.
additional_info = im_nullable_value_factory->string( 'some additional information' ).
template_id = im_nullable_value_factory->string( '000025' ).
department = im_nullable_value_factory->string( 'Department' ).
email = im_nullable_value_factory->string( '[email protected]' ).
user = im_nullable_value_factory->string( 'User Name' ).
org_unit = im_context_bc->get_org_unit( ).
org_unit_nv = im_nullable_value_factory->string( org_unit ).
quest_parm = im_data_object_factory->new_cmp_pb_ec_cr_quest_do(
im_additional_info = additional_info
im_department = department
im_email_address = email
im_template_id = template_id
im_user_name = user
im_org_unit = org_unit_nv ).
im_value->set_create_questionnaire_prm( quest_parm ).
TYPE-POOLS: szadr.
DATA:
adr_sel TYPE addr1_sel,
adr TYPE addr1_val,
vbak TYPE vbak,
ernam TYPE ernam,
user_address TYPE usaddress,
adr3_complete TYPE szadr_addr3_complete,
addr3_line TYPE szadr_addr3_line,
s_department TYPE string,
adsmtp_line TYPE szadr_adsmtp_line,
s_email TYPE string,
user_name TYPE string,
quest_parm TYPE REF TO /aeb/if_cmp_pb_ec_cr_quest_do,
additional_info TYPE REF TO /aeb/cl_01_string_nv,
template_id TYPE REF TO /aeb/cl_01_string_nv,
department TYPE REF TO /aeb/cl_01_string_nv,
email TYPE REF TO /aeb/cl_01_string_nv,
user TYPE REF TO /aeb/cl_01_string_nv,
org_unit TYPE string,
org_unit_nv TYPE REF TO /aeb/cl_01_string_nv.
vbak = im_context_bc->get_vbak( ). "needs to be replaced for other business object data
ernam = vbak-ernam.
CALL FUNCTION 'SUSR_USER_READ'
EXPORTING
user_name = ernam
IMPORTING
user_address = user_address.
CALL FUNCTION 'ADDR_PERS_COMP_GET_COMPLETE'
EXPORTING
addrnumber = user_address-addrnumber
persnumber = user_address-persnumber
IMPORTING
addr3_complete = adr3_complete.
LOOP AT adr3_complete-addr3_tab INTO addr3_line.
IF s_department IS INITIAL
AND addr3_line-data-department IS NOT INITIAL.
s_department = addr3_line-data-department.
EXIT.
ENDIF.
ENDLOOP.
LOOP AT adr3_complete-adsmtp_tab INTO adsmtp_line.
IF s_email IS INITIAL
AND adsmtp_line-adsmtp-smtp_addr IS NOT INITIAL.
s_email = adsmtp_line-adsmtp-smtp_addr.
EXIT.
ENDIF.
ENDLOOP.
additional_info = im_nullable_value_factory->string( 'some additional information' ).
template_id = im_nullable_value_factory->string( '000001' ).
department = im_nullable_value_factory->string( s_department ).
email = im_nullable_value_factory->string( s_email ).
user_name = ernam.
user = im_nullable_value_factory->string( user_name ).
org_unit = im_context_bc->get_org_unit( ).
org_unit_nv = im_nullable_value_factory->string( org_unit ).
quest_parm = im_data_object_factory->new_cmp_pb_ec_cr_quest_do(
im_additional_info = additional_info
im_department = department
im_email_address = email
im_template_id = template_id
im_user_name = user
im_org_unit = org_unit_nv ).
im_value->set_create_questionnaire_prm( quest_parm ).
If you like to have a block until the questionnaire is filled out with status ok, you just have to activate the Risk Assessment Integration in the Compliance Profile in the Compliance Engine.
Now that we created a questionnaire there might be the requirement to add the result of the questionnaire to the export controls check. Don't get confused - at the moment you request the creation of a questionnaire you also have the possibilty to get the questionnaire data.
Let's implement a very common case. The questionnaire does have the information about the end usage of the transaction. In this example we assume that there is only one critical result which holds the end usage of the transaction.
DATA:
items TYPE /aeb/if_cmp_pb_ec_item_do=>tt_ec_item_do,
curr_item TYPE REF TO /aeb/if_cmp_pb_ec_item_do,
questionnaire_do TYPE REF TO /aeb/if_cmp_pb_quest_do,
curr_crit_res TYPE REF TO /aeb/if_cmp_pb_quest_critr_do,
quest_parm TYPE REF TO /aeb/if_cmp_pb_ec_cr_quest_do,
additional_info TYPE REF TO /aeb/cl_01_string_nv,
template_id TYPE REF TO /aeb/cl_01_string_nv,
department TYPE REF TO /aeb/cl_01_string_nv,
email TYPE REF TO /aeb/cl_01_string_nv,
user TYPE REF TO /aeb/cl_01_string_nv,
initial_string_nv TYPE REF TO /aeb/cl_01_string_nv,
final_usage_from_questionnaire TYPE REF TO /aeb/cl_01_char_255_nv,
org_unit TYPE string,
org_unit_nv TYPE REF TO /aeb/cl_01_string_nv,
tmp_char255 TYPE /aeb/01_char255.
additional_info = im_nullable_value_factory->string( 'some additional information' ).
template_id = im_nullable_value_factory->string( '000008' ).
department = im_nullable_value_factory->string( 'Sales Department' ).
email = im_nullable_value_factory->string( '[email protected]' ).
user = im_nullable_value_factory->string( 'User Name' ).
org_unit = im_context_bc->get_org_unit( ).
org_unit_nv = im_nullable_value_factory->string( org_unit ).
quest_parm = im_data_object_factory->new_cmp_pb_ec_cr_quest_do(
im_additional_info = additional_info
im_department = department
im_email_address = email
im_template_id = template_id
im_org_unit = org_unit_nv
im_user_name = user ).
im_value->set_create_questionnaire_prm( quest_parm ).
IF NOT im_questionnaire_bc IS INITIAL. "this is an optional paramter, not every context allows to getQuestionaire
questionnaire_do = im_questionnaire_bc->get_questionnaire_for( im_questionnaire_template_id = template_id->v
im_reference_id_host = im_value->get_transaction_ref_id( )->v ).
READ TABLE questionnaire_do->get_critical_results( ) INTO curr_crit_res INDEX 1.
IF curr_crit_res IS NOT INITIAL.
tmp_char255 = curr_crit_res->get_identcode( ).
final_usage_from_questionnaire = im_nullable_value_factory->char_255( tmp_char255 ).
items = im_value->get_items( ).
LOOP AT items INTO curr_item.
curr_item->set_final_usages( final_usage_from_questionnaire ).
ENDLOOP.
ENDIF.
ENDIF.
Always check if the parameter "im_questionnaire_bc" is initial. Because this parameter is not passed in every context. In a context of an export control check it is available.
The next step is to get the data of the questionnaire with the method "get_questionnaire_for". You have to pass the parameter for the template ID and the referenceIdHost. Then you have the questionnaire. For our example scenario we can now read the final usage from the critical results of the questionnaire. Based on that you can set the final usage for each item.
The method getQuestionnaireFor could raise an exception if an error occured when reading the data. It is not necessary to catch this exception as it will be handled outside.
If you don't want to use this logic to pass the data of the questionnaire to the export control checks, you also have the possibility to save the data locally in your ERP System, when the questionnaire update event will be synchronized. Alos if you just like to get the data of the questionnaire without any context.
Updated 4 months ago