Entering content frame

Function documentation Uploading Files and Manipulating their Content  Locate the document in its SAP Library structure

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" %>
<html>
<body>
<form method="POST" enctype="multipart/form-data">
    <input type=file name="inputFile">
    <input type=submit value="Manipulate">
</form>

<% DATA: content     TYPE STRING,
                 Xcontent   TYPE XSTRING,
                entity        TYPE REF TO if_http_entity,
                idx            TYPE I VALUE 1.

    WHILE idx <= request->num_multiparts( ).
        entity = request->get_multipart( idx ).
        idx = idx + 1.

        IF entity->get_header_field( '~content_filename' ) IS INITIAL.
            CONTINUE.
        ENDIF.

        Xcontent = entity->get_data( ).
        IF XSTRLEN( Xcontent ) IS INITIAL.
            CONTINUE.
        ENDIF.

        DATA: conv   TYPE REF TO CL_ABAP_CONV_IN_CE.
        conv = CL_ABAP_CONV_IN_CE=>CREATE( input = Xcontent ).
        conv->READ( importing data = content ).
        EXIT.
    ENDWHILE.
%>

<h2>Manipulated Contents Example:</h2>
<%   TRANSLATE content TO LOWER CASE.
        TRANSLATE content USING 'aAeEiIoOuU'.
%>
<pre><%=content%></pre>
</body>
</html>

 

 

Leaving content frame