SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Manually change status to 68 (Error) for an idoc



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Mon Feb 16, 2009 12:36 pm    Post subject: Manually change status to 68 (Error) for an idoc Reply with quote

Source from: http: /www.sapfans.com/forums/viewtopic.php?t=257678

Code:
REPORT z_set_idoc_deletion_flag.
************************************************************************

* REPORT Z_SET_IDOC_DELETION_FLAG .
*
* Description: This program sets IDOC-status to '68' (Error - no further

* processing), so it won't be processed any longer or be
* seen in the status monitor for ALE messages.
* The relevant IDOC-number(s) is an input value for this
* action.
*
* Created by:
* Created at:
*
************************************************************************


* IDOC-Status values.
CONSTANTS: c_idoc_status_delete LIKE edi_ds-status VALUE '68'.

* tables
TABLES: edidc.
DATA: t_edidc LIKE edidc OCCURS 0 WITH HEADER LINE.

DATA: total_idocs TYPE i.
DATA: c_no(1) VALUE 'N'.
DATA: c_yes(1) VALUE 'J'.
DATA: textline1 TYPE string.
DATA: answer(1) TYPE c.
DATA: numbers(2) TYPE c.

* Selection-screen
SELECTION-SCREEN: BEGIN OF BLOCK selects WITH FRAME TITLE text-002.
SELECT-OPTIONS: s_idocnr FOR edidc-docnum NO INTERVALS.
SELECTION-SCREEN: END OF BLOCK selects.

* Allow only multiple single values; no ranges in Selection-screen
TYPE-POOLS: sscr.
DATA: restrict TYPE sscr_restrict,
opt_list TYPE sscr_opt_list,
ass TYPE sscr_ass.

INITIALIZATION.

  CLEAR opt_list.
  MOVE: 'EQ' TO opt_list-name
  , 'X' TO opt_list-options-eq.
  APPEND opt_list TO restrict-opt_list_tab.

  CLEAR ass.
  MOVE: 'S' TO ass-kind
  , 'S_IDOCNR' TO ass-name
  , 'I' TO ass-sg_main
  , ' ' TO ass-sg_addy
  , 'EQ' TO ass-op_main
  .
  APPEND ass TO restrict-ass_tab.

  CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'
       EXPORTING
            restriction = restrict.



START-OF-SELECTION.

  CLEAR total_idocs.

  LOOP AT s_idocnr.

    total_idocs = total_idocs + 1.
* Check if Idoc-number exists..
    SELECT SINGLE * FROM edidc AS h WHERE h~docnum EQ s_idocnr-low.
    IF sy-dbcnt <> 0.
      MOVE s_idocnr-low TO t_edidc-docnum.
      APPEND t_edidc.
    ELSE.
      WRITE: /.
      WRITE: / 'IDoc ',s_idocnr-low, ' does not exist.'.
    ENDIF.


  ENDLOOP.

  WRITE: /.
  WRITE: /
'*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'.

  WRITE: /.


* DESCRIBE TABLE t_edidc LINES total_idocs.

  IF total_idocs > 0.
    MOVE 'You selected $1 IDoc(s ) for deletion. Continue ?'
    TO textline1.
    MOVE total_idocs TO numbers.
    REPLACE '$1' WITH numbers INTO textline1.

    CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
         EXPORTING
              defaultoption = c_no
              textline1     = textline1
              titel         = text-003
         IMPORTING
              answer        = answer.

    IF answer <> c_yes.
      EXIT.
    ENDIF.

    LOOP AT t_edidc.
* For every single existing idoc-number
      PERFORM delete_idoc USING t_edidc-docnum.

      IF sy-subrc <> 0.
WRITE: / 'An error occured while removing IDoc ', t_edidc-docnum, '
. please check the idoc-number and try again.'.
      ELSE.
        WRITE: / 'IDoc ',t_edidc-docnum, ' has been deleted.'.
      ENDIF.

    ENDLOOP.

*IF total_idocs > 0.
  ENDIF.

*---------------------------------------------------------------------*
* --> PI_IDOC_NUMBER IDOC number *
*---------------------------------------------------------------------*
FORM delete_idoc USING pi_idoc_number LIKE edidc-docnum.


  DATA: BEGIN OF t_idoc_status OCCURS 0.
          INCLUDE STRUCTURE bdidocstat.
  DATA: END OF t_idoc_status.

* Set IDOC's status to "ready for deletion".............................

  t_idoc_status-docnum = pi_idoc_number.
  t_idoc_status-status = c_idoc_status_delete.
  APPEND t_idoc_status.

  CALL FUNCTION 'IDOC_STATUS_WRITE_TO_DATABASE'
       EXPORTING
            idoc_number = pi_idoc_number
       TABLES
            idoc_status = t_idoc_status.
* exceptions
* idoc_foreign_lock = 01
* idoc_not_found = 02
* idoc_status_records_empty = 03
* idoc_status_invalid = 04
* db_error = 05
* parameter_error = 06.
* IDOC's status set.....................................................

ENDFORM.


see: program RC1_IDOC_SET_STATUS
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.