LOOP AT lt_settle ASSIGNING FIELD-SYMBOL(<lf_settle>).
IF <lf_settle> IS ASSIGNED.
* Making sure that distribution rules are not saved
* If saved then AIAB processing will skip and goes to
* AS02 and AIBU.
IF <lf_settle>-flag NE 'AIAB'.
PERFORM bdc_dynpro USING 'SAPMA15B' '0110'.
PERFORM bdc_field USING 'BDC_CURSOR'
'P_DISVAR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=SEKS'.
IF <lf_settle> IS ASSIGNED.
PERFORM bdc_field USING 'AICOM-BUKRS'
lv_header-company_code.
PERFORM bdc_field USING 'AICOM-ANLN1'
<lf_settle>-auc.
ENDIF.
PERFORM bdc_field USING 'AICOM-ANLN2'
'0'.
PERFORM bdc_field USING 'P_DISVAR'
''.
PERFORM bdc_dynpro USING 'SAPLSSEL' '1104'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=CRET'.
PERFORM bdc_field USING 'BDC_CURSOR'
'%%DYN014-LOW'.
IF <lf_settle> IS ASSIGNED.
PERFORM bdc_field USING '%%DYN003-LOW'
<lf_settle>-fical_year.
PERFORM bdc_field USING '%%DYN006-LOW'
<lf_settle>-document_no.
PERFORM bdc_field USING '%%DYN008-LOW'
<lf_settle>-reference.
PERFORM bdc_field USING '%%DYN012-LOW'
<lf_settle>-po_number.
PERFORM bdc_field USING '%%DYN013-LOW'
<lf_settle>-po_item_number.
PERFORM bdc_field USING '%%DYN014-LOW'
<lf_settle>-sequence_no.
ENDIF.
PERFORM bdc_dynpro USING 'SAPMA15B' '0110'.
PERFORM bdc_field USING 'BDC_CURSOR'
'P_DISVAR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=AUSF'.
IF <lf_settle> IS ASSIGNED.
PERFORM bdc_field USING 'AICOM-BUKRS'
lv_header-company_code.
PERFORM bdc_field USING 'AICOM-ANLN1'
<lf_settle>-auc.
ENDIF.
PERFORM bdc_field USING 'AICOM-ANLN2'
'0'.
PERFORM bdc_field USING 'P_DISVAR'
''.
PERFORM bdc_dynpro USING 'SAPMSSY0' '0120'.
PERFORM bdc_field USING 'BDC_CURSOR'
'07/03'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=&ALL'.
PERFORM bdc_dynpro USING 'SAPMSSY0' '0120'.
PERFORM bdc_field USING 'BDC_CURSOR'
'07/03'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BURG'.
PERFORM bdc_dynpro USING 'SAPLKOBS' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'COBRB-PROZS(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
LOOP AT lt_dist ASSIGNING FIELD-SYMBOL(<lf_dist>)
WHERE capitalization_request = <lf_settle>-capitalization_request
AND auc = <lf_settle>-auc "new
AND document_no = <lf_settle>-document_no
AND sequence_no = <lf_settle>-sequence_no
AND po_number = <lf_settle>-po_number "new
AND po_item_number = <lf_settle>-po_item_number "new
AND fical_year = <lf_settle>-fical_year.
IF <lf_dist> IS ASSIGNED.
READ TABLE lt_asset ASSIGNING FIELD-SYMBOL(<lf_asset>) WITH KEY
capitalization_request = <lf_dist>-capitalization_request
fa_asset = <lf_dist>-settlement_receiver_asset.
IF <lf_asset> IS ASSIGNED.
lv_count = lv_count + 1.
CONCATENATE <lf_asset>-main_asset '-0' INTO DATA(lv_auc).
CONDENSE lv_auc.
* Passing FXA value
CONCATENATE 'COBRB-KONTY(' lv_count ')' INTO DATA(lv_konty).
CONDENSE lv_konty.
PERFORM bdc_field USING lv_konty
'FXA'.
* Passing asset number
CONCATENATE 'DKOBR-EMPGE(' lv_count ')' INTO DATA(lv_dkobr).
CONDENSE lv_dkobr.
PERFORM bdc_field USING lv_dkobr
lv_auc .
IF <lf_dist>-amount IS NOT INITIAL.
lv_amount = <lf_dist>-amount.
IF lwa_defaults-dcpfm NE 'X'.
REPLACE ALL OCCURRENCES OF '.' IN lv_amount WITH ','.
ENDIF.
* Passing amount value
CONCATENATE 'COBRB-BETRR(' lv_count ')' INTO DATA(lv_betrr).
CONDENSE lv_betrr.
PERFORM bdc_field USING lv_betrr
lv_amount.
ENDIF.
IF <lf_dist>-percentage IS NOT INITIAL.
lv_per = <lf_dist>-percentage.
IF lwa_defaults-dcpfm NE 'X'.
* Passing percentage value
lv_per = <lf_dist>-percentage.
REPLACE ALL OCCURRENCES OF '.' IN lv_per WITH ','.
ENDIF.
CONCATENATE 'COBRB-PROZS(' lv_count ')' INTO DATA(lv_prozs).
CONDENSE lv_prozs.
PERFORM bdc_field USING lv_prozs "'COBRB-PROZS
lv_per." percentage .
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
PERFORM bdc_dynpro USING 'SAPLKOBS' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'COBRB-KONTY(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BACK'.
PERFORM bdc_dynpro USING 'SAPMSSY0' '0120'.
PERFORM bdc_field USING 'BDC_CURSOR'
'07/03'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BUCH'.
PERFORM bdc_dynpro USING 'SAPLSPO1' '0200'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=YES'.
DATA(v_mode) = lc_a.
CALL TRANSACTION 'AIAB' USING gt_bdcdata
MODE v_mode
UPDATE 'S'
MESSAGES INTO lt_return.
* Updating flag for particular document number and sequence number
IF sy-subrc = 0.
DATA(lv_flag) = 'AIAB'.
ENDIF.
IF lt_return IS NOT INITIAL.
EXIT.
ENDIF.
CLEAR : gt_bdcdata.
ENDIF.
*************************************************************
* If already document is saved for AUC while settling for any asset
* then skip it.
IF <lf_settle>-document IS INITIAL.
* Calling AIBU
PERFORM bdc_dynpro USING 'SAPMA12B' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LKO74-TESTLAUF'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=AUSF'.
PERFORM bdc_field USING 'ANLA-BUKRS'
lv_header-company_code.
PERFORM bdc_field USING 'ANLA-ANLN1'
<lf_settle>-auc.
PERFORM bdc_field USING 'ANLA-ANLN2'
'0'.
IF i_postdate IS NOT INITIAL.
WRITE i_postdate TO lv_postdate.
ENDIF.
IF i_assetvaldate IS NOT INITIAL.
WRITE i_assetvaldate TO lv_assetdate.
ENDIF.
PERFORM bdc_field USING 'ANEK-BLDAT'
lv_postdate."Document date
PERFORM bdc_field USING 'ANEP-BZDAT'
lv_assetdate."Asset value date
PERFORM bdc_field USING 'ANEK-BUDAT'
lv_postdate. "Posting date
PERFORM bdc_field USING 'ANBZ-MONAT'
'10'.
PERFORM bdc_field USING '*KOMK1-BLART'
'AA'. "Document type
PERFORM bdc_field USING '*KOMK1-XBLNR'
<lf_settle>-reference.
PERFORM bdc_field USING 'LKO74-TESTLAUF'
''.
PERFORM bdc_field USING 'LKO74-LIST'
'X'.
v_mode = lc_a.
CALL TRANSACTION 'AIBU' USING gt_bdcdata
MODE v_mode
UPDATE 'S'
MESSAGES INTO lt_return.
* Get Fiscal year information
CALL FUNCTION 'GET_CURRENT_YEAR'
EXPORTING
bukrs = lv_header-company_code
date = sy-datum " Posting date
IMPORTING
curry = lv_fiscal.
ENDIF.
CLEAR: lwa_mode, gt_bdcdata.
.
**Format Message for lt_return
LOOP AT lt_return INTO DATA(lwa_return).
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = lwa_return-msgid
lang = sy-langu
no = lwa_return-msgnr
v1 = lwa_return-msgv1
v2 = lwa_return-msgv2
v3 = lwa_return-msgv3
v4 = lwa_return-msgv4
IMPORTING
msg = lv_text
EXCEPTIONS
not_found = 1
OTHERS = 2.
CLEAR lwa_bapi.
lwa_bapi-type = lwa_return-msgtyp.
IF lv_text IS NOT INITIAL.
CONCATENATE lv_text ' ' lwa_return-fldname INTO lwa_bapi-message .
ELSE.
CONCATENATE lwa_return-msgv1 ' ' lwa_return-fldname INTO lwa_bapi-message .
ENDIF.
APPEND lwa_bapi TO et_return.
IF lwa_bapi-type = 'E'.
lv_msgtp = lwa_bapi-message.
CONCATENATE lv_msgtp '; ' lv_msg INTO lv_msg.
CLEAR lv_msgtp.
ENDIF.
IF lwa_return-tcode = 'AIBU' AND lwa_return-msgtyp = 'S'.
DATA(lv_fisdoc) = lwa_return-msgv1.
ENDIF.
CLEAR : lwa_return,lv_text, lwa_bapi.
ENDLOOP.
* Updating Distribution rules internal table
LOOP AT lt_dist ASSIGNING FIELD-SYMBOL(<lf_dtl>)
WHERE capitalization_request = <lf_settle>- capitalization_request
AND auc = <lf_settle>-auc "new
AND document_no = <lf_settle>-document_no
AND sequence_no = <lf_settle>-sequence_no
AND po_number = <lf_settle>-po_number "new
AND po_item_number = <lf_settle>-po_item_number "new
AND fical_year = <lf_settle>-fical_year.
IF sy-subrc = 0 .
<lf_dtl>-message = lv_msg.
IF lv_fisdoc IS NOT INITIAL.
<lf_dtl>-document = lv_fisdoc.
<lf_dtl>-fs_year = lv_fiscal.
<lf_dtl>-flag = lv_flag.
ENDIF.
ENDIF.
ENDLOOP.
CLEAR : lt_return, lv_fisdoc, lv_fiscal, lv_flag, lv_msg.
ENDIF.
ENDLOOP.
MODIFY zcap_dist_rules FROM TABLE lt_dist.
ENDFUNCTION.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
4 | |
4 | |
3 | |
3 | |
2 | |
2 | |
2 | |
2 | |
1 |