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

upload document file using gui_upload

Former Member
0 Likes
4,696

Hello Team,

Can u please just how to upload a document file (.DOC file ) into SAP using gui_upload .I tried using ASC type and BIN ..It appears with symbols into internal table..

Please suggest.

Regards,

Geeta

15 REPLIES 15
Read only

Former Member
Read only

0 Likes
2,859

Hai,

Thanks for your reply .. but i am not able to open the second link.

1st link says for uploading Excel file..i need to upload a document .its not working for a document file.

Regards

Geeta

Read only

gouravkumar64
Active Contributor
0 Likes
2,859

Hi, @geeta ,

You can try  like this thread

https://scn.sap.com/thread/260900

You can try also concept of GOS in sap.

Also check this class & its methods

CL_ISHMED_DOC_WORD_DATA.

Try it.

Thanks

Gourav.

Read only

0 Likes
2,859

Hai kumar,

Thanks for your answer...will try this and see.

Regards,

Geeta

Read only

Former Member
0 Likes
2,859

Hi Geetha.......

To upload a word-document in the native word format it is the best to do this directly in binary format (BIN). Important here is to take the binary_file size back from the gui_upload ( u can use either function module / cl_gui_frontend_services). Uploading it directly in binary format avoids later conversion.

For conversion to xstring and back from xstring to binary table you can use function modules SCMS_BINARY_TO_XSTRING and SCMS_XSTRING_TO_BINARY.

Try this u can get the result

Thanks & Regards

G.Kranthi Kumar Reddy.

Read only

0 Likes
2,859

Hi Kranthi,

As u said,first using bin type we should upload doc file in gui_upload then should use this 2 FM SCMS_BINARY_TO_XSTRING and SCMS_XSTRING_TO_BINARY.

Is it correct.

Regards,

Geeta

Read only

0 Likes
2,859

Dear Geetha u are right ,

First upload the Doc into itab ,

and then declare a xstring variable as xstring , import this throw buffer which for the 1st FM ,

and Export this buffer value into 2nd FM.

U can find full at Debugging....

thanks & Regards

Kranthi Kumar Reddy 

🙂

Read only

0 Likes
2,859

Hai kranthi,

I tried the way you said but after the second FM , I got some symbols into internal table.

Regards,

Geeta

Read only

0 Likes
2,859

Dear geetha ,

R U Uploading the file with .doc or .docx ,

Please Check,

Because now a days some people using either  Office 2003 or 2007

Thanks & Rgds,

Kranthi

Read only

0 Likes
2,859

Hai Kranthi,

I am uploading document with .doc only..

Regards,

Geeta

Read only

Former Member
0 Likes
2,859

Hello geeta,

use filetype RAW instead of ASC and BIN.

Thanks

Sabyasachi

Read only

0 Likes
2,859

hello karforma ,

Please check ur answer before posting...

if we use ur answer it throws illegal error.

Plz check

Thanks,

Kranthi

Read only

Former Member
0 Likes
2,859

Hi Geeta,

Could you just go through this program SAPRDEMO_FORM_INTERFACE.

The same is given in this thread : http://scn.sap.com/thread/1656176

Thanks,

Namrata

Read only

Former Member
0 Likes
2,859

Team,

Please suggest any other way to upload a .doc file into sap .

Regards,

Geeta

Read only

0 Likes
2,859

Dear Geetha,

Have u tried this..

DATA : V_BUFFER TYPE XSTRING.

CALL FUNCTION 'GUI_UPLOAD'
   EXPORTING
     filename                      = v_file
     FILETYPE                      = 'BIN'
*   HAS_FIELD_SEPARATOR           = ' '
*   HEADER_LENGTH                 = 0
*   READ_BY_LINE                  = 'X'
*   DAT_MODE                      = ' '
*   CODEPAGE                      = ' '
*   IGNORE_CERR                   = ABAP_TRUE
*   REPLACEMENT                   = '#'
*   CHECK_BOM                     = ' '
*   VIRUS_SCAN_PROFILE            =
*   NO_AUTH_CHECK                 = ' '
* IMPORTING
*   FILELENGTH                    =
*   HEADER                        =
   tables
     data_tab                      = IT_FILE
* EXCEPTIONS
*   FILE_OPEN_ERROR               = 1
*   FILE_READ_ERROR               = 2
*   NO_BATCH                      = 3
*   GUI_REFUSE_FILETRANSFER       = 4
*   INVALID_TYPE                  = 5
*   NO_AUTHORITY                  = 6
*   UNKNOWN_ERROR                 = 7
*   BAD_DATA_FORMAT               = 8
*   HEADER_NOT_ALLOWED            = 9
*   SEPARATOR_NOT_ALLOWED         = 10
*   HEADER_TOO_LONG               = 11
*   UNKNOWN_DP_ERROR              = 12
*   ACCESS_DENIED                 = 13
*   DP_OUT_OF_MEMORY              = 14
*   DISK_FULL                     = 15
*   DP_TIMEOUT                    = 16
*   OTHERS                        = 17
           .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
     EXPORTING
       input_length       = 7
      FIRST_LINE         = 1
      LAST_LINE          = 1
     IMPORTING
      BUFFER             = V_BUFFER
     TABLES
       binary_tab         = it_file
*   EXCEPTIONS
*     FAILED             = 1
*     OTHERS             = 2
             .
   IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
   ENDIF.



  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
     EXPORTING
       buffer                = V_BUFFER
*    APPEND_TO_TABLE       = 'X'
* IMPORTING
*   OUTPUT_LENGTH         =
*
     tables
       binary_tab            = IT_FILE
             .

Here it_file is document file itab

Thanks & Regards

G.Kranthi