on 01-07-2009 5:38 AM
Hi Experts,
Questionnaires are configured in SAP CRM and linked to a transaction type in CRM.
I need to check where / in which table, the details of the questionnaire are stored in SAP CRM?
Is there any unique ID that gets generated for every questionnaire that is configured in SAP CRM( Could be an ID for a questionnaire or an ID for each question in a Questionnaire)?
In case the user answers the questions, where are the answers stored?
Any help regarding the table details would be highly appreciated.
Regards,
Saumya
Hi Saumya,
You are right.there is a unique ID generated for every question and answer of the questionnaire.
You will get those ID's in the below table:
CRM_SVY_RE_QUEST---for question ID's
CRM_SVY_RE_ANSW---for Answer ID's.
Regards,
PePe
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Yes,these tables can get the answers entered by the user for the questionnaire.
First from CRM_ORDER_READ ---> ET_SURVEY...u can get the answer id for a particular opportunity.
Then from the tables u can pass this values and match it with resp answer id and u will get the exact answer.
Regards,
PePe
Thanks PePe and Robert for the wonderful help!
Rewarded your contribution by giving points
Regards,
Saumya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi. You are right. Data are stored in the certain table but I forgot which. Also each questionary gets unique ID and also each question of questionary gets unique ID. he relationships between opportunity questionary and questions are stored in different tables.
We did quite some time ago the function that reads questionary of lead which is similar to opportunity. This function then fills questionary. You can take a look at the code to get pointers. The best approach would be to set breakpoint in opportunity and debug the process.
Code of our function:
*&---------------------------------------------------------------------*
*& Report Z_TEST_LEAD_SURVEY
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT z_test_lead_survey.
DATA: o_survey_runtime TYPE REF TO cl_crm_svy_runtime,
o_surveyvalues TYPE REF TO cl_crm_svy_values,
t_application_params TYPE crm_svy_api_parameter_t,
t_all_values TYPE survy_t_all_values.
DATA: survey_data TYPE string,
valuexml TYPE string,
valuexml_hex TYPE xstring.
DATA: lead_guid TYPE guid_32,
lead_id TYPE crmt_object_id,
valueguid TYPE crm_svy_db_sv_guid,
valueversion TYPE crm_svy_db_sv_vers.
DATA: s_lead_h TYPE crmt_lead_h_com,
t_lead_h TYPE crmt_lead_h_comt,
s_orderadm_h TYPE crmt_orderadm_h_com,
t_orderadm_h TYPE crmt_orderadm_h_comt,
s_field_names TYPE crmt_input_field_names,
t_field_names TYPE crmt_input_field_names_tab,
s_input_fields TYPE crmt_input_field,
t_input_fields TYPE crmt_input_field_tab,
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,
s_survey TYPE crmt_survey_com,
t_survey TYPE crmt_survey_comt.
**********************************************************************
* CREATE LEAD
**********************************************************************
* Fill required structures
s_orderadm_h-object_id = 'BUS2000108'.
s_orderadm_h-process_type = 'ZLEA'.
s_orderadm_h-description = 'TEST LEAD - DENEB'.
APPEND s_orderadm_h TO t_orderadm_h.
s_input_fields-ref_kind = 'A'.
s_input_fields-objectname = 'LEAD_H'.
APPEND s_input_fields TO t_input_fields.
s_input_fields-ref_kind = 'A'.
s_input_fields-objectname = 'ORDERADM_H'.
*Subtable FIELD_NAMES
s_field_names-fieldname = 'DESCRIPTION'.
APPEND s_field_names TO t_field_names.
*/Subtable FIELD_NAMES
s_input_fields-field_names = t_field_names.
APPEND s_input_fields TO t_input_fields.
s_lead_h-lead_type = '0007'.
APPEND s_lead_h TO t_lead_h.
* Create lead
CALL FUNCTION 'CRM_ORDER_MAINTAIN_MULTI_OW'
EXPORTING
it_lead_h = t_lead_h
iv_collect_exceptions = ''
CHANGING
ct_orderadm_h = t_orderadm_h
ct_input_fields = t_input_fields
EXCEPTIONS
error_occurred = 1
document_locked = 2
no_change_allowed = 3
no_authority = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Get GUID of created LEAD for later saving
READ TABLE t_orderadm_h INTO s_orderadm_h INDEX 1.
s_objects_to_save = lead_guid = s_orderadm_h-guid.
APPEND s_objects_to_save TO t_objects_to_save.
**********************************************************************
* CREATE SURVEY SURVEY
**********************************************************************
* Create survey answers input string
CONCATENATE 'svyApplicationId=CRM_SURVEY_LEAD'
'&SurveyId=ZNEW_LEAD_FORM_SISVSAP'
'&svySurveyId=ZNEW_LEAD_FORM_SISVSAP'
'&svyVersion=0000000001'
'&SchemaVersion=1'
'&svySchemaVersion=1'
'&svyLanguage=EN'
'&conid='
'&survey/result/address/name1=1'
'&survey/result/address/street=2'
'&survey/result/address/postalcode=3'
'&survey/result/address/city=4'
'&survey/result/address/region=5'
'&survey/result/address/phone=6'
'&survey/result/address/fax=7'
'&survey/result/address/email=8'
'&survey/result/address/uri=9'
'&survey/result/bankdetails/bankcountry=10'
'&survey/result/bankdetails/bankkey=11'
'&survey/result/bankdetails/bankaccount=12'
'&survey/result/id_ddb164f9ec715ef1acf9001b7840a5e4/id_ddbc6515052e00f1acf9001b7840a5e4=13'
'&survey/result/id_ddb164f9ec715ef1acf9001b7840a5e4/id_ddbc65a01ff500f1acf9001b7840a5e4=14'
'&survey/result/id_ddb164f9ec715ef1acf9001b7840a5e4/id_ddbc66812b7273f1acf9001b7840a5e4=id_ddbc66872638c2f1acf9001b7840a5e4'
'&survey/result/id_ddb164f9ec715ef1acf9001b7840a5e4/id_ddb165018f99b4f1acf9001b7840a5e4=15'
'&survey/result/id_ddb164f9ec715ef1acf9001b7840a5e4/id_ddb1682cf66426f1acf9001b7840a5e4=16'
'&survey/result/id_ddb16650885482f1acf9001b7840a5e4/id_ddb1666f95b6daf1acf9001b7840a5e4=17'
'&survey/result/id_ddb16650885482f1acf9001b7840a5e4/id_ddb1671399e9c2f1acf9001b7840a5e4=18'
'&survey/result/id_ddb16650885482f1acf9001b7840a5e4/id_ddb166a3505462f1acf9001b7840a5e4=19'
'&survey/result/id_ddb16650885482f1acf9001b7840a5e4/id_ddb166bcdef443f1acf9001b7840a5e4=20'
'&survey/result/id_ddb16650885482f1acf9001b7840a5e4/id_ddb166d6b77e3ff1acf9001b7840a5e4=21'
'&survey/result/id_ddb16650885482f1acf9001b7840a5e4/id_ddbd38c6829df9f1acf9001b7840a5e4=22'
'&onInputProcessing(SUBMIT)=Save'
INTO survey_data.
* Create survey runtime object
CREATE OBJECT o_survey_runtime
EXPORTING
i_runtime_mode = 'INBOUND'
i_application_id = 'CRM_SURVEY_LEAD'
i_survey_id = 'ZNEW_LEAD_FORM_SISVSAP'
i_survey_version = '0000000000'
i_language = 'E'
i_media_type = '01'
i_valueversion = '0000000000'
i_no_value_save = ''.
* Save survey answers
o_survey_runtime->set_values( EXPORTING i_survey_data = survey_data
IMPORTING e_valueguid = valueguid
e_valueversion = valueversion
et_application_params = t_application_params ).
* Get survey values object
o_survey_runtime->get_values( IMPORTING er_survey_values = o_surveyvalues ).
* Get XML values - filled out in previous call
o_surveyvalues->get_internal_values_xml( IMPORTING e_internal_values_xml = valuexml
e_internal_values_xml_hex = valuexml_hex ).
**********************************************************************
* LINK SURVEY WITH LEAD
**********************************************************************
* Fill required structures
CLEAR t_input_fields.
s_input_fields-ref_guid = lead_guid.
s_input_fields-ref_kind = 'A'.
s_input_fields-objectname = 'SURVEY'.
*Subtable FIELD_NAMES
CLEAR: s_field_names, t_field_names.
s_field_names-fieldname = 'EVALUATION_INFOS'.
APPEND s_field_names TO t_field_names.
s_field_names-fieldname = 'SURVEYID'.
APPEND s_field_names TO t_field_names.
s_field_names-fieldname = 'SURVEYVERSION'.
APPEND s_field_names TO t_field_names.
s_field_names-fieldname = 'VALUEGUID'.
APPEND s_field_names TO t_field_names.
s_field_names-fieldname = 'VALUEVERSION'.
APPEND s_field_names TO t_field_names.
s_field_names-fieldname = 'VALUEXML'.
APPEND s_field_names TO t_field_names.
*/Subtable FIELD_NAMES
s_input_fields-field_names = t_field_names.
APPEND s_input_fields TO t_input_fields.
s_survey-ref_guid = lead_guid.
s_survey-ref_kind = 'A'.
s_survey-surveyid = 'ZNEW_LEAD_FORM_SISVSAP'.
s_survey-surveyversion = '0000000003'.
s_survey-valueguid = valueguid.
s_survey-valueversion = valueversion.
s_survey-valuexml = valuexml_hex.
s_survey-mode = 'A'.
APPEND s_survey TO t_survey.
* Link survey to lead
CALL FUNCTION 'CRM_ORDER_MAINTAIN_MULTI_OW'
EXPORTING
it_survey = t_survey
iv_collect_exceptions = ''
CHANGING
ct_orderadm_h = t_orderadm_h
ct_input_fields = t_input_fields
EXCEPTIONS
error_occurred = 1
document_locked = 2
no_change_allowed = 3
no_authority = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Save lead
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.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
READ TABLE t_saved_objects INTO s_saved_objects INDEX 1.
lead_id = s_saved_objects-object_id.
* Commit work
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
**********************************************************************
* WRITE GUIDs
**********************************************************************
WRITE: 'LEAD GUID:', lead_guid, /,
'LEAD ID:', lead_id, /,
'VALUE GUID:', valueguid, /.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Robert,
Thanks for your very helpful response!
It would be great if you could also provide me with the database table names.
Actually my requirement is related to data migration, where I need to fetch / store data of opportunity survey questionnaire from / to the database tables.
Else, can we use this approach to do the same?
Please suggest...
Regards,
Saumya
Can't give you the detailed answer right now because I have to look deaper in to this. But the quick pointers:
- use function CRM_SURVEY_DATA_GET to get data
- use program CRM_ORDER_READ to get the fealing how the objects are connected. You will see connection between opportunity and questionary in ET_SURVEY.
Edited by: Robert Kunstelj on Jan 7, 2009 9:13 AM
Dear Robert Kunstelj,
Can you please provide how did you * Create survey answers input string.
Regards,
Sateesh Uppada
Thank you for your inputs Robert. I am checking below tables for Question and Answer GUID's but I didnt find proper GUID'S. If possible can you please let me know the table Question & Answer id's (GUID's) .
SURVEY QUESTIONS:
Table CRM_SVY_RE_QUEST
SURVEY ANSWERS:
Table CRM_SVY_RE_ANSW
SURVEY QUESTIONS AND ANSWERS ID:
Table CRM_SVY_DB_SV
User | Count |
---|---|
8 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.