2023 Jan 27 4:59 AM
Hi Experts,
I need to download the XML files in BG , I done as per requirment.
But i need an format as below. Please advice
FORM convert_xml_form .
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 rlgrap-filename,"string,
lv_data TYPE string.
DATA: gs_name(30) TYPE c VALUE '_Material Received'.
DATA: ls_string TYPE string.
LOOP AT lt_last1 INTO ls_last1.
gs_xml-line = '<Material Received>'.
APPEND gs_xml TO gt_xml.
gs_xml-line = '<Receiving Number>' .
APPEND gs_xml TO gt_xml.
gs_xml-line = ls_last1-mblnr .
APPEND gs_xml TO gt_xml.
gs_xml-line = '</Receiving Number>' .
APPEND gs_xml TO gt_xml.
gs_xml-line = '<Line Item>' .
APPEND gs_xml TO gt_xml.
gs_xml-line = ls_last1-zeile .
APPEND gs_xml TO gt_xml.
gs_xml-line = '</Line Item>' .
APPEND gs_xml TO gt_xml.
gs_xml-line = '<Purshase Order>' .
APPEND gs_xml TO gt_xml.
gs_xml-line = ls_last1-ebeln .
APPEND gs_xml TO gt_xml.
gs_xml-line = '</Purshase Order>' .
APPEND gs_xml TO gt_xml.
gs_xml-line = '<Part Number>' .
APPEND gs_xml TO gt_xml.
gs_xml-line = ls_last1-matnr .
APPEND gs_xml TO gt_xml.
gs_xml-line = '</Part Number>' .
APPEND gs_xml TO gt_xml.
gs_xml-line = '<Unit Of Entry >' .
APPEND gs_xml TO gt_xml.
gs_xml-line = ls_last1-erfme .
APPEND gs_xml TO gt_xml.
gs_xml-line = '</Unit Of Entry >' .
APPEND gs_xml TO gt_xml.
gs_xml-line = '<Qty Of UOM>' .
APPEND gs_xml TO gt_xml.
gs_xml-line = ls_last1-erfmg .
APPEND gs_xml TO gt_xml.
gs_xml-line = '</Qty Of UOM>' .
APPEND gs_xml TO gt_xml.
gs_xml-line = '<Quantity >' .
APPEND gs_xml TO gt_xml.
gs_xml-line = ls_last1-menge.
APPEND gs_xml TO gt_xml.
gs_xml-line = '</Quantity >' .
APPEND gs_xml TO gt_xml.
gs_xml-line = '<Vendor name >' .
APPEND gs_xml TO gt_xml.
gs_xml-line = ls_last1-name1.
APPEND gs_xml TO gt_xml.
gs_xml-line = '</Vendor name >' .
APPEND gs_xml TO gt_xml.
gs_xml-line = '</Material Received>'.
APPEND gs_xml TO gt_xml.
lv_path = p_file.
CLEAR : lv_data.
CONCATENATE ls_last1-matnr '-' ls_last1-mblnr '-' ls_last1-zeile gs_name INTO lv_data.
CONCATENATE lv_path lv_data'.XML' INTO ld_fullpath.
*-----------------------------------------------------------------
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = ld_fullpath
filetype = 'ASC'
CHANGING
data_tab = gt_xml
EXCEPTIONS
OTHERS = 24.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
REFRESH:gt_xml.
CLEAR: ls_last,ls_last1,lv_path,file_path,l_filename,ld_fullpath.
ENDLOOP.
2023 Jan 27 6:55 AM
Perform some search on statement CALL TRANSFORMATION (online help) (forum)
2023 Jan 30 8:02 AM
Thanks Raymond,
I used CALL TRANSFORMATION to download the XML file as below .
Here i need to change the column name as attachment.
Please advice.
DATA: lv_path TYPE rlgrap-filename,"string,Getting output:
Need output:
2023 Jan 27 6:57 AM
Hello,
do you really really need that "pretty print" formating? Keep in mind that it is just for humans. Importing program / API does NOT need it to be able to read it.
If yes, then I suggest to try ID transformation in ABAP using parameter "indend", which formats your XML output:
Check some code examaples here:
https://www.kerum.pl/infodepot/00049?showinfo=00049
(using standard transformation ID_INDENT)
2023 Jan 27 12:41 PM
It seems that your question is not very clear. Could you elaborate?
NB: in background, the program runs on the server in "standalone mode", so you cannot run operations on the frontend (GUI_DOWNLOAD will fail for instance).
2023 Jan 27 2:00 PM
Your right display is a human-readable one as displayed by browsers or editor, be aware that it's not the actual internal format of the xml file. Did you already try to open your flat file in a browser or xml editor?