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

function ws_upload error

Former Member
0 Likes
2,600

Hi ,

I am uploading a file through function module 'WS_UPLOAD' but it does not uploads everything.

It just uploads first 7 fields .

The file which i am uploading is a tab delimited file .Here is my code .

data: pathname type rlgrap-filename,
         filename type rlgrap-filename,
         file_length type n.

  data:  tmp_filename type rlgrap-filename,
         ftype type rlgrap-filetype.



* Get the file name
  clear pathname.

*      perform get_filename using filename 'O' changing pathname.

      call function 'WS_FILENAME_GET'
        exporting
          def_filename     = filename
          def_path         = pathname
          mask             = ',*.*,*.*.'
          mode             = 'O'
        importing
          filename         = tmp_filename
        exceptions
          inv_winsys       = 01
          no_batch         = 02
          selection_cancel = 03
          selection_error  = 04.

      if sy-subrc = 0.
        pathname = tmp_filename.
      endif.


      ftype = 'DAT'.
* Upload the data from the mentioned file name
      if not pathname is initial.
*        perform upload using pathname ftype file_length.

        call function 'WS_UPLOAD'
          exporting
            codepage                = 'IBM'
            filename                = pathname
            filetype                = ftype
            user_form               = ' '
            user_prog               = ' '
            dat_d_format            = ' '
          importing
            filelength              = file_length
          tables
            data_tab                = user_temp_tab
          exceptions
            conversion_error        = 1
            file_open_error         = 2
            file_read_error         = 3
            invalid_type            = 4
            no_batch                = 5
            unknown_error           = 6
            invalid_table_width     = 7
            gui_refuse_filetransfer = 8
            customer_error          = 9
            others                  = 10.

      endif.

Can anyone tell me the reason for this because i am using this function in a BADI to upload the data.

18 REPLIES 18
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,047

WS_UPLOAD is an obsolete FM & should not be used. Instead use GUI_UPLOAD & pass the HAS_FIELD_SEPARATOR = 'X' while calling the FM.

BR,

Suhas

Read only

rainer_hbenthal
Active Contributor
0 Likes
2,047

Even if its old & obsolete, it will NOT stop after the seventh column.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,047

Hey Rainer,

I think the horizontal tabs in the file are the culprit. I am not sure if WS_UPLOAD has the importing param HAS_FIELD_SEPARATOR (currently i cannot login into my SAP server) so i suggested GUI_UPLOAD

BR,

Suhas

Read only

0 Likes
2,047

Hi,

Can u tell that if there is any other format which would work with this function module.

Thanks

Read only

0 Likes
2,047

Hi ,

It still does not work with gui_upload function module.Still first 7 fields are coming not the rest . I have a total of 19 fields.

After 7th field there are numbers which are not being loaded.

Thanks,

Amber

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,047

Is the internal table defined in a way so that it can handle all the 19 fields ?

Anyways can you paste the declaration of your internal table into which you are uploading the data & the call to GUI_UPLOAD ?

BR,

Suhas

Read only

0 Likes
2,047

yes the file format is right and it has 19 fields in same order as there are in the file which i am uploading and the table is already decleared in the standard program so it does not let me create one with the same name in my BADI .

Thanks ,

amber

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,047

If you are uploading a tab delimited file why are you using a codepage = 'IBM' & filetype = 'DAT' ?

Read only

0 Likes
2,047

Hi Amber,

can you post the type declaration for the internal table.

Thanks and Regards,

Gopal

Read only

Former Member
0 Likes
2,047

Hi,

Please check value of file_length.

This might be creating problem.

Read only

0 Likes
2,047

Hi Amber Bhaita,

As per my knowledge, WS_FILENAME_GET is also Obsolete. So you have to replace it with appropriate one i.e. with using class CL_GUI_FRONTEND_SERVICES and method file_open_dialog. Then you try. I hope it would work.

As it is taking 7 fields only means it is making mistake in import of data NOT in the code.

Please give feedback whether it works or not.

Harish

Read only

Former Member
0 Likes
2,047

DATA: BEGIN OF WA_MARA,

matnr type matnr,

END OF WA_MARA.

DATA: FF_PATH TYPE STRING.

FF_PATH = 'C:\Documents and Settings\Desktop\VIG.txt'.

DATA: IT_MARA LIKE TABLE OF WA_MARA WITH HEADER LINE .

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = FF_PATH

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = ' '

TABLES

DATA_TAB = IT_MARA.

WRITE / 'the uploaded records in the internal table are'.

WRITE /.

LOOP AT IT_MARA.

WRITE: / IT_MARA.

ENDLOOP.

Read only

Former Member
0 Likes
2,047

How do you see that it is only uploading the first seven fields? In debugging, what do you see if you enter say the eighth field at the beginning of the display?

Rob

Read only

0 Likes
2,047

Hi Rob,

I cannot put the 8th and any fields after that in the beginning as the fields from 8th till 19 are all of type CURR and the ones in the beginning are either CHAR or NUMC type . I tried putting some values in the first 4 fields still 8th(including 8th) field onwards it does not take any value ...

Read only

Former Member
0 Likes
2,047

Can you try making ALL the fields in your internal table type CHAR instead of CURR. Then as you loop thru the table move the CHAR fields to you CURR fields. At lease give it a try. Seems pretty suspicious that the CHAR fields load fine but the CURR fields don't.

Read only

0 Likes
2,047

Hi All,

I tried uploading the file in another desktop and it is uploading fine in the development server with ws_upload but not in the quality and production server .

As someone told me above to check the file_lenght and it was 0.

Thanks,

Amber

Read only

0 Likes
2,047

Hi,

If the declaration of the internal table is from any table, then check whether the table has those many fields in both development systems and production system, as you are telling it is working fine in development system and not in quality and production system. there may be chances for some of the field addition changes not moved to other systems.

Thanks and Regards,

Gopal

Read only

Former Member
0 Likes
2,047

Thanks All,

It's done . There was a problem with saving the file .

regards,

Amber