Skip to Content
Product Information

Thailand: How to include e-Withholding Tax Payment information in any format.

 

This blog post explains how information related to the Extended WHT payments can be provided. For this solution, it is expected that the Payment Medium Workbench (transaction FBPM, report SAPFPAYM) is used together with DMEE/DMEEX mapping engine for payment media creation.

This blog post is an extension of the existing post about e-withholding Tax in Thailand and will therefore use payment format TH_CGI_XML_CT as an example.

Standard Logic of CGI Payment Format

Under the current logic of the format TH_CGI_XML_CT withholding tax information is already provided and populated in the following fields:

The information related to the withholding tax is stored in the table WITH_ITEM for every document relevant to WHT. Reading of this table is done via the class method ‘cl_idfi_cgi_dmee_utils=>get_tax_info’. This class method is a part of the CGI solution and may not be a part of your system (depending on the SP level of the system). In such cases, either own logic for reading of the WITH_ITEM table could be created or relevant notes implemented as per the collective note 2253571.

Importing parameters are:

  • IV_DOC2R – Reference to Paid Document (original invoice that is paid)
  • IV_SPRAS – Language key
  • IV_ZLAND – Country of the payee

Following fields are selected from WITH_ITEM and text in the language of the payee:

Selecting Other Fields

If other fields are required, you can use the event 06 of the Payment Medium Workbench for a similar select from WITH_ITEM or any other table. Event 06 is an event that is provided for the customers to include their own logic and send additional information to the payment medium.

Examples for potential fields are:

  • Income Type (it could be read from T059Z based on LAND1, WITHT, and WT_WITHCD)
  • Income Type description (it could be read from T059G based on the Income Type from T059Z)
  • Posting Indicator (it could be read from T059Z based on LAND1, WITHT, and WT_WITHCD)

Note: Sample coding for the above-mentioned fields is demonstrated at the end of this blog post.

How to implement event 06

To implement event 06, go to the transaction OBPM3, where you can assign a function module to event 06.

The interface of the function module must be equal to that of the function module FI_PAYMEDIUM_SAMPLE_06.

What fields can be used

In the coding, you can make use of the ZREF fields within the structure FPAYHX_CREF, which are available for every payment.

You can also use the following fields of the structure FPAYP, which are related to the individual invoices.

 

The ZREF fields must be mapped in DMEE(X) tree. Find out more about DMEE and DMEEX in our overview blog on Payment Formats.

Sample code

The bellow code for event 06 is an example and can be adjusted to your needs. It incorporates the earlier mentioned fields Income Type, Income Type description, and Posting Indicator.

Please note that the sample implementation uses the method ‘cl_idfi_cgi_dmee_utils=>get_tax_info’, which is part of the CGI solution and may not be part of your system. In such cases, either your own logic for reading the WITH_ITEM table could be created or relevant notes implemented as per the collective note 2253571.

FUNCTION z_paym_xml_06
  IMPORTING
    VALUE(is_fpayh) LIKE fpayh
    VALUE(is_fpayhx) LIKE fpayhx
    VALUE(i_paymedium) TYPE xfeld OPTIONAL
  EXPORTING
    es_fpayhx_cref LIKE fpayhx_cref
  TABLES
    t_fpayp LIKE fpayp.




  DATA: lv_tax_amt_abs                 TYPE fpayp-qsteu,
        lv_waers                       TYPE isocd,
        ls_extension                   TYPE dmee_exit_interface_aba,
        lv_tax_amt_abs_conv(1500)      TYPE c,
        lv_tax_base_amt_sum_conv(1500) TYPE c,
        ls_t059z                       TYPE t059z,
        ls_t059g                       TYPE t059g,
        lv_tax_category                TYPE wt_withcd,
        lv_tax_method                  TYPE witht,
        lv_tax_forms_code              TYPE qsrec,
        lv_tax_amt_rate                TYPE wt_qsatz,
        lv_tax_base_amt_in_loc_curr    TYPE wt_bs,
        lv_tax_amt_in_loc_curr         TYPE wt_wt,
        lv_zland                       TYPE fpayh-zland,
        lv_qekar                       TYPE t059z-qekar,
        lv_wt_posin                    TYPE t059z-wt_posin,
        lv_zspra                       TYPE fpayh-zspra,
        lv_tax_ctgry_dtls              TYPE text40,
        lv__tax_ctnumber               TYPE ctnumber.
  FIELD-SYMBOLS: <fs_fpayp> TYPE fpayp.

*****WHT Logic*****
*Values for Amount Conversion
  ls_extension-node_values-length = 20.
  ls_extension-node-tree_type     = 'PAYM'.                 "#EC NOTEXT
  ls_extension-node-tree_id       = is_fpayhx-formi.
  ls_extension-node-version       = 000.
  ls_extension-node-cv_rule       = 'AL.='.                 "#EC NOTEXT
  ls_extension-node-length        = 20.

  LOOP AT t_fpayp ASSIGNING <fs_fpayp>.

*Standard logic used in CGI (notes from 2253571 necessary)
    cl_idfi_cgi_dmee_utils=>get_tax_info(
      EXPORTING
        iv_doc2r                    = <fs_fpayp>-doc2r
        iv_spras                    = is_fpayh-zspra
        iv_zland                    = is_fpayh-zland
      IMPORTING
        ev_tax_category             = lv_tax_category
        ev_tax_ctnumber             = lv_tax_ctnumber
        ev_tax_method               = lv_tax_method
        ev_tax_forms_code           = lv_tax_forms_code
        ev_tax_ctgry_dtls           = lv_tax_ctgry_dtls
        ev_tax_amt_rate             = lv_tax_amt_rate
        ev_tax_amt_in_loc_curr      = lv_tax_amt_in_loc_curr
        ev_tax_base_amt_in_loc_curr = lv_tax_base_amt_in_loc_curr
    ).

    <fs_fpayp>-zref01(10)    = lv_tax_category.
    <fs_fpayp>-zref01+10(10) = lv_tax_ctnumber.
    <fs_fpayp>-zref01+20(10) = lv_tax_method.
    <fs_fpayp>-zref01+30(10) = lv_tax_forms_code.
    <fs_fpayp>-zref01+40(40) = lv_tax_ctgry_dtls.
    <fs_fpayp>-zref01+80(10) = lv_tax_amt_rate.

    lv_waers = <fs_fpayp>-waers.        "currency of the item in ISO currency code format

    lv_tax_amt_abs = abs( <fs_fpayp>-qsteu ).     "for Amount absolute value needed



*     Get Amount with Currency (Using Spell_Amount)
    " Tax Amount
    CALL METHOD cl_idfi_cgi_dmee_utils=>amount_with_curr
      EXPORTING
        iv_p_value  = lv_tax_amt_abs
        iv_currency = lv_waers
      IMPORTING
        ev_p_value  = lv_tax_amt_abs.

    CALL METHOD cl_idfi_cgi_dmee_utils=>convert
      EXPORTING
        iv_p_value   = lv_tax_amt_abs
        iv_currency  = lv_waers
        is_extension = ls_extension
        iv_nation    = ''
      CHANGING
        cv_o_value   = lv_tax_amt_abs_conv.

    <fs_fpayp>-zref01+90(20)  = lv_tax_amt_abs_conv.

    " Tax Base Amount
    CALL METHOD cl_idfi_cgi_dmee_utils=>amount_with_curr
      EXPORTING
        iv_p_value  = lv_tax_base_amt_in_loc_curr
        iv_currency = lv_waers
      IMPORTING
        ev_p_value  = lv_tax_base_amt_in_loc_curr.

    CALL METHOD cl_idfi_cgi_dmee_utils=>convert
      EXPORTING
        iv_p_value   = lv_tax_base_amt_in_loc_curr
        iv_currency  = lv_waers
        is_extension = ls_extension
        iv_nation    = ''
      CHANGING
        cv_o_value   = lv_tax_base_amt_sum_conv.

    <fs_fpayp>-zref01+110(20)  = lv_tax_base_amt_sum_conv.

*Read T059Z (Withholding tax code)
    lv_zland = is_fpayh-zland.
    PERFORM read_t059z USING lv_zland lv_tax_method lv_tax_category ls_t059z.
    lv_qekar    = ls_t059z-qekar.
    lv_wt_posin = ls_t059z-wt_posin.
    <fs_fpayp>-zref02(4)   = lv_qekar.
    <fs_fpayp>-zref02+4(1) = lv_wt_posin.

*Read T059G (Income Types: Names)
    lv_zspra = is_fpayh-zspra.
    PERFORM read_t059g USING lv_zspra lv_zland lv_qekar ls_t059g.
    <fs_fpayp>-zref02+5(40) = ls_t059g-eatxt.

  ENDLOOP.

ENDFUNCTION.

FORM read_t059z USING lv_zland lv_tax_method lv_tax_category ls_t059z.

  STATICS: lss_t059z TYPE t059z.
  IF lss_t059z-land1     <> lv_zland      AND
     lss_t059z-witht     <> lv_tax_method AND
     lss_t059z-wt_withcd <> lv_tax_category.

    SELECT SINGLE * INTO ls_t059z FROM t059z WHERE
    land1     = lv_zland      AND
    witht     = lv_tax_method AND
    wt_withcd = lv_tax_category.

    IF sy-subrc = 0.
      lss_t059z = ls_t059z.

    ENDIF.
  ENDIF.

ENDFORM.

FORM read_t059g USING lv_zspra lv_zland lv_qekar ls_t059g.

  STATICS: lss_t059g TYPE t059g.
  IF lss_t059g-land1 <> lv_zland AND
  lss_t059g-qekar <> lv_qekar.

    "First with logon BP language
    SELECT SINGLE * INTO ls_t059g FROM t059g WHERE
    spras = lv_zspra AND
    land1 = lv_zland AND
    qekar = lv_qekar.

    IF sy-subrc = 0.
      lss_t059g = ls_t059g.
    ELSE.
      "Then with any language
      SELECT SINGLE * INTO ls_t059g FROM t059g WHERE
      land1 = lv_zland AND
      qekar = lv_qekar.
      IF sy-subrc = 0.
        lss_t059g = ls_t059g.
      ENDIF.
    ENDIF.
  ENDIF.
ENDFORM.

 


Do you have any further comments regarding this topic? Do not hesitate to share them in the comment section below. You are also welcome to ask any questions about SAP S4/HANA Finance in the Community Q&A section.

Be the first to leave a comment
You must be Logged on to comment or reply to a post.