Skip to Content
0
Former Member
Nov 18, 2010 at 06:36 PM

crmd_orderadm_h table not updated with value for a field.

522 Views

Hi

I am writing a executable report to update a field ZZORDERADM_H0201 in the table "crmd_orderadm_h".

But the value does not get updated in the table!!

I wrote the below report.

lt_input_data has the OBJECT_ID and a flag( either C or W).i got it into this table from flat file.

When i see the output of CRM_ORDER_SAVE , * lt_saved_obj * is 0.

CRM_ORDER_READ gets me the structure for the object_id. Somewhere in ORDER MAINTAIN or ORDER SAVE there is a problem.

Can you please help me out and indicate what am i doing wrong!

-


REPORT----


LOOP AT lt_input_data into wa_input_data.

  • SELECT SINGLE * FROM crmd_orderadm_h

  • INTO ls_orderadm

  • WHERE object_id EQ wa_input_data-object_id.

REFRESH: lt_orderadm_h_comt,lt_input_fields,lt_field,lt_header_guid.

SELECT guid from crmd_orderadm_h

INTO table lt_header_guid

WHERE object_id EQ wa_input_data-object_id.

IF sy-subrc NE 0.

CONCATENATE 'This transaction number ' wa_input_data-object_id

'does not exist' INTO lv_var.

WRITE lv_var.

CLEAR lv_var.

CONTINUE.

ENDIF.

CALL FUNCTION 'CRM_ORDER_READ'

EXPORTING

it_header_guid = lt_header_guid

IMPORTING

ET_ORDERADM_H = lt_orderadm_h

EXCEPTIONS

document_not_found = 1

error_occurred = 2

document_locked = 3

no_change_authority = 4

no_display_authority = 5

no_change_allowed = 6

OTHERS = 7.

IF sy-subrc EQ 0.

CLEAR :ls_orderadm_h.

LOOP AT lt_orderadm_h INTO ls_orderadm_h.

if ls_orderadm_h-object_id is INITIAL.

continue.

endif.

IF wa_input_data-ZZORDERADM_H0201 EQ 'C'.

  • ls_orderadm_h-ZZORDERADM_H0201 = 'CLE'.*

ELSEIF wa_input_data-ZZORDERADM_H0201 EQ 'W'.

ls_orderadm_h-ZZORDERADM_H0201 = 'WAS'.

ENDIF.

MOVE-CORRESPONDING ls_orderadm_h TO ls_orderadm_h_comt.

APPEND ls_orderadm_h_comt TO lt_orderadm_h_comt.

  • Prepare the input fields.

ls_field-fieldname = 'ZZORDERADM_H0201'.

INSERT ls_field INTO TABLE lt_field.

READ TABLE lt_header_guid into ls_header_guid INDEX 1.

CLEAR: ls_input_fields.

ls_input_fields-ref_guid = ls_header_guid.

ls_input_fields-objectname = 'ORDERADM_H'.

ls_input_fields-field_names = lt_field.

INSERT ls_input_fields INTO TABLE lt_input_fields.

CLEAR : ls_orderadm_h_comt.

ENDLOOP.

IF lt_orderadm_h_comt IS NOT INITIAL.

CALL FUNCTION 'CRM_ORDER_MAINTAIN'

CHANGING

CT_ORDERADM_H = lt_orderadm_h_comt

ct_input_fields = lt_input_fields

EXCEPTIONS

error_occurred = 1

document_locked = 2

no_change_allowed = 3

no_authority = 4

OTHERS = 5.

  • IF sy-subrc NE 0.

  • WRITE /.

  • WRITE 'Data is not valid'.

  • CONTINUE.

  • ENDIF.

INSERT ls_header_guid into table lt_objects_to_save.

IF lt_objects_to_save is not INITIAL.

CALL FUNCTION 'CRM_ORDER_SAVE'

EXPORTING

it_objects_to_save = lt_objects_to_save

IMPORTING

et_saved_objects = lt_saved_obj

et_exception = lt_exception

et_objects_not_saved = lt_not_saved

EXCEPTIONS

document_not_saved = 1

OTHERS = 2.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

DESCRIBE TABLE lt_saved_obj LINES lv_total.

end loop.