2007 Jun 28 11:49 AM
Hi all,
How can I change the status of an IDOC once I processed it?
Thanks,
2007 Jun 28 11:53 AM
Hi
Plz check this sample code:
&----
*& Form add_status
&----
Add status record to IDoc
----
form add_status.
data: l_answer(1) type c, " reply from popup
l_text1(50) type c, " text for popup
l_text2(50) type c. " text for popup
refresh i_status.
clear: i_status, l_text1, l_text2.
i_status-status = p_status.
i_status-msgty = 'E'.
i_status-msgid = 'FB'.
i_status-msgno = '000'.
i_status-msgv1 = p_text1.
i_status-msgv2 = p_text2.
i_status-msgv3 = p_text3.
i_status-msgv4 = p_text4.
append i_status.
concatenate 'IDoc' p_docnum 'has a status of' edidc-status '.'
into l_text1 separated by space.
concatenate 'Update IDoc type' edidc-idoctp '?'
into l_text2 separated by space.
call function 'POPUP_TO_CONFIRM_STEP'
exporting
defaultoption = 'N'
textline1 = l_text1
textline2 = l_text2
titel = sy-title
importing
answer = l_answer
exceptions
others = 1.
if l_answer = 'J'. " (J)a = YES
call function 'IDOC_STATUS_WRITE_TO_DATABASE'
exporting
idoc_number = p_docnum
tables
idoc_status = i_status
exceptions
idoc_foreign_lock = 1
idoc_not_found = 2
idoc_status_records_empty = 3
idoc_status_invalid = 4
db_error = 5
others = 6.
if sy-subrc <> 0.
message i000 with '** ERROR UDPATING IDOC' p_docnum.
else.
message i000 with 'IDoc' p_docnum 'update to status' p_status.
endif.
endif.
endform. " add_status
Regards
Raj
2007 Jun 28 11:54 AM
Hi,
Hi,
You can use this program RC1_IDOC_SET_STATUS to change IDoc status
(or)
thought the newer releases had a transaction to do this? this program will help you...
report zsu_idoc_status no standard page heading
message-id fb
line-size 120
line-count 90(0).
*----
Program Name : ZSU_IDOC_STATUS
Create Date : 10/17/2001
Application : FI
Logical DB : None
Description : Utility to add a status record to an existing
inbound IDoc. Changes status to 68 (Error -
no further processing).
*
Inputs : None
Functions : POPUP_TO_CONFIRM_STEP - confirm step
IDOC_STATUS_WRITE_TO_DATABASE - add status record
*
Components :
*
*
Modifications:
*----
----
Tables *
----
tables: edidc, " Control record (IDoc)
bhdgd. " Common data area batch heading routine
----
Data Declarations *
----
data: w_abort(1) type c. " abort flag
----
Internal Tables and Structures
----
status records to add
data: begin of i_status occurs 1.
include structure bdidocstat.
data: end of i_status.
----
Selection Screen Parameters
----
selection-screen skip 1.
selection-screen begin of block aa01 with frame title text-001.
parameters:
p_docnum like edidc-docnum obligatory. " IDoc number
selection-screen skip 1.
parameters:
p_text1 like bdidocstat-msgv1, " status text
p_text2 like bdidocstat-msgv2,
p_text3 like bdidocstat-msgv3,
p_text4 like bdidocstat-msgv4.
selection-screen skip 1.
parameters:
p_status like bdidocstat-status default '68'. " status value
selection-screen end of block aa01.
----
Constants
----
initialization.
perform check_authorization.
perform close_status_field.
----
Start of Selection
----
start-of-selection.
perform check_authorization. " verify authorization
perform get_idoc_info. " get IDoc control record
if not w_abort is initial. " exit if not found or outbound
message i000 with 'IDoc' p_docnum 'is invalid'.
exit.
endif.
perform add_status. " add status record
end-of-selection.
&----
*& Form check_authorization
&----
Check authorization
----
form check_authorization.
authorization check
authority-check object 'ZIDOCSTAT'
id 'ACTVT' field '01'.
if sy-subrc <> 0.
message e000(fb) with 'No authorization for IDoc *status update'.
endif.
endform. " check_authorization
&----
*& Form add_status
&----
Add status record to IDoc
----
form add_status.
data: l_answer(1) type c, " reply from popup
l_text1(50) type c, " text for popup
l_text2(50) type c. " text for popup
refresh i_status.
clear: i_status, l_text1, l_text2.
i_status-status = p_status.
i_status-msgty = 'E'.
i_status-msgid = 'FB'.
i_status-msgno = '000'.
i_status-msgv1 = p_text1.
i_status-msgv2 = p_text2.
i_status-msgv3 = p_text3.
i_status-msgv4 = p_text4.
append i_status.
concatenate 'IDoc' p_docnum 'has a status of' edidc-status '.'
into l_text1 separated by space.
concatenate 'Update IDoc type' edidc-idoctp '?'
into l_text2 separated by space.
call function 'POPUP_TO_CONFIRM_STEP'
exporting
defaultoption = 'N'
textline1 = l_text1
textline2 = l_text2
titel = sy-title
importing
answer = l_answer
exceptions
others = 1.
if l_answer = 'J'. " (J)a = YES
call function 'IDOC_STATUS_WRITE_TO_DATABASE'
exporting
idoc_number = p_docnum
tables
idoc_status = i_status
exceptions
idoc_foreign_lock = 1
idoc_not_found = 2
idoc_status_records_empty = 3
idoc_status_invalid = 4
db_error = 5
others = 6.
if sy-subrc <> 0.
message i000 with '** ERROR UDPATING IDOC' p_docnum.
else.
message i000 with 'IDoc' p_docnum 'update to status' p_status.
endif.
endif.
endform. " add_status
&----
*& Form close_status_field
&----
Close the new status value field for input; display only
----
form close_status_field.
loop at screen.
if screen-name = 'P_STATUS'.
screen-input = '0'. " output only
modify screen.
endif.
endloop.
endform. " close_status_field
&----
*& Form get_idoc_info
&----
Get IDoc information from control record
----
form get_idoc_info.
clear edidc.
select single * from edidc " get control record
where docnum = p_docnum.
if sy-subrc <> 0 or " not found
edidc-direct <> '2'. " not inbound
w_abort = 'X'.
endif.
endform. " get_idoc_info
Regards