Skip to Content
0
Former Member
Mar 23, 2008 at 08:22 AM

could not add answers to questionnaire created by 'CRM_ORDER_MAIN'

29 Views

Dears,

I could not add answers to questionnaire via TCODE 'CRMD_BUS2000126'. These questionnaires are created by FM 'CRM_ORDER_MAIN'

with parameter 'IT_SURVEY' . Here is example:

For question how many days. when i input the answer 10 days and click submit button, the answer 10 days disappear....

But there are no such cases in other activities with survey created by 'CRMD_BUS2000126' .

Any advice ?

Here is my sample code.....

----


&

  • Build header

CLEAR GS_ORDERADM_H_COM.

  • GS_ORDERADM_H_COM-HANDLE = '0000000000'.

  • GS_ORDERADM_H_COM-GUID = '47DD69FFE3B552C2E10000000A0A0C52'.

GS_ORDERADM_H_COM-PROCESS_TYPE = 'ZSUR'.

GS_ORDERADM_H_COM-POSTING_DATE = SY-DATUM.

GS_ORDERADM_H_COM-DESCRIPTION = 'upload test by gavin'.

GS_ORDERADM_H_COM-DESCR_LANGUAGE = 'E'.

GS_ORDERADM_H_COM-CREATED_BY = 'EDS_GAVIN'.

GS_ORDERADM_H_COM-CHANGED_BY = 'EDS_GAVIN'.

GS_ORDERADM_H_COM-MODE = 'A'.

INSERT GS_ORDERADM_H_COM INTO TABLE GT_ORDERADM_H_COM.

----


&

*Build INPUT_FIELDS

CLEAR GT_INPUT_FIELDS.

CLEAR GS_INPUT_FIELD-FIELD_NAMES.

*ORDERADM_H

CLEAR GT_INPUT_FIELDS.

GS_INPUT_FIELDS-REF_KIND = ''.

  • GS_INPUT_FIELDS-REF_GUID = '47DD69FFE3B552C2E10000000A0A0C52'.

GS_INPUT_FIELDS-OBJECTNAME = 'ORDERADM_H'.

GS_INPUT_FIELDS-LOGICAL_KEY = ''.

GS_INPUT_FIELD_NAMES-FIELDNAME = 'DESCRIPTION'.

INSERT GS_INPUT_FIELD_NAMES INTO TABLE GS_INPUT_FIELDS-FIELD_NAMES.

GS_INPUT_FIELD_NAMES-FIELDNAME = 'DESCR_LANGUAGE'.

INSERT GS_INPUT_FIELD_NAMES INTO TABLE GS_INPUT_FIELDS-FIELD_NAMES.

GS_INPUT_FIELD_NAMES-FIELDNAME = 'POSTING_DATE'.

INSERT GS_INPUT_FIELD_NAMES INTO TABLE GS_INPUT_FIELDS-FIELD_NAMES.

GS_INPUT_FIELD_NAMES-FIELDNAME = 'PROCESS_TYPE'.

INSERT GS_INPUT_FIELD_NAMES INTO TABLE GS_INPUT_FIELDS-FIELD_NAMES.

INSERT GS_INPUT_FIELDS INTO TABLE GT_INPUT_FIELDS.

CLEAR GS_INPUT_FIELDS.

----


&

  • Create Activity

CALL FUNCTION 'CRM_ORDER_MAINTAIN'

EXPORTING

IT_ACTIVITY_H = GT_ACTIVITY_H_COM

  • IT_ACTIVITY_I = GT_ACTIVITY_I_COM

  • IT_SALES = GT_SALES_COM

  • IT_ORGMAN = GT_ORGMAN_COM

  • IT_CUSTOMER_H = GT_CUSTOMER_H_COM

  • GT_CUSTOMER_H_COM

  • IT_CUSTOMER_I = GT_CUSTOMER_I_COM

  • IT_TEXT = GT_TEXT_COM

  • IT_PARTNER = GT_PARTNER_COM

  • IT_STATUS = GT_STATUS_COM

  • IT_APPOINTMENT = GT_APPOINTMENT_COM

  • IT_BILLPLAN = GT_BILLPLAN_COM

CHANGING

CT_ORDERADM_H = GT_ORDERADM_H_COM

  • CT_ORDERADM_I = GT_ORDERADM_I_COM

  • CT_DOC_FLOW = GT_DOC_FLOW_COM

CT_INPUT_FIELDS = GT_INPUT_FIELDS

CV_LOG_HANDLE = GV_LOGHANDLE

EXCEPTIONS

ERROR_OCCURRED = 1

DOCUMENT_LOCKED = 2

NO_CHANGE_ALLOWED = 3

NO_AUTHORITY = 4

OTHERS = 5.

IF SY-SUBRC = 0.

CLEAR GS_ORDERADM_H_COM.

LOOP AT GT_ORDERADM_H_COM INTO GS_ORDERADM_H_COM.

INSERT GS_ORDERADM_H_COM-GUID INTO TABLE GT_OBJ_GUIDS.

  • Create survey {

----


&

  • Create Survey

  • generate GUID

data guid type guid_32.

  • call function 'GUID_CREATE'

  • IMPORTING

  • ev_guid_32 = guid.

CREATE OBJECT gr_survey_runtime

EXPORTING

i_application_id = 'CRM_SURVEY_ACTIVITY'

i_survey_id = 'Z_SURVEY_UPLOAD_TESTING'

i_survey_version = '0000000000'

i_language = 'E'

  • I_VALUEGUID = guid

i_no_value_save = 'X'

EXCEPTIONS

survey_not_found = 1

values_not_found = 2

survey_outdated = 3

OTHERS = 4.

data: E_SURVEY_XML type xstring.

DATA: lr_survey_values TYPE REF TO cl_crm_svy_values.

DATA: lv_survey_html_hex TYPE xstring,

I_PROCESSING_MODE type string.

*

----


&

*Build survey data

data: SURVEY_DATA type string.

concatenate if_crm_svy_survey_data=>gc_application_id '=' 'CRM_SURVEY_ACTIVITY' '&'

'SurveyId' '=' 'Z_SURVEY_UPLOAD_TESTING' '&'

if_crm_svy_survey_data=>gc_survey_id '=' 'Z_SURVEY_UPLOAD_TESTING' '&'

if_crm_svy_survey_data=>gc_version '=' '0000000001' '&'

'SchemaVersion' '=' '1 ' '&'

if_crm_svy_survey_data=>gc_schema_version '=' '1 ' '&'

if_crm_svy_survey_data=>gc_language '=' 'EN' '&'

'Conid' '=' '' '&'

'survey/result/q1/a1' '=' 'eeettt' '&'

'survey/result/id_47dc723d727f52c2e10000000a0a0c52/id_47dc7245727f52c2e10000000a0a0c52'

'=' '' '&'

'onInputProcessing(SUBMIT)' '=' 'Save'

into SURVEY_DATA.

  • pass data to runtime

  • clear gr_survey_runtime->gv_no_value_save.

  • CALL METHOD gr_survey_runtime->set_values

  • EXPORTING

  • i_survey_data = survey_data.

CALL METHOD gr_survey_runtime->GET_XML

IMPORTING

E_SURVEY_XML_HEX = E_SURVEY_XML

  • E_SURVEY_XML_HEX =

.

  • get the instance of the values

CALL METHOD gr_survey_runtime->get_values

IMPORTING

er_survey_values = lr_survey_values

EXCEPTIONS

transformation_failure = 1

OTHERS = 2.

data: tt type survy_t_all_values.

CALL METHOD lr_survey_values->VALUES_GET_ALL

IMPORTING

ET_ALL_VALUES = tt.

guid = gr_survey_runtime->GV_VALUEGUID.

CLEAR GS_SURVEY.

GS_SURVEY-REF_GUID = GS_ORDERADM_H_COM-GUID.

GS_SURVEY-REF_KIND = 'A'.

GS_SURVEY-SURVEYID = 'Z_SURVEY_UPLOAD_TESTING'.

GS_SURVEY-SURVEYVERSION = '0000000001'.

GS_SURVEY-VALUEGUID = guid.

GS_SURVEY-VALUEVERSION = '0000000001'.

GS_SURVEY-VALUEXML = E_SURVEY_XML.

GS_SURVEY-MODE = 'A'.

INSERT GS_SURVEY INTO TABLE GT_SURVEY.

----


&

*Build INPUT_FIELDS

CLEAR GT_INPUT_FIELDS.

refresh GT_INPUT_FIELDS.

CLEAR GS_INPUT_FIELD.

clear GS_INPUT_FIELD-FIELD_NAMES.

refresh GS_INPUT_FIELD-FIELD_NAMES.

clear GS_INPUT_FIELD_NAMES.

  • SURVEY

GS_INPUT_FIELDS-REF_KIND = 'A'.

GS_INPUT_FIELDS-REF_GUID = GS_ORDERADM_H_COM-GUID.

GS_INPUT_FIELDS-OBJECTNAME = 'SURVEY'.

GS_INPUT_FIELDS-LOGICAL_KEY = ''.

GS_INPUT_FIELD_NAMES-FIELDNAME = 'EVALUATION_INFOS'.

INSERT GS_INPUT_FIELD_NAMES INTO TABLE GS_INPUT_FIELDS-FIELD_NAMES.

GS_INPUT_FIELD_NAMES-FIELDNAME = 'SURVEYID'.

INSERT GS_INPUT_FIELD_NAMES INTO TABLE GS_INPUT_FIELDS-FIELD_NAMES.

GS_INPUT_FIELD_NAMES-FIELDNAME = 'SURVEYVERSION'.

INSERT GS_INPUT_FIELD_NAMES INTO TABLE GS_INPUT_FIELDS-FIELD_NAMES.

GS_INPUT_FIELD_NAMES-FIELDNAME = 'VALUEGUID'.

INSERT GS_INPUT_FIELD_NAMES INTO TABLE GS_INPUT_FIELDS-FIELD_NAMES.

GS_INPUT_FIELD_NAMES-FIELDNAME = 'VALUEVERSION'.

INSERT GS_INPUT_FIELD_NAMES INTO TABLE GS_INPUT_FIELDS-FIELD_NAMES.

GS_INPUT_FIELD_NAMES-FIELDNAME = 'VALUEXML'.

INSERT GS_INPUT_FIELD_NAMES INTO TABLE GS_INPUT_FIELDS-FIELD_NAMES.

INSERT GS_INPUT_FIELDS INTO TABLE GT_INPUT_FIELDS.

CLEAR GS_INPUT_FIELDS.

  • }

  • bring changed fields with values to object layer

CALL FUNCTION 'CRM_ORDER_MAINTAIN'

EXPORTING

  • it_activity_h = it_activity_h

it_survey = gt_survey

  • it_status = lt_status

CHANGING

  • ct_orderadm_i = lt_orderadm_i

ct_input_fields = Gt_input_fields

EXCEPTIONS

error_occurred = 1

document_locked = 2

no_change_allowed = 3

no_authority = 4

OTHERS = 5.

ENDLOOP.

  • Save Objects

CALL FUNCTION 'CRM_ORDER_SAVE'

EXPORTING

IT_OBJECTS_TO_SAVE = GT_OBJ_GUIDS

IMPORTING

ET_SAVED_OBJECTS = GT_SAVED_OBJECTS

EXCEPTIONS

DOCUMENT_NOT_SAVED = 1.