Google Search - Blog...........

ABAP - Report Program To Modify Change Inbound Proxy Status.

The following report can be used to modify the status of an inbound proxy message on an Application System. This is something that should not be done (especially in a productive environment) but that might be useful while doing some developments and test of custom proxy implementation.
In particular, this report changes a successfully processed message into a message with an Application error, giving the ability to reprocess the same message again and verify that the code underneath the proxy is working as expected.
It plays with three tables:
• SXMSPMAST which holds the current status of the message
• SXMSPVERS which holds all the versions of the message
• SXMSPERROR which holds and entry for each message with an error


• *&---------------------------------------------------------------------*
• *& Report Z_CHANGE_STATUS
• *&
• *&---------------------------------------------------------------------*
• *&
• *& AUTHOR: Sergio Cipolla
• *&
• *&---------------------------------------------------------------------*


• REPORT z_change_status.


• PARAMETERS p_msg_id TYPE sxmspmast-msgguid OBLIGATORY.

• START-OF-SELECTION.

• DATA :
• lw_sxmspmast TYPE sxmspmast,
• lw_sxmsperror TYPE sxmsperror,
• lt_sxmspvers TYPE sxmspvers OCCURS 0,
• lw_sxmspvers TYPE sxmspvers,
• l_tstamp TYPE timestampl,
• l_oldtimestamp TYPE timestampl,
• l_answer.

• CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
• EXPORTING
• defaultoption = 'N'
• textline1 = 'This is a test report, not to be used in productive environment.'
• textline2 = 'Do you want to proceed?'
• titel = 'Warning'
• * START_COLUMN = 25
• * START_ROW = 6
• * CANCEL_DISPLAY = 'X'
• IMPORTING
• answer = l_answer.

• IF l_answer EQ 'J'.
• WRITE : / 'Action Confirmed by user ', sy-uname.
• ELSE.
• MESSAGE 'Action Canceled' TYPE 'E'.
• ENDIF.

• GET TIME STAMP FIELD l_tstamp.

• SELECT SINGLE * FROM sxmspmast
• INTO lw_sxmspmast
• WHERE msgguid = p_msg_id
• AND pid = 'RECEIVER'
• AND msgstate = '003'.

• IF sy-subrc <> 0.
• MESSAGE 'No record found in SXMSPMAST for Received message' TYPE 'E'.
• ENDIF.
• l_oldtimestamp = lw_sxmspmast-exetimest.

• WRITE : / 'Record found in SXMSPMAST for message id ', p_msg_id.

• SELECT * FROM sxmspvers
• INTO TABLE lt_sxmspvers
• WHERE msgguid = lw_sxmspmast-msgguid
• AND pid = lw_sxmspmast-pid
• AND msgstate = '3'
• AND timestamp EQ l_oldtimestamp.

• IF sy-subrc <> 0.
• MESSAGE 'No record found in SXMSPVERS' TYPE 'E'.
• ENDIF.

• WRITE : / 'Record found in SXMSPVERS for message id ', p_msg_id.
• READ TABLE lt_sxmspvers INTO lw_sxmspvers INDEX 1.
• IF sy-subrc <> 0.
• MESSAGE 'Error with SXMSPVERS' TYPE 'E'.
• ENDIF.



• ***********************************************************
• ***********************************************************
• WRITE : / 'Updating SXMSPMAST...'.
• lw_sxmspmast-msgstate = '017'.
• lw_sxmspmast-adminuser = sy-uname.
• lw_sxmspmast-exetimest = l_tstamp.
• UPDATE sxmspmast FROM lw_sxmspmast.
• IF sy-subrc <> 0.
• MESSAGE 'Error while updating SXMSPMAST' TYPE 'E'.
• ROLLBACK WORK.
• ENDIF.
• WRITE : 'Updated'.


• ***********************************************************
• ***********************************************************
• WRITE : / 'Updating SXMSPVERS...'.
• lw_sxmspvers-msgstate = '17'.
• lw_sxmspvers-timestamp = l_tstamp.
• UPDATE sxmspvers FROM lw_sxmspvers.
• IF sy-subrc <> 0.
• MESSAGE 'Error while updating SXMSPVERS' TYPE 'E'.
• ROLLBACK WORK.
• ENDIF.
• WRITE : 'Updated'.


• ***********************************************************
• ***********************************************************
• WRITE : / 'Creating entry in SXMSPERROR...'.
• lw_sxmsperror-msgguid = lw_sxmspmast-msgguid.
• lw_sxmsperror-pid = lw_sxmspmast-pid.
• lw_sxmsperror-errstat = 'E'.
• lw_sxmsperror-errcat = 'ABAP'.
• lw_sxmsperror-errcode = 'APPLICATION_ERROR'.
• lw_sxmsperror-errtxt = 'Dirty Status Change'.
• lw_sxmsperror-retry = 'M'.
• lw_sxmsperror-exetimest = l_tstamp.
• INSERT sxmsperror FROM lw_sxmsperror.
• IF sy-subrc <> 0.
• MESSAGE 'Error while updating SXMSPERROR' TYPE 'E'.
• ROLLBACK WORK.
• ENDIF.
• WRITE : 'Created'.

• ***********************************************************
• ***********************************************************
• COMMIT WORK AND WAIT.

WRITE : / 'Status update Completed'.

No comments:

Post a Comment