Skip to Content
0
Former Member
Sep 11, 2007 at 07:42 AM

Problem with IDOC_OUTPUT_ORDERS

594 Views

Hello Experts!

My requirement calls for all previous sales documents where an outbound IDOC were successfully generated be resent. The steps that I did are the following:

form read_data.

  CLEAR i_nast[].

  SELECT *
  INTO CORRESPONDING FIELDS OF TABLE i_nast
  FROM       NAST AS a
  INNER JOIN VBAK AS b ON b~vbeln = a~objky
  WHERE b~vbeln  IN s_vbeln
    AND b~erdat  IN s_erdat
    AND a~kappl  EQ 'V1'
    AND a~kschl  EQ 'ZALE'
    AND a~vstat  EQ '1'.

endform.                    " read_data

*==============================================

form process_data.
  DATA v_idoc       TYPE edidc-docnum.
  DATA i_edidd      TYPE TABLE OF edidd.
  DATA wa_idoc_ctrl TYPE edidc.

  LOOP AT i_nast INTO wa_nast.
    CLEAR i_msgs[].
    CALL FUNCTION 'WFMC_PROTOCOL_GET'
      EXPORTING
        cps_nast        = wa_nast
      tables
        messages        = i_msgs
     EXCEPTIONS
       NOT_FOUND       = 1
       OTHERS          = 2.

    LOOP AT i_msgs INTO wa_msgs WHERE arbgb EQ 'E0'.
*--- Check first if there is an IDOC
      IF wa_msgs-msgv1 IS INITIAL.
        CONTINUE.
      ENDIF.

      v_idoc = wa_msgs-msgv1.

      CLEAR i_edidd[].
      CLEAR wa_idoc_ctrl.

      CALL FUNCTION 'IDOC_READ_COMPLETELY'
        EXPORTING
          document_number                = v_idoc
        IMPORTING
          IDOC_CONTROL                   = wa_idoc_ctrl
*         NUMBER_OF_DATA_RECORDS         =
*         NUMBER_OF_STATUS_RECORDS       =
        TABLES
*         INT_EDIDS                      =
          INT_EDIDD                      = i_edidd
        EXCEPTIONS
*         DOCUMENT_NOT_EXIST             = 1
*         DOCUMENT_NUMBER_INVALID        = 2
          OTHERS                         = 3.

      BREAK CAFL1EXT.
      CALL FUNCTION 'IDOC_OUTPUT_ORDERS'
        EXPORTING
          object                              = wa_nast
          control_record_in                   = wa_idoc_ctrl
*       IMPORTING
*         OBJECT_TYPE                         =
*         CONTROL_RECORD_OUT                  =
        tables
          int_edidd                           = i_edidd
        EXCEPTIONS
          ERROR_MESSAGE_RECEIVED              = 1
          DATA_NOT_RELEVANT_FOR_SENDING       = 2
          OTHERS                              = 3
                .
      IF sy-subrc <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      COMMIT WORK.

    ENDLOOP.
  ENDLOOP.

Now the problem I keep encountering is that when I finally pass the necessary data to IDOC_OUTPUT_ORDERS, it keeps checking the sales document I passed against table EKKO, which is the table for PO's. Is this the correct fm to use? If yes, is there some additional data that I should change or watch, like the message type, etc.? Points for every useful answer. Thanks in advance.