Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

XML download

divsmart
Participant
0 Kudos
253

lDear Team,

I have an requirment to download the ALV to XML files by single line item via 'Material , Document no & lines items'

Here the issue's was when i download the XML 'I getting some characters in document'

Please help me how to clear it.

FORM convert_xml_form .

TYPES: BEGIN OF ty_xml,
mblnr TYPE mseg-mblnr,
zeile TYPE mseg-zeile,
ebeln TYPE mseg-ebeln,
matnr TYPE mseg-matnr,
erfme TYPE mseg-erfme,
erfmg TYPE mseg-erfmg,
menge TYPE mseg-menge,
lifnr TYPE mseg-lifnr,
name2 TYPE lfa1-name2,
END OF ty_xml.
DATA: BEGIN OF gt_xml OCCURS 0,
line(120),
END OF gt_xml.

DATA: lt_xml TYPE TABLE OF ty_xml,
ls_xml TYPE ty_xml.

DATA: ld_filename TYPE string,
file_path TYPE string,
l_filename TYPE string,
ld_path TYPE string,
ld_fullpath TYPE string,
ld_result TYPE i,
lv_path TYPE string,
lv_data TYPE string.

LOOP AT lt_last INTO ls_last.

gt_xml-line = '<Material Received>'.
APPEND gt_xml.

gt_xml-line = '<Receiving Number>' .
APPEND gt_xml.

gt_xml-line = '<Line Item>' .
APPEND gt_xml.

gt_xml-line = '<Purshase Order>' .
APPEND gt_xml.

gt_xml-line = '<Part Number>' .
APPEND gt_xml.

gt_xml-line = '<Unit Of Entry >' .
APPEND gt_xml.

gt_xml-line = '<Qty Of UOM>' .
APPEND gt_xml.

gt_xml-line = '<Quantity >' .
APPEND gt_xml.

gt_xml-line = '<Vendor name >' .
APPEND gt_xml.

gt_xml-line = ls_last-mblnr .
APPEND gt_xml.

gt_xml-line = ls_last-zeile .
APPEND gt_xml.

gt_xml-line = ls_last-ebeln .
APPEND gt_xml.

gt_xml-line = ls_last-matnr .
APPEND gt_xml.

gt_xml-line = ls_last-erfme .
APPEND gt_xml.

gt_xml-line = ls_last-erfmg .
APPEND gt_xml.

gt_xml-line = ls_last-menge.
APPEND gt_xml.

gt_xml-line = ls_last-name2.
APPEND gt_xml.

gt_xml-line = '</Receiving Number>' .
APPEND gt_xml.

gt_xml-line = '</Line Item>' .
APPEND gt_xml.

gt_xml-line = '</Purshase Order>' .
APPEND gt_xml.

gt_xml-line = '</Part Number>' .
APPEND gt_xml.

gt_xml-line = '</Unit Of Entry >' .
APPEND gt_xml.

gt_xml-line = '</Qty Of UOM>' .
APPEND gt_xml.

gt_xml-line = '</Quantity >' .
APPEND gt_xml.

gt_xml-line = '</Vendor >' .
APPEND gt_xml.

gt_xml-line = '</Material Received>'.
APPEND gt_xml.

lv_path = p_file.


CLEAR : lv_data.
CONCATENATE ls_last-matnr '-' ls_last-mblnr '-' ls_last-zeile INTO lv_data.

l_filename = lv_data.


CONCATENATE lv_path 'ZMPNREP1\' l_filename'.XML' INTO ld_fullpath.

CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = ld_fullpath
filetype = 'DBF'
TABLES
data_tab = gt_xml
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
REFRESH:gt_xml.
CLEAR: ls_last,lv_path,file_path,l_filename,ld_fullpath.
ENDLOOP.

ENDFORM. " CONVERT_XML_FORM

image.png

3 REPLIES 3

Sandra_Rossi
Active Contributor
0 Kudos
176

You should not use DBF format (DBase format), it's not supported. You should use ASC or BIN. ASC in your case.

divsmart
Participant
0 Kudos
176

Thanks for reply Sandra Rossi.

I need to download the .XML format. I got as per client requirment .

But my issue was when i download it 'I getting some char as per above attached attachment.

Please help me!!!!.

divsmart
Participant
0 Kudos
176

Hi ,

Please help for above Question.

I have an requirment to download the ALV to XML files by single line item via 'Material , Document no & lines items'

Here the issue's was when i download the XML 'I getting some characters in document'

Please help me how to clear it.

FORM convert_xml_form .

TYPES: BEGIN OF ty_xml,
mblnr TYPE mseg-mblnr,
zeile TYPE mseg-zeile,
ebeln TYPE mseg-ebeln,
matnr TYPE mseg-matnr,
erfme TYPE mseg-erfme,
erfmg TYPE mseg-erfmg,
menge TYPE mseg-menge,
lifnr TYPE mseg-lifnr,
name2 TYPE lfa1-name2,
END OF ty_xml.
DATA: BEGIN OF gt_xml OCCURS 0,
line(120),
END OF gt_xml.

DATA: lt_xml TYPE TABLE OF ty_xml,
ls_xml TYPE ty_xml.

DATA: ld_filename TYPE string,
file_path TYPE string,
l_filename TYPE string,
ld_path TYPE string,
ld_fullpath TYPE string,
ld_result TYPE i,
lv_path TYPE string,
lv_data TYPE string.

LOOP AT lt_last INTO ls_last.

gt_xml-line = '<Material Received>'.
APPEND gt_xml.

gt_xml-line = '<Receiving Number>' .
APPEND gt_xml.

gt_xml-line = '<Line Item>' .
APPEND gt_xml.

gt_xml-line = '<Purshase Order>' .
APPEND gt_xml.

gt_xml-line = '<Part Number>' .
APPEND gt_xml.

gt_xml-line = '<Unit Of Entry >' .
APPEND gt_xml.

gt_xml-line = '<Qty Of UOM>' .
APPEND gt_xml.

gt_xml-line = '<Quantity >' .
APPEND gt_xml.

gt_xml-line = '<Vendor name >' .
APPEND gt_xml.

gt_xml-line = ls_last-mblnr .
APPEND gt_xml.

gt_xml-line = ls_last-zeile .
APPEND gt_xml.

gt_xml-line = ls_last-ebeln .
APPEND gt_xml.

gt_xml-line = ls_last-matnr .
APPEND gt_xml.

gt_xml-line = ls_last-erfme .
APPEND gt_xml.

gt_xml-line = ls_last-erfmg .
APPEND gt_xml.

gt_xml-line = ls_last-menge.
APPEND gt_xml.

gt_xml-line = ls_last-name2.
APPEND gt_xml.

gt_xml-line = '</Receiving Number>' .
APPEND gt_xml.

gt_xml-line = '</Line Item>' .
APPEND gt_xml.

gt_xml-line = '</Purshase Order>' .
APPEND gt_xml.

gt_xml-line = '</Part Number>' .
APPEND gt_xml.

gt_xml-line = '</Unit Of Entry >' .
APPEND gt_xml.

gt_xml-line = '</Qty Of UOM>' .
APPEND gt_xml.

gt_xml-line = '</Quantity >' .
APPEND gt_xml.

gt_xml-line = '</Vendor >' .
APPEND gt_xml.

gt_xml-line = '</Material Received>'.
APPEND gt_xml.

lv_path = p_file.


CLEAR : lv_data.
CONCATENATE ls_last-matnr '-' ls_last-mblnr '-' ls_last-zeile INTO lv_data.

l_filename = lv_data.


CONCATENATE lv_path 'ZMPNREP1\' l_filename'.XML' INTO ld_fullpath.

CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = ld_fullpath
filetype = 'DBF'
TABLES
data_tab = gt_xml
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
REFRESH:gt_xml.
CLEAR: ls_last,lv_path,file_path,l_filename,ld_fullpath.
ENDLOOP.

ENDFORM. " CONVERT_XML_FORM