*&---------------------------------------------------------------------*
*& Form FRM_CALL_BAPI_POST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_call_bapi_post .
DATA: ls_loan TYPE bapiloan_create,
ls_conditionheader TYPE bapicondhead_create,
lt_partner TYPE STANDARD TABLE OF bapirel_bpobj,
lwa_partner TYPE bapirel_bpobj,
lt_item TYPE STANDARD TABLE OF bapicondition_create,
lwa_item TYPE bapicondition_create,
lt_return TYPE STANDARD TABLE OF bapiret2,
lwa_return TYPE bapiret2.
DATA: lv_loannumber TYPE bapiloan_get-contract_no,
lv_error TYPE c,
lv_flg TYPE c,
lv_date TYPE sy-datum,
lv_count TYPE i.
LOOP AT gt_upload INTO gwa_upload.
ls_loan-comp_code = 'JNPC'.
ls_loan-partner = gwa_upload-partner. "贷款人
ls_loan-prod_type = gwa_upload-prod_type. "产品类型
ls_loan-status = '35'.
ls_loan-loan_type = '10'. " 贷款类型
ls_loan-loan_class = gwa_upload-loan_class. "贷款用途
ls_loan-sec_type = gwa_upload-sec_type. "抵押类型
ls_loan-currency = gwa_upload-currency. "货币
ls_loan-bantrag = gwa_upload-bantrag.
ls_loan-loan_pur = '10'. "贷款目的
ls_loan-financtype = '10'. "筹款类型
ls_loan-maturity = gwa_upload-matruity. "期限
ls_loan-long_text = gwa_upload-long_text. "贷款合同
ls_loan-grp_key_i = gwa_upload-key1. "贷款用途
ls_loan-zuond = gwa_upload-rate.
ls_loan-merkm = gwa_upload-merkm.
ls_conditionheader-condition_valid_from = gwa_upload-term_start.
ls_conditionheader-term_start = gwa_upload-term_start. "期限开始
ls_conditionheader-final_due_date = gwa_upload-final_due_date. "期限结束
IF gwa_upload-comm_cap IS INITIAL.
ls_conditionheader-comm_cap = gwa_upload-bantrag. "金额
ELSE.
ls_conditionheader-comm_cap = gwa_upload-comm_cap. "金额
ENDIF.
ls_conditionheader-currency = gwa_upload-currency.
ls_conditionheader-repayment_type = gwa_upload-repayment_type. "还款类型
CLEAR lwa_partner.
lwa_partner-comp_code = 'JNPC'.
lwa_partner-partner = gwa_upload-partner. "贷款人
lwa_partner-role_type = 'TR0100'.
lwa_partner-appl_cat = '0013'.
lwa_partner-role_sbtyp = '1100'.
APPEND lwa_partner TO lt_partner.
IF gwa_upload-repayment_type = '1'.
********
CLEAR lwa_item.
IF gwa_upload-prod_type = 'Z01'.
lwa_item-condition_type = '9101'. "贷款条件类型
ELSEIF gwa_upload-prod_type = 'Z02'.
lwa_item-condition_type = '9201'. "贷款条件类型
ENDIF.
lwa_item-valid_from = gwa_upload-term_start."生效日
IF gwa_upload-fx_type = '10'.
lwa_item-frequency_month = '3'.
ELSEIF gwa_upload-fx_type = '20'.
lwa_item-frequency_month = '1'.
ENDIF.
PERFORM frm_get_due_date USING lwa_item-frequency_month
gwa_upload-term_start
CHANGING lv_date.
lwa_item-due_date = lv_date. "到期日
CLEAR lv_flg.
PERFORM frm_numberic_check USING gwa_upload-rate
CHANGING lv_flg.
IF lv_flg IS INITIAL.
lwa_item-percentage_rate = gwa_upload-rate. "贷款利息率
ELSE.
ENDIF.
APPEND lwa_item TO lt_item.
****
CLEAR lwa_item.
IF gwa_upload-prod_type = 'Z01'.
lwa_item-condition_type = '9102'. "贷款条件类型
ELSEIF gwa_upload-prod_type = 'Z02'.
lwa_item-condition_type = '9202'. "贷款类型
ENDIF.
lwa_item-valid_from = gwa_upload-term_start."生效日
CLEAR lv_date.
IF gwa_upload-final_due_date IS NOT INITIAL.
lv_date = gwa_upload-final_due_date - 1.
ENDIF.
lwa_item-due_date = gwa_upload-final_due_date. "到期日
lwa_item-calc_date = lv_date.
APPEND lwa_item TO lt_item.
* 长期付款的 分期付款
ELSEIF gwa_upload-repayment_type = '2'.
CLEAR lwa_item.
lwa_item-condition_type = '9201'. "贷款条件类型
lwa_item-valid_from = gwa_upload-term_start."生效日
IF gwa_upload-fx_type = '10'.
lwa_item-frequency_month = '3'.
ELSEIF gwa_upload-fx_type = '20'.
lwa_item-frequency_month = '1'.
ENDIF.
PERFORM frm_get_due_date USING lwa_item-frequency_month
gwa_upload-term_start
CHANGING lv_date.
lwa_item-due_date = lv_date. "到期日
CLEAR lv_flg.
PERFORM frm_numberic_check USING gwa_upload-rate
CHANGING lv_flg.
IF lv_flg IS INITIAL.
lwa_item-percentage_rate = gwa_upload-rate. "贷款利息率
ELSE.
ENDIF.
APPEND lwa_item TO lt_item.
CLEAR lwa_item.
lwa_item-condition_type = '9203'. "贷款条件类型
lwa_item-valid_from = gwa_upload-term_start."生效日
CLEAR lv_date.
PERFORM frm_get_due_date USING '12'
gwa_upload-term_start
CHANGING lv_date.
lwa_item-frequency_month = '12'.
lwa_item-amount = '1'.
lwa_item-currency = gwa_upload-currency.
lwa_item-due_date = lv_date.
lwa_item-calc_date = lv_date.
APPEND lwa_item TO lt_item.
CLEAR lwa_item.
lwa_item-condition_type = '9204'. "贷款条件类型
CLEAR lv_date.
PERFORM frm_get_due_date USING '12'
gwa_upload-term_start
CHANGING lv_date.
lwa_item-valid_from = lv_date."生效日
lwa_item-calc_date = lv_date.
APPEND lwa_item TO lt_item.
ENDIF.
CALL FUNCTION 'BAPI_LOAN_CONTRACT_CREATE'
EXPORTING
loan = ls_loan
conditionheader = ls_conditionheader
* CORRESPONDENCE =
* USERFIELDS =
testrun = p_test
* REFRESH = ' '
* PROCESSEXTENSION = ' '
* steering = ls_steering
IMPORTING
loannumber = lv_loannumber
error = lv_error
TABLES
partner = lt_partner
conditions = lt_item
* FORMULA =
* OBJECTS =
* COLLATERALS =
* ENCUMBRANCES =
* CLERKS =
* EXTENSION_IN =
return = lt_return
.
CLEAR gwa_output.
LOOP AT lt_return INTO lwa_return WHERE type = 'E' OR type = 'A'.
lv_error = 'X'.
EXIT.
ENDLOOP.
IF sy-subrc <> 0.
gwa_output-partner = gwa_upload-partner.
gwa_output-loan_no = lv_loannumber.
gwa_output-icon = '@08@'.
IF p_test IS INITIAL.
gwa_output-msg = text-t03. "'创建成功'.
ELSE.
gwa_output-msg = text-t04.
ENDIF.
ELSE.
gwa_output-partner = gwa_upload-partner.
LOOP AT lt_return INTO lwa_return.
CONCATENATE gwa_output-msg lwa_return-type lwa_return-id lwa_return-number lwa_return-message
INTO gwa_output-msg SEPARATED BY space.
ENDLOOP.
gwa_output-icon = '@0A@'.
ENDIF.
gwa_output-line = lv_count + 1.
APPEND gwa_output TO gt_output.
IF p_test IS INITIAL.
IF lv_error IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " FRM_CALL_BAPI_POST
阅读(941) | 评论(0) | 转发(0) |