2008 Jun 17 10:18 AM
HI Abaper's,
Could you explain me how write the IDOC program for outbound report from scratch,
Thanks,
Hari.
2008 Jun 17 10:20 AM
2008 Jun 17 10:36 AM
Try out the following options to have an idea on outbound idoc program:
1.Refer to RBDSEMAT program or
2.Open program for any Tcode BD10, BD12, BD14 u will find the way to deal with sending of IDOC data
In addition if you are dealing with standard idocs/ Idocs with documentaion maintained
Goto WE60 tcode ,there give ur message and basic type,u will get the documentation of the required segments.
for mandatory segments u should always pass the data...
Reward if find useful
2008 Jun 17 10:42 AM
Hi,
Steps for developing an outbound prog. are given below:
STRUCTURE OF SEGMENT 'Z1CHGSTOCK' OF INBOUND IDOC 'Z2BSTATC', WHICH IS ASSOCIATED WITH THE MESSAGE TYPE 'Z2SDBATCHSTATCHGX001'
Segment Field Size Type Description
Z2MESTYP 3 CHAR Message Type
Z2COMPCD 1 CHAR Company Code
Z2MATCD 18 CHAR Material Code
Z2WERKS 4 CHAR Plant
Z2BATCH 10 CHAR Batch
Z2QUANT 7 NUM Quantity
Z2PALLETSSCC 18 NUM Pallet SSCC
Z2OLDPQC 2 CHAR Old Quarantine Code
Z2NEWPQC 2 CHAR New Quarantine Code
Z2REASCD 2 CHAR Reason Code
Z2REFNUM 16 CHAR Reference Number
POPULATE THE CONTROL INFORMATION TO BE SENT TO THE OUTGOING IDOC IN AN INTERNAL TABLE
Local variable to hold own logical system name
data: l_logsys like tbdls-logsys.
Internal table to hold the value for sending and receiving system
data: i_model like bdi_mmodel occurs 0 with header line.
Internal table to hold sending logical system name
data: begin of i_snd_sys occurs 0.
include structure bdi_logsys.
data: end of i_snd_sys.
Call function OWN_LOGICAL_SYSTEM_GET to retrieve own logical
system name
CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
IMPORTING
OWN_LOGICAL_SYSTEM = l_logsys
EXCEPTIONS
OWN_LOGICAL_SYSTEM_NOT_DEFINED = 1
OTHERS = 2.
IF SY-SUBRC = 0.
Populate sending logical system name in i_snd_sys
i_snd_sys-logsys = l_logsys.
append i_snd_sys.
clear i_snd_sys.
Call function MMODEL_INT_VALID_GET to retrieve the
receiving logical system names
CALL FUNCTION 'MMODEL_INT_VALID_GET'
EXPORTING
MESTYP = 'Z2SDBATCHSTATCHGX001'
TABLES
SND_SYSTEM = i_snd_sys
MODEL = i_model.
if not i_model[] is initial.
Read the entry in the table i_model
loop at i_model
where rcvsystem = 'X1217TRANS'.
x_edidc-mandt = sy-mandt.
x_edidc-docrel = 46C.
x_edidc-direct = '1'.
x_edidc-rcvprt = 'LS'.
x_edidc-sndprt = 'LS'.
x_edidc-rcvprn = i_model-rcvsystem.
x_edidc-sndprn = i_model-sndsystem.
x_edidc-doctyp = 'Z2BSTATC'.
x_edidc-mestyp = 'Z2SDBATCHSTATCHGX001'.
x_edidc-sndpfc = 'LS'.
endloop.
endif.
POPULATE THE DATA INFORMATION TO BE SENT TO THE OUTGOING IDOC IN AN INTERNAL TABLE
g_z1chgstock : Its structure is same as the segment 'Z1CHGSTOCK'
Populate message type
g_z1chgstock-z2mestyp = 'CSS'.
Populate company code
g_z1chgstock-z2compcd = '1217'.
Populate material number
g_z1chgstock-z2matcd = g_viqmel-matnr.
Populate plant
g_z1chgstock-z2werks = g_viqmel-mawerk.
Populate batch
g_z1chgstock-z2batch = g_viqmel-charg.
Populate quantity
g_z1chgstock-z2quant = g_viqmel-rkmng.
Populate old primary quarantine code
g_z1chgstock-z2oldpqc = 'RE'.
Populate new primary quarantine code
g_z1chgstock-z2newpqc = 'UN'.
Populate material slip
g_z1chgstock-z2refnum = g_mat_slip.
Move all information to i_edidd
i_edidd-mandt = sy-mandt.
i_edidd-segnam = c_segnam.
i_edidd-sdata = g_z1chgstock.
append i_edidd.
clear i_edidd.
SEND IDOC
Send IDoc
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
MASTER_IDOC_CONTROL = x_edidc
TABLES
COMMUNICATION_IDOC_CONTROL = i_comm_idoc_contrl
MASTER_IDOC_DATA = i_edidd
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 = 0.
MESSAGE S000 WITH 'IDoc created'.
Close LUW
commit work.
ELSE.
MESSAGE ID W000 WITH 'Error in IDoc creation'.
ENDIF.
Regards,
Joy.
2008 Jun 17 10:44 AM
hi
check this link, will give clear understanding of OUTBOUND/INBOUND IDOC Program.
http://saptechnical.com/Tutorials/ALE/DataDistributeCustomIDOC/page1.htm
please reward points if helpful.
thanks and regards.
venu
2008 Jun 17 10:52 AM
Hi,
I am giving example program, I hope you may understand this program.
tables : kna1.
select-options : s_kunnr for kna1-kunnr.
data : it_edidc like edidc occurs 0 with header line..
data : it_edidd like edidd occurs 0 with header line.
data : it_kna1 like kna1 occurs 0 with header line.
data : wa_edidc like edidc.
data : wa_zsegidoc like zsegidoc.
start-of-selection.
select * from kna1 into table it_kna1 where kunnr in s_kunnr.
*Control record
wa_edidc-rcvprn = u2018SAPLERu2019.
wa_edidc-rcvprt = u2018LSu2019.
wa_edidc-rcvpor = u2018SAPLERu2019.
wa_edidc-direct = 1.
wa_edidc-mestyp = u2018ZMSGIDOCu2019.
wa_edidc-idoctp = u2018ZBASICIDOCu2019.
*Data record
loop at it_kna1.
move : it_kna1-kunnr to wa_zsegidoc-kunnr,
it_kna1-name1 to wa_zsegidoc-name1,
it_kna1-land1 to wa_zsegidoc-land1.
move : wa_zsegidoc to it_edidd-sdata,
zsegidoc to it_edidd.
call function u2018master_idoc_distrubutionu2019
exporting
master_idoc = wa_edidc
tables
communication = it_edidc
master_idoc = it_edidd
(decomment all exceptions)
if sy-subrc <> 0.
else.
clear it_edidc.
read table it_edidc intex 1.
write : /1 it_edidc-docnum.
endif.
____________________________________________________
Thanks,
Murali