Quantcast
Channel: SCN : Document List - ABAP Development
Viewing all articles
Browse latest Browse all 935

Transfer File using HTTP REQUEST

$
0
0

Introduction:

 

There are different solutions for sending document / file to an external NON-SAP System, this document highlights the technique of sending a file using simple HTTP URL.

 

This document illustrates how a HTTP client object is created using ABAP and the usage of different parameters/ attributes involved with it.

 

The file receiver component in the Webserver will be triggered using an HTTP URL, thereby certain aspects such as data security and validity should be accounted while designing the HTTP Service URL in the receiver system.

 

The attributes/parameter sent with the URL during the request, can be used for the below purpose.

 

  • Describing metadata of the file/document that is sent.
  • Security certificates/credentials of authenticity.
  • Handshake during communication between the two systems.

 

These attributes can be sent as URL parameters or as a separate file to the external system along with the file.


A simple scenario of uploading a file using SAP WEB Application and transfer it to a web server using  HTTP  REQUEST POST  is illustrated in this document.

 

The standard class  'CL_HTTP_ENTITY' is used for this purpose.


The code block to transfer the file is generic and can be added in a ABAP Report or it can also be reused by creating  Function Module , ABAP Class etc. This technique can be used to send files currently existing in SAP system or from local clients system.

 

Pre-requisites:

The receiving component should be enabled/active and it should receive the file when the file transfer is triggered from sender system (SAP) using HTTP URL Call .

 

The HTTP URL used here is provided by the receiving system.

 

The file transfer technique is explained below with an example, it divided into following parts.


    1. Web Application using SAP Webdynpro ABAP to upload file from client system and transfer it to NON SAP System     

         using a custom method  'SEND_DOCUMENT'.

    2. ABAP class containing the method 'SEND_DOCUMENT' to transfer the uploaded file.

    3. Executing the application.

 

1. Creating a simple Webdynpro ABAP application, which will use a custom method in a ABAP  Class to transfer the uploaded file using HTTP URL.

 

  • Create Component

Figure_1_a.jpg

Figure 1.a

 

  • Create a node - 'ND_FILE_UPLOAD' to map UI element.

 

Attribute types used in the node.

 

FILE_NAME                  TYPE                             STRING

FILE_TYPE                   TYPE                             STRING

FILE_SIZE                   TYPE                             STRING

FILE_CONTENTS          TYPE                             XSTRING

 

Figure_1_b.jpg

Figure 1.b

 

  • Create a view - 'V_UPLOAD' and map the corresponding node  - 'ND_FILE_UPLOAD' map it to the 'FileUpload' UI Element.

 

Figure_1_c.jpg

Figure 1.c

 

  • The action handler of Submit button will calls a method SEND_DOCUMENT from webdynpro components assistance class as specified in the file 'SUBMIT_ACTION' attached with the document. The method used in the assistance class is elaborated  in part 2 below.

   

 

  • Create Webdynpro Application for the above component.

Figure_1_e.jpg

Figure 1.e

 

 

2. Create a class which contains the method for sending data to other systems.

 

  • Create an ABAP class 'YXX_CL_ARCHIVE_DOCUMENT' with a PUBLIC method 'SEND_DOCUMENT'.

Figure_2_a.jpg

Figure 2.a

 

  • The logic in the 'SEND_DOCUMENT' method is present in the file 'SEND_DOCUMENT' attached with the document.

 

 

 

3. Excecuting the Application :

 

  • Open the URL generated while creating the Webdynpro application, refer Figure 1.e for the URL.

Figure_3_a.jpg

Figure 3.a

  • Upload a test file from local system.

Figure_3_b.jpg

Figure 3.b

  • Submit - Trigger file transfer.

Figure_3_c.jpg

Figure 3.c

 

Conclusion:


The demonstration above explains the file transfer technique using HTTP Request, this is help full in small file transfer.


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>