Advertising:
Step-by-step for creating custom IDoc: Difference between revisions
From SAP Knowledge Base
(Created page with "category: IDoc == Schritt-für-Schritt Anleitung == * WE31 - Create segment ==== Don't forget to release the latest version. ==== WE30 - Create basic type ==== Don't forget to release the base type. ==== WE81 - Create message type ==== ==== WE82 - Assign basis type to message type ==== ==== SE80 - Funktionsgruppe erstellen ==== ==== SE37 - Create custom IDoc processing function module ==== <div class="toccolours mw-collapsible mw-collapsed">Code snippet <di...") |
No edit summary |
||
(12 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{Template:MetaDesc|This wiki article teaches how to create an IDoc in the customer namespace. All necessary steps in customizing and development are explained. Templates provided.}} | |||
[[category: IDoc]] | [[category: IDoc]] | ||
== | ==== WE31 - Create segment ==== | ||
Don't forget to release the latest version. | Don't forget to release the latest version. | ||
Line 13: | Line 12: | ||
==== WE82 - Assign basis type to message type ==== | ==== WE82 - Assign basis type to message type ==== | ||
==== SE80 - | ==== SE80 - Create function group ==== | ||
==== SE37 - Create custom IDoc processing function module ==== | ==== SE37 - Create custom IDoc processing function module ==== | ||
Copy e.g. idoc_input_fidcc2 in customer namespace | |||
<div class="toccolours mw-collapsible mw-collapsed">Code snippet | <div class="toccolours mw-collapsible mw-collapsed">Code snippet | ||
<div class="mw-collapsible-content"> | <div class="mw-collapsible-content"> | ||
Line 114: | Line 113: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</div> | </div> | ||
</div> | </div> | ||
==== WE57 - Assign function module to message and basis type ==== | |||
Note: SAP indicates that it may not be transported. You should check in every system. | |||
==== | ==== BD51 - Create entry for custom inbound fm ==== | ||
==== WE41/42 - Create process code ==== | |||
For example, if the output IDoc is not created via message control with a process code in the output (behind this function module), then the output IDoc must be created yourself. For this kind of creating you can use FM MASTER_IDOC_DISTRIBUTE. | |||
==== BD54 - | ==== BD54 - Create logical system ==== | ||
==== SM59 - | ==== SM59 - Configurate SM59 RFC Connection ==== | ||
==== WE20 - | ==== WE20 - Maintaining partner profiles ==== | ||
Latest revision as of 16:23, 31 December 2024
WE31 - Create segment
Don't forget to release the latest version.
WE30 - Create basic type
Don't forget to release the base type.
WE81 - Create message type
WE82 - Assign basis type to message type
SE80 - Create function group
SE37 - Create custom IDoc processing function module
Copy e.g. idoc_input_fidcc2 in customer namespace
Code snippet
DATA: eid TYPE bdwfretvar-wf_param VALUE 'Error_IDOCs',
pid TYPE bdwfretvar-wf_param VALUE 'Processed_IDOCs',
apo TYPE bdwfretvar-wf_param VALUE 'Appl_Objects',
c_wf_result_error TYPE bdwfap_par-result VALUE '99999',
c_wf_result_ok TYPE bdwfap_par-result VALUE '0',
xyz_struc_seg TYPE xyz_seg_structure,
error_occurend TYPE char1,
msgv1 TYPE edids-stapa1,
msgv2 TYPE edids-stapa2,
msgv3 TYPE edids-stapa3,
msgv4 TYPE edids-stapa4,
message TYPE bapiret2-message,
error_log TYPE bal_t_msg.
CONSTANTS: status_51_failed TYPE edidc-status VALUE '51',
status_53_successful TYPE edidc-status VALUE '53',
segnam_xyz TYPE String VALUE 'XYZ',
mestyp_xyz TYPE String VALUE 'XYZ'.
IF idoc_contrl-mestyp <> mestyp_xyz.
RAISE wrong_function_called.
ENDIF.
LOOP AT idoc_contrl.
error_occurend = ''.
TRY.
* Have a look for ZCL_BAL here: https://wiki.m1ch3l.de/ZCL_BAL
DATA(bal) = NEW zcl_bal(
object = zcl_bal=>cs_object-idoc
subobject = zcl_bal=>cs_subobject-idoc_xyz
extnumber = |IDoc_{ idoc_contrl-mestyp }_{ idoc_contrl-docnum }|
).
CATCH zcx_basic INTO DATA(zcx_basic).
RAISE bal_creating_failed.
ENDTRY.
LOOP AT idoc_data WHERE docnum = idoc_contrl-docnum.
CASE idoc_data-segnam.
WHEN segnam_xyz.
ENDCASE.
ENDLOOP.
IF error_occurend = abap_true. "Error
IF lines( bal->get_all_msgs_bapiret2( ) ) > 0.
bal->store_and_free( ).
ENDIF.
idoc_status-docnum = idoc_contrl-docnum.
idoc_status-status = status_51_failed.
idoc_status-msgty = 'E'.
idoc_status-msgid = 'ZMC_XYZ'.
idoc_status-msgno = '004'.
idoc_status-msgv1 = |TCODE: SLG1|.
idoc_status-msgv2 = zcl_bal=>cs_object-idoc.
idoc_status-msgv3 = zcl_bal=>cs_subobject-idoc_xyz.
idoc_status-msgv4 = |IDoc_{ idoc_contrl-mestyp }_{ idoc_contrl-docnum }|.
APPEND idoc_status.
ELSE. "OK
idoc_status-docnum = idoc_contrl-docnum.
idoc_status-status = status_53_successful.
idoc_status-msgty = 'S'.
idoc_status-msgid = 'ZMC_XYZ'.
idoc_status-msgno = '012'.
idoc_status-repid = sy-repid.
idoc_status-msgv1 = 'XYZ'.
idoc_status-msgv2 = 'XYZ'.
APPEND idoc_status.
ENDIF.
* set workflow output parameters
* Allocate IDOC numbers to Workflow output parameters
IF lv_error_occurend = abap_true.
workflow_result = c_wf_result_error.
return_variables-wf_param = eid.
return_variables-doc_number = idoc_contrl-docnum.
APPEND return_variables.
ELSE.
workflow_result = c_wf_result_ok.
return_variables-wf_param = pid.
return_variables-doc_number = idoc_contrl-docnum.
APPEND return_variables.
return_variables-wf_param = apo.
return_variables-doc_number = idoc_contrl-docnum.
APPEND return_variables.
ENDIF.
ENDLOOP.
WE57 - Assign function module to message and basis type
Note: SAP indicates that it may not be transported. You should check in every system.
BD51 - Create entry for custom inbound fm
WE41/42 - Create process code
For example, if the output IDoc is not created via message control with a process code in the output (behind this function module), then the output IDoc must be created yourself. For this kind of creating you can use FM MASTER_IDOC_DISTRIBUTE.