class zcl_ua_fieb_change_bs_data definition
public
final
create public .
public section.
types:
tt_febcl type standard table of febcl with default key .
class-methods process_line
importing
!iv_note_to_payee type string
changing
!cs_febko type febko
!cs_febep type febep
!ct_febcl type standard table .
protected section.
private section.
constants:
begin of c_bdc,
first_line_1st_area type febep-fkoa1 value '0',
first_line_2nd_area type febep-fkoa1 value '1',
second_line_1st_area type febep-fkoa1 value '2',
second_line_2nd_area type febep-fkoa1 value '3',
end of c_bdc.
class-methods handle_inc_down_payment
importing
iv_note type string
changing
cs_febep type febep.
class-methods get_pro_forma_invoice_nr
importing
iv_note type string
returning
value(rv_vbeln) type vbeln_vf.
class-methods is_valid_vbeln
importing
iv_vbeln type vbeln
returning
value(rv_yes) type abap_bool.
class-methods get_default_tax_code
returning
value(rv_mwskz) type mwskz.
endclass.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Public Method ZCL_UA_FIEB_CHANGE_BS_DATA=>PROCESS_LINE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_NOTE_TO_PAYEE TYPE STRING
* | [<-->] CS_FEBKO TYPE FEBKO
* | [<-->] CS_FEBEP TYPE FEBEP
* | [<-->] CT_FEBCL TYPE STANDARD TABLE
* +--------------------------------------------------------------------------------------</SIGNATURE>
method process_line.
cache_default_posting_rules( cs_febko ).
handle_inc_down_payment(
exporting
iv_note = iv_note_to_payee
changing
cs_febep = cs_febep ).
endmethod.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Private Method ZCL_UA_FIEB_CHANGE_BS_DATA=>HANDLE_INC_DOWN_PAYMENT
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_NOTE TYPE STRING
* | [<-->] CS_FEBEP TYPE FEBEP
* +--------------------------------------------------------------------------------------</SIGNATURE>
method handle_inc_down_payment.
" Adjust the posting rule
cs_febep-vgint = ms_default_posting_rules-inc_down_payment.
" Extract the reference to proforma invoice number
data lv_vbeln type vbeln.
lv_vbeln = get_pro_forma_invoice_nr( iv_note ).
" Fill the reference to proforma invoice number
if lv_vbeln <> ''.
cs_febep-fnam1 = 'BSEG-XREF2'.
cs_febep-fval1 = lv_vbeln.
cs_febep-fkoa1 = c_bdc-second_line_2nd_area.
else.
return.
endif.
" Get tax code for a down-payment posting
data lv_tax_code type mwskz.
lv_tax_code = get_default_tax_code( ).
" Fill tax code & the flag "Calculate tax"
if lv_tax_code <> ''.
cs_febep-fnam2 = 'BSEG-MWSKZ'.
cs_febep-fval2 = lv_tax_code.
cs_febep-fkoa2 = c_bdc-second_line_2nd_area.
cs_febep-fnam3 = 'BKPF-XMWST'.
cs_febep-fval3 = 'X'.
cs_febep-fkoa3 = c_bdc-second_line_2nd_area.
endif.
endmethod.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Private Method ZCL_UA_FIEB_CHANGE_BS_DATA=>GET_PRO_FORMA_INVOICE_NR
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_NOTE TYPE STRING
* | [<-()] RV_VBELN TYPE VBELN_VF
* +--------------------------------------------------------------------------------------</SIGNATURE>
method get_pro_forma_invoice_nr.
" Utility method to extract proforma invoice number
" Proforma invoice numbers begin with 90, have 8 digits and might be separated by space
constants: lc_proforma_pattern type string value '(?=90)((\s?\d\s?){8})'.
" Find numbers that might be proforma numbers
data lv_proforma_nr type string.
find regex lc_proforma_pattern in iv_note
ignoring case
submatches lv_proforma_nr.
if sy-subrc is not initial.
return.
else.
condense lv_proforma_nr no-gaps. " Remove all spaces
unpack lv_proforma_nr to rv_vbeln. " Add leading zeros i.e. padding
endif.
" Check if proforma number exists in the system
if is_valid_vbeln( rv_vbeln ) = abap_false.
clear: rv_vbeln.
endif.
endmethod.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Private Method ZCL_UA_FIEB_CHANGE_BS_DATA=>IS_VALID_VBELN
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_VBELN TYPE VBELN
* | [<-()] RV_YES TYPE ABAP_BOOL
* +--------------------------------------------------------------------------------------</SIGNATURE>
method is_valid_vbeln.
data lv_vbeln type vbeln.
select single vbeln
from vbrk
into lv_vbeln
where vbeln = iv_vbeln.
if sy-subrc = 0.
rv_yes = abap_true.
endif.
endmethod.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Private Method ZCL_UA_FIEB_CHANGE_BS_DATA=>GET_DEFAULT_TAX_CODE
* +-------------------------------------------------------------------------------------------------+
* | [<-()] RV_MWSKZ TYPE MWSKZ
* +--------------------------------------------------------------------------------------</SIGNATURE>
method get_default_tax_code.
constants: lc_country type land1 value 'UA'.
constants: lc_group_version type t007k-version value 'EBS'.
" Select the tax code from the grouping version EBS
select single mwskz
from t007k
into rv_mwskz
where land1 = lc_country
and version = lc_group_version.
endmethod.
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 | |
3 | |
2 | |
2 | |
2 | |
2 | |
2 | |
2 | |
2 | |
2 |