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

BDC.....PROPLEM WHILE GUI_UPLOAD

Former Member
0 Likes
547

Hi,

In BDC while uploading a flat file(which is with ',' seperator), but this is not suporting at the time of exectuion the screen-field value is displaying with value

and , is also displayed....help me out to solve this problem..

5 REPLIES 5
Read only

Former Member
0 Likes
527

Hi,

You better to import the data in one long field of the internal table & later you can split that long field by ',' [or any delimeter] and move the field values into actual table.

So that you will not get this issue.

regards,

  • Dj

reward, if its useful

Read only

Former Member
0 Likes
527

Hi Martin,

As DJ said its better to upload into a single one and then split it. Check the below example

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = lv_file

filetype = 'ASC'

<b> has_field_separator = ','</b>

header_length = 0

read_by_line = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

ignore_cerr = 'X'

replacement = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

data_tab = data_mat

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

ELSE.

LOOP AT data_mat.

<b>SPLIT</b> data_mat-datastring AT ',' INTO

it_data-old_matno

it_data-x_comp

it_data-alt_uom

it_data-y_comp

it_data-matnr.

APPEND it_data.

CLEAR it_data.

ENDLOOP.

Regards

Aneesh.

Read only

Former Member
0 Likes
527

hello,

In BDC.How to put an MS-EXCEL flat file i had given 'XLS' file type even it is giving error at runtime..plz suggest me with prg syntax.

Read only

Former Member
0 Likes
527

hi martin,

use the FM 'ALSM_EXCEL_TO_INTERNAL_TABLE'

chk this sample code...........

PARAMETERS:

P_INFL like RLGRAP-FILENAME.

DATA:

BEGIN OF T_DATA1 OCCURS 0,

RESOURCE(25) TYPE C,

DATE(10) TYPE C,

DURATION TYPE P DECIMALS 2,

ACTIVITY(25) TYPE C,

B_NBILL(1) TYPE C,

END OF T_DATA1,

T_DATA TYPE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE,

BEGIN OF T_FINAL OCCURS 0,

RESOURCE(25) TYPE C,

DATE(10) TYPE C,

DURATION(15) TYPE C,

ACTIVITY(25) TYPE C,

B_NBILL(10) TYPE C,

END OF T_FINAL.

  • Work area.

DATA:

WA_DATA LIKE T_FINAL.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_INFL.

PERFORM GET_FILENAME CHANGING P_INFL.

----


START-OF-SELECTION.

----


PERFORM UPLOAD_DATA_FROMEXCEL.

PERFORM PROCESS_DATA.

FORM UPLOAD_DATA_FROMEXCEL.

  • Downloading the data from presentation server

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

FILENAME = p_infl

I_BEGIN_COL = 1

I_BEGIN_ROW = 2

I_END_COL = 8

I_END_ROW = 1000

TABLES

INTERN = T_DATA

EXCEPTIONS

INCONSISTENT_PARAMETERS = 1

UPLOAD_OLE = 2

OTHERS = 3.

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. " upload_data_fromexcel

&----


*& Form process_data

&----


  • text

----


FORM PROCESS_DATA .

T_FINAL-RESOURCE = 'Resource'.

T_FINAL-DATE = 'Date'.

T_FINAL-DURATION = 'Duration'.

T_FINAL-ACTIVITY = 'Activity'.

T_FINAL-B_NBILL = 'Billable'.

APPEND T_FINAL.

SORT T_DATA BY ROW COL.

LOOP AT T_DATA.

CASE T_DATA-COL.

WHEN 3.

T_DATA1-RESOURCE = T_DATA-VALUE.

WHEN 4.

T_DATA1-DATE = T_DATA-VALUE.

WHEN 5.

T_DATA1-DURATION = T_DATA-VALUE.

WHEN 6.

  • t_data1-activity = t_data-value.

WHEN 7.

T_DATA1-B_NBILL = T_DATA-VALUE.

ENDCASE.

AT END OF ROW.

COLLECT T_DATA1.

ENDAT.

ENDLOOP.

LOOP AT T_DATA1.

T_FINAL-RESOURCE = T_DATA1-RESOURCE.

T_FINAL-DATE = T_DATA1-DATE.

T_FINAL-DURATION = T_DATA1-DURATION.

T_FINAL-ACTIVITY = T_DATA1-ACTIVITY.

T_FINAL-B_NBILL = T_DATA1-B_NBILL.

APPEND T_FINAL.

ENDLOOP.

ENDFORM. " process_data

&----


*& Form get_filename

&----


FORM GET_FILENAME CHANGING P_FILENAME.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

DEF_FILENAME = SPACE

DEF_PATH = P_FILENAME

MASK = ',. ,..'

MODE = 'O' " O = Open, S = Save

  • TITLE = BOX_TITLE

IMPORTING

FILENAME = P_FILENAME

EXCEPTIONS

INV_WINSYS = 1

NO_BATCH = 2

SELECTION_CANCEL = 3

SELECTION_ERROR = 4

OTHERS = 5.

*

  • CASE SY-SUBRC.

  • WHEN 1.

  • MESSAGE I999 WITH

  • 'File selector not available on this windows system'(046).

  • WHEN 2.

  • MESSAGE E999 WITH

  • 'Frontend function cannot be executed in background'(047).

  • WHEN 3.

  • MESSAGE I999 WITH 'Selection was cancelled'(048).

  • WHEN 4.

  • MESSAGE E999 WITH 'Communication error'(049).

  • WHEN 5.

  • MESSAGE E999 WITH 'Other error'(050).

  • ENDCASE.

ENDFORM. " get_filename

reward if usefullll

Read only

Former Member
0 Likes
527

1 Simple way is to save the excel file as a tab-dilimited file you get that format when you use save as in excel sheet and then use the GUI_DOWNLOAD to get the data into an internal table.