adesso orange🍊Stellenangebote:
Software Engineer Trainee · Senior
| (Senior) Cloud Software Engineer BTP
(Senior) Consultant Technologie · Consultant ABAP
Werkstudent Softwareentwicklung · Fiori / UI5 · Consulting · Application Management
Muster für ZIDoc EingangsverarbeitungsFuBa
Aus SAP Wiki ツ
Version vom 11. September 2021, 18:35 Uhr von M1ch3lde (Diskussion | Beiträge) (M1ch3lde verschob die Seite Muster für ZIDoc VerarbeitungsFuBa nach Muster für ZIDoc EingangsverarbeitungsFuBa)
Kopie eines Standard FuBas
Kopie von "idoc_input_fidcc2" erstellen.
Codeschnipsel
Neu hinzugefügte Variante
DATA: lv_eid TYPE bdwfretvar-wf_param VALUE 'Error_IDOCs',
lv_pid TYPE bdwfretvar-wf_param VALUE 'Processed_IDOCs',
lv_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',
ls_xyz_struc_seg TYPE xyz_seg_structure,
lv_error_occurend TYPE char1,
lv_msgv1 TYPE edids-stapa1,
lv_msgv2 TYPE edids-stapa2,
lv_msgv3 TYPE edids-stapa3,
lv_msgv4 TYPE edids-stapa4,
lv_message TYPE bapiret2-message,
lt_error_log TYPE bal_t_msg.
CONSTANTS: lc_status_51_failed TYPE edidc-status VALUE '51',
lc_status_53_successful TYPE edidc-status VALUE '53',
lc_segnam_xyz TYPE String VALUE 'XYZ',
lc_mestyp_xyz TYPE String VALUE 'XYZ'.
IF idoc_contrl-mestyp <> lc_mestyp_xyz.
RAISE wrong_function_called.
ENDIF.
LOOP AT idoc_contrl.
lv_error_occurend = ''.
TRY.
* Have a look for ZCL_BAL here: https://wiki.m1ch3l.de/ZCL_BAL
DATA(lo_bal) = NEW zcl_bal(
iv_object = zcl_bal=>cs_object-idoc
iv_subobject = zcl_bal=>cs_subobject-idoc_xyz
iv_extnumber = |IDoc_{ idoc_contrl-mestyp }_{ idoc_contrl-docnum }|
).
CATCH zcx_basic INTO DATA(lo_zcx_basic).
RAISE bal_creating_failed.
ENDTRY.
LOOP AT idoc_data WHERE docnum = idoc_contrl-docnum.
CASE idoc_data-segnam.
WHEN lc_segnam_xyz.
ENDCASE.
ENDLOOP.
IF lv_error_occurend = abap_true. "Error
IF lines( lo_bal->get_all_msgs_bapiret2( ) ) > 0.
lo_bal->store_and_free( ).
ENDIF.
idoc_status-docnum = idoc_contrl-docnum.
idoc_status-status = lc_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_zgen_wostate.
idoc_status-msgv4 = |IDoc_{ idoc_contrl-mestyp }_{ idoc_contrl-docnum }|.
APPEND idoc_status.
ELSE. "OK
idoc_status-docnum = idoc_contrl-docnum.
idoc_status-status = lc_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 = lv_eid.
return_variables-doc_number = idoc_contrl-docnum.
APPEND return_variables.
ELSE.
workflow_result = c_wf_result_ok.
return_variables-wf_param = lv_pid.
return_variables-doc_number = idoc_contrl-docnum.
APPEND return_variables.
return_variables-wf_param = lv_apo.
return_variables-doc_number = idoc_contrl-docnum.
APPEND return_variables.
ENDIF.
ENDLOOP.
Ältere hinzugefügte Variante
INCLUDE mbdconwf.
DATA:
cv_mestyp TYPE edidc-mestyp VALUE 'ZIDOC',
cv_wf_par_error_idocs TYPE bdwfretvar-wf_param VALUE 'Error_IDOCs',
cv_wf_result_ok TYPE bdwf_param-result VALUE '0 ' ##NEEDED,
cv_wf_result_error TYPE bdwf_param-result VALUE '99999',
ls_data TYPE zgglpay,
lv_error TYPE char01,
ls_lmess TYPE lmess,
lt_xreturn TYPE TABLE OF bdwfretvar.
lt_return TYPE bapiret2_t.
FIELD-SYMBOLS: <ls_xreturn> TYPE bdwfretvar.
READ TABLE idoc_contrl INDEX 1.
IF idoc_contrl-mestyp NE cv_mestyp.
RAISE wrong_function_called.
ENDIF.
LOOP AT idoc_contrl.
LOOP AT idoc_data WHERE docnum = idoc_contrl-docnum. "#EC CI_NESTED
ls_data = idoc_data-sdata.
lv_compcode = ls_data-header_company.
lv_refdoc = ls_data-ref_doc_number.
ENDLOOP.
ENDLOOP.
IF lt_return IS NOT INITIAL.
READ TABLE lt_return INTO DATA(ls_return) INDEX 1.
IF ls_return-type = 'E'.
ls_lmess-msgid = ls_return-id.
ls_lmess-msgno = ls_return-number.
ls_lmess-msgty = ls_return-type.
ls_lmess-msgv1 = ls_return-message_v1.
ls_lmess-msgv2 = ls_return-message_v2.
ls_lmess-msgv3 = ls_return-message_v3.
ls_lmess-msgv4 = ls_return-message_v4.
lv_error = abap_true.
ENDIF.
ENDIF.
***************************************************
CLEAR in_update_task.
CLEAR call_transaction_done.
IF lv_error EQ abap_true.
CALL FUNCTION 'L_IDOC_ERROR_SAVE'
EXPORTING
i_docnum = idoc_contrl-docnum
i_mestyp = cv_mestyp
i_lmess = ls_lmess
i_categorie = cv_wf_par_error_idocs
i_result = cv_wf_result_error
EXCEPTIONS
OTHERS = 1. "#EC CI_SUBRC
MOVE cv_wf_result_error TO workflow_result.
ELSE. "lDoc processed successfully
CALL FUNCTION 'L_IDOC_OK_SAVE'
EXPORTING
i_docnum = idoc_contrl-docnum
i_mestyp = cv_mestyp
EXCEPTIONS
OTHERS = 1. "#EC CI_SUBRC
MOVE c_wf_result_ok TO workflow_result.
ENDIF.
"Write status of IDOC
LOOP AT idoc_contrl.
CLEAR idoc_status.
"Determine and create status of IDOC
CALL FUNCTION 'L_IDOC_STATUS_CREATE'
EXPORTING
i_iheader = idoc_contrl
i_mass_processing = mass_processing
IMPORTING
o_istatus = idoc_status
EXCEPTIONS
OTHERS = 1. "#EC CI_SUBRC
IF idoc_status-status IS INITIAL.
MESSAGE e010(lk) WITH idoc_contrl-docnum RAISING others.
ENDIF.
APPEND idoc_status.
ENDLOOP.
"Define table for further workflow process.
LOOP AT idoc_contrl.
"Determine and create status of IDOC
CLEAR lt_xreturn. REFRESH lt_xreturn.
CALL FUNCTION 'L_IDOC_RETURN_CREATE'
EXPORTING
i_iheader = idoc_contrl
i_mass_processing = mass_processing
TABLES
treturn = lt_xreturn
EXCEPTIONS
OTHERS = 1. "#EC CI_SUBRC
LOOP AT lt_xreturn ASSIGNING <ls_xreturn>.
MOVE-CORRESPONDING <ls_xreturn> TO return_variables.
APPEND return_variables.
ENDLOOP.
IF sy-subrc NE 0.
MESSAGE e011(lk) WITH idoc_contrl-docnum RAISING others.
ENDIF.
ENDLOOP.
COMMIT WORK.