*----------------------------------------------------------------------*
* DECLARATIONS *
*----------------------------------------------------------------------*
DATA: BEGIN OF gt_xls OCCURS 0,
kdmat LIKE VBAP-KDMAT,
zhtccd LIKE ZSD_TRU_HTC_MAT-ZHTCCD,
ihrez_e LIKE VBKD-IHREZ_E,
taxm1(3) TYPE C,
kbmeng LIKE VBAP-KBMENG,
zzccn LIKE ZSD_TRU_CCN-ZZCCN,
zprgccn LIKE VBAP-ZPRGCCN,
END OF gt_xls.
DATA: BEGIN OF gs_vat,
sign TYPE I,
rate TYPE F,
END OF gs_vat.
DATA: BEGIN OF gs_ggd,
kdmat LIKE VBAP-KDMAT,
kbmeng LIKE VBAP-KBMENG,
END OF gs_ggd.
DATA: BEGIN OF gt_ggd,
ggdln LIKE TABLE OF gs_ggd,
END OF gt_ggd.
DATA: BEGIN OF gs_xml,
zprgccn LIKE VBAP-ZPRGCCN,
zhtccd LIKE ZSD_TRU_HTC_MAT-ZHTCCD,
ihrez_e LIKE VBKD-IHREZ_E,
vattb LIKE TABLE OF gs_vat,
ggdtb LIKE TABLE OF gt_ggd,
END OF gs_xml.
DATA: gt_xml LIKE TABLE OF gs_xml.
*----------------------------------------------------------------------*
* LAYOUT *
*----------------------------------------------------------------------*
PARAMETERS: pa_local(255) TYPE C LOWER CASE OBLIGATORY.
*----------------------------------------------------------------------*
* FORM READ_XML *
*----------------------------------------------------------------------*
FORM read_xml.
DATA: BEGIN OF lt_txt OCCURS 0,
line TYPE STRING,
END OF lt_txt.
DATA: lv_string TYPE STRING.
lv_string = pa_local.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = lv_string
TABLES
DATA_TAB = lt_txt.
CLEAR lv_string.
LOOP AT lt_txt.
CONCATENATE lv_string lt_txt-line INTO lv_string.
ENDLOOP.
CALL TRANSFORMATION ZTRU_CCN
SOURCE XML lv_string
RESULT root = gt_xml.
SEARCH pa_local FOR 'Container_'.
SHIFT pa_local BY SY-FDPOS PLACES LEFT.
SHIFT pa_local BY 10 PLACES LEFT.
REPLACE '_' WITH '/' INTO pa_local.
REPLACE '_' WITH '/' INTO pa_local.
LOOP AT gt_xml INTO gs_xml.
gt_xls-zprgccn = gs_xml-zprgccn.
gt_xls-zhtccd = gs_xml-zhtccd.
gt_xls-ihrez_e = gs_xml-ihrez_e.
LOOP AT gs_xml-vattb INTO gs_vat WHERE sign = 4.
IF gs_vat-rate = '18'.
gt_xls-taxm1 = '18%'.
ELSE.
gt_xls-taxm1 = '10%'.
ENDIF.
ENDLOOP.
gt_xls-zzccn = pa_local(23).
LOOP AT gs_xml-ggdtb INTO gt_ggd.
LOOP AT gt_ggd-ggdln INTO gs_ggd.
gt_xls-kdmat = gs_ggd-kdmat.
gt_xls-kbmeng = gs_ggd-kbmeng.
APPEND gt_xls.
ENDLOOP.
ENDLOOP.
CLEAR gt_xls.
ENDLOOP.
ENDFORM. "read_xml
*----------------------------------------------------------------------*
Trasformazione ZTRU_CCN
Nessun commento:
Posta un commento