Uploading Files and Manipulating their Content
Use
In addition to purely uploading files, there can also be scenarios in which you first want to upload a file from the browser and then change the content of this file. You may want to enhance an order form with specific information, for example. The uploaded file is returned as
XSTRING. However, when you manipulate the content you require data type STRING. You therefore need to convert XSTRING to STRING.Three ABAP classes are available for conversions:
Imports external formats into ABAP data objects. (Reads a binary input stream.)
Outputs ABAP data objects to an external format. (Writes to a binary output stream.)
Imports data in any format and outputs data in any other format. (Reads from a binary input stream and writes to a binary output stream.)
You can find additional information about the conversion classes in the keyword documentation in ABAP Objects ® ABAP System Classes ® Classes for Character Set and Number Format Conversion.
Example
<%@ page language="abap" %> <% DATA: content TYPE STRING, WHILE idx <= request->num_multiparts( ). IF entity->get_header_field( '~content_filename' ) IS INITIAL. Xcontent = entity->get_data( ). DATA: conv TYPE REF TO CL_ABAP_CONV_IN_CE. <h2>Manipulated Contents Example:</h2> |