12-11-2007 9:49 PM
Hi,
I am creating material master through new extension.
i developed custom program which populates all segments by reading data from custom tables.for this i am using INBOUND_IDOC_PROCESS function module
but at the time of idoc creation i am getting status code 60.
which means (segment cannot be identified)
Basically this idoc has parent and child segments,but my program creating all segments one after one and giving status code 60.
i am not populating SEGNUM ,PSGNUM and HLEVEL in EDIDD structure.is this causes a problem..?
if that is the case how should i approuch this..?if any body has sample code plz send immd'tly.
Thanks in advance,
sara
12-12-2007 8:19 AM
Hello Sara,
What are you trying to do? I understand you want to create an outgoing idoc?
In that case you should not use the INBOUND_IDOC_PROCESS function module.
Some sample code to generate an idoc.
Fill idoc control record - EDIDC
p_wa_edidc-mestyp = lv_mestyp.
p_wa_edidc-idoctp = lv_idoctp.
p_wa_edidc-rcvprt = lv_rcvprt.
CONCATENATE 'SAP' sy-sysid INTO p_wa_edidc-sndpor.
p_wa_edidc-sndprt = lv_sndprt.
Gets port and receiver info from BD64 distribution model tables
SELECT SINGLE sndsystem
rcvsystem
FROM tbd05
INTO (p_wa_edidc-sndprn, p_wa_edidc-rcvprn)
WHERE mestyp = lv_mestyp.
SELECT SINGLE rcvpor
FROM edp13
INTO (p_wa_edidc-rcvpor)
WHERE idoctyp = lv_idoctp.
Fill data segments --> sdata contains the content of the segments
lt_edidd-segnam = lv_segmcocd.
lt_edidd-segnum = 1.
lt_edidd-sdata = wa_header_segment.
APPEND: lt_edidd.
CLEAR: lt_edidd.
lt_edidd-segnam = lv_segmpostvar.
lt_edidd-segnum = 2.
lt_edidd-sdata = gt_idoc_period_segment.
APPEND: lt_edidd.
CLEAR: lt_edidd.
distribute idoc
CLEAR: gt_comm_idocs.
REFRESH: gt_comm_idocs.
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
master_idoc_control = wa_edidc
TABLES
communication_idoc_control = gt_comm_idocs
master_idoc_data = lt_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.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
MESSAGE e011(zgl).
ENDIF.