Method ABAP
Method ABAP
Method ABAP
data:
g_obj_type TYPE BAPIACHE09-OBJ_TYPE,
g_obj_key TYPE BAPIACHE09-OBJ_KEY,
g_obj_sys TYPE BAPIACHE09-OBJ_SYS .
DATA:
lwa_header TYPE bapiache09,
lt_ar TYPE TABLE OF bapiacar09,
ls_return TYPE bapiret2,
lv_text TYPE string,
lwa_ar TYPE bapiacar09,
wa_zNRS_INV_HD TYPE zNRS_INV_HD,
wa_zNRS_INV_HD_2 TYPE zNRS_INV_HD, "CHECK
wa_zNRS_INV_error TYPE zNRS_INV_error,
toleranta_err TYPE char255,
wa_zNRS_INV_NR TYPE zNRS_INV_NR,
lt_return TYPE TABLE OF bapiret2,
lwa_return TYPE bapiret2,
lt_curr TYPE TABLE OF bapiaccr09,
LT_ACCOUNTTAX TYPE TABLE OF BAPIACTX09,
WA_ACCOUNTTAX TYPE BAPIACTX09,
LT_CRITERIA TYPE TABLE OF BAPIACKEC9,
WA_CRITERIA TYPE BAPIACKEC9,
lwa_curr TYPE bapiaccr09,
lwa_curr_tax TYPE bapiaccr09,
it_extension1 TYPE STANDARD TABLE OF bapiacextc,
wa_extension1 TYPE bapiacextc,
it_EXTENSION2 TYPE STANDARD TABLE OF BAPIPAREX,
wa_EXTENSION2 type BAPIPAREX.
data: tipdoc(20),
wa_ZFB_XNEGP TYPE ZFB_XNEGP,
WA_ZFB_C_ACCFI TYPE ZFB_C_ACCFI,
it_accountgl TYPE STANDARD TABLE OF bapiacgl09 ,
CUSTOMERCPD TYPE BAPIACPA09,
lwa_accountgl TYPE bapiacgl09.
DATA:
lv_change TYPE wrbtr,
ls_payment TYPE zvs_incasare,
ls_mmp TYPE zvs_mmp,
ls_ZNRS_PLATA TYPE ZNRS_PLATA.
lv_mtext = text-025.
me->mo_log-
>add_custom_message_to_log( EXPORTING iv_state = zcl_interface_log=>mc_info_s
tate
iv_mtext = lv_mtext ).
FIELD-SYMBOLS:
<fs_payment> TYPE ZINTF_S_INV_p,
<fs_change> TYPE zintf_sales_change_s.
lv_count = 1.
CONCATENATE IS_TRANSACTION-HEADER-INVOICEDATE '/' IS_TRANSACTION-HEADER-
INVOICEPOS into mv_guid.
SELECT SINGLE * FROM zNRS_INV_HD INTO wa_zNRS_INV_HD_2 WHERE GUID = mv_guid
AND INVOICEID = IS_TRANSACTION-HEADER-INVOICEID.
IF wa_zNRS_INV_HD_2-ZIMPORT = 'X'. " DE VERIFICAT LA MAI MULTE ANTETE
EXIT.
ENDIF.
lwa_header-bus_act = 'RFBU'.
lwa_header-OBJ_TYPE = 'BKPFF' .
lwa_header-OBJ_KEY = '$'.
lwa_header-comp_code = '1000'.
lwa_header-USERNAME = sy-uname.
lwa_header-doc_date = lv_date.
lwa_header-pstng_date = lv_date.
lwa_header-trans_date = lv_date.
lwa_header-HEADER_TXT = is_transaction-header-invoiceID .
lwa_header-fisc_year = lv_date+0(4).
lwa_header-fis_period = lv_date+4(2).
lwa_header-doc_type = ls_incasare-blart.
lwa_header-ref_doc_no = is_transaction-header-invoiceSerial.
wa_extension2-structure = 'ZFB_XNEGP' .
wa_ZFB_XNEGP-posnr = lv_count.
wa_ZFB_XNEGP-BSCHL = LS_INCASARE-BSCHL_CRD.
wa_ZFB_XNEGP-XNEGP = LS_INCASARE-XNEGP_CRD.
wa_extension2-valuepart1 = wa_ZFB_XNEGP.
append wa_extension2 to it_extension2.
lwa_curr-itemno_acc = lv_count.
lwa_curr-curr_type = '00'.
lwa_curr-currency = 'RON'.
lwa_curr-amt_doccur = <fs_payment>-invoicePaymentValue.
lwa_curr-amt_BASE = <fs_payment>-invoicePaymentValue.
APPEND lwa_curr TO lt_curr.
wa_extension2-structure = 'ZFB_XNEGP' .
wa_ZFB_XNEGP-posnr = lv_count.
lwa_accountgl-gl_account = ls_mmp-SAKNR.
lwa_accountgl-comp_code = ls_mmp-BUKRS.
wa_ZFB_XNEGP-BSCHL = LS_INCASARE-BSCHL_DEB.
wa_ZFB_XNEGP-XNEGP = LS_INCASARE-XNEGP_DEB.
wa_extension2-valuepart1 = wa_ZFB_XNEGP.
lwa_ar-itemno_acc = lv_count.
lwa_ar-SP_GL_IND = ls_ZNRS_PLATA-UMSKZ.
lwa_ar-CUSTOMER = ls_ZNRS_PLATA-kunnr.
lwa_ar-gl_account = ''. "verificat
lwa_ar-comp_code = ls_ZNRS_PLATA-BUKRS.
APPEND lwa_ar TO lt_ar.
* lwa_accountgl-gl_account = ls_ZNRS_PLATA-kunnr.
* lwa_accountgl-comp_code = ls_mmp-BUKRS.
wa_extension2-structure = 'ZFB_XNEGP' .
wa_ZFB_XNEGP-posnr = lv_count.
wa_ZFB_XNEGP-BSCHL = ls_ZNRS_PLATA-BSCHL.
wa_extension2-valuepart1 = wa_ZFB_XNEGP.
endif.
ENDLOOP.
IF lt_curr IS INITIAL.
lv_mtext = text-016.
me->mo_log-
>add_custom_message_to_log( EXPORTING iv_state = zcl_interface_log=>mc_info_s
tate
iv_mtext = lv_mtext ).
RETURN.
ENDIF.
*break florinz. " incasare
if wa_zNRS_INV_HD_2-BELNR_INCASARE is INITIAL.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
EXPORTING
DOCUMENTHEADER = lwa_header
CUSTOMERCPD = CUSTOMERCPD
TABLES
ACCOUNTGL = it_accountgl
ACCOUNTRECEIVABLE = lt_ar
CURRENCYAMOUNT = lt_curr
EXTENSION1 = it_extension1
RETURN = lt_return .
*break florinz.
IF sy-subrc <> 0.
me->mo_log->add_system_message_to_log( ).
ENDIF.
*BREAK-POINT.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
DOCUMENTHEADER = lwa_header
CUSTOMERCPD = CUSTOMERCPD
* CONTRACTHEADER =
IMPORTING
obj_type = g_obj_type
obj_key = g_obj_key
obj_sys = g_obj_sys
TABLES
ACCOUNTGL = it_accountgl
ACCOUNTRECEIVABLE = lt_ar
* ACCOUNTPAYABLE =
* ACCOUNTTAX = LT_ACCOUNTTAX
CURRENCYAMOUNT = lt_curr
* CRITERIA = LT_CRITERIA
* VALUEFIELD =
EXTENSION1 = it_extension1
RETURN = lt_return
* PAYMENTCARD =
* CONTRACTITEM =
EXTENSION2 = it_EXTENSION2
* :REALESTATE =
* ACCOUNTWT =
.
data error(1).
clear error.
else.
g_obj_key(10) = wa_zNRS_INV_HD_2-BELNR_INCASARE.
ENDIF.
*BREAK FLORINZ.
LOOP AT lt_return INTO lwa_return WHERE type = 'E' .
error = 'X'.
ev_bukrs = '1000'.
ev_belnr = g_obj_key(10).
ev_gjahr = lv_date+0(4)..
lv_mtext = text-026.
REPLACE FIRST OCCURRENCE OF '&' IN lv_mtext WITH lwa_return-ID.
REPLACE FIRST OCCURRENCE OF '&' IN lv_mtext WITH lwa_return-
NUMBER.
REPLACE FIRST OCCURRENCE OF '&' IN lv_mtext WITH lwa_return-
MESSAGE.
REPLACE FIRST OCCURRENCE OF '&' IN lv_mtext WITH lwa_return-
LOG_NO.
REPLACE FIRST OCCURRENCE OF '&' IN lv_mtext WITH lwa_return-
LOG_MSG_NO.
REPLACE FIRST OCCURRENCE OF '&' IN lv_mtext WITH lwa_return-
MESSAGE_V1.
REPLACE FIRST OCCURRENCE OF '&' IN lv_mtext WITH lwa_return-
MESSAGE_V2.
REPLACE FIRST OCCURRENCE OF '&' IN lv_mtext WITH lwa_return-
MESSAGE_V3.
REPLACE FIRST OCCURRENCE OF '&' IN lv_mtext WITH lwa_return-
MESSAGE_V4.
me->mo_log-
>add_custom_message_to_log( EXPORTING iv_state = zcl_interface_log=>mc_error_
state
iv_mtext = lv_mtext ).
clear wa_zNRS_INV_error.
wa_zNRS_INV_error-guid = mv_guid.
wa_zNRS_INV_error-step = 'INCASARE' .
wa_zNRS_INV_error-DATA = SY-DATUM.
wa_zNRS_INV_error-TIMLO = SY-TIMLO.
wa_zNRS_INV_error-INVOICEID = IS_TRANSACTION-header-INVOICEID.
wa_zNRS_INV_error-message = lv_mtext.
modify zNRS_INV_error FROM wa_zNRS_INV_error .
IF sy-subrc = 0.
ENDMETHOD.