Application Development 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: 

Problem with GUI_UPLOAD

Former Member
0 Kudos

Dear All,

I have a problem with GUI_UPLOAD. I have an excel file containing 255 characters of data in one column. I want to take it into one internal table.I cannot use ALSM_EXCEL_TO_INTERNAL_TABLE as the max character upto which it can upload is 50 characters. I have uploaded the file (taken into Text file with TAB delemeted). It is showing # where the file has been tab delemeted. But while splitting through SPLIT command, system is not able to read # as split parameter. I have tried to upload the excel or Text file in DAT mode, but system is unable to recognize the mode. The internal tables that I have declared: one with 255 characters where all the records will be uploaded and another is two columns one with 18 character and another with 255 characters where the split value will be taken. Can you please suggest anything on this?

Thanks and regards,

Atanu

5 REPLIES 5

Former Member
0 Kudos

try to use FM text_convert_xls_to_sap

this may remove your problem

do reward

Former Member
0 Kudos

Try dis;

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

  • I_FIELD_SEPERATOR =

i_line_header = 'X'

i_tab_raw_data = it_raw " WORK TABLE

i_filename = p_file

TABLES

i_tab_converted_data = it_ft "ACTUAL DATA

EXCEPTIONS

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

ENDFORM. " convert_excelto_intab

Also u can try :

KCD_EXCEL_OLE_TO_INT_CONVERT

Former Member
0 Kudos

Hi,

try this..



REPORT ZVATPHASE2_UPLOAD .

TYPE-POOLS: TRUXS.

TABLES: J_1IMOVEND.

DATA: I_TEXT_DATA       TYPE TRUXS_T_TEXT_DATA,
      V_FILENAME_STRING TYPE STRING,
      FILE_NAME         LIKE IBIPPARMS-PATH,
      WF_LINES(6).

*DATA : BEGIN OF ITAB1 OCCURS 0.
*          INCLUDE TYPE J_1IMOVEND.
*DATA : END OF ITAB1.
DATA : BEGIN OF ITAB1 OCCURS 0,
          LIFNR     LIKE J_1IMOVEND-LIFNR,
          J_1ILSTNO LIKE J_1IMOVEND-J_1ILSTNO,
       END OF ITAB1.

*SELECTION-SCREEN BEGIN  OF  BLOCK B1 WITH FRAME TITLE TEXT-001.
*  PARAMETERS: P_FILE LIKE RLGRAP-FILENAME.
*SELECTION-SCREEN END     OF   BLOCK B1 .
*
*AT SELECTION-SCREEN.

CALL FUNCTION 'F4_FILENAME'
 EXPORTING
   PROGRAM_NAME        = SYST-CPROG
   DYNPRO_NUMBER       = SYST-DYNNR
 IMPORTING
   FILE_NAME           = FILE_NAME.


*START-OF-SELECTION.
IF NOT FILE_NAME IS INITIAL.
  V_FILENAME_STRING = FILE_NAME.

  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      FILENAME                      = V_FILENAME_STRING
      FILETYPE                      = 'ASC'
      HAS_FIELD_SEPARATOR           = 'X'
      DAT_MODE                      = ''
    TABLES
      DATA_TAB                      = I_TEXT_DATA.

  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
      I_FIELD_SEPERATOR          = 'X'
*     I_LINE_HEADER              =
      I_TAB_RAW_DATA             = I_TEXT_DATA
      I_FILENAME                 = FILE_NAME
    TABLES
      I_TAB_CONVERTED_DATA       = ITAB1
    EXCEPTIONS
      CONVERSION_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.

ELSE.
  PERFORM CALLERR USING 'Enter a Valid File Name, Thank You'.
ENDIF.


*&*&
DATA : BEGIN OF ITAB OCCURS 0.
          INCLUDE TYPE J_1IMOVEND.
DATA : END OF ITAB.

SELECT * FROM J_1IMOVEND INTO TABLE ITAB.

*LOOP AT ITAB.
*  READ

LOOP AT  ITAB1.
 UPDATE J_1IMOVEND SET J_1ILSTNO = ITAB1-J_1ILSTNO
                   WHERE LIFNR EQ ITAB1-LIFNR.
ENDLOOP.

CLEAR : WF_LINES.
DESCRIBE TABLE ITAB1 LINES WF_LINES.

WRITE : WF_LINES, 'Records Updated Successfully'.

*&---------------------------------------------------------------------*
*&      Form  CALLERR
*&---------------------------------------------------------------------*
*  CALLING FUN MOD FOR GIVING STATUS MESSAGE & ERER MSG
*----------------------------------------------------------------------*
  FORM CALLERR USING TEXT1.

    CALL FUNCTION 'FC_POPUP_ERR_WARN_MESSAGE'
         EXPORTING
              POPUP_TITLE  = 'VAT Report Phase II'
              IS_ERROR     = 'X'
              MESSAGE_TEXT = TEXT1
              START_COLUMN = 30
              START_ROW    = 8.
    STOP.

  ENDFORM.                    " CALLERR 

With Rgds,

S.barani

ravishankar_reddy2
Active Participant
0 Kudos

hi,

Use this one.

DATA : l_tab(1) TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = fname

filetype = 'ASC'

header_length = 0

TABLES

data_tab = it_upload

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.

LOOP AT it_upload.

SPLIT it_upload AT l_tab INTO it_rec-aufnr

it_rec-vornr

it_rec-ltxa1

it_rec-dauno

it_rec-arbei

it_rec-arbpl

it_rec-mat_prkst

it_rec-prkst

it_rec-waers

it_rec-sakto IN CHARACTER MODE.

APPEND it_rec.

CLEAR it_rec.

ENDLOOP.

if u want to download the file,

then use like this

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = fname1

filetype = 'ASC'

write_field_separator = 'X'

TABLES

data_tab = it_msg[]

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6

header_not_allowed = 7

separator_not_allowed = 8

filesize_not_allowed = 9

header_too_long = 10

dp_error_create = 11

dp_error_send = 12

dp_error_write = 13

unknown_dp_error = 14

access_denied = 15

dp_out_of_memory = 16

disk_full = 17

dp_timeout = 18

file_not_found = 19

dataprovider_exception = 20

control_flush_error = 21

OTHERS = 22.

reward point if helpful,

regards

ravi shankar reddy

rainer_hbenthal
Active Contributor
0 Kudos

Store your XLS as CSV, then read it via gui_upload, split the lines via the SPLIT command