分类: 系统运维
2012-12-12 14:45:39
CRM_SVY_DB_SV and CRM_SVY_DB_SVS. These tables contain the actual survey response but encrypted in XML format. So you will find VALUEGUID in the CRMD_SURVEY table that will join to the VALUEGUID in the above 2 tables.
In this table crmc_svy_det crmc_svy_act
CRM_SVY_DB_SD - survey title
CRM_SVY_RE_QUEST - survey questions and descriptions
CRM_SVY_RE_ANSW - survey answers and descriptions
1. You can use CRM_SURVEY_DATA_GET FM and pass the GUID for the transaction and get the survey data from et_survey_ui table.
2. Read the Survey data from CRM_SVY_SURVEY_READ FM.
3. Create the Object for an class cl_crm_svy_values and pass the XML and HXML.
4. Call question_ids_get, answer_ids_get and values_get method you can get the Value.
Creation for Questionnaire for Leads
Step 1)
Go to IMG – SPRO – CRM- Transaction – Setting For Leads –
Questionnaire for Leads- Define Questionnaire-
Here you need create you Questions and Answers…..
Step 2)
Go to IMG – SPRO – CRM- Transaction – Setting For Leads –
Questionnaire for Leads- Define Determination for
Questionnaire
Here You Need to Choose New Entries.
2. Enter an ID and a description for determination.
3. Choose the transaction type and item category.
4. Enter a validity period for determination.
5. Choose the survey for which you wish to carry out
determination.
6. Set the indicators Mandatory and Active to specify
whether the survey should be completed or whether the
determination rule should be active. Remember that the
Mandatory indicator is only evaluated when the document is
saved. When saving the document, the system checks whether
a survey has been found with the Mandatory indicator, but
has not yet been filled out. In this case, the system
creates an error message.
7. Save your entries.
Step 3)
Go to IMG – SPRO – CRM- Transaction – Setting For Leads –
Questionnaire for Leads- Assign Qualification Levels to
Questionnaire
Here You Need to Choose New Entries and
select Your Questionnaire and maintain Qualification levels
and save
Step4)
Next Go To Lead Transaction and Assign Your Questionnaire,
Then You will get in Business Transaction Creation
For More Details go to Help. sap there you can find some
notes and Best Practices
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(IV_GUID) TYPE CRMT_OBJECT_GUID OPTIONAL
*" VALUE(IV_SURVEYID) TYPE CRM_SVY_DB_SID DEFAULT
*" 'ZANZ_FBM_OPR_CHK_LS'
*"----------------------------------------------------------------------
DATA: s_objects_to_save TYPE crmt_object_guid,
t_objects_to_save TYPE crmt_object_guid_tab,
s_saved_objects TYPE crmt_return_objects_struc,
t_saved_objects TYPE crmt_return_objects.
***** survey**********
DATA: survey_value_guid TYPE guid_32,
lt_values TYPE crm_svy_api_string_t,
ls_value TYPE string .
DATA: et_survey_param TYPE crm_svy_api_parameter_t,
it_survey_param TYPE crm_svy_api_parameter_t,
wa_survey_param TYPE crm_svy_api_parameter,
cs_evaluation_info TYPE crm_svy_re_tar_obj.
DATA: o_survey_runtime TYPE REF TO cl_crm_svy_runtime,
o_surveyvalues TYPE REF TO cl_crm_svy_values.
DATA: lv_process_type TYPE crmt_process_type,
it_survey_ui TYPE crmt_survey_ui_tab,
is_survey_ui TYPE crmt_survey_ui.
DATA: lv_applicationid TYPE crm_svy_db_appl_id VALUE 'CRM_SURVEY_ACTIVITY' .
****** end survey *****
*******************************************************************************
CHECK iv_guid IS NOT INITIAL .
CALL FUNCTION 'CRM_SURVEY_DATA_GET'
EXPORTING
iv_object_kind = 'A'
iv_object_guid = iv_guid
IMPORTING
ev_process_type = lv_process_type
et_survey_ui = it_survey_ui
EXCEPTIONS
error_occurred = 1
OTHERS = 2.
CLEAR is_survey_ui .
READ TABLE it_survey_ui INTO is_survey_ui WITH KEY surveyid = iv_surveyid .
CHECK sy-subrc = 0 .
* Create survey runtime object
CLEAR: o_survey_runtime.
CREATE OBJECT o_survey_runtime
EXPORTING
i_runtime_mode = 'INBOUND'
i_application_id = lv_applicationid
i_survey_id = is_survey_ui-surveyid
i_survey_version = is_survey_ui-surveyversion
i_language = 'E'
i_media_type = '01'
i_valueguid = is_survey_ui-valueguid
i_valueversion = is_survey_ui-valueversion
i_no_value_save = ''.
o_survey_runtime->get_values( IMPORTING er_survey_values = o_surveyvalues ).
IF o_survey_runtime->gv_valueguid IS INITIAL.
CALL FUNCTION 'GUID_CREATE'
IMPORTING
ev_guid_32 = survey_value_guid.
o_survey_runtime->gv_valueguid = survey_value_guid.
ENDIF.
IF o_survey_runtime->gv_valueversion IS INITIAL.
o_survey_runtime->gv_valueversion = '0000000001' .
ENDIF.
CALL METHOD o_surveyvalues->values_get
EXPORTING
i_question_id = 'id_5054f5f348ff70e0e10080000a780d18'
i_answer_id = 'id_5054f5fc48ff70e0e10080000a780d18'
IMPORTING
et_values = lt_values.
CALL METHOD o_surveyvalues->values_delete
EXPORTING
i_question_id = 'q1'
i_answer_id = 'a1'
it_values = lt_values.
ls_value = 'Nama tamu nih'.
APPEND ls_value TO lt_values.
CALL METHOD o_surveyvalues->values_set
EXPORTING
i_question_id = 'q1'
i_answer_id = 'a1'
it_values = lt_values.
CALL FUNCTION 'CRM_INTLAY_SET_HEADER_GUID'
EXPORTING
iv_header_guid = iv_guid.
wa_survey_param-name = 'svyApplicationId'.
wa_survey_param-value = lv_applicationid.
APPEND wa_survey_param TO it_survey_param.
wa_survey_param-name = 'SurveyId'.
wa_survey_param-value = is_survey_ui-surveyid.
APPEND wa_survey_param TO it_survey_param.
wa_survey_param-name = 'svySurveyId'.
wa_survey_param-value = is_survey_ui-surveyid.
APPEND wa_survey_param TO it_survey_param.
wa_survey_param-name = 'svyVersion'.
wa_survey_param-value = is_survey_ui-surveyversion.
APPEND wa_survey_param TO it_survey_param.
wa_survey_param-name = 'SchemaVersion'.
wa_survey_param-value = '1'.
APPEND wa_survey_param TO it_survey_param.
wa_survey_param-name = 'svySchemaVersion'.
wa_survey_param-value = '1'.
APPEND wa_survey_param TO it_survey_param.
wa_survey_param-name = 'svyLanguage'.
wa_survey_param-value = 'EN'.
APPEND wa_survey_param TO it_survey_param.
wa_survey_param-name = 'conid'.
wa_survey_param-value = ''.
APPEND wa_survey_param TO it_survey_param.
wa_survey_param-name = 'onInputProcessing(SUBMIT)'.
wa_survey_param-value = 'Save'.
APPEND wa_survey_param TO it_survey_param.
CALL FUNCTION 'CRM_SVY_ACTIVITY_PAI'
EXPORTING
i_application_id = lv_applicationid
i_survey_id = is_survey_ui-surveyid
i_survey_version = is_survey_ui-surveyversion
i_language = 'E'
i_valueguid = o_survey_runtime->gv_valueguid
i_valueversion = o_survey_runtime->gv_valueversion
ir_survey_values = o_surveyvalues
it_survey_params = it_survey_param
IMPORTING
et_survey_params = et_survey_param
CHANGING
cs_evaluation_infos = cs_evaluation_info.
* Save
s_objects_to_save = iv_guid.
APPEND s_objects_to_save TO t_objects_to_save.
CALL FUNCTION 'CRM_ORDER_SAVE'
EXPORTING
it_objects_to_save = t_objects_to_save
IMPORTING
et_saved_objects = t_saved_objects
EXCEPTIONS
document_not_saved = 1
OTHERS = 2.
* Commit work
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.