2012 Nov 02 10:01 AM
Hello Experts,
I am being able to update IDOC segments using the following FMs:
The problem is that two IDOCs are being generated, one for the modified idoc (status 53) and one for the original (status 70).
I want only the modified IDOC being generated, is there any solutions? Below is my code:
CALL FUNCTION 'EDI_DOCUMENT_OPEN_FOR_EDIT'
EXPORTING
document_number = idoc_docnum
IMPORTING
idoc_control = ls_edidc
TABLES
idoc_data = lt_idoc_data
EXCEPTIONS
document_foreign_lock = 1
document_not_exist = 2
document_not_open = 3
status_is_unable_for_changing = 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.
READ TABLE lt_idoc_data ASSIGNING <fs_data>
WITH KEY docnum = idoc_docnum
segnam = c_e1fikpf
BINARY SEARCH.
IF sy-subrc EQ 0.
ls_e1fikpf = <fs_data>-sdata.
IF ls_e1fikpf-bukrs IS INITIAL .
ls_e1fikpf-bukrs = ls_e1fikpf-xref2_hd(3).
ENDIF.
<fs_data>-sdata = ls_e1fikpf.
CALL FUNCTION 'EDI_CHANGE_DATA_SEGMENT'
EXPORTING
idoc_changed_data_record = <fs_data>
EXCEPTIONS
idoc_not_open = 1
data_record_not_exist = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'EDI_DOCUMENT_CLOSE_EDIT'
EXPORTING
document_number = idoc_docnum
do_commit = 'X'
EXCEPTIONS
idoc_not_open = 1
db_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Hello Experts,
I am being able to update IDOC segments using the following FMs:
The problem is that two IDOCs are being generated, one for the modified idoc (status 53) and one for the original (status 70).
I want only the modified IDOC being generated, is there any solutions? Below is my code:
CALL FUNCTION 'EDI_DOCUMENT_OPEN_FOR_EDIT'
EXPORTING
document_number = idoc_docnum
IMPORTING
idoc_control = ls_edidc
TABLES
idoc_data = lt_idoc_data
EXCEPTIONS
document_foreign_lock = 1
document_not_exist = 2
document_not_open = 3
status_is_unable_for_changing = 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.
READ TABLE lt_idoc_data ASSIGNING <fs_data>
WITH KEY docnum = idoc_docnum
segnam = c_e1fikpf
BINARY SEARCH.
IF sy-subrc EQ 0.
ls_e1fikpf = <fs_data>-sdata.
IF ls_e1fikpf-bukrs IS INITIAL .
ls_e1fikpf-bukrs = ls_e1fikpf-xref2_hd(3).
ENDIF.
<fs_data>-sdata = ls_e1fikpf.
CALL FUNCTION 'EDI_CHANGE_DATA_SEGMENT'
EXPORTING
idoc_changed_data_record = <fs_data>
EXCEPTIONS
idoc_not_open = 1
data_record_not_exist = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'EDI_DOCUMENT_CLOSE_EDIT'
EXPORTING
document_number = idoc_docnum
do_commit = 'X'
EXCEPTIONS
idoc_not_open = 1
db_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
2012 Nov 02 12:15 PM
This is standard behaviour, that you cannot - or at least should not - change. As you noted, the IDoc in status 70 contains the original data before modification, and this is supposed to be saved e.g. for auditing purposes.
Thomas
2013 Feb 22 2:44 PM