Q
Problem solve Get help with specific problems with your technologies, process and projects.

How to send an inbound IDoc from SAP for tracking

Wondering how to send an inbound IDoc from SAP for tracking purposes? NetWeaver, ALE and IDoc expert Axel Angeli explains how.

For the purpose of tracking, I would like to send myself an inbound IDoc from SAP. Maybe this sounds weird, but is an idea that sounds workable. Is there any way to do this?
That's not weird at all, but a common method to achieve a lot of goals. You can create an inbound IDoc with transaction WE19 for test purposes. And you can send an IDoc to a system by calling the RFC function IDOC_INBOUND_ASYNCHRONOUS. Here is some example code:



report  zaxx_idoc_picking_create.
*
tables: likp.
*
parameters: vbeln_va type vbeln_va .
parameters: vbeln_vl type vbeln_vl .
parameters: vbelp    type vbelp    .
*
data: object like nast.
data: control_record like edidc.
data: int_edidd type table of edidd with header line.
data: own_logical_system type tbdls-logsys.
*
data: int_edi_dc type edi_dc.
data: int_edi_dd type table of edi_dd with header line.
*
perform init_control.
perform build_idoc using vbeln_vl vbelp.
*
perform idoc_send_async tables int_edidd using control_record.
*
write: / sy-subrc color col_normal,
         control_record-docnum color col_normal hotspot.
hide: control_record.
*
form idoc_send_async
  tables int_edidd structure edidd
   using x_edidc structure edidc.      .
  data: tedi_dc40 type table of edi_dc40 with header line.
  data: tedi_dd40 type table of edi_dd40 with header line.
*
  refresh tedi_dd40 .
  loop at int_edidd.
    move-corresponding int_edidd to tedi_dd40.
    append tedi_dd40 .
  endloop.
*
  call function 'IDOC_CONTROL_OUTBOUND_CONVERT'
    exporting
      control_record         = x_edidc
      port_version           = '3'
    importing
*   CONTROL_30             =
      control_40             = tedi_dc40
   exceptions
     conversion_error       = 1
     others                 = 2            .
  append tedi_dc40.

  call function 'IDOC_INBOUND_ASYNCHRONOUS'
    destination 'NONE'
    tables
      idoc_control_rec_40 = tedi_dc40[]
      idoc_data_rec_40    = tedi_dd40[].

  call function 'BAPI_TRANSACTION_COMMIT'
   destination 'NONE'
   exporting
     wait          = 'X'            .
*
  select max( docnum ) into x_edidc-docnum
    from edidc
   where idoctp eq x_edidc-idoctp
     and sndpor eq x_edidc-sndpor
     and mestyp eq x_edidc-mestyp.
*
endform.                    "idoc_send
*
form build_idoc using vbeln posnr.
  data: header type e1vpdlh.
  data: item   type e1vpdli.
*
  unpack vbeln to header-vbeln_vl.
  header-vbeln = header-vbeln_vl.
  unpack '1' to header-tanum.
  header-komue = 'X'.
  perform add_segment
    tables int_edidd
     using control_record-docnum 'E1VPDLH' header.

  item-vbeln_vl = header-vbeln_vl.
  item-posnr_vl = posnr.
  item-vbeln    = header-vbeln.
  item-posnn = '900101'.
  item-pikmg    = '222'.
  item-meins    = 'KG'.
  item-brgew    = '333'.
  item-ntgew    = '222'.
  item-gewei    = 'KG'.
  item-charg    = 'CHARGE'.
  item-matnr    = 'MAT01'.

  perform add_segment
    tables int_edidd
     using control_record-docnum 'E1VPDLI' item.

endform.                    "build_idoc
*
form add_segment
  tables int_edidd structure edidd
  using docnum segnam like edidd-segnam
        sdata.
  unpack docnum to int_edidd-docnum.
  int_edidd-segnam = segnam.
  int_edidd-sdata = sdata.
  append int_edidd.
endform.                    "add_segment
*
form init_control.
  control_record-mestyp = 'SDPICK'.
  control_record-idoctp = 'SDPIID01'.
  unpack '1' to control_record-docnum.
*
  call function 'OWN_LOGICAL_SYSTEM_GET'
    importing
      own_logical_system             = own_logical_system
    exceptions
      own_logical_system_not_defined = 1
      others                         = 0.
*
  control_record-sndprt = 'LS'.
  control_record-sndprn = own_logical_system.
  control_record-sndpor = own_logical_system.
*
  control_record-rcvprt = 'LS'.
  control_record-rcvprn = own_logical_system.
  control_record-rcvpor = space.
*
endform.                    "init_control
*
at line-selection.
  data: fdnam type string.
  get cursor field fdnam.
  case fdnam.
    when 'CONTROL_RECORD-DOCNUM'.
      if not control_record-docnum is initial.
        call function 'EDI_DOCUMENT_TREE_DISPLAY'
          exporting
            docnum              = control_record-docnum
*     OPEN                =
         exceptions
           no_idoc_found       = 1
           others              = 2
                  .
        if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        endif.

      endif.
    when 'LIKP-VBELN'.
      set parameter id 'VL' field likp-vbeln.
      call transaction 'VL02'.
  endcase.
*
This was last published in November 2005

Dig Deeper on SAP interface technologies

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchManufacturingERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchCRM

SearchContentManagement

SearchFinancialApplications

Close