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,
Ajith
Hi 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
Similar Messages
-
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 -
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 -
How to handle merge cells in the excel sheet while uploading
Hi guys,
I have a requirement where i need to upload the excel sheet. The data is given below.
field1 field2 field3 field4
a x 1 1
2 2
3 3
y1 4 4
y2 5 5
y3 6
The output must be
a x 1 1
a x 2 2
a x 3 3
a y1 4 4
a y2 5 5
a y3 5 6
Here the field1 column is merged.
Please let me know if you guys have sample code to handle the merge cells in the excel sheet, that would be of gereat help.
Regards,
KarthikHi guys,
I have a requirement where i need to upload the excel sheet. The data is given below.
field1 field2 field3 field4
a x 1 1
2 2
3 3
y1 4 4
y2 5 5
y3 6
The output must be
a x 1 1
a x 2 2
a x 3 3
a y1 4 4
a y2 5 5
a y3 5 6
Here the field1 column is merged.
Please let me know if you guys have sample code to handle the merge cells in the excel sheet, that would be of gereat help.
Regards,
Karthik -
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 -
FM to upload the Excel file to internal table
Hi
Is any FM available to upload the Excel file to internal table.
Thanks
AnbuHi
se this code
EXCEL to INTERNAL TABLE and then to APPLICATION SERVER
*& Report ZSD_EXCEL_INT_APP
REPORT ZSD_EXCEL_INT_APP.
parameter: file_nm type localfile.
types : begin of it_tab1,
f1(20),
f2(40),
f3(20),
end of it_tab1.
data : it_tab type table of ALSMEX_TABLINE with header line,
file type rlgrap-filename.
data : it_tab2 type it_tab1 occurs 1,
wa_tab2 type it_tab1,
w_message(100) TYPE c.
at selection-screen on value-request for file_nm.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
STATIC = 'X'
MASK = ' '
CHANGING
file_name = file_nm
EXCEPTIONS
MASK_TOO_LONG = 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.
start-of-selection.
refresh it_tab2[].clear wa_tab2.
file = file_nm.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = file
i_begin_col = '1'
i_begin_row = '1'
i_end_col = '10'
i_end_row = '35'
tables
intern = it_tab
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.
loop at it_tab.
case it_tab-col.
when '002'.
wa_tab2-f1 = it_tab-value.
when '004'.
wa_tab2-f2 = it_tab-value.
when '008'.
wa_tab2-f3 = it_tab-value.
endcase.
at end of row.
append wa_tab2 to it_tab2.
clear wa_tab2.
endat.
endloop.
data : p_file TYPE rlgrap-filename value 'TEST3.txt'.
OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
*--- Display error messages if any.
IF sy-subrc NE 0.
MESSAGE e001(zsd_mes).
EXIT.
ELSE.
*---Data is downloaded to the application server file path
LOOP AT it_tab2 INTO wa_tab2.
TRANSFER wa_tab2 TO p_file.
ENDLOOP.
ENDIF.
*--Close the Application server file (Mandatory).
CLOSE DATASET p_file.
loop at it_tab2 into wa_tab2.
write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.
endloop. -
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 Journal Voutures of customer master from the Excel sheet using BAPI
Hi experts,
Can U have any sample program so that it can help me for my coding.Hi,
You need write the abap program in the following manner,
1. Read the data from the excel sheet and then enforce the checks if at all any in the new program.
2. Fill all the parameters of the BAPI *BAPI_CASHJOURNALDOC_CREATE *.
3. After the above BAPI call, you need to call another *BAPI_TRANSACTION_COMMIT *.
4. Once Transaction commit bapi is successfully executed then only you will get the document number.
Please follow all the above mentioned steps then you can create the Journal Voutures migrated from an excel sheet to SAP successfully.
Thanks,
Mahesh. -
Pasting data from Excel sheet to Table in web dynpro View
Hii All,
Is it possible to copy data ( some rows) from Excel sheet and paste in table in a view?
I tried doing this, but only first element is getting pasted..
Does anybody know how to do this?
Is there any way to perform similar thing?
Pls help.
regards,
AmeyHi,
Copy paste may work if you have that many rows in your table(not sure).
One thing you can do is upload the excel and then populate the context of the node bound to the table by fetching data from the excel
For this you can make use of JXL or APACHE POI.
Regards
Ayyapparaj -
Need to open the excel sheet in the selection screen
Hi All,
my requirement is to upload the data from excel sheet but that excel sheet have mutiple tabs and all individual tab have mutiple records inside. I need to open the excel sheet from selection screen and select dynamically any tab and i need to put all the records into internal table of that paricular tab.
Please suggest how it can be done.
<removed_by_moderator>
Thanks,
Madhu
Edited by: Julius Bussche on Oct 21, 2008 11:41 AM>
madhu singh wrote:
> Thanks for reply but this FM is actually transfer the tha data frrom excel sheet to the internal table. which we can use later before that i need to open the excel sheet on the selection screen.
it depends on which event do you call the FM. If you call in INITIALIZATION (or LOAD-OF-PROGRAM) than the Excel sheet will be uploaded before the selection screen appears at all. The problem with the above FM is that it will upload the actual tabstrip of the sheet, probably not what you want (and definetly no multiple ways). To upload data form Excel from multiple tabs, you need to code it on your own with the help of OLE commands. -
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. -
Error while opening the EXCEL Sheet from a Report Program
Hi All,
I am getting an error saying 'SYLK: File Format is not valid' when my program is trying to open an excel sheet. I am using the function module WS_EXCEL to download it to excel sheet.
Following is the code:
Excel download
types: begin of t_excel,
c01(20),
c02(20),
c03(20),
c04(20),
c05(70),
c06(20),
c07(20),
c08(20),
c09(20),
c10(20),
end of t_excel.
data: a00_excel type standard table of t_excel.
concatenate 'C:\' sy-repid sy-uzeit 'FILE01' '.xls' into z_fname.
condense z_fname no-gaps.
call function 'WS_EXCEL'
exporting
filename = z_fname
tables
data = a00_excel
exceptions
others = 1.
if sy-subrc ne 0.
message e019(zsd).
Download to Excel failed.
endif.
a00_excel contains the data that is to be downloaded into the excel sheet. I used the same code in the other program it is working fine. If you see in the type declaration for C5 its 70 characters, i tried putting it as same as others to 20... still it doesnt work.
Thank You,
SureshNot sure man, your code works ok for me.
report zrich_0001.
types: begin of t_excel,
c01(20),
c02(20),
c03(20),
c04(20),
c05(70),
c06(20),
c07(20),
c08(20),
c09(20),
c10(20),
end of t_excel.
data: a00_excel type standard table of t_excel.
data: x00_excel like line of a00_excel.
data: z_fname type string.
x00_excel-c01 = 'A'.
x00_excel-c02 = 'B'.
x00_excel-c03 = 'C'.
x00_excel-c04 = 'D'.
x00_excel-c05 = 'E'.
x00_excel-c06 = 'F'.
x00_excel-c07 = 'G'.
x00_excel-c08 = 'H'.
x00_excel-c09 = 'I'.
x00_excel-c10 = 'J'.
append x00_excel to a00_excel.
x00_excel-c01 = 'K'.
x00_excel-c02 = 'L'.
x00_excel-c03 = 'M'.
x00_excel-c04 = 'N'.
x00_excel-c05 = 'O'.
x00_excel-c06 = 'P'.
x00_excel-c07 = 'Q'.
x00_excel-c08 = 'R'.
x00_excel-c09 = 'S'.
x00_excel-c10 = 'T'.
append x00_excel to a00_excel.
concatenate 'C:' sy-repid sy-uzeit 'FILE01' '.xls' into z_fname.
condense z_fname no-gaps.
call function 'WS_EXCEL'
exporting
filename = z_fname
tables
data = a00_excel
exceptions
others = 1.
if sy-subrc ne 0.
message e019(zsd).
* download to excel failed.
endif.
Regards,
Rich Heilman -
How to set the Data types of the Excel sheet while exporting details to it.
Hi All,
We are trying to export some order details to the excel sheet from a jsp. It is working fine when the local system language is set to English.
But when i change it to Russian. the details like Line Numbers(e.g: 1.1, 1.2, 1.3 and so on... ) are getting changed into some other data type(e.g: 01.янв, 02.янв, 03.янв and so on....).
i guess this is mainly due to some data type mismatch, so i tried setting all the possible charset for response in the jsp, but could not succeeded.
This is only for the details which or of decimal format, working fine for the details which are in String type. like Description, Item name etc...
As it is high preference issue for our client, Please help me in this regard ASAP.
Thanks & Regards,
Praveen Reddy Bhi Shiv..
Its not an OAF page but it is from Apps only (i.e.Oracle iStore).
we tried writing this:
<%response.setContentType("application/vnd.ms-excel; charset=UTF-8");%>
<%response.setHeader("Content-Disposition", "attachment; filename=downloadOrders.xls" );%>
<head>
<title>Logitech_iStore</title>
<style>
table {
border-style: solid;
table th.mainHeader {
border-style: solid;
background-color:#000099;
border-color:#000000;
color:#FFFFFF;
font-family:Arial, Helvetica, sans-serif;
font-weight:bold;
font-size:13pt;
table th {
border-style: solid;
background-color:#6687C4;
border-color:#000000;
color:#FFFFFF;
font-family:Arial, Helvetica, sans-serif;
font-weight:bold;
font-size:12pt;
table td.color1 {
border-style: solid;
background-color:#FFFFFF;
border-color:#000000;
color:#000000;
font-family:"Times New Roman", Times, serif;
font-weight:normal;
font-size:12pt;
table td.color2 {
border-style: solid;
background-color:#C0C0C0;
border-color:#000000;
color:#000000;
font-family:"Times New Roman", Times, serif;
font-weight:normal;
font-size:12pt;
table td {
border-style: solid;
background-color:#FFFFFF;
border-color:#000000;
color:#000000;
font-family:"Times New Roman", Times, serif;
font-weight:normal;
font-size:12pt;
</style>
</head>
<body>
<%
/*BigDecimal resp_id=RequestCtx.getResponsibilityId();
String respIdParam="";
String respkey="";
if(resp_id!=null)
respIdParam=resp_id.toString();
out.println("respIdParam"+respIdParam);
logi.oracle.apps.ibe.util.LogiDAOImpl dao=new logi.oracle.apps.ibe.util.LogiDAOImpl();
respkey=dao.getRespKey(respIdParam);
out.println("respkey"+respkey);
logi.oracle.apps.ibe.util.LogiOrderDetailsBean orderDetailsBean = new logi.oracle.apps.ibe.util.LogiOrderDetailsBean();
java.util.ArrayList ls = new java.util.ArrayList();
String resp_key=request.getParameter("respkey");
System.out.println(resp_key);
String noofDays=request.getParameter("noOfDays");
String qCustAcctId=request.getParameter("qCustAcctId");
logi.oracle.apps.ibe.util.LogiDAOImpl daoimpl=new logi.oracle.apps.ibe.util.LogiDAOImpl();
String decideTab=request.getParameter("decideTab");
String startDate=request.getParameter("startDate");
String endDate=request.getParameter("endDate");
String queryCondition=request.getParameter("queryCondition");
String queryOperator=request.getParameter("queryOperator");
String queryValue=request.getParameter("queryValue");
String queryDateValue=request.getParameter("queryDate");
System.out.println("queryDateValue"+queryDateValue);
%>
<table cellspacing="1" cellpadding="1" width="100%" border="0" class="OraBGAccentDark">
<tr>
<th><%=AOLMessageManager.getMessageSt("IBE","IBE_LGT_ORD_NUM")%></th>
<th>Customer Name</th>
<th><%=AOLMessageManager.getMessageSt("IBE","IBE_LGT_ORD_DATE")%></th>
<th><%=AOLMessageManager.getMessageSt("IBE","IBE_LGT_BOOKED_DATE")%></th>
<th>Request Date</th>
<th><%=AOLMessageManager.getMessageSt("IBE","IBE_LGT_ORD_STATUS")%></th>
<th><%=AOLMessageManager.getMessageSt("IBE","IBE_LGT_ORD_PO")%></th>
<th>Currency</th>
<th>Payment Terms</th> <th>Freight Terms</th>
<th>FOB</th>
<th>Sales Channel</th>
<th>Ship to Location</th>
<th>Bill to Location</th>
<th>SalesTerritory Country</th>
<th>Order Type</th>
<th>Order Total</th>
<th><%=AOLMessageManager.getMessageSt("IBE","IBE_LGT_LINE_NUM")%></th>
<th><%=AOLMessageManager.getMessageSt("IBE","IBE_LGT_ITEM")%></th>
<th>Customer SKU</th>
<th>Description</th>
<th><%=AOLMessageManager.getMessageSt("IBE","IBE_LGT_QTY")%></th>
<th>Shipped Quantity</th>
<th>ScheduleShip Date</th>
<th>Unit Price</th>
<th>Extented Amount</th>
<th>Taxes Total</th>
<th>Freight Charges</th>
<th>Case pack charge</th>
<th>Charges Total</th>
<th><%=AOLMessageManager.getMessageSt("IBE","IBE_LGT_LINE_STATUS")%></th>
<th>Ship Date</th>
<th>Warehouse</th>
<th>Tracking Number</th>
<th>Waybill Number</th>
<th>Delivery Number</th>
<th>Pro Number</th>
<th>Hold Applied</th>
<th>Pallet Qty</th>
<th>Pallet#</th>
<th>Invoice Number</th>
<th>Promo Number</th>
<th>Ship Method</th>
</tr>
<%
int pSiteid=0;
java.math.BigDecimal mSiteId=oracle.apps.ibe.util.RequestCtx.getMinisiteId();
if(mSiteId!=null)
pSiteid=mSiteId.intValue();
out.println("pSiteid"+pSiteid);
if(decideTab!=null && decideTab.trim().equalsIgnoreCase("days"))
if(qCustAcctId!=null)
ls=daoimpl.downOrderDetails(qCustAcctId,noofDays,pSiteid);
else if(decideTab!=null && decideTab.trim().equalsIgnoreCase("dates"))
if(qCustAcctId!=null)
ls=daoimpl.downOrderDateDetails(qCustAcctId,queryDateValue,startDate,endDate);
else if(decideTab!=null && decideTab.trim().equalsIgnoreCase("condition"))
if(qCustAcctId!=null)
ls=daoimpl.downOrderConditionDetails(qCustAcctId,queryCondition,queryOperator,queryValue);
for(int i=0;i<ls.size();i++)
orderDetailsBean=(logi.oracle.apps.ibe.util.LogiOrderDetailsBean)ls.get(i);
String orderNumber= orderDetailsBean.getOrderNumber(); //Order Number
if(orderNumber==null)orderNumber="";
String customerName=orderDetailsBean.getCustomerName(); //Customer Name
if(customerName==null)customerName="";
String orderedDate=orderDetailsBean.getOrderDate(); //Order Date
if(orderedDate==null)orderedDate="";
String bookeddate= orderDetailsBean.getBookedDate(); //Booked Date
if(bookeddate==null)bookeddate="";
String requestdate= orderDetailsBean.getRequestDate(); //Requested Date
if(requestdate==null)requestdate="";
String orderstatus= orderDetailsBean.getOrderStatus(); //Order Status
if(orderstatus==null)orderstatus="";
String ponumber= orderDetailsBean.getPoNumber(); //PO Number
if(ponumber==null)ponumber="";
String currency=orderDetailsBean.getCurrencyCode(); //Currency
if(currency==null)currency="";
String paymentterms= orderDetailsBean.getPaymentTerms(); //Payment Terms
if(paymentterms==null)paymentterms="";
String frieghtterms=orderDetailsBean.getFreightTerms(); //Freight Terms
if(frieghtterms==null)frieghtterms="";
String fobterms=orderDetailsBean.getFobTerms(); //Fob Terms
if(fobterms==null)fobterms="";
String saleschannel=orderDetailsBean.getSalesTerms(); //Sales Channel
if(saleschannel==null)saleschannel="";
String billtoloc=orderDetailsBean.getBillToLocation(); // Bill to Location
if(billtoloc==null)billtoloc="";
String shiptoloc=orderDetailsBean.getShipToLocation(); //Ship To Location
if(shiptoloc==null)shiptoloc="";
String salesterr=orderDetailsBean.getSalesCountry(); // Sales Territory
if(salesterr==null)salesterr="";
String ordertype=orderDetailsBean.getOrderType(); // Order Type
if(ordertype==null)ordertype="";
String ordertotal=orderDetailsBean.getOrderTotal(); //Order Total
if(ordertotal==null)ordertotal="";
String linenumber=orderDetailsBean.getLinenumber(); //Line Number
if(linenumber==null)linenumber="";
String item= orderDetailsBean.getItem(); //Item Name
if(item==null)item="";
String sku= orderDetailsBean.getCustomerSKU(); // Customer SKU
if(sku==null)sku="";
String desc= orderDetailsBean.getDescription(); //Item Description
if(desc==null)desc="";
desc = URLEncoder.encode(desc); // Added by Sunil
desc = URLDecoder.decode(desc);
String qty=orderDetailsBean.getQty(); //Ordered Quantity
if(qty==null)qty="";
String shippedqty=orderDetailsBean.getShippedQty(); //Shipped Quantity
if(shippedqty==null)shippedqty="";
String scheduleqty=orderDetailsBean.getScheduleDate(); //Schedule Date
if(scheduleqty==null)scheduleqty="";
String unitprice=orderDetailsBean.getUnitPrice(); //Unit Price
if(unitprice==null)unitprice="";
String xamount=orderDetailsBean.getXAmount(); //Extended Amount
if(xamount==null)xamount="";
String taxestotal=orderDetailsBean.getTaxesTotal(); //Taxes Total
if(taxestotal==null)taxestotal="";
String freightcharges=orderDetailsBean.getFreightCharges();//Freight Charges
if(freightcharges==null)freightcharges="";
String palletcharges=orderDetailsBean.getPalletSurcharge(); //Pallet Charges
if(palletcharges==null)palletcharges="";
String chargestotal=orderDetailsBean.getChargesTotal(); //Charges Total
if(chargestotal==null)chargestotal="";
String linestatus=orderDetailsBean.getLinestatus(); //Line Status
if(linestatus==null)linestatus="";
String shipdate=orderDetailsBean.getShipDate(); //Ship Date
if(shipdate==null)shipdate="";
String warehouse=orderDetailsBean.getWareHouse(); //Ware House
if(warehouse==null)warehouse="";
String trackingnumber=orderDetailsBean.getTrackingNumber();//Tracking Number
if(trackingnumber==null)trackingnumber="";
String waybill=orderDetailsBean.getWayBillnumber(); //Waybill Number
if(waybill==null)waybill="";
String deliverynumber=orderDetailsBean.getDeliveryNumber(); //Delivery Number
if(deliverynumber==null)deliverynumber="";
String pronumber=orderDetailsBean.getProNumber(); //Pro Number
if(pronumber==null)pronumber="";
String holdapplied=orderDetailsBean.getHoldApplied(); //Hold Applied
if(holdapplied==null)holdapplied="";
String palletqty=orderDetailsBean.getPalletQty(); //Pallet Qty
if(palletqty==null)palletqty="";
String pallethash=orderDetailsBean.getPalletHash(); //Pallet Hash
if(pallethash==null)pallethash="";
String invoicenumber=orderDetailsBean.getInvoiceNumber(); //invoice Number
if(invoicenumber==null)invoicenumber="";
String promonumber=orderDetailsBean.getPromoNumber(); //Promonumber
if(promonumber==null)promonumber="";
String shipmethod=orderDetailsBean.getShipMethod(); //Promonumber
if(shipmethod==null)shipmethod="";
%>
<tr>
<td><%=orderNumber%></td>
<td><%=customerName%></td>
<td><%=orderedDate%></td>
<td><%=bookeddate%></td>
<td><%=requestdate%></td>
<td><%=orderstatus%></td>
<td><%=ponumber%></td>
<td><%=currency%></td>
<td><%=paymentterms%></td>
<td><%=frieghtterms%></td>
<td><%=fobterms%></td>
<td><%=saleschannel%></td>
<td><%=billtoloc%></td>
<td><%=shiptoloc%></td>
<td><%=salesterr%></td>
<td><%=ordertype%></td>
<td><%=ordertotal%></td>
<td><%=linenumber%></td>
<td><%=item%></td>
<td><%=sku%></td>
<td><%= desc %></td>
<td><%=qty%></td>
<td><%=shippedqty%></td>
<td><%=scheduleqty%></td>
<td><%=unitprice%></td>
<td><%=xamount%></td>
<td><%=taxestotal%></td>
<td><%=freightcharges%></td>
<td><%=palletcharges%></td>
<td><%=chargestotal%></td>
<td><%=linestatus%></td>
<td><%=shipdate%></td>
<td><%=warehouse%></td>
<td><%=trackingnumber%></td>
<td><%=waybill%></td>
<td><%=deliverynumber%></td>
<td><%=pronumber%></td>
<td><%=holdapplied%></td>
<td><%=palletqty%></td>
<td><%=pallethash%></td>
<td><%=invoicenumber%></td>
<td><%=promonumber%></td>
<td><%=shipmethod%></td>
</tr>
<% }
%>
</table>
</body>
</html>
Please suggest the needful...
Praveen Reddy -
How to modify data in the excel sheet.
Hi,
I have a requirement like ,
i have a excel file which contains only one column (all the data in the single colume )so now i have to modify that excel sheet and have to make some more columns based on my requirement.
eg:
column1
mumbaikolkata
delhichennai
mumbaikolkata
this shud be converted like this
column1 column2
mumbai kolkata
delhi chennai
mumbai kolkata
can i directly modify the excel sheet based on my requirement without using internal tables in between.
like excel ->internal table-> modified internaltable-> excel.
Edited by: Sravani Bellana on Dec 18, 2008 5:46 AMHi sravani,
true that we need to specify the rows and columns,
I have worked on such applications i shall describe the possibilities and then you can find the necessary option,
1) Function module:SAP_CONVERT_TO_XLS_FORMAT .
it needs
file path p_file type rlgrap-filename and
i_tab_sap_data (the internal table name).
2) Function module : MS_EXCEL_OLE_STANDARD_DAT
it needs
file path p_file like RLGRAP-FILENAME
data_tab (int_data "internal table with data)
fieldnames (int_head "internal table with header)
3) if the download application is a one time then go for the following option:
write the program to display the data in the internal table on the screen.
execute the program.
type %pc on the command bar and try downloading using the options displayed.
hope any one of these work out.
get back if you till have any clarificatrion
thanks
srikanth -
Need leading Zeros in the excel sheet which is sent from ABAP
Hi ,
I am downloading data from SAP to excel sheet using the WS_DOWNLOAD Function Module. The numeric data in not having leading zeros. if it is 0010 it is displaying 10 in the excel sheet . i need the leading zeros in the excel sheet. without manulally changing it to Text in the excel sheet .
Is there any way to do it .
Thanks,
ChetanHi Chetan,
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = w_file_path
filetype = 'DBF' "declare the File type as DBF then leading zeros will appear
write_field_separator = 'X'
confirm_overwrite = 'X'
TABLES
data_tab = Itab.
Regards,
Prabhudas
Maybe you are looking for
-
I have 3 users on one computer with 3 unique user accounts. Each of us have separate and unique ITunes accounts. How do we share our music libraries using Home Sharing? Everything that I can find talks about sharing between networked computers, bu
-
Allignment problem between Report Builder And Apps
Hi All : If i am running a report in report builder i am getting 20 records in each page of the reports.but when i am running this same report in apps i am getting 24 records in each page of the apps more than this the records allignment everything h
-
Preview and Adobe fonts problem/missing in PDF
I have a PDF document that doesn't show some fonts. The PDF was displaying fine on preview and then all of the sudden the next day it got messed up. I didn't performed any update or installed any new app. The problem persists in both Preview app and
-
Connecting a second computer to wireless printer
I have just installed the software for the Envy 4500 printer and everything is working fine. I would like to be able to print from a second computer but have been unable to locate instructions on how to install on a second computer. Can anyone direct
-
Oracle 9i Lite: Table structure changed
Hello, how do I add a new column to a database table? I mean what actions to I have to take to add the column to the database on the server and how is this change transferred to the clients? Are these changes impossible to do with Oracle Lite? Stefan