
There are certain ways that we could use in S4 to trigger an outbound IDocs. For example, using change pointers, Output type determination. The ideal fit needs to be chosen based on the requirement. Moreover, when master data creation or delta changes have to be informed to another system change pointers are the best fit where for transactional data, output determination is widely used.
Nevertheless, what if, there is no standard process code found (WE41 / TMSG1 table) for IDoc basic type/message which is required by business requirment.
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
master_idoc_control = ls_edidc
* OBJ_TYPE = ''
* CHNUM = ''
TABLES
communication_idoc_control = lt_edidc
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
Generated IDoc
Material Document with no relationship to IDoc
Paramter interface of class method
METHOD create_relations_to_idoc.
TYPES:
BEGIN OF ty_related.
INCLUDE TYPE sibflporb.
TYPES:
relation TYPE oblreltype,
END OF ty_related.
TYPES:
ty_relation TYPE ty_related.
DATA: ls_prop TYPE sibflporb,
ls_relation TYPE ty_relation, "sibflporbt,
lwa_relate_key TYPE sibflporb,
lv_done TYPE flag,
ls_parent TYPE borident,
lv_relation TYPE binreltyp,
ls_related TYPE borident,
lv_errstr TYPE string,
lx_obl TYPE REF TO cx_obl.
*** Set material document properties : properties of Referent
ls_prop-instid = obj_no_matdoc.
ls_prop-typeid = obj_type_matdoc.
ls_prop-catid = obj_cat_matdoc.
**** set reference : Properties of reference
ls_relation-instid = obj_no_idoc.
ls_relation-typeid = obj_type_idoc.
ls_relation-catid = obj_cat_idoc.
ls_relation-relation = relation.
*** Create relationship to IDoc.
MOVE-CORRESPONDING ls_relation TO lwa_relate_key.
TRY .
* First calling method to create the Link
CALL METHOD cl_binary_relation=>create_link
EXPORTING
is_object_a = ls_prop "material document properties.
is_object_b = lwa_relate_key "IDoc properties
ip_reltype = ls_relation-relation. "IDC0 in this case
*
lv_done = 'X'.
* if the class method doesn't help, call the FM to create the link
CATCH cx_obl_model_error.
ls_parent-objkey = ls_prop-instid. "material document
ls_parent-objtype = ls_prop-typeid. "material document
ls_related-objkey = ls_relation-instid.
ls_related-objtype = ls_relation-typeid.
lv_relation = ls_relation-relation.
CALL FUNCTION 'BINARY_RELATION_CREATE'
EXPORTING
obj_rolea = ls_parent "material document
obj_roleb = ls_related "IDoc
relationtype = lv_relation "IDC0 in this case
EXCEPTIONS
no_model = 1
internal_error = 2
unknown = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
lv_done = 'X'.
ENDIF.
CATCH cx_obl INTO lx_obl.
lv_errstr = lx_obl->get_text( ).
MESSAGE lv_errstr TYPE 'S'.
ENDTRY.
ENDMETHOD.
CALL METHOD zcl_mb_document_badi=>create_relations_to_idoc
EXPORTING
obj_no_matdoc = lv_mblnr " material document number + mjahr (document year)
obj_type_matdoc = lc_obj_typ_matdoc " BUS2017
obj_cat_matdoc = lc_obj_cat " BO
obj_no_idoc = lv_idoc_num " IDoc number generated by FM Master_IDoc_distribute
obj_type_idoc = lc_obj_typ_idoc " IDOC
obj_cat_idoc = lc_obj_cat " BO
relation = lc_relation. " IDC0
Outbound IDoc number updated in relationship browser
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |