Mass Idoc Change Corrections

How to mass edit about 10000 idocs which have a wrong value for a particular field in a segment?

SAP did not provide any standard program to let you mass correct your idoc data.  You will have to change the documents yourself using WE02/WE05/BD87.  What you can do is to create a report for that instead of going one by one.

Here is a sample code used for changing a field in the idoc WPUUMS.

TABLES: edid4 ,
        edidc ,
        mean .

DATA: t_edidc TYPE edidc OCCURS 0 WITH HEADER LINE.
DATA: t_edid4 LIKE edid4 OCCURS 0 WITH HEADER LINE .
DATA: BEGIN OF t_docs OCCURS 0,
        docnum LIKE edidc-docnum ,
      END OF t_docs.
DATA: wa_e1wpu02 LIKE e1wpu02 .
DATA: wa_e1wpu03 LIKE e1wpu03 .
DATA: t_itedidd LIKE edi_dd40 OCCURS 0 WITH HEADER LINE ,
      t_itedidc LIKE edi_dc40 OCCURS 0 WITH HEADER LINE ,
      fw_itedidc LIKE edi_dc40 ,
      fw_itedidd LIKE edi_dc40 .
DATA: l_matnr TYPE mara-matnr,
      l_tam TYPE i.
DATA: l_idoc_number TYPE edidc-docnum.
**********************************************************************
* Ecran de selecção
**********************************************************************
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_docnum FOR  edid4-docnum ,
                s_credat FOR  edidc-credat DEFAULT sy-datum ,
                s_cretim FOR  edidc-cretim .

PARAMETER:      p_mestyp LIKE edidc-mestyp DEFAULT 'WPUUMS' ,
                p_status LIKE edidc-status DEFAULT '51' .

*SELECTION-SCREEN SKIP.
*PARAMETER:      p_ean11 TYPE mean-ean11.
SELECTION-SCREEN : END OF BLOCK b1.
**********************************************************************
AT SELECTION-SCREEN.
  IF p_status <> '51'.
    MESSAGE e001(yre) WITH 'Apenas pode modificar IDOCS com erro'.
  ENDIF.

  IF p_mestyp <> 'WPUUMS'.
    MESSAGE e001(yre) WITH 'Apenas pode lançar WPUUMS'.
  ENDIF.

*AT SELECTION-SCREEN ON p_ean11.
*  SELECT SINGLE * FROM mean WHERE
*    ean11 = p_ean11.
*  IF sy-subrc <> 0.
*    MESSAGE e001(yre) WITH 'Ean não existente'.
*  ENDIF.

START-OF-SELECTION.

  SELECT docnum INTO TABLE t_docs FROM edidc
                     WHERE status =  p_status
                     AND   mestyp =  p_mestyp
                     AND   docnum IN s_docnum
                     AND   credat IN s_credat
                     AND   cretim IN s_cretim .

  CHECK sy-subrc = 0 .

  LOOP AT t_docs.
    CLEAR : wa_e1wpu02.

    SELECT * FROM edidc INTO TABLE t_edidc
      WHERE docnum = t_docs-docnum.

    CHECK sy-subrc = 0.

    SELECT * FROM edid4 INTO TABLE t_edid4
                  WHERE docnum = t_docs-docnum AND
                        segnam = 'E1WPU02'.
    CHECK sy-subrc = 0.

    SORT t_edid4 BY segnum.
    LOOP AT t_edid4 .

      wa_e1wpu02 = t_edid4-sdata.
      WRITE wa_e1wpu02-artnr TO l_matnr NO-ZERO.
      CONDENSE l_matnr.

*      l_tam = STRLEN( l_matnr ).
*      IF l_tam <= 6.

        SELECT SINGLE ean11 INTO wa_e1wpu02-artnr FROM ytre00004 WHERE
          codcurto = l_matnr.
        IF sy-subrc = 0.
          WRITE : /1 'Código ', l_matnr, ' alterado para ', wa_e1wpu02-artnr.
        ELSE.
          WRITE : /1 'Código ', l_matnr, ' não encontrado na tabela de conversão'.
          CONTINUE.
        ENDIF.

*        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
*          EXPORTING
*            input  = p_ean11
*          IMPORTING
*            output = wa_e1wpu02-artnr.
*      ENDIF.

      UPDATE edid4 SET   sdata   = wa_e1wpu02
                   WHERE docnum  = t_edid4-docnum
                   AND   counter = t_edid4-counter
                   AND   segnum  = t_edid4-segnum .

      IF sy-subrc <> 0 .
        ROLLBACK WORK .
        WRITE: / t_edid4-docnum .
      ELSE.
        COMMIT WORK.
      ENDIF.

    ENDLOOP.

  ENDLOOP.

END-OF-SELECTION.

---

Notes

Edited Idoc data will have the status 69.  You need to process them using program:

RBDAGAIE - Reprocessing of Edited IDocs

Mass Idoc Change Corrections

ABAP Tips

Read Also

Get help for your ABAP problems
Do you have a ABAP Question?

ABAP Books
ABAP Certification, BAPI, Java, Web Programming, Smart Forms, Sapscripts Reference Books

More ABAP Tips

Main Index
SAP ERP Modules, Basis, ABAP and Other IMG Stuff

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.  The site www.erpgreat.com is in no way affiliated with SAP AG. 
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk. 
 The content on this site may not be reproduced or redistributed without the express written permission of 
www.erpgreat.com or the content authors.