ZCL_AII_UTILS=>CREATE_BTD

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
method CREATE_BTD.
*{ INSERT AIDK900022 1
data:
lv_devgrp_intid TYPE /AIN/PUB_DEVGRP_INTID_STR,
lt_devgrp TYPE /AIN/PUB_DEVGRP_TAB,
ls_devgrp LIKE LINE OF LT_DEVGRP,
lv_devgrp_id TYPE /AIN/DM_DEVGRP_ID.
DATA: ls_doc TYPE /ain/dm_doc_str,
lt_intid TYPE /ain/pub_intid_tab,
lt_doc TYPE /ain/ui_document_tab,
lt_btd_header TYPE /ain/pub_btd_header_cre_tab,
ls_btd_header LIKE LINE OF lt_btd_header,
lt_btd_othattr TYPE /ain/pub_btd_othattr_cre_tab,
ls_btd_othattr LIKE LINE OF lt_btd_othattr,
EV_DOC_GUID TYPE /AIN/DM_DOC_GUID.
data: lv_msg TYPE string,
error_saving TYPE wdy_boolean,
lt_return TYPE bapirettab,
lv_para1 TYPE string,
lv_exists TYPE WDY_BOOLEAN,
lv_error_msg TYPE bapi_msg,
error_exists TYPE WDY_BOOLEAN.
data:
lt_tzone TYPE /ain/pub_btd_header_tzone_tab,
ls_tzone LIKE LINE OF lt_tzone.
FIELD-SYMBOLS:
<fs_doc> LIKE LINE OF lt_doc,
<fs_intid> LIKE LINE OF lt_intid.
LS_DOC-DOC_TYPE = IV_DOC_TYPE. "'51'. "WD_COMP_CONTROLLER->GV_BTD_TYPE.
* every time we start scan we generate new btd ext id
ls_doc-DOC_ID = zcl_aii_utils=>get_next_ext_btd_id( ls_doc-doc_type ).
LV_DEVGRP_ID = IV_DEVGRP_ID.
IF LV_DEVGRP_ID is NOT INITIAL.
LV_EXISTS = ZCL_AII_UTILS=>CHECK_BTD_EXISTS( IV_DOC_ID = LS_DOC-DOC_ID IV_DOC_TYPE = LS_DOC-DOC_TYPE ).
IF LV_EXISTS is INITIAL.
CALL FUNCTION '/AIN/PUB_INTID_GENERATE'
TABLES
et_intid = lt_intid.
READ TABLE lt_intid ASSIGNING <fs_intid> INDEX 1.
ls_btd_header-btd_intid = <fs_intid>-intid.
ls_btd_header-btd_extid = ls_doc-doc_id.
ls_btd_header-btd_type = ls_doc-doc_type.
LS_BTD_HEADER-ACTION_TYPE = IV_ACT_TYPE.
APPEND ls_btd_header TO lt_btd_header.
LS_TZONE-BTD_INTID = LS_BTD_HEADER-BTD_INTID.
LS_TZONE-TZONE = sy-zonlo.
APPEND LS_TZONE to LT_TZONE.
CALL FUNCTION '/AIN/PUB_BTD_CREATE'
TABLES
it_btd_header = lt_btd_header
it_btd_othattr = lt_btd_othattr
IT_BTD_HEADER_TZONE = LT_TZONE
et_return = lt_return
EXCEPTIONS
technical_level_error = 1
business_level_error_input = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO lv_msg.
* WD_COMP_CONTROLLER->msg_mgr->report_error_message( lv_msg ).
error_saving = abap_true.
ENDIF.
IF error_saving IS INITIAL.
CALL FUNCTION '/AIN/PUB_BO_SAVE'
TABLES
ET_RETURN = LT_RETURN
EXCEPTIONS
technical_level_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO lv_msg.
* WD_COMP_CONTROLLER->msg_mgr->report_error_message( lv_msg ).
error_saving = abap_true.
ENDIF.
IF ERROR_SAVING is INITIAL.
CALL FUNCTION '/AIN/UI_DOCUMENT_SEARCH'
EXPORTING
iv_doc_id = ls_doc-doc_id
iv_doc_type = ls_doc-doc_type
IMPORTING
et_doc = lt_doc.
IF LINES( lt_doc ) >= 1.
READ TABLE lt_doc INDEX 1 ASSIGNING <fs_doc>.
ev_doc_guid = <fs_doc>-doc_guid.
lv_para1 = <fs_doc>-doc_id.
LV_MSG = LV_PARA1.
* lv_msg = wd_assist->get_text( key = '020' para1 = lv_para1 ).
ET_DOC_TAB = LT_DOC.
* WD_COMP_CONTROLLER->msg_mgr->report_success( lv_msg ).
ELSE.
CONCATENATE 'Документ "' LS_DOC-DOC_ID '" тип' ls_doc-DOC_TYPE 'не был найден после создания' INTO lv_msg SEPARATED BY space.
ENDIF.
ENDIF.
ENDIF.
else.
CONCATENATE 'Документ "' LS_DOC-DOC_ID '" тип' ls_doc-DOC_TYPE ' уже существует' INTO lv_msg SEPARATED BY space.
ENDIF.
ENDIF.
EV_MSG = LV_MSG.
*} INSERT
endmethod.