Uploading to excel sheet
hi all,
I just want to know that how a data can be uploaded to excel sheet with zeroes..
question in detail.
i have data with field : pos(4) character...i cant use type n...
now pos is havin data suppose...
0765
0987
7891
so the o/p is comin in excel as:
765
987
7891...but i need
0765
0987..
in excel sheet ...so gurus help me out...thanks in advance..
bob.
Hi
PARAMETER P_file like RLGRAP-FILENAME
data : begin of int_head occurs 0,
Filed1(20) type c, " Header Data
end of int_head.
int_head-Filed1 = 'PLTNY'.
APPEND int_head.
CLEAR int_head.
int_head-Filed1 = 'WERKS'.
APPEND int_head.
CLEAR int_head.
int_head-Filed1 = 'KTEXT'.
APPEND int_head.
CLEAR int_head.
Select plnty werks ktext from plko into CORRESPONDING FIELDS OF TABLE itab
Where plnty = 'Q' .
v_filetype = '.xls'. "I just manipulate the file name using XLS file type.
v_filename = p_file.
CONCATENATE p_file v_filetype INTO lv_filename.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lv_filename
filetype = 'ASC'
write_field_separator = 'X'
TABLES
data_tab = ITAB
FIELDNAMES = int_head
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.
IF sy-subrc <> 0.
ENDIF.
ENDFORM.
Similar Messages
-
can anyone tel me how 2 upload data from a excel sheet ??
can it be done using gui_upload or os there any other funtion module ??Hi Vignesh,
Steps to create a BDC program.
1. Create an internal table with fields same as Excel sheet fields.
2. Declare an internal table with BDCDATA table to store the BDC recording.
3. Declare an internal table with BDCMSGCOL to store the error messages after
the execution of the BDC.
4. Write the code using the fun. module ALSM_EXCEL_TO_INTERNAL_TABLE
to upload the data from the excel sheet.
5. loop that internal table and write the Subroutines to fill the internal table
BDCDATA with the recording of a specified Transaction Code.
6. Using Call Transaction execute the BDC recording.
7. Check Sy-subrc = 0 and store the error messages in the internal table.
8. If you want you can pass those error records to a session using the SESSION method.
Here is an example of a BDC program, but this program is from a text file. Change the function module WS_UPLOAD with ALSM_EXCEL_TO_INTERNAL_TABLE
to upload an excel and write the program with your BDC recording. You can do recording using t-code SHDB.
Sample Program:
REPORT ZRAJ_DATASET_XD01 NO STANDARD PAGE HEADING LINE-SIZE 132
LINE-COUNT 60
MESSAGE-ID Z00.
Table/Structure declarations. *
TABLES : KNA1. "Customer master
Constants declarations. *
CONSTANTS : C_MODE VALUE 'N',
C_UPDATE VALUE 'S',
C_X VALUE 'X',
C_SESS TYPE APQI-GROUPID VALUE 'ZCUSTOMER', "Session Name
C_XD01 LIKE TSTC-TCODE VALUE 'XD01'.
Variable declarations. *
DATA : V_FNAME(15) VALUE SPACE, " Name of file to be created
V_FAILREC TYPE I, " No of failed records
V_MSG(255), " Message Text
V_ERRREC TYPE I, " No of failed records
V_LINES TYPE I. " No of records
*-- FLAG DECLARATIONS
DATA : FG_DATA_EXIST VALUE 'X', " Check for data
FG_SESSION_OPEN VALUE ' '. " Check for Session Open
Structures / Internal table declarations *
*-- Structure to hold BDC data
TYPES : BEGIN OF T_BDCTABLE.
INCLUDE STRUCTURE BDCDATA.
TYPES END OF T_BDCTABLE.
*-- Structure to trap BDC messages
TYPES : BEGIN OF T_MSG.
INCLUDE STRUCTURE BDCMSGCOLL.
TYPES : END OF T_MSG.
*-- Structure to trap ERROR messages
TYPES : BEGIN OF T_ERR_MSG,
MESSAGE(255),
END OF T_ERR_MSG.
*--Internal table to store flat file data
DATA:BEGIN OF IT_KNA1 OCCURS 0,
KUNNR LIKE KNA1-KUNNR,
KTOKD LIKE T077D-KTOKD,
NAME1 LIKE KNA1-NAME1,
SORTL LIKE KNA1-SORTL,
ORT01 LIKE KNA1-ORT01,
PSTLZ LIKE KNA1-PSTLZ,
LAND1 LIKE KNA1-LAND1,
SPRAS LIKE KNA1-SPRAS,
LZONE LIKE KNA1-LZONE,
END OF IT_KNA1.
*-- Internal table to hold BDC data
DATA: IT_BDCDATA TYPE STANDARD TABLE OF T_BDCTABLE WITH HEADER LINE,
*-- Internal Table to store ALL messages
IT_MSG TYPE STANDARD TABLE OF T_MSG WITH HEADER LINE,
*-- Internal Table to store error messages
IT_ERR_MSG TYPE STANDARD TABLE OF T_ERR_MSG WITH HEADER LINE.
Selection Screen. *
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FLNAME(15) OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS : R_LIST RADIOBUTTON GROUP GRP1.
SELECTION-SCREEN COMMENT 5(20) TEXT-003.
PARAMETERS : R_SESS RADIOBUTTON GROUP GRP1.
SELECTION-SCREEN COMMENT 30(20) TEXT-004.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B2.
Event:Initialization *
INITIALIZATION.
AT Selection Screen. *
AT SELECTION-SCREEN.
Event: Start-of-Selection *
START-OF-SELECTION.
V_FNAME = P_FLNAME.
PERFORM GET_DATA.
PERFORM GENERATE_DATASET.
Event: End-of-Selection *
END-OF-SELECTION.
IF FG_DATA_EXIST = ' '.
MESSAGE I010 WITH TEXT-009.
EXIT.
ENDIF.
PERFORM GENERATE_BDCDATA.
PERFORM DISPLAY_ERR_RECS.
Event: top-of-page
TOP-OF-PAGE.
FORM DEFINITIONS *
*& Form get_data
Subroutine to get the data from mard
--> p1 text
<-- p2 text
FORM GET_DATA.
CALL FUNCTION 'UPLOAD'
EXPORTING
CODEPAGE = ' '
FILENAME = 'C:\XD01.TXT'
FILETYPE = 'DAT'
ITEM = ' '
FILEMASK_MASK = ' '
FILEMASK_TEXT = ' '
FILETYPE_NO_CHANGE = ' '
FILEMASK_ALL = ' '
FILETYPE_NO_SHOW = ' '
LINE_EXIT = ' '
USER_FORM = ' '
USER_PROG = ' '
SILENT = 'S'
IMPORTING
FILESIZE =
CANCEL =
ACT_FILENAME =
ACT_FILETYPE =
TABLES
DATA_TAB = IT_KNA1
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF IT_KNA1[] IS INITIAL.
FG_DATA_EXIST = ' '.
ENDIF.
ENDFORM. " get_data
*& Form GENERATE_DATASET
text
--> p1 text
<-- p2 text
FORM GENERATE_DATASET.
MESSAGE I010 WITH 'OPENING FILE IN APPLICATION SERVER'.
**--Creating a data set in application server
OPEN DATASET V_FNAME FOR OUTPUT IN TEXT MODE.
**---Transfering data from internal table to dataset
MESSAGE I010 WITH 'TRANSFERING DATA FROM INETERAL TABLE TO THE FILE'.
LOOP AT IT_KNA1.
TRANSFER IT_KNA1 TO V_FNAME.
ENDLOOP.
**--Closing the dataset
MESSAGE I010 WITH 'CLOSING THE FILE'.
CLOSE DATASET V_FNAME.
ENDFORM. " GENERATE_DATASET
*& Form BDC_DYNPRO
text
-->P_0467 text
-->P_0468 text
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR IT_BDCDATA.
IT_BDCDATA-PROGRAM = PROGRAM.
IT_BDCDATA-DYNPRO = DYNPRO.
IT_BDCDATA-DYNBEGIN = 'X'.
APPEND IT_BDCDATA.
ENDFORM.
*& Form BDC_FIELD
text
-->P_0472 text
-->P_0473 text
FORM BDC_FIELD USING FNAM FVAL.
IF NOT FVAL IS INITIAL.
CLEAR IT_BDCDATA.
IT_BDCDATA-FNAM = FNAM.
IT_BDCDATA-FVAL = FVAL.
APPEND IT_BDCDATA.
ENDIF.
ENDFORM.
*& Form GENERATE_BDCDATA
text
--> p1 text
<-- p2 text
FORM GENERATE_BDCDATA.
REFRESH IT_KNA1.
Opening dataset for reading
OPEN DATASET V_FNAME FOR INPUT IN TEXT MODE.
Reading the file from application server
DO.
CLEAR: IT_KNA1,IT_BDCDATA.
REFRESH IT_BDCDATA.
READ DATASET V_FNAME INTO IT_KNA1.
IF SY-SUBRC <> 0.
EXIT.
ELSE.
Populate BDC Data for Initial Screen
PERFORM : BDC_DYNPRO USING 'SAPMF02D' '0100',
BDC_FIELD USING 'BDC_CURSOR' 'RF02D-KUNNR',
BDC_FIELD USING 'BDC_OKCODE' '/00',
BDC_FIELD USING 'RF02D-KUNNR' IT_KNA1-KUNNR,
BDC_FIELD USING 'RF02D-KTOKD' IT_KNA1-KTOKD.
Populate BDC Data for Second Screen
PERFORM : BDC_DYNPRO USING 'SAPMF02D' '0110',
BDC_FIELD USING 'BDC_CURSOR' 'KNA1-NAME1',
BDC_FIELD USING 'BDC_OKCODE' '/00',
BDC_FIELD USING 'KNA1-NAME1' IT_KNA1-NAME1,
BDC_FIELD USING 'KNA1-SORTL' IT_KNA1-SORTL,
BDC_FIELD USING 'KNA1-ORT01' IT_KNA1-ORT01,
BDC_FIELD USING 'KNA1-PSTLZ' IT_KNA1-PSTLZ,
BDC_FIELD USING 'KNA1-LAND1' IT_KNA1-LAND1,
BDC_FIELD USING 'KNA1-SPRAS' IT_KNA1-SPRAS.
Populate BDC Data for Third Screen
PERFORM : BDC_DYNPRO USING 'SAPMF02D' '0120',
BDC_FIELD USING 'BDC_CURSOR' 'KNA1-LZONE',
BDC_FIELD USING 'BDC_OKCODE' '=UPDA',
BDC_FIELD USING 'KNA1-LZONE' IT_KNA1-LZONE.
CALL TRANSACTION C_XD01 USING IT_BDCDATA
MODE C_MODE
UPDATE C_UPDATE
MESSAGES INTO IT_MSG.
IF SY-SUBRC <> 0.
*--In case of error list display
IF R_LIST = C_X.
V_ERRREC = V_ERRREC + 1.
PERFORM FORMAT_MESSAGE.
IT_ERR_MSG-MESSAGE = V_MSG.
APPEND IT_ERR_MSG.
CLEAR : V_MSG,IT_ERR_MSG.
ENDIF.
*--In case of session log
IF R_SESS = C_X.
*-- In case of transaction fails.
IF FG_SESSION_OPEN = ' '.
FG_SESSION_OPEN = C_X.
PERFORM BDC_OPEN_GROUP.
ENDIF. " IF FG_SESSION_OPEN = ' '.
*-- Insert BDC Data..
PERFORM BDC_INSERT_DATA.
ENDIF. " IF R_SESS = C_X.
ENDIF. " IF SY-SUBRC <> 0.
ENDIF. " IF SY-SUBRC <> 0.
ENDDO.
Closing the dataset
CLOSE DATASET V_FNAME.
*-- Close the session if opened
IF FG_SESSION_OPEN = C_X.
PERFORM BDC_CLOSE_GROUP.
CALL TRANSACTION 'SM35'.
ENDIF.
ENDFORM. " GENERATE_BDCDATA
*& Form BDC_OPEN_GROUP
text
--> p1 text
<-- p2 text
FORM BDC_OPEN_GROUP.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
DEST = FILLER8
GROUP = C_SESS
HOLDDATE = FILLER8
KEEP = C_X
USER = SY-UNAME
RECORD = FILLER1
IMPORTING
QID =
EXCEPTIONS
CLIENT_INVALID = 1
DESTINATION_INVALID = 2
GROUP_INVALID = 3
GROUP_IS_LOCKED = 4
HOLDDATE_INVALID = 5
INTERNAL_ERROR = 6
QUEUE_ERROR = 7
RUNNING = 8
SYSTEM_LOCK_ERROR = 9
USER_INVALID = 10
OTHERS = 11
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. " BDC_OPEN_GROUP
*& Form BDC_INSERT_DATA
text
--> p1 text
<-- p2 text
FORM BDC_INSERT_DATA.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = C_XD01
POST_LOCAL = NOVBLOCAL
PRINTING = NOPRINT
TABLES
DYNPROTAB = IT_BDCDATA
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7
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. " BDC_INSERT_DATA
*& Form BDC_CLOSE_GROUP
text
--> p1 text
<-- p2 text
FORM BDC_CLOSE_GROUP.
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 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. " BDC_CLOSE_GROUP
*& Form FORMAT_MESSAGE
text
--> p1 text
<-- p2 text
FORM FORMAT_MESSAGE.
CLEAR V_LINES.
DESCRIBE TABLE IT_MSG LINES V_LINES.
READ TABLE IT_MSG INDEX V_LINES.
CLEAR V_MSG.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = IT_MSG-MSGID
LANG = IT_MSG-MSGSPRA
NO = IT_MSG-MSGNR
V1 = IT_MSG-MSGV1
V2 = IT_MSG-MSGV2
V3 = IT_MSG-MSGV3
V4 = IT_MSG-MSGV4
IMPORTING
MSG = V_MSG
EXCEPTIONS
NOT_FOUND = 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. " FORMAT_MESSAGE
*& Form DISPLAY_ERR_RECS
text
--> p1 text
<-- p2 text
FORM DISPLAY_ERR_RECS.
LOOP AT IT_ERR_MSG.
WRITE: / IT_ERR_MSG-MESSAGE.
ENDLOOP.
ENDFORM. " DISPLAY_ERR_RECS
And
To simply load Excel to Internal table follow this :
First of all , before you move your data from excel sheet to the internal table, you need to specify a location for uploading the excel sheet into your internal table.
for this u need to use two specific FM's .
the first one for file selection : WS_FILENAME_GET.
The second one for data upload : TEXT_CONVERT_XLS_TO_SAP.
After doing this the regular part of mapping comes and then we can run the session and then execute and release it.
Hope this resolves your query.
<b>Reward all the helpful answers.</b>
Regards -
Upload the excel sheet in table maintenance
Hi,
I have a requirement to add a button in the application toolbar of the table maintenance screen of a custom table. This button should upload the excel sheet data into the maintenance screen online.
I have created the button in the table maintenance generator. Also, uploaded the data into the internal table from the excel sheet.
The problem is I am unable to populate the data from the internal table to the maintenance screen online.
Any pointers in this regards will be appreciated.
Thanks,
Best regards,
AjithHi Mukul,
I created a custom table ZHEDGERES. Then in the table maintenance -> environment -> modification -> user interface I selected Individual interface.
Then, in the Menu painter for the program SAPLZHEDGERES, modified the PF status EULG and added the additional button in the Application toolbar. This application toolbar needs to be used to trigger the upload of excel into the custom table.
Below is the standard code which is generated in the screen painter of the custom table.
PROCESS BEFORE OUTPUT.
MODULE LISTE_INITIALISIEREN.
LOOP AT EXTRACT WITH CONTROL
TCTRL_ZHEDGERES CURSOR NEXTLINE.
MODULE LISTE_SHOW_LISTE.
ENDLOOP.
PROCESS AFTER INPUT.
MODULE LISTE_EXIT_COMMAND AT EXIT-COMMAND.
MODULE LISTE_BEFORE_LOOP.
LOOP AT EXTRACT.
MODULE LISTE_INIT_WORKAREA.
CHAIN.
FIELD ZHEDGERES-HDATE .
FIELD ZHEDGERES-CHAIN .
FIELD ZHEDGERES-HEDGE_VALUE .
FIELD ZHEDGERES-CURRENCY .
MODULE SET_UPDATE_FLAG ON CHAIN-REQUEST.
ENDCHAIN.
FIELD VIM_MARKED MODULE LISTE_MARK_CHECKBOX.
CHAIN.
FIELD ZHEDGERES-HDATE .
MODULE LISTE_UPDATE_LISTE.
ENDCHAIN.
ENDLOOP.
MODULE LISTE_AFTER_LOOP.
Need to add logic to extract the values from the excel sheet to an internal table and append the values from the internal table to the table control of the table maintenance.
Thanks,
Best regards,
Ajith -
Upload in Excel Sheet for Mid Year Go Live
Hi Friends,
How to upload T558 B & C tables in Excel Sheet for Mid Year Go Live.
Awaiting for your reply
Regards
Praveen PHi,
t558c template here between postingdate and amount two blank tab is there
client pernr period country wagetype postingdate amount
t558b template here between period and posting date two blank tab is there
client pernr period postingdate periodparameter year period monthstartrdate enddate month
and the date format is YYYYMMDD
Edited by: BALAPANI on Oct 13, 2009 12:19 PM -
Problems in uploading from excel sheet to internal table
hi experts,
i got one problem regarding uploading data from excel sheet to int.table. I used FM ALSM_EXCEL_TO_INTERNAL_TABLE but in that the value is char of 50. but i need a case where i have to send value more than 50 characters. please suggest me any other FM to overcome this problem.
advanced thanks
vijayHi,
>
Vijay Krishna Arvapalli wrote:
> hi tarun,
>
> thank you for your reply
>
> but when i tried to use FM TEXT_CONVERT_XLS_TO_SAP it is giving error actually that 'Error generating the test frame'.
>
> so can you suggest me with some other option where i can upload the field with more than 50 character length.
>
> thank you
> regards
> vijay
Yes, when you execute the FM from SE37, then it displays a message.
Just copy the below code and paste it in a report (SE38) and execute.
Create a file in C:/ with name test.xls and execute it will display the records even with more than 50 characters of length.
I have tested and its working.
I have taken three fields in the excel file empid, name and doj.
TYPE-POOLS : truxs.
PARAMETERS : p_file TYPE rlgrap-filename DEFAULT 'C:\TEST.XLS'.
DATA : BEGIN OF itab OCCURS 0,
empid(150) TYPE c,
name(150) TYPE c,
doj(150) TYPE c,
END OF itab.
DATA: it_raw TYPE truxs_t_text_data.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM f4_file_process USING p_file.
AT SELECTION-SCREEN.
PERFORM validate_file_path USING p_file.
START-OF-SELECTION.
PERFORM upload_data.
END-OF-SELECTION.
PERFORM display_data.
*& Form F4_FILE_PROCESS
* text
* -->P_FILE_PATH text
FORM f4_file_process USING p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
IF sy-subrc NE 0.
MESSAGE e000(zsd).
ENDIF.
ENDFORM. " F4_FILE_PROCESS
*& Form VALIDATE_FILE_PATH
* text
* -->P_FILE text
FORM validate_file_path USING p_file.
DATA : lv_dir TYPE string,
lv_file TYPE string,
lv_result(1) TYPE c.
DATA : lv_filename TYPE string.
lv_filename = p_file.
CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
EXPORTING
full_name = p_file
IMPORTING
stripped_name = lv_file
file_path = lv_dir
EXCEPTIONS
x_error = 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.
CALL METHOD cl_gui_frontend_services=>directory_exist
EXPORTING
directory = lv_dir
RECEIVING
result = lv_result
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
not_supported_by_gui = 4
OTHERS = 5.
IF lv_result IS INITIAL.
MESSAGE 'Invalid Directory' TYPE 'E'.
ENDIF.
CLEAR lv_result.
CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file = lv_filename
RECEIVING
result = lv_result
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
not_supported_by_gui = 4
OTHERS = 5.
IF lv_result IS INITIAL.
MESSAGE 'Invalid File' TYPE 'E'.
ENDIF.
ENDFORM. " VALIDATE_FILE_PATH
*& Form UPLOAD_DATA
* text
* --> p1 text
* <-- p2 text
FORM upload_data .
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
i_line_header = 'X'
i_tab_raw_data = it_raw
i_filename = p_file
TABLES
i_tab_converted_data = itab[]
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. " UPLOAD_DATA
*& Form DISPLAY_DATA
* text
* --> p1 text
* <-- p2 text
FORM display_data .
LOOP AT itab.
WRITE : / itab-empid, itab-name, itab-doj.
ENDLOOP.
ENDFORM. " DISPLAY_DATA
Hope this helps you.
Regards,
Tarun -
How to upload the Excel sheet into SAP
Hello Gurus,
Please let me know the steps how to upload excel sheet file in sap at one time.Suppose i have entered the employee details and their caste .This detail has been maintained in Excel.I want to know the total steps how to upload this total file into SAP System.
Regards
AM. TCode : LSMW.
2. Enter Project name, sub project name and object name.
Execute.
3. Maintain object attributes.
Execute
select Batch Input recording
goto->Recording overview
create
recording name.
enter transaction code.
start recording
do recording as per ur choice.
save + back.
enter recording name in lsmw screen.
save + back
Now there will be 14 steps.
2. MAINTAIN SOURCE STRUCTURES.
Here you have to enter the name of internal table.
display change
create
save + back
3. MAINTAIN SOURCE FIELDS.
display change
select structure
source_fields->copy fields.
a dialogue window will come .
select -> from data file
apply source fields
enter No. of fields
length of fields
attach file
save + back
4. MAINTAIN STRUCTURE RELATIONS
display change
save + back
5. MAINTAN FIELD MAPPING & CONVERSION RULE
display change
click on source field, select exact field from structue and enter
repeat these steps for all fields.
save+back
6. MAINTAIN FIXED VALUES, TRANSACTION, USER DEFINED
execute
save + back
7. SPECIFY FILES.
display change
click on legacy data
attah flat file
give description
select tabulatore
enter
save + back
8. ASSIGN FILE
execute
display change
save + back
9. IMPORT DATA.
execute
display change
save + back
10. DISPLAY IMPORTED DATA
enter ok, it willl show records only.
back
11. CONVERT DATA
execute
display change
save + back
12. DISPLAY CONVERTED DATA
execute
display change
save + back
13. CREATE BATCH INPUT SESSION
tick keep batch input folder
F8
back
14. RUN BATCH INPUT SESSION.
sm35 will come
Object name will be shown here
select object & process
inputs given by KAPIL -
Uploading multiple excel sheets
Dear All,
We are having 4 different excel sheets where data is stored regarding the quantity of laptops, desktops, printers & xerox machines. This data is to be loaded into the SAP tables with Co Code & BA Code as primary key which is there available in excel sheets.
Plz help me in code to upload all the 4 files in SAP tables based on a combination of CO Code & BA Code.
The selection screen will have 4 fields to specify the path of all the 4 excel sheets & all the fields are obligatory.
Thanks & Reg,
NishantHi Satesh,
Thanks very much for your prompt reply.
I am attaching the code herewith, please guide me where to use FORM & PERFORM to upload the other 3 excel sheets of the same format.
REport nis1234.
TABLES: bseg,
zfi_is_qty.
DATA:
t_excel LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE,
l_nodata TYPE c,
l_excelfile(128) TYPE c. " filename to be passed to excel file
DATA: BEGIN OF t_type,
bukrs LIKE bseg-bukrs,
gsber LIKE bseg-gsber,
COUNT TYPE I,
END OF t_type.
data: l_charlen1 type i,
l_charlen2 type i.
DATA: t_type2 LIKE t_type OCCURS 0 WITH HEADER LINE.
DATA: l_end_row TYPE i,
l_endrow1 TYPE i,
charlen type c.
DATA l_count TYPE I.
DATA : q_count TYPE i value 1.
PARAMETER :
p_endrow TYPE i OBLIGATORY,
p_file TYPE rlgrap-filename OBLIGATORY.
****clearing the contents of database table before uploading a new file everytime
DELETE FROM ZFI_IS_QTY.
*****selection-screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
field_name = p_file
CHANGING
file_name = p_file.
START-OF-SELECTION.
l_excelfile = p_file.
l_endrow1 = p_endrow.
p_endrow = p_endrow + 1.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = l_excelfile
i_begin_col = 5
i_begin_row = 2
i_end_col = 6
i_end_row = p_endrow
i_end_row = 4000
TABLES
intern = t_excel
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.
MESSAGE i010(zn) WITH 'Error in upload Please check the upload file'.
ENDIF.
DESCRIBE TABLE T_EXCEL LINES L_ENDROW1.
L_ENDROW1 = L_ENDROW1 / 2.
DO.
LOOP AT t_excel WHERE row = q_count.
IF t_excel-col = 1.
t_type2-gsber = t_excel-value.
ELSEIF t_excel-col = 2.
t_type2-bukrs = t_excel-value.
ENDIF.
ENDLOOP.
l_charlen1 = strlen( t_type2-bukrs ).
l_charlen2 = strlen( t_type2-gsber ).
if ( t_type2-bukrs <> ' ' and t_type2-gsber <> ' ' ).
if ( l_charlen1 = 4 and l_charlen2 = 4 ).
APPEND t_type2. CLEAR t_type2.
endif.
endif.
q_count = q_count + 1.
IF q_count > l_endrow1.
EXIT.
ENDIF.
ENDDO.
SORT T_TYPE2 BY BUKRS GSBER.
*****uploading data from internal table into database table
LOOP AT T_TYPE2.
MOVE-CORRESPONDING T_TYPE2 TO T_TYPE.
L_COUNT = L_COUNT + 1.
AT END OF GSBER.
AT END OF BUKRS.
write:/ t_type-BUKRS,
t_type-GSBER,
L_COUNT.
zfi_is_qty-COMPANY_CODE = t_type-bukrs.
zfi_is_qty-BAREA = t_type-gsber.
zfi_is_qty-DT = l_count.
insert zfi_is_qty.
CLEAR L_COUNT.
ENDAT.
ENDAT.
ENDLOOP.
************to read the data from the database table.
data: itab like zfi_is_qty occurs 0 with header line.
select * from zfi_is_qty into corresponding fields of table itab.
ULINE.
loop at itab.
WRITE:/ ITAB-COMPANY_CODE,
ITAB-BAREA,
ITAB-DT.
Endloop.
Thanks in advance,
nishu -
Uploading the excel sheet in XLSX format
Hi ,
While uploading excel sheet into sap , I am using the FM 'TEXT_CONVERT_XLS_TO_SAP' .This FM works fine when the excel sheet is in 'XLS' format .But when the excel sheet is in 'XLSX' format this FM is giving error .Please advice how to correct the error.
Any pointers will be highly appreciated.
Thanks ,
NikhilCopied from the link given above
hi,
try like this once
After calling FM 'ALSM_EXCEL_TO_INTERNAL_TABLE', need to fill the final table at each row and column level,
Please check this sample of code below.
Call FM to upload file from Presentation server.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = rp_file
i_begin_col = 1
i_begin_row = 2
i_end_col = 3
i_end_row = 6000
TABLES
intern = rt_excel[]
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.
Process Records and get only records into table T_FINAL.
IF rt_excel[] IS NOT INITIAL.
LOOP AT rt_excel INTO lw_file.
Move the records into final table.
IF lw_file-col = c_1.
lw_final-bukrs = lw_file-value .
ELSEIF lw_file-col = c_2.
lw_final-csl_type = lw_file-value.
ELSEIF lw_file-col = c_3.
lw_final-fpl = lw_file-value.
ENDIF.
AT END OF row.
APPEND lw_final TO rt_final.
CLEAR lw_final.
ENDAT.
CLEAR : lw_file.
ENDLOOP.
endif.
regards,
bab
Edited by: Matt on Jan 14, 2010 9:20 AM -
Uploading an excel sheet data using Oracle APEX 3.2
Hi All,
Please help me out to upload excel sheet data using oracle APEX 3.2.
Am following the steps mentioned in the below link, but even after that am getting an error saying no data found
http://avdeo.com/2008/05/21/uploading-excel-sheet-using-oracle-application-express-apex/
Please help me to proceed further.
Regards,
SakthiHi Andy,
Thank you very much for looking into my thread.
Actually i followed everything that is been mentioned in "http://avdeo.com/2008/05/21/uploading-excel-sheet- using-oracle-application-express-apex/" and i got a successful result.
But, with the above process I can only upload a .csv format excel and not a .xls format excel file.
Thats where i got stucked and unable to find any clue on how to move further to achieve in uploading .xls file.
It would be very great if you guide me through in this process.
Shiva -
Need to upload mass excel sheet using the bapi bapi_acc_document_post.
I am assigned with an object, where I need to post the records from a mass excel sheet in to ECC or/and BW basing the dimensions using the bapi bapi_acc_document_post.the excel sheet has header and Item data. I am pretty much new to this bapi's
please do the need fulCheck report "ACC_BAPI_TEST_INVOICE_RECEIPT",
this report calls BAPI "BAPI_ACC_INVOICE_RECEIPT_POST",
but the parameters are nearly the same.
Best Regards, Dirk -
Upload Specific Excel Sheet from excel file in sap internal table..
I have an excel sheet and it contains many sheets.. I want to read a specific sheet no.. or that sheet would have sheet name.. i want to read that specific sheet and load its data in the internal table.
Hello,
In this case you need to create OLE object and then get specific workbook using it's method.
For e.g.:
CREATE OBJECT gh_excel 'EXCEL.APPLICATION'.
CALL METHOD OF gh_excel 'Workbooks'= gh_mapl.
You can search SAP help for more information on using OLE objects.
Thanks,
Augustin. -
Error in uploading from excel sheet
i am working on sap crm so i am not able 2 use the fm ALSM_EXCEL_TO_INTERNAL_TABLE . i tried using gui_upload . it exists . wats should i give to the value for 'HAS_FIELD_SEPERATOR' in order to read from the excel file ?? i tried giving a tab space and it dumped my prog saying type conflict erroe while calling function module
Hi Vignesh,
Plz use this function module.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR =
i_line_header = 'X'
i_tab_raw_data = it_raw
i_filename = p_file1
TABLES
i_tab_converted_data = it_itab
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.
Rewords some points .
Rgds,
P.Naganaja Reddy -
On excel sheet upload read the workbook and populate data to sharepoint list
Requirement in my current project:
In a document library when I upload an excel sheet, a specific workbook has to be read and the contents have to be uploaded to a sharepoint custom list.
The approach followed was create an event receiver and register as a feature. Following is the code for event receiver.
public override void ItemAdded(SPItemEventProperties properties)
base.ItemAdded(properties);
var list = getSPList("{150301BF-D0BD-452C-90D7-2D6CD082A247}");
SPListItem doc = properties.ListItem;
doc["Msg"] = "items deleted from req list";
doc.Update();
string excelname=doc.File.Name;
System.Diagnostics.EventLog.WriteEntry("ExcelUpload", "calling read excel");
string filepath = doc.File.Url.ToString();
doc["Msg"] = "excel name" + excelname + filepath;
doc.Update();
readExcel(excelname,filepath);
private static SPList getSPList(String SPListGuid)
// SPSite Site = SPContext.Current.Site;
SPSite Site = new SPSite("http://omistestsrv:32252/sites/OMD");
SPWeb web = Site.OpenWeb();
Guid listid = new Guid(SPListGuid);
web.AllowUnsafeUpdates = true;
SPList List = web.Lists[listid];
return List;
private void readExcel(string excelname,string filepath)
try
SPSecurity.RunWithElevatedPrivileges(delegate()
using (SPSite Site = new SPSite("http://omistestsrv:32252/sites/OMD"))
SPWeb web = Site.OpenWeb();
string workbookpath = web.Url + "/" + filepath;
web.AllowUnsafeUpdates = true;
var _excelApp = new Microsoft.Office.Interop.Excel.Application();
System.Diagnostics.EventLog.WriteEntry("ExcelUpload", "iside read excel");
//my code breaks or fails when cursor reaches this statement. I am not able to open the excel sheet, there is no //problem related to the permission. same code snippet works in a console application. but when tried as an
event //handler in sharepoint it breaks. can anyone help me to resolve the problem
workBook = _excelApp.Workbooks.Open(workbookpath, Type.Missing, Type.Missing, Type.Missing, Type.Missing,Type.Missing,
Type.Missing, Type.Missing, Type.Missing,Type.Missing, Type.Missing, Type.Missing, Type.Missing,Type.Missing, Type.Missing);
System.Diagnostics.EventLog.WriteEntry("ExcelUpload", "after excel open");
int numSheets = workBook.Sheets.Count;
// Iterate through the sheets. They are indexed starting at 1.
System.Diagnostics.EventLog.WriteEntry("ExcelUpload", numSheets.ToString());
for (int sheetNum = 12; sheetNum < 13; sheetNum++)
System.Diagnostics.EventLog.WriteEntry("ExcelUpload", "inside first for
loop");
Worksheet sheet = (Microsoft.Office.Interop.Excel.Worksheet)workBook.Sheets[sheetNum];
Microsoft.Office.Interop.Excel.Range excelRange = sheet.get_Range("A13",
"P89") as Microsoft.Office.Interop.Excel.Range;
object[,] valueArray = (object[,])excelRange.get_Value(
Microsoft.Office.Interop.Excel.XlRangeValueDataType.xlRangeValueDefault);
var list = getSPList("{150301BF-D0BD-452C-90D7-2D6CD082A247}");
for (int L = 1; L <= excelRange.Rows.Count; L++)
string stringVal = valueArray[L, 1] as string;
if ((valueArray[L, 1] != null) && (!string.IsNullOrEmpty(stringVal)))
System.Diagnostics.EventLog.WriteEntry("ExcelUpload",
"inside second for loop");
SPListItemCollection
listItems = list.Items;
SPListItem item = listItems.Add();
item["Product"] = valueArray[L,
1];
item["App"] = valueArray[L,
2];
web.AllowUnsafeUpdates
= true;
item.Update();
web.AllowUnsafeUpdates = false;
//Or Another Method with valueArray Object like "ProcessObjects(valueArray);"
_excelApp.Workbooks.Close();
//workBook.Close(false, excelname, null);
//Marshal.ReleaseComObject(workBook);
catch (Exception e)
System.Diagnostics.EventLog.WriteEntry("ExcelUpload", e.Message.ToString());
finally
System.Diagnostics.EventLog.WriteEntry("ExcelUpload", "finally block");
Is this the only approach to meet this requirement or is there any other way to crack it. sharepoint techies please help me.as you described the scenario of the event that it should happen when user upload excel to a document library. Event Receiver is your best bet. However if you would have a requirement that users can send excel files any time to a network file location and
you want to pick it, read it and create list items etc. You would write a sharepoint timer job that would run every 10 minute to check for file and if available on the network drive, perform the operation etc. so that users who send excel file does not need
to come to the sharepoint etc. You can see that you have Event Receivcer option or Timer job option OR you would write a console application to trigger the code at a scheduled time on sharepoint server etc. so you are using the event receiver in the correct
scenario.
Moonis Tahir MVP, MCPD, MCSD.net, MCTS BizTalk 2006/SQL 2005/SharePoint Server 2007 (Dev & Config) -
Error while uploading Excel sheet
Hello Everybody,
I haave developed one application in which I am uploading one excel sheet. This code is working fine on my local WAS. But, it is giving me following error on Development server.
Application error occurred during request processing.
Details: java.lang.NoSuchMethodError: com.sap.engine.services.servlets_jsp.lib.multipart.MultipartMessage.setCharset(Ljava/lang/String;)V
Exception id: [0012799E23D0004E0000021C000022E900043C0595771BD9]
From the error it seems that it is not from my application but this error is coming from the server side. What could be the issues/problem from the server?
Did anybody encounter the same error?
Please help me in this regard.
Thanks,
Bhavik DevishaHello Bhavik,
are you using any external library in your project?
Can you please share the code which is posing problem?
Ashu -
FM for uploading data into internal table from Excel sheet
Hi,
I have a slight problem in one of the function modules that I have created. Actually it has been copied from a standard SAP function module KCD_EXCEL_OLE_TO_INT_CONVERT. Now my created function module is throwing me a dump suggesting Data objects in a Unicode program are not convertible. Can anybody help me out in removing the error .
Actually the need of copying the standard FM to a ZFM is to increase the length of the column which can be uploaded thru this FM. The standard FM has a restriction of being able to upload 32 characters whereas my requirement is to upload data having at least 150 characters. So in order to care the need I made a ZStructure ZAKHIL_CELLS taking the Value parameters as 150 characters instead of 32 characters.
Well this is all done because I wanted to upload a excel sheet into an internal table and not use a tab delimited file. Can anybody help in this regard or suggest some other function module which can upload more than 150 characters from a excel sheet .
m also attaching structure of my ZStructure for ur reference .
STRUCTURE ZAKHIL_CELLS1 .
ROW KCD_EX_ROW_N NUMC 4 Flexible Excel upload: row number
COL KCD_EX_COL_N NUMC 4 Column
VALUE KCD_VALUE CHAR 150 External Data Transfer: Values of Parameters or Variables
Thanks & Rgds,
Akhilhi,
sample excel sheet.
coloumn 1 is name and column 2 is age
name age
A 8
C 13
D 55
DATA : int_excel LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.
data : record like db_name_age occurs 0 with header line.
DATA : v_start_col TYPE i VALUE '1', "starting col
v_start_row TYPE i VALUE '1', " starting row
v_end_col TYPE i VALUE '2', " total columns
v_end_row TYPE i VALUE '10'. "total no of record
FORM f_upload .
CLEAR : int_excel, int_excel[].
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = wf_filename
i_begin_col = v_start_col
i_begin_row = v_start_row
i_end_col = v_end_col
i_end_row = v_end_row
TABLES
intern = int_excel
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
*Message is 'Unable to upload data from ' wf_filename.
MESSAGE e169(zm050) WITH wf_filename.
ELSE.
SORT int_excel BY row col.
REFRESH : record.
CLEAR : record.
LOOP AT int_excel.
CASE int_excel-col. "go thru each column.
WHEN 1.
record-name = int_excel-value.
WHEN 2.
record-age = int_excel-value.
ENDCASE.
AT END OF row.
APPEND record.
CLEAR record.
ENDAT.
ENDLOOP.
*inserting into table
ENDIF.
if this helped pld rewrd points,
rgrds
anver
Maybe you are looking for
-
No data in table TRFCQDATA when update IM in ECC after EWM PGR
Hi Experts, In our client system, when Inbound delivery (Customer Return) has been completed PGR in EWM, ECC system cannot be updated in IM stock and occurs an error :No data in Table TRFCQDATA(Internal) via SMQ2 query it. Who can advise how to solv
-
Gray image frames when opening CS4 in CS3
Hi, When I export a CS4 inx file to open in CS3, without the images correctly linked there is no image preview, just gray boxes. Is there anyway for this not to happen? For now, I have to give the editor this inx file for editing copy only on a diffe
-
IGWFolderRights *gwFolderRights NULL; DIGWAddress *gwAddressD = NULL; status = gwFolderRights->get_Address(&gwAddressD); I call that sometime crash in windows vista, then I tried catch this exception as below, but didn's work, still crash at here. us
-
JScrollBar - Issue when changing models
Hey All- Well, I've come up with another interesting question which I haven't been able to resolve myself. Basically, I have a single view port which consists of a custom JPanel and (2) JScrollbar's. I then have multiple data and view models which ar
-
Does Sun Messaging Server support Microsoft Active Directory
Hello, I just got this qustion. Does Sun Messaging Server work with Microsoft Active Directory? Thanks.