Tabla de retorno de la función:
Creación de estructura en la SE11:
Código fuente de la función:
DATA: lt_data TYPE STANDARD TABLE OF zcfcl_fi_es_tax,
ls_data TYPE zcfcl_fi_es_tax.
DATA: ls_t007a TYPE t007a,
lt_t007a TYPE STANDARD TABLE OF t007a,
lt_ftaxp TYPE STANDARD TABLE OF ftaxp,
ls_ftaxp TYPE ftaxp,
lv_kalsm TYPE t005-kalsm,
lv_txjcd TYPE txjcd.
DATA: lv_valor TYPE p DECIMALS 2.
CONSTANTS: lc_fix_kappl TYPE kappl VALUE 'TX'.
CLEAR lv_kalsm.
REFRESH: lt_t007a[], lt_ftaxp[], et_data[].
SELECT SINGLE kalsm FROM t005 INTO lv_kalsm
WHERE land1 EQ iv_land1.
IF sy-subrc EQ 0.
CLEAR lv_txjcd.
SELECT SINGLE txjcd FROM ttxj INTO lv_txjcd
WHERE kalsm EQ lv_kalsm.
IF sy-subrc NE 0 OR lv_txjcd IS INITIAL.
MOVE 'X' TO lv_txjcd.
ENDIF.
SELECT * FROM t007a INTO TABLE lt_t007a
WHERE kalsm EQ lv_kalsm.
IF sy-subrc EQ 0.
CLEAR ls_t007a.
LOOP AT lt_t007a INTO ls_t007a.
CALL FUNCTION 'GET_TAX_PERCENTAGE'
EXPORTING
aland = iv_land1
datab = sy-datum
mwskz = ls_t007a-mwskz
txjcd = lv_txjcd
TABLES
t_ftaxp = lt_ftaxp.
IF lt_ftaxp[] IS NOT INITIAL.
CLEAR ls_ftaxp.
READ TABLE lt_ftaxp INTO ls_ftaxp INDEX 1.
IF sy-subrc EQ 0.
MOVE-CORRESPONDING ls_ftaxp TO ls_data.
MOVE ls_t007a-mwskz TO ls_data-mwskz.
lv_valor = ls_ftaxp-kbetr / 10.
WRITE lv_valor TO ls_data-tax DECIMALS 2 .
REPLACE ALL OCCURRENCES OF '.' IN ls_data-tax WITH ','.
CONDENSE ls_data-tax.
APPEND ls_data TO lt_data.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
MOVE lt_data[] TO et_data[].
No hay comentarios:
Publicar un comentario