Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Any FM/methods to update idoc segments without changing idoc status

Former Member
0 Kudos

Hi All,

My requirement is a reprocessor program which fills up some fields in the idoc segment before posting. So, after updating the segments, the idoc status should remain as before.

Is there any function modules or methods to update idoc fields in segments without changing the idoc status?

I have tried the FMs EDI_DOCUMENT_OPEN_FOR_EDIT, EDI_CHANGE_DATA_SEGMENT and EDI_DOCUMENT_CLOSE_EDIT, but it changes the idoc status.

Thanks,

Arun Mohan

3 REPLIES 3

ThomasZloch
Active Contributor
0 Kudos

There is probably legal/auditing reasons behind that, it must be visible that IDoc content was changed compared to the original contents, so I don't think there is a way around the status change to '69' in the SAP standard.

By the way, an additional IDoc with status 70 is created as well with the original content, for the same reasons.

Thomas

PedroGuarita
Active Contributor
0 Kudos

As for FM to do this, i don't know if there are any, but i think you can go directly to the tables with the IDOC data and change them without triggering the changes in status like FM do. Still, i am not sure this is completely true, but you could give it a try. Also, i don't know if this is the best way to do it, because of those legal/audit questions mentioned by Thomas.

Here is a sample code of a program we have to change a field in a segment of WPUUMS.


*&---------------------------------------------------------------------*
*& Report  YRE00021INTPG
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT  yre00021reppg.

TABLES: edid4 ,
        edidc ,
        mean .

**********************************************************************
* Variaveis Auxiliares
**********************************************************************
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.

0 Kudos

Thanks Pedro and Thomas.

I was also thinking of directly updating the tables, but thought that this won't be the ideal solution.

Arun Mohan