To continue reading for free, register below or login
To read more you must become a member of SearchSAP.com
');
// -->

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