Application Development and Automation 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: 
Read only

Problem with IDOC_OUTPUT_ORDERS

Former Member
0 Likes
1,620

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.

1 ACCEPTED SOLUTION
Read only

former_member404244
Active Contributor
0 Likes
1,025

Hi,

already i have suggested to change the code,did u chek that..anyways once again do like this

LOOP AT i_msgs INTO wa_msgs WHERE arbgb EQ 'V1'.

instead of 'E0' use V1 for sales,as V1 is the application area for sales.

Regards,

Nagaraj

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.

3 REPLIES 3
Read only

former_member404244
Active Contributor
0 Likes
1,026

Hi,

already i have suggested to change the code,did u chek that..anyways once again do like this

LOOP AT i_msgs INTO wa_msgs WHERE arbgb EQ 'V1'.

instead of 'E0' use V1 for sales,as V1 is the application area for sales.

Regards,

Nagaraj

Read only

0 Likes
1,025

Hi Nagaraj,

I tried this actually, but I'm not getting anything. In my testing data I have around 130 possible entries, but all of them only have E0, no V1.

Any other thoughts on this?

Thanks again.

Read only

former_member404244
Active Contributor
0 Likes
1,025

Hi,

since u want sales order ....u have to specify the application area,then only it will recognise whetehr its related to sales or purchase.Usually we for purchase it starts with E,but for sales it is V..thats why i told u to go for V1 forsales,V2 for shipping and V3 for invoice like this.also check what are the messages u r getting in the internal table i_msgs..whether u r getting V1 or not..If u get V1 then i think u can change the code and change the test data by changing from 'E0' to 'V1' and then can check....i hope u might get some idea on this..please try my friend.

Regards,

nagaraj