2006 May 19 5:34 AM
hi all
during bdc recording when i upload files using pgm the values are uploaded using a # symbol why such error is occurin can anyone help me plz
Hi varalakshmi,
1. Instead of using excel file directly,
2. Its always recommended
to save the excel file as 'TAB DELIMITED FILE'
3. and then use the fm GUI_UPLOAD
to upload the data in the file into internal table.
regards,
amit m.
2006 May 19 5:38 AM
Is it an excel sheet from which you are trying to upload the data from??
2006 May 19 5:39 AM
this might be because of file data type you are giving for upload function . try to give 'ASC' or 'DAT' for that .
hope it wil help you else you send your code to forum we will try to resolv it .
regards
Siddharth
2006 May 19 5:49 AM
2006 May 19 6:05 AM
Check out the below code for the uploading of data from an excel sheet...
*&---------------------------------------------------------------------*
*& Report ZUPLOAD_CLASS *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZUPLOAD_CLASS .
*added for Excel file upload
selection-screen begin of block selscr with frame title text-001.
parameters : p_file type rlgrap-filename obligatory . "Input File
parameters: begcol type i default 1 no-display,
begrow type i default 1 no-display,
endcol type i default 100 no-display,
endrow type i default 32000 no-display.
* Tick don't append header
parameters: kzheader as checkbox.
selection-screen end of block selscr.
data: begin of intern occurs 0.
include structure alsmex_tabline.
data: end of intern.
data: begin of intern1 occurs 0.
include structure alsmex_tabline.
data: end of intern1.
data: begin of t_col occurs 0,
col like alsmex_tabline-col,
size type i.
data: end of t_col.
data: zwlen type i,
zwlines type i.
data: begin of fieldnames occurs 3,
title(60),
table(6),
field(10),
kz(1),
end of fieldnames.
data: begin of data_tab occurs 0,
value_0001(50),
value_0002(50),
value_0003(50),
value_0004(50),
value_0005(50),
value_0006(50),
value_0007(50),
value_0008(50),
value_0009(50),
value_0010(50),
value_0011(50),
value_0012(50),
value_0013(50),
value_0014(50),
value_0015(50),
value_0016(50),
value_0017(50),
value_0018(50),
value_0019(50),
value_0020(50),
value_0021(50),
value_0022(50),
value_0023(50),
value_0024(50),
value_0025(50),
value_0026(50),
end of data_tab.
types : begin of ttab ,
type(3),
class(18),
desc(50),
alloc(1),
char1(30),
char2(30),
char3(30),
char4(30),
char5(30),
char6(30),
char7(30),
char8(30),
char9(30),
char10(30),
char11(30),
char12(30),
char13(30),
char14(30),
char15(30),
char16(30),
char17(30),
char18(30),
char19(30),
char20(30),
org(10),
origin(10),
end of ttab.
data itab type ttab occurs 0 with header line.
data: tind(4) type n.
data: zwfeld(19).
data : CLASSNUMNEW like BAPI_CLASS_KEY-CLASSNUM.
data : CLASSTYPENEW like BAPI_CLASS_KEY-CLASSTYPE.
data : CLASSBASICDATA like BAPI1003_BASIC.
data : CLASSDESCRIPTIONS like BAPI1003_CATCH occurs 0 with header line.
data : CLASSLONGTEXTS like BAPI1003_LONGTEXT occurs 0 with header line.
data : BAPIRET2 like BAPIRET2 occurs 0 with header line.
data : CLASSCHARACTERISTICS like BAPI1003_CHARACT occurs 0
with header line.
field-symbols: <fs1>.
*include zbdcrecx1.
data : n type i.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN
*----------------------------------------------------------------------*
* F4 for Input file
at selection-screen on value-request for p_file.
perform get_local_file_name using p_file.
start-of-selection.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file
i_begin_col = begcol
i_begin_row = begrow
i_end_col = endcol
i_end_row = endrow
TABLES
intern = intern
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
others = 3.
if sy-subrc <> 0.
write:/ 'Upload Error ', sy-subrc.
endif.
end-of-selection.
loop at intern.
intern1 = intern.
clear intern1-row.
append intern1.
endloop.
sort intern1 by col.
loop at intern1.
at new col.
t_col-col = intern1-col.
append t_col.
endat.
zwlen = strlen( intern1-value ).
read table t_col with key col = intern1-col.
if sy-subrc eq 0.
if zwlen > t_col-size.
t_col-size = zwlen.
* Internal Table, Current Row Index
modify t_col index sy-tabix.
endif.
endif.
endloop.
describe table t_col lines zwlines.
sort intern by row col.
if kzheader = 'X'.
loop at intern.
fieldnames-title = intern-value.
append fieldnames.
at end of row.
exit.
endat.
endloop.
else.
do zwlines times.
write sy-index to fieldnames-title.
append fieldnames.
enddo.
endif.
sort intern by row col.
loop at intern.
if kzheader = 'X'
and intern-row = 1.
continue.
endif.
tind = intern-col.
concatenate 'DATA_TAB-VALUE_' tind into zwfeld.
assign (zwfeld) to <fs1>.
<fs1> = intern-value.
at end of row.
append data_tab.
clear data_tab.
endat.
endloop.
loop at data_tab.
itab-type = data_tab-value_0001.
itab-class = data_tab-value_0002.
itab-desc = data_tab-value_0003.
itab-alloc = data_tab-value_0004.
itab-char1 = data_tab-value_0005.
itab-char2 = data_tab-value_0006.
itab-char3 = data_tab-value_0007.
itab-char4 = data_tab-value_0008.
itab-char5 = data_tab-value_0009.
itab-char6 = data_tab-value_0010.
itab-char7 = data_tab-value_0011.
itab-char8 = data_tab-value_0012.
itab-char9 = data_tab-value_0013.
itab-char10 = data_tab-value_0014.
itab-char11 = data_tab-value_0015.
itab-char12 = data_tab-value_0016.
itab-char13 = data_tab-value_0017.
itab-char14 = data_tab-value_0018.
itab-char15 = data_tab-value_0019.
itab-char16 = data_tab-value_0020.
itab-char17 = data_tab-value_0021.
itab-char18 = data_tab-value_0022.
itab-char19 = data_tab-value_0023.
itab-char20 = data_tab-value_0024.
itab-org = data_tab-value_0025.
itab-origin = data_tab-value_0026.
append itab.
clear itab.
endloop.
n = 0.
loop at itab.
CLASSNUMNEW = itab-class.
CLASSTYPENEW = itab-type.
* CLASSTYPENEW-CLASSNUM = itab-class.
CLASSBASICDATA-STATUS = '1'.
CLASSBASICDATA-CLASSGROUP = 'NFG_CLASS'.
CLASSBASICDATA-DEPARTMENT_VIEW = itab-org.
CLASSBASICDATA-VALID_FROM = '20050405'.
CLASSDESCRIPTIONS-LANGU = 'E'.
CLASSDESCRIPTIONS-LANGU_ISO = 'EN'.
CLASSDESCRIPTIONS-CATCHWORD = itab-desc.
append CLASSDESCRIPTIONS.
CLASSCHARACTERISTICS-NAME_CHAR = itab-char1.
append CLASSCHARACTERISTICS.
CLASSCHARACTERISTICS-NAME_CHAR = itab-char2.
append CLASSCHARACTERISTICS.
CLASSCHARACTERISTICS-NAME_CHAR = itab-char3.
append CLASSCHARACTERISTICS.
CLASSCHARACTERISTICS-NAME_CHAR = itab-char4.
append CLASSCHARACTERISTICS.
CLASSCHARACTERISTICS-NAME_CHAR = itab-char5.
append CLASSCHARACTERISTICS.
CLASSCHARACTERISTICS-NAME_CHAR = itab-char6.
append CLASSCHARACTERISTICS.
CLASSCHARACTERISTICS-NAME_CHAR = itab-char7.
append CLASSCHARACTERISTICS.
CLASSCHARACTERISTICS-NAME_CHAR = itab-char8.
append CLASSCHARACTERISTICS.
CLASSCHARACTERISTICS-NAME_CHAR = itab-char9.
append CLASSCHARACTERISTICS.
CLASSCHARACTERISTICS-NAME_CHAR = itab-char10.
append CLASSCHARACTERISTICS.
CLASSCHARACTERISTICS-NAME_CHAR = itab-char11.
append CLASSCHARACTERISTICS.
CLASSCHARACTERISTICS-NAME_CHAR = itab-char12.
append CLASSCHARACTERISTICS.
CLASSCHARACTERISTICS-NAME_CHAR = itab-char13.
append CLASSCHARACTERISTICS.
CLASSCHARACTERISTICS-NAME_CHAR = itab-char14.
append CLASSCHARACTERISTICS.
CLASSCHARACTERISTICS-NAME_CHAR = itab-char15.
append CLASSCHARACTERISTICS.
CLASSCHARACTERISTICS-NAME_CHAR = itab-char16.
append CLASSCHARACTERISTICS.
CLASSCHARACTERISTICS-NAME_CHAR = itab-char17.
append CLASSCHARACTERISTICS.
CLASSCHARACTERISTICS-NAME_CHAR = itab-char18.
append CLASSCHARACTERISTICS.
CLASSCHARACTERISTICS-NAME_CHAR = itab-char19.
append CLASSCHARACTERISTICS.
CLASSCHARACTERISTICS-NAME_CHAR = itab-char20.
append CLASSCHARACTERISTICS.
CALL FUNCTION 'BAPI_CLASS_CREATE'
EXPORTING
CLASSNUMNEW = CLASSNUMNEW
CLASSTYPENEW = CLASSTYPENEW
* CHANGENUMBER =
CLASSBASICDATA = CLASSBASICDATA
* CLASSDOCUMENT =
* CLASSADDITIONAL =
* CLASSSTANDARD =
TABLES
RETURN = BAPIRET2
CLASSDESCRIPTIONS = CLASSDESCRIPTIONS
CLASSLONGTEXTS = CLASSLONGTEXTS
CLASSCHARACTERISTICS = CLASSCHARACTERISTICS
* CHARACTOVERWRITE =
* CHARACTVALUEOVERWRITE =
* CHARACTVALUETEXTOVR =
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT =
* IMPORTING
* RETURN =
.
clear CLASSNUMNEW.
clear CLASSTYPENEW.
clear CLASSBASICDATA.
clear CLASSDESCRIPTIONS .
refresh CLASSDESCRIPTIONS .
clear CLASSLONGTEXTS.
refresh CLASSLONGTEXTS.
clear CLASSCHARACTERISTICS.
refresh CLASSCHARACTERISTICS.
loop at bapiret2 where type = 'E'.
write :/ bapiret2-message , itab-class.
endloop.
loop at bapiret2 where type = 'S' or type = 'W' or type = 'I'.
at last.
n = n + 1.
write : / 'Uploaded class' , itab-class.
endat.
endloop.
endloop.
write :/ 'Records Uploaded ', n.
************************************************************************
form get_local_file_name using file type rlgrap-filename.
call function 'KD_GET_FILENAME_ON_F4'
CHANGING
file_name = file
EXCEPTIONS
mask_too_long = 1
others = 2.
if sy-subrc <> 0.
message i000(fb) with
'Error in getting filename'(004).
endif.
endform. " GET_LOCAL_FILE_NAME
***********************************************************************
2006 May 19 6:22 AM
Use split statement
SPLIT T_FLAT AT <b>CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB</b> INTO T_UPLOADEQUI-EQTYP
-
.
APPEND T_UPLOADEQUI.
b]CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB</b> represent #.
regards
vinod
2006 May 19 6:26 AM
2006 May 19 6:29 AM
2006 May 19 6:30 AM
use...
<b>replace all occurences of CL_ABAP_CHAR_UTILITIES=>NEWLINE in record with ''.</b>you should do it inside do loop. since for each record you need to do it.
2006 May 19 6:31 AM
Hi varalakshmi,
1. Instead of using excel file directly,
2. Its always recommended
to save the excel file as 'TAB DELIMITED FILE'
3. and then use the fm GUI_UPLOAD
to upload the data in the file into internal table.
regards,
amit m.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |