Dear SAP & DMS experts,
I would like to know how to check the size of the file being uploaded on the Application Server -AL11- at runtime.
My problem ist the following:
When using the FM HTTP_GET_FILE
to upload the DMS files (original draws of Materials) on the Application Server (T-code AL11), I sometimes face the following problem:
The uploaded files in the app server are picked up incomplete by another report (SAP background job). This may be due to overlapping of both reports (the 1st report uploading the documents into the app server and the 2nd report (job) reading it and sending it as Email).
Up to this point, my attempt to solve the problem was: During the 2nd report, the size of the original file is compared to the uploaded file. If both sizes are unequal, wait 1 second and compare again until both sizes are equal. Unfortunately I couldn’t implement this solution because I don’t have access to the file size during uploading.
If it is not possible to determine the file size, are there any other ideas to avoid this problem?
I hope that I could give a clear idea of the problem.
I am thankful for all help and information.
Khaled
Edit (Just to clarify the use of HTTP_GET_FILE
):
Get the link of original file using the FM CVAPI_DOC_VIEW
Then, "upload" the file using the returned pfx_url
to the sap application server (AL11)
To get the size of a file on the application server, nothing is proposed out-of-the-box by SAP. You have to use:
SXPG_COMMAND_EXECUTE
)C_DIR_READ_START
, C_DIR_READ_NEXT
, C_DIR_READ_FINISH
.You may find some examples in the web for the two first possibilities.
Calculate the file size in ABAP (slow performance for big files) :
data read_buffer type x length 1000.
data(fullpath) = `/tmp/file`.
data(file_size) = 0.
open dataset fullpath for input in binary mode.
do.
read dataset fullpath into read_buffer ACTUAL LENGTH data(actual_length).
if actual_length = 0.
exit.
endif.
add actual_length to file_size.
enddo.
close dataset fullpath.