Skip to Content
author's profile photo Former Member
Former Member

Survey Data creation in service

Hi all,

I have requierement to upload data for survey for transaction service Request.

But when i am trying this then it is deleting all and creating new survey .

CALL FUNCTION 'CRM_SURVEY_DATA_GET'

EXPORTING

iv_object_kind = 'A'

iv_object_guid = '46237A4EBD780B64E10000000A8D6829'

IMPORTING

ev_object_guid_header = guid_h

ev_object_guid_item = guid_i

ev_process_type = process_type

ev_item_type = item_type

ev_object_type = object_type

ev_process_mode = process_mode

et_survey_ui = it_survey_ui

EXCEPTIONS

error_occurred = 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.

  • Create survey runtime object

CLEAR: o_survey_runtime.

CREATE OBJECT o_survey_runtime

EXPORTING

i_runtime_mode = 'INBOUND'

i_application_id = 'CRM_SURVEY_SERVICE'

i_survey_id = 'Z_GOODWILL_SRVHISTORY'

i_survey_version = '0000000005' "your survey version

i_language = 'E'

i_media_type = '01'

i_valueversion = '0000000001'

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_16 =

  • EV_GUID_22 =

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 = o_survey_runtime->gv_valueversion + 1.

ENDIF.

CALL METHOD o_surveyvalues->values_get_all

IMPORTING

et_all_values = t_all_values.

CALL METHOD o_surveyvalues->values_delete

EXPORTING

i_question_id = 'q1'

i_answer_id = 'a1'

it_values = it_values.

value = 'Sample survey value / answer'.

APPEND value TO it_values.

CALL METHOD o_surveyvalues->values_set

EXPORTING

i_question_id = 'q1'

i_answer_id = 'a1'

it_values = it_values.

CALL FUNCTION 'CRM_INTLAY_SET_HEADER_GUID'

EXPORTING

iv_header_guid = '46237A4EBD780B64E10000000A8D6829'.

.

wa_survey_param-name = 'SurveyId'.

wa_survey_param-value = 'Z_GOODWILL_SRVHISTORY'.

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 = 'q15k'.

wa_survey_param-value = 'id_4b31aa4c7cce2a72e10000000a8d6829'.

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_SERVICE_PAI'

EXPORTING

i_application_id = 'CRM_SURVEY_SERVICE'

i_survey_id = 'Z_GOODWILL_SRVHISTORY'

i_survey_version = '0000000001' "your survey version

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_infos.

s_objects_to_save = '46237A4EBD780B64E10000000A8D6829'.

APPEND s_objects_to_save TO t_objects_to_save.

IF t_objects_to_save IS NOT INITIAL.

CLEAR: t_saved_objects.

  • 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 NE 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CALL FUNCTION 'CRM_SURVEY_DATA_GET'

EXPORTING

iv_object_kind = 'A'

iv_object_guid = '46237A4EBD780B64E10000000A8D6829'

IMPORTING

ev_object_guid_header = guid_h

ev_object_guid_item = guid_i

ev_process_type = process_type

ev_item_type = item_type

ev_object_type = object_type

ev_process_mode = process_mode

et_survey_ui = it_survey_ui

EXCEPTIONS

error_occurred = 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.

  • Create survey runtime object

CLEAR: o_survey_runtime.

CREATE OBJECT o_survey_runtime

EXPORTING

i_runtime_mode = 'INBOUND'

i_application_id = 'CRM_SURVEY_SERVICE'

i_survey_id = 'Z_GOODWILL_SRVHISTORY'

i_survey_version = '0000000005' "your survey version

i_language = 'E'

i_media_type = '01'

i_valueversion = '0000000001'

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_16 =

  • EV_GUID_22 =

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 = o_survey_runtime->gv_valueversion + 1.

ENDIF.

CALL METHOD o_surveyvalues->values_get_all

IMPORTING

et_all_values = t_all_values.

CALL METHOD o_surveyvalues->values_delete

EXPORTING

i_question_id = 'q1'

i_answer_id = 'a1'

it_values = it_values.

value = 'Sample survey value / answer'.

APPEND value TO it_values.

CALL METHOD o_surveyvalues->values_set

EXPORTING

i_question_id = 'q1'

i_answer_id = 'a1'

it_values = it_values.

CALL FUNCTION 'CRM_INTLAY_SET_HEADER_GUID'

EXPORTING

iv_header_guid = '46237A4EBD780B64E10000000A8D6829'.

.

wa_survey_param-name = 'SurveyId'.

wa_survey_param-value = 'Z_GOODWILL_SRVHISTORY'.

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 = 'q15k'.

wa_survey_param-value = 'id_4b31aa4c7cce2a72e10000000a8d6829'.

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_SERVICE_PAI'

EXPORTING

i_application_id = 'CRM_SURVEY_SERVICE'

i_survey_id = 'Z_GOODWILL_SRVHISTORY'

i_survey_version = '0000000001' "your survey version

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_infos.

s_objects_to_save = '46237A4EBD780B64E10000000A8D6829'.

APPEND s_objects_to_save TO t_objects_to_save.

IF t_objects_to_save IS NOT INITIAL.

CLEAR: t_saved_objects.

  • 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 NE 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.

WRITE: / 'ID:' , s_saved_objects-object_id.

*READ TABLE t_saved_objects INTO s_saved_objects INDEX 1.

*lead_id = s_saved_objects-object_id.

*activity_id = s_saved_objects-object_id.

  • Commit work

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ENDIF.

  • Commit work

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ENDIF.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Sep 28, 2011 at 06:59 AM

    Solved my own

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.