Code: Alles auswählen.
Importing IV_PARTNER TYPE BU_PARTNER Geschäftspartnernummer
QImporting IV_CREDIT_SEGMENT TYPE UKM_CREDIT_SGMNT Kreditsegment
QReturning value( RV_SEGMENT_STATUS ) TYPE CHAR1 boolsche Variable (X=true, -=false, space=unknown)
METHOD set_credit_segment.
DATA:
lo_facade TYPE REF TO cl_ukm_facade,
lo_bupa_factory TYPE REF TO cl_ukm_bupa_factory,
lo_account TYPE REF TO cl_ukm_account,
ls_bp_credit_sgm TYPE ukm_s_bp_cms_sgm,
lt_monitor_return TYPE ukm_t_monitor_return.
CLEAR rv_segment_status.
* check if Credit segment exist
SELECT SINGLE credit_sgmnt
INTO @DATA(lv_credit_sgmnt)
FROM ukmbp_cms_sgm
WHERE partner = @iv_partner
AND credit_sgmnt = @iv_credit_segment.
* if not, create
IF sy-subrc <> 0.
lo_facade = cl_ukm_facade=>create( i_activity = cl_ukm_cnst_eventing=>bp_maintenance ).
lo_bupa_factory = lo_facade->get_bupa_factory( ).
CALL METHOD lo_bupa_factory->get_credit_account
EXPORTING
i_partner = iv_partner " Business Partner Number
i_credit_sgmnt = iv_credit_segment " Credit Segment
RECEIVING
ro_credit_account = lo_account. " Credit Account
IF lo_account IS BOUND.
lo_account->get_bp_cms_sgm( IMPORTING es_bp_cms_sgm = ls_bp_credit_sgm ).
ls_bp_credit_sgm-credit_limit = '0.0'.
* ls_bp_credit_sgm-xcritical = 'X'.
ls_bp_credit_sgm-limit_chg_date = sy-datum.
lo_account->set_bp_cms_sgm( EXPORTING is_bp_cms_sgm = ls_bp_credit_sgm ).
lt_monitor_return = lo_bupa_factory->save_all( ).
LOOP AT lt_monitor_return ASSIGNING FIELD-SYMBOL(<ls_monitor_return>)
WHERE msgty = 'E' OR
msgty = 'A'.
ENDLOOP.
IF sy-subrc <> 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = abap_true.
rv_segment_status = 'C'. "created
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
rv_segment_status = 'E'. "errror
ENDIF.
ENDIF.
ELSE.
rv_segment_status = 'X'. "exists
ENDIF.
ENDMETHOD.