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

problem in uploading

Former Member
0 Likes
1,317

hi gurus,

I am doing bdc program, in THIS when iam using Fm upload. it will upload the data, but when iam using gui_upload its not working

give me some soln regarding this... I HAVE TO SAVE THE VALUE IN TABLE DIRECTLY THROUGH FLAT FILE

the code is...

CALL FUNCTION ' GUI_UPLOAD'

exporting

filename =

table

itab = ITAB.

INSERTED ZABC FROM TABLE ITAB. " WHERE ZABC IS THE TABLE

SO WHAT I WILL DO TO GET THE FUNCTIONALITY OF UPLOAD IN GUI_UPLOAD.

1 ACCEPTED SOLUTION
Read only

venkat_o
Active Contributor
0 Likes
1,268

Hi Sharma, Try this way. file should be TAB delimited.

REPORT ztest_notepad.
DATA: BEGIN OF it_upload OCCURS 0,
        pernr TYPE pa0001-pernr,
        subty TYPE pa0001-subty,
        ename TYPE pa0001-ename,
      END OF it_upload.
"START-OF-SELECTION

START-OF-SELECTION.
  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename = 'C:\test.txt'
      filetype = 'ASC'
    TABLES
      data_tab = it_upload.
  IF sy-subrc EQ 0.
    LOOP AT it_upload.
      WRITE:/ it_upload-pernr, it_upload-subty, it_upload-ename.
    ENDLOOP.
  ENDIF.
Thanks Venkat.O

13 REPLIES 13
Read only

Former Member
0 Likes
1,268

Hi,

See :

For Scenario 1 u2013

DATA: V_FILE TYPE STRING.
CALL FUNCTION 'GUI_UPLOAD'
 EXPORTING
    FILENAME                = V_FILE
    FILETYPE                = 'ASC'
    HAS_FIELD_SEPARATOR     = u2018Xu2019
    DAT_MODE                = u2018Xu2019
  TABLES
    DATA_TAB                = IT_INPUT
  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.
ENDIF.


DATA: V_FILE TYPE STRING.
CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    FILENAME                = V_FILE
    FILETYPE                = 'ASC'
  TABLES
    DATA_TAB                = IT_INPUT
  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.
ENDIF

.

Read only

Former Member
0 Likes
1,268

are you trying to upload an excel file. If yes, Try using a text file.

I had similar issues while uploading an excel file using GUI_UPLOAD. I encountered this issue after Windows XP SP3 Patch was applied.

Read only

0 Likes
1,268

I AM UPLOADING THE DATA FROM TXT FILE.... BUT ITS NOT TAKING THE VALUE

AFTER GUI_UPLOAD ITS NOT INSERTING THE VALUE FROM ITAB TO ZTABLE

Read only

0 Likes
1,268

Hi,

How are you inserting from your internal table to your database table?

LOOP on the internal table and then insert each record in to the Z table using INSERT statement.

Can you show your code?

Regards,

Ankur Parab

Read only

0 Likes
1,268

Hi,

Take a look at the following code to insert data into ztable:

DATA: lv_err_flag TYPE c,

lv_recnum(10) TYPE c.

LOOP AT gi_itab INTO wa_itab.

INSERT into zhralcon values wa_zhralcon.

IF sy-subrc NE 0.

READ TABLE gi_itab INTO wa_itab INDEX sy-tabix.

lv_recnum = sy-tabix.

WRITE: /'Record# '(001) NO-GAP, lv_recnum NO-GAP, 'was not created- '(002), wa_itab.

lv_err_flag = 'X'.

ENDIF.

ENDLOOP.

ULINE.

IF lv_err_flag = 'X'.

WRITE /'Process completed with some error records.'(003).

ELSE.

WRITE /'Process completed successfully.'(004).

ENDIF.

Regards,

Rajesh Kumar

Read only

0 Likes
1,268

IAM USING CODE...

DATA: ITAB LIKE ZABC OCCURS 0 WITH HEADER LINE.

CALL FUNCTION ' GUI_UPLOAD'

exporting

filename =

table

itab = ITAB.

INSERTED ZABC FROM TABLE ITAB.

Read only

0 Likes
1,268

Hai,

Go through this following Example:

TYPES: begin of g_excel,

Numbr type /saxag/cm_eqcrh-numbr,

Wert type /saxag/cm_eqcri-pydat,

Rate type n,

Tilgung type /saxag/cm_eqcri-hwbtr,

END of g_excel.

DATA: gt_excel type table of g_excel.

DATA: gtw_excel like line of gt_excel .

parameters: p_file type rlgrap-filename.

DATA: it_raw TYPE truxs_t_text_DATA.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

I_LINE_HEADER = 'X'

I_TAB_RAW_DATA = it_raw

I_FILENAME = p_file

TABLES

I_TAB_CONVERTED_DATA = gt_excel.

*--Insert into Database Table

INSERT DBTAB from table gt_excel.

Note: The fields in the above internal table are same as the header names in the Excel file with the same Order. Also, make sure that the Excel file is not opened while running the Program.

Best Regards,

rama

Edited by: newtoAbap on Jul 30, 2009 1:31 PM

Read only

knitinkumarsethy
Explorer
0 Likes
1,268

HI Maneesh,

You can use the Function module as below. Make sure that uploading text file's column are in same order with you declared internal table, and must be separated by a tab.

PARAMETERS : P_FILE LIKE IBIPPARMS-PATH OBLIGATORY.

DATA: BEGIN OF GT_FILE OCCURS 0,

KUNNR(10)," LIKE KNA1-KUNNR,

WRBTR(20)," LIKE BSEG-WRBTR,

SGTEXT(250) TYPE C,

END OF GT_FILE.

DATA: L_FILE TYPE STRING.

L_FILE = P_FILE.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = L_FILE

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

READ_BY_LINE = 'X'

TABLES

DATA_TAB = GT_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.

Regards,

Nitin

Read only

0 Likes
1,268

YES, I AM DOING THE SAME THING, BUT ITS NOT WORKING, ITS NOT INSERTING THE VALUE IN THE TABLE AFTER THE GUI_UPLOAD...

I WANT TO TRANSFER THE DATA FROM ITAB TO ZTABLE.

I am TAKING THE VALUE FROM TXT FILE.

Edited by: Manish Sharma on Jul 30, 2009 12:52 PM

Read only

0 Likes
1,268

Hi,

After the populating the internal table from text file using GUI_UPLOAD, use the following


INSERT ZTABLE  FROM TABLE ITAB.

Read only

Former Member
0 Likes
1,268

Hi,

Use the FM as mentioed below.

DATA: lv_filetype(10) TYPE c,

lv_gui_sep TYPE c,

lv_file_name TYPE string.

lv_filetype = 'ASC'.

lv_gui_sep = 'X'.

lv_file_name = pa_dfile.

  • FM call to upload file

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = lv_file_name

filetype = lv_filetype

has_field_separator = lv_gui_sep

TABLES

data_tab = gi_zhralcon_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.

But the file mentioed here should be a tab delimited file not an excel work sheet.

hope it helps you.

Regards,

Rajesh Kumar

Edited by: Rajesh Kumar on Jul 30, 2009 12:47 PM

Read only

venkat_o
Active Contributor
0 Likes
1,269

Hi Sharma, Try this way. file should be TAB delimited.

REPORT ztest_notepad.
DATA: BEGIN OF it_upload OCCURS 0,
        pernr TYPE pa0001-pernr,
        subty TYPE pa0001-subty,
        ename TYPE pa0001-ename,
      END OF it_upload.
"START-OF-SELECTION

START-OF-SELECTION.
  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename = 'C:\test.txt'
      filetype = 'ASC'
    TABLES
      data_tab = it_upload.
  IF sy-subrc EQ 0.
    LOOP AT it_upload.
      WRITE:/ it_upload-pernr, it_upload-subty, it_upload-ename.
    ENDLOOP.
  ENDIF.
Thanks Venkat.O

Read only

Former Member
0 Likes
1,268

Hi Manish,

Follow the code given by Balu Latpate (First example by him) , before following his code save your excel file as Text(tab delimited). Your internal table fields should be same as per your excel sheet . I mean follow the same sequence .

In debug mode you can check your internal table. It will definately work.