Copyright 2024 - BV TallVision IT

Transaction WE19 is your main tool to test both inbound and outbound Idocs, whether set up completely or not. The test tool is effectively an editor with which an Idoc can be set up and then send out or in.

Even if you have the inbound processing function module which has not been set up (no partner profile, ports, etc) the module can be tested. The transaction has a selection screen which allows you to build your Idoc, e.g. from an existing one (my favorit way) or by specifying the message type, basic type and extension. The result of WE19 is an Idoc, either inbound or outbound. Idocs that were created with the test transaction have a special status: "74: This Idoc has been generated though a test transaction". Testing Idocs is an ongoing thing, and you won't have to do the same changes again and again, the transaction will hang on to the last Idoc created...

One thing that cannot be tested with WE19 is what would happen is the Customer Distrubution Model, which would only be started when an Idoc without receiver is handed to the system. Use the following hand-made tool to accomplish this:

This is a short Idoc generation program that allows Idocs that are produced e.g. by WE19to be created without receivers, so effectively handing them to the Customer Distribution Model:

REPORT ZU_WE19_FOR_CDM LINE-SIZE 90.

parameters: p_idoc like edidc-docnum.
parameters: p_distr as checkbox default space.

data: l_control like edidc,
  i_com_control type table of edidc with header line,
  i_edid4 type table of edid4 with header line,
  idoc_data type table of edidd with header line,
  color_changer.

select single * from edidc
  into l_control
  where docnum eq p_idoc.

if sy-subrc ne 0.
  write: 'Idocnumber invalid'.
else.
  select * from edid4
    into table i_edid4
    where docnum eq p_idoc.
  refresh idoc_data.
  loop at i_edid4 where segnam(6) ne 'Z1UFIL'.
    move-corresponding i_edid4 to idoc_data.
    append idoc_data.
  endloop.

*CALL FUNCTION 'Z_UX_IDOC_FILTER_CONTROL'
*  EXPORTING
*    MASTER_IDOC_CONTROL = l_control
*  TABLES
*    MASTER_IDOC_DATA    = idoc_data
*  EXCEPTIONS
*    IDOC_DEFINITION     = 1
*    CONFIG_SETTINGS     = 2
*    OTHERS              = 3.

format color col_heading intensified off.
write: / 'Idoc:',
      p_idoc no-zero, at sy-linsz '',
    / 'Message type:',
      l_control-mestyp, at sy-linsz '',
    / 'Basic type:  ',
      l_control-idoctp, at sy-linsz '',
    / 'Extension:   ',
      l_control-cimtyp,  at sy-linsz ''.
uline.
loop at idoc_data.
  if color_changer eq 'X'.
    format color col_normal intensified on.
    clear color_changer.
  else.
    format color col_normal intensified off.
    color_changer = 'X'.
  endif.
  write: at idoc_data-hlevel
    idoc_data-segnam(20),
    25(66) idoc_data-sdata.
  new-line.
endloop.

format color off.
if p_distr eq 'X'.
  uline.
* Clear the receiver data:
clear: l_control-RCVPOR, l_control-RCVPRT, l_control-RCVPRN.

CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
  EXPORTING
    MASTER_IDOC_CONTROL                  = l_control
  TABLES
    COMMUNICATION_IDOC_CONTROL           = i_com_control
    MASTER_IDOC_DATA                     = idoc_data
  EXCEPTIONS
    ERROR_IN_IDOC_CONTROL                = 1
    ERROR_WRITING_IDOC_STATUS            = 2
    ERROR_IN_IDOC_DATA                   = 3
    SENDING_LOGICAL_SYSTEM_UNKNOWN       = 4
    OTHERS                               = 5.
IF SY-SUBRC ne 0.
  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
else.
  format color col_heading intensified off.
  write: 'The following Idocs were produced:',
    at sy-linsz ''.
    loop at i_com_control.
      if color_changer eq 'X'.
        format color col_normal intensified on.
        clear color_changer.
      else.
        format color col_normal intensified off.
        color_changer = 'X'.
      endif.
      write: / i_com_control-docnum,
        at sy-linsz ''.
    endloop.
  ENDIF.
endif.
endif.
uline.