You are on page 1of 5

METHOD if_ex_ukm_fill~fill_fields .

DATA: lo_exc TYPE REF TO cx_root.

* input -
DATA: ls_in LIKE LINE OF is_notification.
DATA: l_tot_amount LIKE ls_in-amount.
* output struktur mit tabellen

DATA: ls_out TYPE ukmr3_commitment_notification.


* payload
DATA: lt_data TYPE ukmr3_credit_commitment_tab.
DATA: ls_data TYPE ukmr3_credit_commitment,
ls_data_clear LIKE ls_data.

*
DATA: l_business(60).
DATA: l_false TYPE boolean VALUE space.
DATA: l_active TYPE boolean.
DATA: l_bi TYPE flag,
l_bd TYPE flag.

* Check for clearing documents with clearing date in the future"2009736


DATA: w_bukrs TYPE bukrs,
w_mansp TYPE mansp,
w_belnr TYPE belnr_d,
w_buzei TYPE buzei,
w_gjahr TYPE gjahr.
* Check for clearing documents with clearing date in the future"2009736

STATICS: g_bound.

CLEAR: ls_data, ls_data_clear.

LOOP AT is_notification INTO ls_in.


ls_data = ls_data_clear.

ls_data-debtor_party-internal_id-value = ls_in-partner.
IF ls_data-debtor_party-internal_id-value IS INITIAL.
ls_data-debtor_party-internal_id-value = ls_in-kunnr.
ENDIF.
CALL FUNCTION 'LCR_GET_OWN_BUSINESS_SYSTEM'
IMPORTING
bs_key_name = l_business.

ls_data-debtor_party-internal_id-scheme_agency_id =
l_business.
* es ist keine Guid
ls_data-debtor_party-internal_id-scheme_id = 'PartyID'.
* call badi for conversion debtor - business partner
* ls_data-debtor_party-internal_id-value
* = convert_guid_to_number( ls_data-debtor_party-internal_id ).

ls_data-credit_segment_internal_id = ls_in-credit_sgmnt.

ls_data-type_code = ls_in-comm_typ.

IF NOT ls_in-currency IS INITIAL.


TRY.
CALL METHOD cl_gdt_conversion=>amount_outbound
EXPORTING
im_value = ls_in-amount
im_currency_code = ls_in-currency
IMPORTING
ex_value = ls_data-unsecured_amount-value
ex_currency_code = ls_data-unsecured_amount-currency_code.

CALL METHOD cl_gdt_conversion=>amount_outbound


EXPORTING
im_value = ls_in-amount_sec
im_currency_code = ls_in-currency
IMPORTING
ex_value = ls_data-secured_amount-value
ex_currency_code = ls_data-secured_amount-currency_code.
* Gesamtbetrag
l_tot_amount = ls_in-amount + ls_in-amount_sec.
CALL METHOD cl_gdt_conversion=>amount_outbound
EXPORTING
im_value = l_tot_amount
im_currency_code = ls_in-currency
IMPORTING
ex_value = ls_data-amount-value
ex_currency_code = ls_data-amount-currency_code.

CATCH cx_gdt_conversion.
MESSAGE e012(ukm_pi) WITH ls_in-currency.
ENDTRY.

ENDIF.
* 1 Absolutbetrag EP gemeldet
* 2 Deltabetrag EP gemeldet
* 3 Absolutbetrag Summe gemeldet
* 4 Deltabetrag Summe gemeldet
l_bi = l_bd = space.
CASE ls_in-sum_typ.
WHEN '1'. l_bi = space . l_bd = space.
WHEN '2'. l_bi = space . l_bd = 'X'.
WHEN '3'. l_bi = 'X' . l_bd = space.
WHEN '4'. l_bi = 'X' . l_bd = 'X'.
ENDCASE.

* immer Absolutbetrag EP gemeldet SUM_TYP


CALL METHOD cl_gdt_conversion=>indicator_outbound
EXPORTING
im_value = l_bi
IMPORTING
ex_value = ls_data-amount_balance_indicator.

CALL METHOD cl_gdt_conversion=>indicator_outbound


EXPORTING
im_value = l_bd
IMPORTING
ex_value = ls_data-amount_difference_indicator.
*
IF NOT ls_in-pmkey IS INITIAL.
MOVE: ls_in-pmkey TO ls_data-pending_commitment-group_id.
CASE ls_in-pmtyp.
WHEN '1'.
ls_in-pmtyp = ' '.
WHEN '2'.
ls_in-pmtyp = 'X'.
ENDCASE.
CALL METHOD cl_gdt_conversion=>indicator_outbound
EXPORTING
im_value = ls_in-pmtyp
IMPORTING
ex_value = ls_data-pending_commitment-completed_indicator.

ENDIF.

DATA: ls_document LIKE ls_data-accounting_document_reference-id,


ls_previous TYPE ukmr3_business_transaction_doc-id.
.
MOVE:
ls_in-date TO ls_data-validity_date.
* abh�ngig vom com typ references setzen
MOVE:
ls_in-logsys TO ls_document-scheme_agency_id,
ls_in-objtype TO ls_document-scheme_id,
ls_in-objkey TO ls_document-value.
* determine previos document
*

MOVE:
ls_in-prec_logsys TO ls_previous-scheme_agency_id,
ls_in-prec_objtype TO ls_previous-scheme_id,
ls_in-prec_objkey TO ls_previous-value.

CASE: ls_in-comm_typ.
* order value
WHEN '100'.
ls_data-sales_order_reference-id = ls_document.
* Trading Kontrakt
WHEN '150'.
ls_data-sales_order_reference-id = ls_document.
* open item
WHEN '200'.
ls_data-accounting_document_reference-id = ls_document.
* open item (special )
WHEN '300'.
ls_data-accounting_document_reference-id = ls_document.
* delivery
WHEN '400'.
ls_data-outbound_delivery_reference-id = ls_document.
CLEAR ls_data-sales_order_reference.
* billing - Faktura
WHEN '500'.
ls_data-invoice_reference-id = ls_document.
CLEAR ls_data-outbound_delivery_reference.
* Agenturbelege
WHEN '550'.
ls_data-invoice_reference-id = ls_document.

WHEN OTHERS.
ls_data-accounting_document_reference-id = ls_document.

ENDCASE.
** previos document---
CASE: ls_previous-scheme_id.
* order value
WHEN 'VBAK'.
ls_data-predecessor_reference-sales_order_reference-id = ls_previous.
* open item
WHEN 'BSEG'.
ls_data-predecessor_reference-accounting_document_reference-id =
ls_previous.
* open item (special )
WHEN 'BKPF'.
ls_data-predecessor_reference-accounting_document_reference-id =
ls_previous.
* delivery
WHEN 'LIKP'.
ls_data-predecessor_reference-outbound_delivery_reference-id = ls_previous.
* billing - Faktura
WHEN 'VBRK'.
ls_data-predecessor_reference-invoice_reference-id = ls_previous.
ENDCASE.

* Check for clearing documents with clearing date in the future"2009736


w_bukrs = ls_in-objkey(4).
w_belnr = ls_in-objkey+4(10).
w_gjahr = ls_in-objkey+14(4).
w_buzei = ls_in-objkey+18(3).
DATA: l_bseg TYPE bseg.
IF ls_in-amount = 0 AND ls_in-comm_typ(1) = '2'.
SELECT SINGLE * FROM bseg AS b INTO l_bseg
WHERE bukrs = w_bukrs
AND belnr = w_belnr
AND gjahr = w_gjahr
AND buzei = w_buzei
AND augdt > sy-datlo.

IF sy-subrc = 0 AND l_bseg-augdt > l_bseg-augcp.


DATA: l_transfer TYPE ukm_transfer_ar.
MOVE-CORRESPONDING ls_in TO l_transfer.
MOVE-CORRESPONDING l_bseg TO l_transfer.
* item is new and inserted
INSERT INTO ukm_transfer_ar VALUES l_transfer.
* item already in table (from previous clearing or report run)
IF sy-subrc <> 0.
* do not delete this item from table
l_transfer-x_rebuild = space.
UPDATE ukm_transfer_ar FROM l_transfer.
ENDIF.
* do not send it to FSCM
CONTINUE.
ENDIF.
ENDIF.
* Check for clearing documents with clearing date in the future"2009736

APPEND ls_data TO lt_data.

ENDLOOP.

et_xi_msg = lt_data.
* for reporting purposes you can return the (changed) table
EXPORT ukm_item = is_notification TO MEMORY ID 'UKM_ITEM'.

ENDMETHOD.