Uploaded by FARES NAIT SLIMANE

IDOC DOCUMENT

advertisement
IDOC
OUTBOUND FOR OTHER SYSTEM
BD 54 CREATE Log System :
WE21 :
Own generate name
Create a TCP/IP in SM59
WE20 :
External Party :
Transaction SMGW.
BD64 ==> Create Model View puis ajout Message type.
Sender : Le systeme
Receiver : Boomi
Genere IDOC ==> Une transaction (ex : BD10 pour les matériaux).
Enhancement : https://www.youtube.com/watch?v=4CTlW1Q9vBg
External Party :
Transaction SMGW.
BD64 ==> Create Model View puis add Message type.
Sender : Le systeme
Receiver : Boomi
Genere IDOC ==> Une transaction (ex : BD10 pour les matériaux).
BD21 pour les pointeurs.
Enhancement : https://www.youtube.com/watch?v=4CTlW1Q9vBg
Table EDIDC : entête
Table EDID4 : donnée
Exemple code : rajout d'un segment d'extension
---------------------------------------*
DATA ls_zzaeoi TYPE zzaeoi.
DATA wa_elmaram TYPE e1maram.
DATA lv_revlv TYPE aeoi-revlv.
CASE segment_name.
WHEN 'E1MARAM'.
wa_elmaram = idoc_data-sdata.
SELECT * FROM aeoi INTO TABLE @DATA(lt_revlv)
WHERE objkt = @wa_elmarammatnr AND aetyp = '41'. "On va prendre le dernier
LOOP AT lt_revlv INTO DATA(ls_revlv).
ENDLOOP.
IF ls_revlv-revlv IS NOT INITIAL.
idoc_data-segnam = 'ZZAEOI'.
idoc_data-sdata = ls_revlv-revlv.
APPEND idoc_data.
endif.
Exemple code : création from scratch.
DATA ls_edidc
TYPE edidc.
DATA communication_idoc_control TYPE STANDARD TABLE OF edidc.
DATA lt_idoc_data
TYPE STANDARD TABLE OF edidd.
DATA
DATA
DATA
data
data
*
ls_idoc_data
TYPE edidd.
ls_segment_item TYPE e1bp2017_gm_item_create.
ls_segment_serial_numb TYPE E1BP2017_GM_SERIALNUMBER.
lt_objk type table of objk.
ls_objk type objk.
ls_edidc-mestyp = 'MBGMCR'.
ls_edidc-doctyp = 'MBGMCR01'.
ls_edidc-cimtyp = c_extended_type. " extended type
ls_edidc-rcvpor = 'BOOMI'. "port number of receiver
ls_edidc-rcvprn = 'BOOMI'.
*ls_edidc-rcvprn = 'LS'. "partner number of receiver
*
ls_edidc-rcvprt = 'LS'. "partner type of receiver
*ls_edidc-PARNUM = 'BOOMI'.
"Num serie
SELECT obknr, mblnr, mjahr, zeile from SER03
into table @DATA(lt_ser03)
FOR ALL ENTRIES IN @xmkpf
where mblnr = @XMKPF-MBLNR and MJAHR = @XMKPF-MJAHR.
* SELECT ifnr, IDNLF from EINA
* into table @DATA(lt_EINA)
* FOR ALL ENTRIES IN @xmseg
* where mblnr = @XMseg-MBLNR and MJAHR = @XMseg-MJAHR.
SELECT e~EBELN , e~EBELP , ei~idnlf
INTO TABLE @DATA(lt_idnlf)
FROM EKPO AS E INNER JOIN EINA AS EI
ON
E~INFNR = EI~INFNR
FOR ALL ENTRIES IN @xmseg
where EBELN = @XMseg-EBELN and EBELP = @XMseg-EBELP.
* SER03 & OBJK to read the serial number
*
*Read OBKNR from SER03 with the above link & pass the same to OBJK table here
you can get the serial number (OBJK-SERNR)
LOOP AT xmseg INTO DATA(ls_xmseg) WHERE bwart = '101'.
REFRESH lt_idoc_data.
CLEAR ls_idoc_data.
clear ls_segment_item.
ls_segment_item-material = ls_xmseg-matnr.
ls_segment_item-plant = ls_xmseg-werks.
ls_segment_item-batch = ls_xmseg-charg.
ls_segment_item-entry_qnt = ls_xmseg-erfmg.
ls_segment_item-entry_uom = ls_xmseg-erfme.
ls_segment_item-po_number = ls_xmseg-ebeln.
ls_segment_item-po_item = ls_xmseg-ebelp.
ls_segment_item-expirydate = ls_xmseg-vfdat.
ls_segment_item-stck_type = ls_xmseg-insmk.
READ TABLE lt_idnlf INTO DATA(ls_idnlf) with key ebeln =
po_number ebelp = ls_segment_item-po_item.
if sy-subrc = 0.
ls_segment_item-item_text = ls_idnlf-idnlf.
endif.
ls_idoc_data-segnam = 'E1BP2017_GM_ITEM_CREATE'.
ls_idoc_data-sdata = ls_segment_item.
APPEND ls_idoc_data TO lt_idoc_data.
MBLNR
read table lt_ser03 into data(ls_ser03) with key
MJAHR = ls_xmseg-MJAHR zeile = ls_xmseg-zeile.
ls_segment_item-
mblnr = ls_xmseg-
if sy-subrc = 0.
ls_idoc_data-segnam = 'E1BP2017_GM_SERIALNUMBER'.
select * FROM OBJK into ls_objk where obknr = ls_ser03-obknr.
ls_segment_serial_numb-serialno =
ls_objk-sernr.
ls_idoc_data-sdata = ls_segment_serial_numb.
*
APPEND ls_idoc_data TO lt_idoc_data.
add 1 TO ls_idoc_data-segnum.
ENDSELECT.
endif.
*
E1BP2017_GM_SERIALNUMBER
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
master_idoc_control
= ls_edidc
*
OBJ_TYPE
= ''
*
CHNUM
= ''
TABLES
communication_idoc_control
= communication_idoc_control
master_idoc_data
= lt_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 <> 0.
* Implement suitable error handling here
ENDIF.
ENDLOOP.
Download