Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Error looping function gui_upload

Former Member
0 Likes
2,537

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

12 REPLIES 12
Read only

Sandra_Rossi
Active Contributor
2,380

Can you explain what happens exactly when there is a "read file error"?

Read only

FredericGirod
Active Contributor
2,380

I read somewhere that the PERFORM ... IN PROGRAM is now a BAD PRACTICE and should not be used anymore

Read only

Former Member
0 Likes
2,380

hi Sandra the error:

Error opening file

Read only

Former Member
0 Likes
2,380

Hi fred is there other way to upload bmp to se78 using abap?

Read only

matt
Active Contributor
2,380

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).

Read only

matt
Active Contributor
0 Likes
2,380

sam.indra2 You could look at the code of the FORM and see how SAP did it.

Read only

Former Member
0 Likes
2,380

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.

Read only

FredericGirod
Active Contributor
2,380

or maybe the filename is wrong

or maybe you have not the authorization to read it at OS level

...

Read only

Sandra_Rossi
Active Contributor
2,380

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).

Read only

Former Member
0 Likes
2,380

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

Read only

Sandra_Rossi
Active Contributor
0 Likes
2,380

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.

Read only

Former Member
0 Likes
2,380

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.