‎2019 Dec 10 9:35 AM
dear Experts,
I tried to upload bmp image to se78 using:
perform import_bitmap_bds
in program saplstxbitmaps
using filename
name
'GRAPHICS' "Object
'BMAP' "ID
'BMON' "BMON : B/W, BCOL: Color image
'BMP' "Extension
title
space
space
'X'
changing l_docid
l_resolution.
This sub routine is called in loop.
So I have for example 2 files bmp and I loop those 2 files and upload them to se78 using above sub routine, the problem is whenever I upload the second one, a read file error occured everytime.
What seems to be the problem?
Thanks
Error
‎2019 Dec 10 10:02 AM
Can you explain what happens exactly when there is a "read file error"?
‎2019 Dec 10 10:04 AM
I read somewhere that the PERFORM ... IN PROGRAM is now a BAD PRACTICE and should not be used anymore
‎2019 Dec 10 10:10 AM
‎2019 Dec 10 10:11 AM
Hi fred is there other way to upload bmp to se78 using abap?
‎2019 Dec 10 10:15 AM
frdric.girod It's in the ABAP documentation that PERFORM shouldn't be used (obsolete), and PERFORM IN PROGRAM really should be used! (obsolete and bad practice).
‎2019 Dec 10 10:17 AM
sam.indra2 You could look at the code of the FORM and see how SAP did it.
‎2019 Dec 10 10:20 AM
matthew.billingham already did and it's just throw that error , just can't figured it out why, if I upload them one by one then it's no problem.
it seems that maybe it cannot be used in a loop, because it's too fast to process.
‎2019 Dec 10 10:25 AM
or maybe the filename is wrong
or maybe you have not the authorization to read it at OS level
...
‎2019 Dec 10 10:28 AM
More precisely, forms is an obsolete technology, people shouldn't create subroutines anymore, PERFORM is not obsolete because there are still subroutines in old programs. What is obsolete is PERFORM subr(prog), which should be replaced with PERFORM subr IN PROGRAM prog.
(but it could be argued that some programs might contain some old technologies, and improvements would require the creation of subroutines by force...)
NB: sam.indra2 I still don't understand if the error produces a short dump or something else...
EDIT:
I looked at the standard code, the concerned line is below (message TD811 = "Error opening file &")
message e811 with p_filename.
which is executed after function module GUI_UPLOAD if it returns the exception file_open_error.
Conclusion: in your custom program, if the variable filename contains an incorrect path, it will send this error. Or maybe it's because the file is locked at Windows level (just close the file before running the ABAP program).
‎2019 Dec 11 2:42 AM
sandra.rossi I'm sure the function cannot be executed in background or automatic processing.
because I try to execute the subroutine using BDC and it's generating the same error. BUT if I do it manually, it works like a charm.
Because it's the nature of GUI_UPLOAD.
Updated:
as I expected, this article below showed that any gui function cannot be used in background. So how do I upload images to se78 automatically?
I also tried to call this function using SAP PI, whether using SOAP to RFC or file to RFC but whenever it reaches the function, it's always being cancelled.
this is so confusing.
https://answers.sap.com/questions/3288523/a-function-module-that-can-replace-guiupload.html
‎2019 Dec 11 5:58 AM
Sam Indra I'm confused too, it's no more a matter of looping.
Now that you're talking about BDC (in background mode) or background, I confirm that GUI_UPLOAD cannot work in background, no workaround. But I don't understand why you said that in the loop it used to work for the first file.
If you want to access files without connection to SAP GUI, you may for instance store the files on the application server (if the files originally come from a user's laptop, the user has to transfer it to the server in dialog, before you run your program).
If you want to import files from any location into SE78, Unfortunately, there is no other solution than copying the code of the subroutine import_bitmap_bds of program saplstxbitmaps (essentially it's made of four parts: GUI_UPLOAD, SAPSCRIPT_CONVERT_BITMAP_BDS, write to BDS via CL_BDS_DOCUMENT_SET, insert table STXBITMAPS), and rewrite the GUI_UPLOAD section, for instance with OPEN DATASET, etc. if the file is on the application server. Unfortunately, there is no other solution than writing directly to the table STXBITMAPS.
‎2019 Dec 11 6:32 AM
sandra.rossi yes I tried to do it manually using loop in se38 custom program, but when upload the second one, it's prompted with a read error message, and second try was using bdc where it failed from the start.
I also tried to make a BDC for se78, it works actually BUT unfortunately I have to open the folder manually and click the import image menu and cannot be done with any short cut that resulted =%_GC 118 22 value in BDC which means it's unreachable.
The project description is to upload the bmp files to SAP that later be used in adobe form report. But the uploaded process should be done automatically.
Yes re-writing the entire code may be the last option I could think off. But still open with another ways of doing this, if any.