Regarding upload from excel to alv.
Hi
here is my code:
TABLES
TABLES: ioheader, " IOC Communication structure
ioitem, " IOC Communication structure
klah, " Class and Class type
ksml, " Characteristic Keys for Class and Type
cabn, " Characteristics
cabnt, " Characteristic Descriptions
vbap, " SAles details
sscrfields.
Includes
INCLUDE rvreuse_global_data. " ALV Types etc
DATA - INTERNAL TABLES AND FIELD LISTS
Types
TYPE-POOLS: ibco2. " Characteristic types
DATA - CONSTANTS
CONSTANTS: c_true(1) TYPE c VALUE 'X',
c_false(1) TYPE c VALUE ' ',
c_zioheader TYPE dd02l-tabname VALUE 'ZIOHEADER',
c_command TYPE slis_formname VALUE 'USER_COMMAND',
c_backhoe(7) TYPE c VALUE 'BACKHOE',
c_300(3) TYPE c VALUE '300',
c_no_data(7) TYPE c VALUE 'No Data',
c_save(1) TYPE c VALUE 'A'.
Internal Tables
Main IO Table
DATA: i_header LIKE zioheader OCCURS 0 WITH HEADER LINE.
Characteristic Values
DATA: i_config TYPE ibco2_instance_tab2.
Characteristics Keys
DATA: BEGIN OF i_imerk OCCURS 0,
imerk LIKE ksml-imerk,
END OF i_imerk.
ALV Grid Control
DATA: i_grid TYPE sd_alv.
Catalogues
DATA: wa_cat LIKE LINE OF i_grid-fieldcat.
Structures
Structure for layout variant
DATA: s_variant LIKE disvariant.
DATA : filename TYPE string.
DATA - WORKING VARIABLES
DATA - FIELD GROUPS
*field-groups:
SELECTION SCREEN
Variant control
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t02.
PARAMETERS: p_var LIKE disvariant-variant.
SELECTION-SCREEN END OF BLOCK b1.
Printer Control
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-t03.
PARAMETERS: rad1 RADIOBUTTON GROUP rad USER-COMMAND radio,
rad2 RADIOBUTTON GROUP rad,
rad3 RADIOBUTTON GROUP rad.
PARAMETER p_floc(128) DEFAULT '/usr/tmp/testfile.dat'
LOWER CASE.
SELECTION-SCREEN END OF BLOCK b3.
MAIN PROGRAM *************************
INITIALIZATION.
PERFORM initialise. " Set up program defaults
move 'Report Only' to rad1.
move 'Export Sequence List' to s_but2.
move 'Import Sequence List' to S_but3.
Selection Screen Options
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_var.
PERFORM get_variant CHANGING p_var. " ALV Layout
DATA : l_no_of_lines TYPE i,
la_matnr LIKE s_matnr.
DESCRIBE TABLE s_matnr LINES l_no_of_lines.
IF l_no_of_lines > 1.
MESSAGE e000(z1) WITH 'Enter only one product'.
ENDIF.
READ TABLE s_matnr INTO la_matnr WITH KEY sign = 'I'
option = 'EQ'.
IF sy-subrc NE 0.
MESSAGE e000(z1) WITH 'Enter only one product'.
ENDIF.
AT SELECTION-SCREEN.
DATA : l_no_of_lines TYPE i,
la_matnr LIKE s_matnr.
DESCRIBE TABLE s_matnr LINES l_no_of_lines.
IF l_no_of_lines > 1.
MESSAGE e000(z1) WITH 'Enter only one product'.
ENDIF.
READ TABLE s_matnr INTO la_matnr WITH KEY sign = 'I'
option = 'EQ'.
IF sy-subrc NE 0.
MESSAGE e000(z1) WITH 'Enter only one product'.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_floc.
data : pname type syst-repid.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = pname
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FLOC'
STATIC = ' '
MASK = ' '
CHANGING
FILE_NAME = p_floc
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.
PERFORM set_catalogue. " Set up basic headings from Itab
PERFORM get_char_keys. " Get the characteristic keys
PERFORM modify_catalogue_key. " Amend headings for char keys
IOC Logical Database Event
GET ioheader.
PERFORM get_subsequent_data. " Retrieve additional data
END-OF-SELECTION.
PERFORM modify_catalogue_title. " Place correct titles for AVL
PERFORM alv_display. " Display in ALV Grid
if rad1 = 'X' .
PERFORM modify_catalogue_title. " Place correct titles for AVL
PERFORM alv_display. " Display in ALV Grid
elseif rad2 = 'X' .
*if p_floc is initial .
MESSAGE e000(z1) WITH
' Enter the file location'.
*else.
PERFORM download. " Export sequence list to excel
PERFORM modify_catalogue_title. " Place correct titles for AVL
PERFORM alv_display. " Display in ALV Grid
*endif.
elseif rad3 = 'X' .
if p_floc is initial .
MESSAGE e000(z1) WITH
' Enter the file location'.
else .
PERFORM upload.
endif.
endif.
*AT SELECTION-SCREEN OUTPUT.
*TOP-OF-PAGE.
*END-OF-PAGE.
*AT USER-COMMAND.
perform PF_STATUS_SET.
SUBROUTINES *******************************
FORM get_variant *
Retrieve ALV display variant *
--> X_VAR Variant *
FORM get_variant CHANGING x_var.
PERFORM f4_alv_layout(ppio_entry) USING i_grid-program
CHANGING x_var.
ENDFORM.
FORM get_subsequent_data *
Retrieve additional data and place into I_HEADER Itab *
FORM get_subsequent_data.
Prime extended table
i_header = ioheader.
PERFORM get_serial_number. " Get Sales Order Serial No
PERFORM get_char_values. " Get Characteristic Values
PERFORM build_char_entries." Put Char Values into I_HEADER
Add to extended table
APPEND i_header.
ENDFORM.
FORM get_serial_number *
Retrieve the serial number *
FORM get_serial_number.
SELECT SINGLE zuonr submi
INTO (i_header-zuonr,i_header-submi)
FROM vbak
WHERE vbeln EQ i_header-kdauf_aufk.
ENDFORM.
FORM get_char_values *
Retrieve the characteristic values for the production order *
FORM get_char_values.
Get Ready
REFRESH i_config.
Get Object key
SELECT SINGLE cuobj
FROM vbap
INTO vbap-cuobj
WHERE vbeln EQ i_header-kdauf_aufk
AND matnr EQ i_header-plnbez.
Get characteristic config values
CALL FUNCTION 'CUCB_GET_CONFIGURATION'
EXPORTING
instance = vbap-cuobj
IMPORTING
configuration = i_config
EXCEPTIONS
invalid_input = 1
invalid_instance = 2
instance_is_a_classification = 3
OTHERS = 4.
Not found, no config values will be pulled through
IF sy-subrc <> 0.
ENDIF.
ENDFORM.
FORM build_char_entries *
For each character value. Find the relevent "slot" in the *
table by checking the characteristic key against the catalogue*
stored key
FORM build_char_entries.
DATA: la_config LIKE LINE OF i_config, " i_config header line
li_values TYPE ibvalue0 OCCURS 0, " Charact'ic Values Itab
la_values LIKE LINE OF li_values, " li_values header line
l_atwrt LIKE la_values-atwrt, " Characteristic Value
l_atinn LIKE la_values-atinn, " Characteristic Key
l_key(20), " Working built key
l_entry(20), " FieldName to be updated
l_len LIKE sy-tabix, " Length of string
l_tabix LIKE sy-tabix. " Index position of Itab
FIELD-SYMBOLS: <f_field>. " This will be the field to update
Loop on characteristics
LOOP AT i_config INTO la_config.
Extract the characteristic values imbedded table
MOVE la_config-values TO li_values.
Loop on the characteristics values
LOOP AT li_values INTO la_values.
We now have the charecteristic key la_values-atinn
and the value in la_values-atwrt. However, there may be
Multiple values for key la_values-atinn
So if they are the same append to one long string.
Is it a new value
IF la_values-atinn EQ l_atinn.
CONCATENATE l_atwrt '|' la_values-atwrt INTO l_atwrt.
CONTINUE.
ENDIF.
New Value (and not first pass) so save built values
IF NOT l_atinn IS INITIAL.
Find the correct field to place the value in.
This is done by finding the Itab field description in the AVL display
field Catalogue called "No Data|nnnnnn" where nnnn is the
characteristic Key
Build the key
CONCATENATE c_no_data '|' l_atinn INTO l_key.
Loop till we find it. This gives us the field name
LOOP AT i_grid-fieldcat INTO wa_cat WHERE seltext_l = l_key.
Set up the field name to be amended
CONCATENATE wa_cat-tabname '-' wa_cat-fieldname INTO l_entry.
ASSIGN (l_entry) TO <f_field>.
Update field with the Char value
MOVE l_atwrt TO <f_field>.
No need to continue this loop
EXIT.
ENDLOOP.
ENDIF.
Prime for next value
l_atinn = la_values-atinn.
l_atwrt = la_values-atwrt.
ENDLOOP.
ENDLOOP.
ENDFORM.
FORM alv_display *
Display data in ALV grid *
FORM alv_display.
Set up Variant
i_grid-variant-variant = p_var. " Variant
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
i_callback_program = i_grid-program
I_CALLBACK_PF_STATUS_SET = i_grid-pf_status_set
i_callback_user_command = i_grid-user_command
i_structure_name = i_grid-structure
is_layout = i_grid-layout
it_fieldcat = i_grid-fieldcat
IT_EXCLUDING = i_grid-excluding
IT_SPECIAL_GROUPS = i_grid-special_groups
IT_SORT = i_grid-sort
IT_FILTER = i_grid-filter
IS_SEL_HIDE = i_grid-sel_hide
I_DEFAULT = i_grid-default
i_save = I_grid-save
is_variant = i_grid-variant
IT_EVENTS = i_grid-events
IT_EVENT_EXIT = i_grid-event_exit
IS_PRINT = i_grid-print
IS_REPREP_ID =
I_SCREEN_START_COLUMN = i_grid-start_column
I_SCREEN_START_LINE = i_grid-start_line
I_SCREEN_END_COLUMN = i_grid-end_column
I_SCREEN_END_LINE = i_grid-end_line
IMPORTING
E_EXIT_CAUSED_BY_CALLER = i_grid-exit
ES_EXIT_CAUSED_BY_USER = i_grid-user_exit
TABLES
t_outtab = i_header
EXCEPTIONS
program_error = 1
OTHERS = 2.
ALV Failed.
IF sy-subrc <> 0.
WRITE: / 'Failed with',sy-subrc.
ENDIF.
ENDFORM.
FORM initialise *
Set up basic report details *
FORM initialise.
ALV controls
i_grid-program = sy-repid. " Program Name
i_grid-user_command = c_command. " ALV user FORM
i_grid-save = c_save. " Save Options
ALV Variant Details for saved report layouts
i_grid-variant-report = i_grid-program.
i_grid-variant-username = sy-uname.
ENDFORM.
FORM user_command *
Routine called by ALV *
--> X_UCOMM Function selected *
--> X_SELFIELD Selection field Itab *
FORM user_command USING x_ucomm LIKE sy-ucomm
x_selfield TYPE slis_selfield.
DATA: l_answer(1). " Answer returned from popup box
Only allow drill down on Order number
CHECK x_selfield-fieldname = 'AUFNR'.
Get option for display or modify
CALL FUNCTION 'POPUP_TO_DECIDE'
EXPORTING
textline1 = 'Please Choose'
text_option1 = 'Display'
text_option2 = 'Modify'
titel = 'Production Order'
IMPORTING
answer = l_answer.
Did they cancel
CHECK l_answer NE 'A'.
Set up parameters.
SET PARAMETER ID 'ANR' FIELD x_selfield-value.
Display
IF l_answer = '1'.
CALL TRANSACTION 'CO03' AND SKIP FIRST SCREEN.
Modify
ELSEIF l_answer = '2'.
CALL TRANSACTION 'CO02' AND SKIP FIRST SCREEN.
ENDIF.
*IF rad2 = 'X'.
If sy-ucomm ='%PC'.
IF sy-subrc <> 0.
WRITE: / 'Failed with',sy-subrc.
else.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
TITEL = 'File Transfer Status'
TXT1 = 'File transfered to location:'
TXT2 = filename
TXT3 = ' '
TXT4 = ' '
ENDIF.
endif.
ENDFORM.
FORM set_catalogue *
Retrieve the title and field information from the *
Data Dictionary. This will then be amended to the correct *
Characteristic titles during the end-of-selection event *
FORM set_catalogue.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = i_grid-program
i_internal_tabname = 'I_HEADER'
i_structure_name = c_zioheader
i_client_never_display = 'X'
CHANGING
ct_fieldcat = i_grid-fieldcat.
ENDFORM.
FORM get_char_keys *
Retrieve the list of characteristic keys *
template of BACKHOE class 300 *
FORM get_char_keys.
DATA : la_inob TYPE inob.
SELECT SINGLE * FROM inob INTO la_inob
WHERE objek = s_matnr-low.
IF sy-subrc NE 0.
MESSAGE e000(z1) WITH
' Could not get INOB table for ' s_matnr-low.
ENDIF.
Get Major Object key
SELECT SINGLE clint
FROM klah
INTO klah-clint
WHERE klart = la_inob-klart
AND class = s_matnr-low.
IF sy-subrc NE 0.
MESSAGE e001(z296) WITH c_backhoe c_300.
ENDIF.
Use Major key to retrieve Characteristics keys
This is the template for the headings
SELECT imerk
FROM ksml
INTO TABLE i_imerk
WHERE clint EQ klah-clint " Objct Key
AND lkenz EQ space " Delete Indicator
AND datuv LE sy-datum. " Validity to
IF sy-subrc NE 0.
MESSAGE e002(z296) WITH klah-clint.
ENDIF.
ENDFORM.
FORM modify_catalogue_key *
Change the default "No Data" titles with the characteristic *
key values in the form "No Data|nnnnnnn" where nnnnnn is *
the characteristic key. This is used as a method of allocating*
characteristic values to the I_HEADER Itab positions *
CHAR_001 to CHAR_100 *
FORM modify_catalogue_key.
DATA: l_index LIKE sy-tabix, " Table Index for Read
l_tabix LIKE sy-tabix, " Table Index Position
l_seltext_l LIKE dd03p-scrtext_l. " Heading Text
Get into Key Sequence
SORT i_imerk.
Loop on catalogue for dummy titles
LOOP AT i_grid-fieldcat INTO wa_cat WHERE seltext_l(7) = c_no_data.
l_tabix = sy-tabix.
Get the next characteristic
l_index = l_index + 1.
READ TABLE i_imerk INDEX l_index.
No Characteristic, No display
IF sy-subrc NE 0.
wa_cat-no_out = c_true.
wa_cat-tech = c_true.
MODIFY i_grid-fieldcat FROM wa_cat INDEX l_tabix.
CONTINUE.
ENDIF.
Place the char key against the "No Data" title
so that later we know what values to place against the keys
the title will become "No Data:nnnnnnnnnn" (nnn = Key)
CONCATENATE c_no_data '|' i_imerk-imerk INTO wa_cat-seltext_l.
MODIFY i_grid-fieldcat FROM wa_cat INDEX l_tabix.
ENDLOOP.
ENDFORM.
FORM modify_catalogue_title *
At this stage the catalogue titles for the characteristics *
are in the form "No Data|nnnnn" Where nnnn is the *
characteristic key. Using the Key, replace this text with *
the real characteristic title
FORM modify_catalogue_title.
DATA: l_key(20), " Characteristic Key in Alpha form
l_len LIKE sy-tabix. " Length of string
Loop on the characteristic keys
LOOP AT i_imerk.
Get the real title
SELECT SINGLE atbez
FROM cabnt
INTO cabnt-atbez
WHERE atinn EQ i_imerk-imerk.
Not found, leave alone
CHECK sy-subrc EQ 0.
Place key into char form for comparison in loop
l_key = i_imerk-imerk.
Now loop on the catalogue to get the key
LOOP AT i_grid-fieldcat INTO wa_cat WHERE seltext_l+8 = l_key.
Place the title into the catalogue
wa_cat-seltext_l = cabnt-atbez.
wa_cat-seltext_m = cabnt-atbez.
wa_cat-seltext_s = cabnt-atbez.
wa_cat-reptext_ddic = cabnt-atbez.
And update
MODIFY i_grid-fieldcat FROM wa_cat.
ENDLOOP.
ENDLOOP.
IF rad2 = 'X'.
LOOP AT i_grid-fieldcat INTO wa_cat.
*IF wa_cat-fieldname = 'AUFNR'.
*wa_cat-col_pos = '10'.
*endif.
case wa_cat-fieldname.
when 'AUFNR'.
wa_cat-fix_column = 'X'.
when 'CY_SEQNR'.
wa_cat-fix_column = 'X'.
when 'ZOUNR'.
wa_cat-fix_column = 'X'.
when 'GLTRP'.
wa_cat-fix_column = 'X'.
when 'SUBMI'.
wa_cat-fix_column = 'X'.
endcase.
modify i_grid-fieldcat FROM wa_cat.
endloop.
endif.
ENDFORM.
*SELECT z099seqno z099heading
INTO table i_header
FROM z099 join z100 ON
z099seqno = z100seqno WHERE
z100~product = s_matnr.
*& Form download
Download file to excel
*FORM download.
*filename = p_floc .
*CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = filename
FILETYPE = 'ASC'
APPEND = 'X'
WRITE_FIELD_SEPARATOR = ','
HEADER = 'l_seltext_l'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = i_header
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.
WRITE: / 'Failed with',sy-subrc.
else.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
TITEL = 'File Transfer Status'
TXT1 = 'File transfered to location:'
TXT2 = filename
TXT3 = ' '
TXT4 = ' '
ENDIF.
*ENDFORM. " download
*& Form upload
text
--> p1 text
<-- p2 text
FORM upload.
*DATA : i_upload TYPE STANDARD TABLE OF alsmex_tabline.
**data : i_upload like zioheader occurs 0 with header line.
data file like RLGRAP-FILENAME.
file = p_floc .
DATA: BEGIN OF i_upload OCCURS 0.
INCLUDE STRUCTURE alsmex_tabline.
DATA: END OF i_upload.
DATA: BEGIN OF i_upload1 OCCURS 0.
INCLUDE STRUCTURE alsmex_tabline.
DATA: END OF i_upload1.
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: tind(4) TYPE n.
FIELD-SYMBOLS: <fs1>.
DATA: zwfeld(19).
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = file
I_BEGIN_COL = '1'
I_BEGIN_ROW = '1'
I_END_COL = '200'
I_END_ROW = '6500'
TABLES
INTERN = i_upload.
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 i_upload.
i_upload1 = i_upload.
CLEAR i_upload1-row.
APPEND i_upload1.
ENDLOOP.
SORT i_upload1 BY col.
LOOP AT i_upload1.
AT NEW col.
t_col-col = i_upload1-col.
APPEND t_col.
ENDAT.
zwlen = strlen( i_upload1-value ).
READ TABLE t_col WITH KEY col = i_upload1-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 i_upload BY row col.
IF kzheader = 'X'.
LOOP AT i_upload.
fieldnames-title = i_upload-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 i_upload BY row col.
LOOP AT i_upload.
IF kzheader = 'X'
i_upload-row = 1.
CONTINUE.
ENDIF.
tind = i_upload-col.
CONCATENATE 'DATA_TAB-VALUE_' tind INTO zwfeld.
ASSIGN (zwfeld) TO <fs1>.
<fs1> = i_upload-value.
AT END OF row.
APPEND i_upload.
CLEAR i_upload.
ENDAT.
ENDLOOP.
if sy-subrc = 0.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = i_grid-program
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = i_grid-fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = i_save
IS_VARIANT = i_grid-variant
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_ADD_FIELDCAT =
IT_HYPERLINK =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = i_upload.
EXCEPTIONS
PROGRAM_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.
endif.
when i execute the program i am getting a short dump
GETWA_NOT_ASSIGNED
what might be the problem.
this is a very urgent question.
pls suggest me the clear way to over come this problem.
HI
use this code for uploading the excel file to internal table....
data: begin of itab_string occurs 0,
record type char255,
end of itab_string.
data: L_FILETABLE TYPE FILETABLE,
L_FILETAB_H TYPE FILETABLE WITH HEADER LINE.
data: p_file1 type string.
selection screen .
PARAMETERS: P_FILE TYPE LOCALFILE.
initialization.
at selection-screen on value-request for P_FILE.
IF THE USER SELECT EXTENTION BUTTON IT WILL OPEN THE LOCAL DIRECTORY FOR SELECTING THE FILE LOCATION.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
EXPORTING
WINDOW_TITLE =
DEFAULT_EXTENSION = 'CSV'
DEFAULT_FILENAME = 'C:\Documents and Settings\196093\Desktop\STATUS.csv'
FILE_FILTER =
INITIAL_DIRECTORY = 'C:\Documents and Settings\196093\Desktop\'
MULTISELECTION =
WITH_ENCODING =
CHANGING
FILE_TABLE = L_FILETABLE
RC = RC
USER_ACTION =
FILE_ENCODING =
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
NOT_SUPPORTED_BY_GUI = 4
others = 5
IF SY-SUBRC <> 0.
ELSE.
LOOP AT l_filetable INTO L_FILETAB_H.
P_FILE = L_FILETAB_H-FILENAME.
move p_file to p_file1.
EXIT.
ENDLOOP.
ENDIF.
passing the selected file name to gui_upload for loading the data
into internal table
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = p_file1
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = itab_string
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 I000(Z00) WITH 'PLEASE PROVIDE CORRECT FILE NAME'.
ENDIF.
reward points to all helpful answers
kiran.M
Similar Messages
-
Hi,
I have a requirement to upload data from EXCEL to ALV. I could not find any standard functionality which does the same. Any pointers in this regard would be of great help.
Thanks & Regards,
Nirupamaa.Hi,
I have a requirement to upload data from EXCEL to ALV. I could not find any standard functionality which does the same. Any pointers in this regard would be of great help.
Thanks & Regards,
Nirupamaa. -
GLPLUP - big uploads from Excel
Transaction code GLPLUP (program G_FLEX_UPL) is used for budget data upload in SAP ECC6. There are need for about 250000 budget data rows to be uploaded into SAP. With GLPLUP can be uploaded about 1400 rows per one time, so with 250000 rows would mean the uploads for quite many times and this seems not so sensible.
Is there any (standard) solutions for big budget data uploads from Excel into SAP?Thanks for the tips!
We created transaction ZGLPLUP and Excel file is to be uploaded into SAP. Budget upload is processed in batch input session. In that way it could be processed also big amounts of data and output logs could also be created. -
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 -
Data upload from excel into SAP
Hi Gurus
Could anyone please guide me how to upload excel data into SAP?
I need to update existing Gross weight and Net weight data. Got new data in excel format.So need to upload excel file straight into SAP and update the data.
Step by step procedure will be much appreciated.
Rgds
Utpaltry with bdc .....
below coding is move the data from excel to internal table ....
TYPES: BEGIN OF s_ovro,
VKORG LIKE V_TVSFK-VKORG,
VTWEG LIKE V_TVSFK-VTWEG,
SPART LIKE V_TVSFK-SPART,
STGKU LIKE V_TVSFK-STGKU,
STGAK LIKE V_TVSFK-STGAK,
STAFO LIKE V_TVSFK-STAFO,
END OF s_ovro.
DATA: I_OVRO TYPE TABLE OF s_ovro,
w_ovro type s_ovro.
data : request(15) type c,
i type c.
DATA : IT_EXCEL TYPE STANDARD TABLE OF ALSMEX_TABLINE WITH HEADER LINE.
FIELD-SYMBOLS: <FS1> TYPE ANY.
include bdcrecx1.
SELECTION-SCREEN BEGIN OF BLOCK DATA WITH FRAME.
PARAMETERS: P_FILE TYPE RLGRAP-FILENAME DEFAULT 'C:\Documents and Settings\itfactory\Desktop\sd1.xls' OBLIGATORY.
SELECTION-SCREEN END OF BLOCK DATA.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
IMPORTING
FILE_NAME = P_FILE.
start-of-selection.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FILE
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 24
I_END_ROW = 60000
TABLES
INTERN = IT_EXCEL
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
LOOP AT IT_EXCEL.
ASSIGN COMPONENT IT_EXCEL-COL OF STRUCTURE
W_ovro TO <FS1>.
<FS1> = IT_EXCEL-VALUE.
AT END OF ROW.
MOVE-CORRESPONDING: Wib TO Iib.
APPEND w_ovro to I_ovro.
CLEAR W_ovro.
ENDAT.
ENDLOOP.
through bdc program update the data from internal table to bdc... -
Pls tell me how to upload from excel file to database.
hello,experts,
I want to upload data from excel local file to database table created by myself.when I use function
CALL FUNCTION 'GUI_DOWNLOAD'
the data in the internal table just become error code data that can not understand.
who can help me out?
thanks.Hi,
1st copy the values in XLS into internal table by using function Module:-
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = file_name<it is file path of u r XLS>
i_begin_col = 1
i_begin_row = 1
i_end_col = 250
i_end_row = 1
tables
intern = itab<this structure is same like u r database table>
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
if sy-subrc 0.
then modify or insert these values to database from internal table:-
modify <DB table> from itab accepting duplicate keys.
for file popup use :
at selection-scree on <screen field>.
call function 'F4_FILENAME'
exporting
program = sy-cprog
dynnr = sy-dynnr
importing
filename = zfilename.
here zfilename of type rlgrap-filename.
and pass this as path in ASLA_EXCEL_TO_INTERNAL_TABLE
Edited by: vijay Mekala on Dec 29, 2007 12:45 PM -
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 -
Oracle Projects - data upload from excell
Dear Experts,
Currently we are in the process of implementing oracle R12.1.3 . Consultants are in the stage of BRD requirement analysis.
Projects billing, costing, management and service contract.
Here as per our business requirement, we need to upload the excel - items which are having around 200+ items for every projects.(manual entry is not possible )
Now , we the client and the consultants are do not know how to do this.
Can you please explore the possibilities of excel sheet upload to projects
Required result is:
Upload data in projects costing, then data move to INV and all other rest flows.
ThanksIf an open interface/API is not available, you might want to take a look at DataLoad (dataload.com); if interface/API is available and you want to use Excel, a custom Web ADI integrator can be created.
-
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 -
Uploading data from Excel into data dictionary
Hi all,
I am new to ABAP. I have a huge excel spreadsheet and I want to develop some graphs and reports using ABAP ALVs. I want to know if I can import an excel spreadsheet into data dictionary, create a table and then develop an ALV report.
Plz let me know.
Thank you.
Krish.Refer to this sample code
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/36f08758-0a01-0010-c291-c03004aeb1af">Function Module To Upload Data From</a>
or
Use ALSM_EXCEL_TO_INTERNAL_TABLE function module to upload.
Example programs added
http://www.sapdevelopment.co.uk/file/file_upexcel.htm
excel upload program
UPLOADING FROM EXCEL TO Z TABLE
Regds
Manohar
Message was edited by: Manohar Reddy -
Getting short dumps while reading bulky data from excel sheet
Hi all,
We have converted our non-unicode based sap system (R/3 4.7, Windows 2003,
SQL 2000) into a unicode based system recently. We are facing two peculiar
problems for last few days.
*Problem 1 - *Whenever we want to upload the data from excel sheet, the
system throws a dump after reading about 400 entries, while last week the
same system used to read about 8000 entries in a single go.
*Problem 2 - *Also, whenever we realease a transport requst from development
containing a lot of changes, the request will reach the quality system but
without the changes. but if i ll try to import the changes into quality
system after generating more than one request containing small small
changes, they get reflected in QAS immediately. Is there any size
constraint in transporting a request fro DEV->QAS->PRD.
Please suggest some ways.
I am pasting the dump (that I am getting while data uploading from Excel).
~~~~~~~~~~~~~~~~~~
Runtime errors
MESSAGE_TYPE_X*
Occurred on
22.02.2008 at
13:21:02*
The current application triggered a termination with a short dump.
What happened?
The current application program detected a situation which really
should not occur. Therefore, a termination with a short dump was
triggered on purpose by the key word MESSAGE (type X).
What can you do?
Print out the error message (using the "Print" function)
and make a note of the actions and input that caused the
error.
To resolve the problem, contact your SAP system administrator.
You can use transaction ST22 (ABAP Dump Analysis) to view and administer
termination messages, especially those beyond their normal deletion
date.
Error analysis
Short text of error message:
Control Framework : Error processing control
Technical information about the message:
Diagnosis
An error occurred when the system tried to process the commands
from the Automation Queue on the presentation server.
There are several possible reasons for this:
- The installation of the SAP GUI on the presentation server is
faulty or obsolete.
- There is an error in the application program
- There is an error in the SAPGUI or an integrated control
Procedure
1. Make sure that you have imported the appropriate Support
Package, the current kernel, and GUI patch for the release of your
System
2. Check whether the error occurs locally on one or a few PCs, or
generally on all PCs. Note whether the error only occurs for some
users, for example because of a specific Customizing setting.
If it only occurs locally, this suggests an installation problem
with the PC. Check the installation; if necessary, reinstall the
software. In the dump, search for the SY-MSGLI field, since it may
point to the cause of the error.
3. Activate the Automation Trace (in accordance with SAP Note
158985).
4.Start the transaction and continue until the screen immediately
before the dump.
5. From the System -> Utilities menu, choose Autom. Queue,
Synchronous Processing.
The status bar of the GUI displays the text:
"Automation synchron flush mode on"
6. If you now proceed with the application, the short dump will
display the ABAP call that caused the error; the Automation Trace
will contain the error on the presentation server.
7. If necessary, load the short dump and trace files on to
sapservX, so that SAP can analyze them.
Message classe...... "CNDP"
Number.............. 006
Variable 1.......... " "
Variable 2.......... " "
Variable 3.......... " "
Variable 4.......... " "
Variable 3.......... " "
Variable 4.......... " "
How to correct the error
Probably the only way to eliminate the error is to correct the program.
You may able to find an interim solution to the problem
in the SAP note system. If you have access to the note system yourself,
use the following search criteria:
"MESSAGE_TYPE_X" C
"SAPLOLEA" or "LOLEAU02"
"AC_SYSTEM_FLUSH"
If you cannot solve the problem yourself, please send the
following documents to SAP:
1. A hard copy print describing the problem.
To obtain this, select the "Print" function on the current screen.
2. A suitable hardcopy prinout of the system log.
To obtain this, call the system log with Transaction SM21
and select the "Print" function to print out the relevant
part.
3. If the programs are your own programs or modified SAP programs,
supply the source code.
To do this, you can either use the "PRINT" command in the editor or
print the programs using the report RSINCL00.
4. Details regarding the conditions under which the error occurred
or which actions and input led to the error.
System environment
SAP Release.............. "620"
Application server....... "nhbho930"
Network address.......... "192.168.0.30"
Operating system......... "Windows NT"
Release.................. "5.2"
Hardware type............ "4x Intel 801586"
Character length......... 16 Bits
Pointer length........... 32 Bits
Work process number...... 0
Short dump setting....... "full"
Database server.......... "NHBHO930"
Database type............ "MSSQL"
Database name............ "DEV"
Database owner........... "dev"
Character set............ "C"
SAP kernel............... "640"
Created on............... "Aug 17 2007 00:18:58"
Created in............... "NT 5.0 2195 Service Pack 4 x86 MS VC++ 13.10"
Database version......... "SQL_Server_8.00 "
Patch level.............. "196"
Patch text............... " "
Supported environment....
Database................. "MSSQL 7.00.699 or higher, MSSQL 8.00.194"
SAP database version..... "640"
Operating system......... "Windows NT 5.0, Windows NT 5.1, Windows NT 5.2,
Windows NT 6.0"
User, transaction...
Client.............. 300
User................ "NHBABAP"
Language key........ "E"
Transaction......... "SE38 "
Program............. "SAPLOLEA"
Screen.............. "SAPMSDYP 0010"
Screen line......... 0
Information on where terminated
The termination occurred in the ABAP program "SAPLOLEA" in
"AC_SYSTEM_FLUSH".
The main program was "ZBDC_CONTRACT ".
The termination occurred in line 29 of the source code of the (Include)
program "LOLEAU02"
of the source code of program "LOLEAU02" (when calling the editor 290).
~~~~~~~~~~~~~~~~~~~~~
Thank you all.
Cheers.
Mitra __.____._for the 50 millionth time: Excel spreadsheets are NOT databases, you should NOT try to use them as such and NEVER access them using JDBC.
You should also under NO condition use the JDBC-ODBC bridge driver (that was actually the 78 millionth time that was told someone). -
Upload from Spreadsheet How To
All,
Josh Millinger, an Oracle SC in Reston, VA, has just completed a great How To document which outlines the steps required to create your own "upload from a spreadsheet" form in Oracle HTML DB.
Please take a look at his document, which can be found on our OTN Home Page: http://htmldb.oracle.com/otn
Thanks,
- Scott -Hi,
I know how to upload from excel to the database using Utilities. But i want to know how to upload data from an excel by browsing that excel from the application frontend. Say I have fiven a file browse option in one screen, through which i need to select a file and then if i say upload, it should get uploaded in the database and from there to the report..
Please guide me...
Regards,
Pallavi -
Loading data from excel to BPS layout
Hi,
I have BPS layouts in place and also excel sheets which are exact replica of those layouts.
I know 2 options to load excel data into the BPS. These are:
1) Copy and paste the data from excel to BPS layout.
2) Create a flat file in line format from excel and then use method explained in document "How to Load a Flat File into BW-BPS Using SAPGUI.pdf".
Is there any other way I can upload the same?
Any help in this regard will be highly appreciated.
thanks in advance.
regards,
PankajThanks to Vlad, Laurent & Srini for prompt replies.
But here the user needs to load data directly to the transactional cube.
So it is a case of "instead of keying in values" on to the BPS planning layout, user wants to upload the data from excel into the BPS layout.
Planning is done on SAP GUI and not web browser.
I am able to do the same using the document "How to Load a Flat File into BW-BPS Using SAPGUI".
But in this case the data needs to be converted into a simple csv file in line item format before it can be uploaded.
Is there any way, where we can upload from excel file without having it to change to csv format as required in "How to Load a Flat File into BW-BPS Using SAPGUI"?
thanks in advance.
regards,
Pankaj -
Creation of material from excel sheet
Hi All,
Can we create material by uploading from excel sheet.
I have created all necessary product categories in system.
I want to create 20 materials in one product category from excel sheet.
Abdul RaheemHi Abdul,
have you tried to import the data via Import Data (System Administration --> Import and Export Tools --> Import Data).
Also did you use the correct template; to access the correct template, please follow these steps:
Go to Import Data
Insert a dummy .xls file
From the dropdown list, choose Materials
On the next screen, download the template.csv file
Populate the fields as required on that spreadsheet
Repeat the import.
Hope this helps, if it solves your question, please mark this answer as solved.
Thanks,
Armin -
Upload to Excel option in Table maintenence View
Hello Gurus,
I have a Z table, for which we have created a table maintenence view generated and then we've attached a Z taransaction code to the same.
So if the user want, he can go to this transaction and add/edit/delete table entries right then and there.
But now the user wants a upload from excel utility/option from the same screen.
I have read somewhere on SDN that we can create custom routines and attach it to table maintenence generator, but i donno how to do it.
Can anyone please guide me or point me to some links...it would be very helpful.
Thanks in advance.
Cheers,
Tatvagna Shah.HI ALL,
Recently I faced the same issue, I had to upload 1300 records into the table using table maintenance, First I thought of wiritng a Z program, but realised that it is not acceptable to client, because if the table is uploaded in testing servor or production servor, we have to trasport the program,and this this will only increase no of programs in the produiction servor and this many of these one are required for one time only, because we may require to create table miantenace for many z tables has a whole for the complete project.
My suggestion is to upload the data from excel by pasting (if possible) or manually.
Please correct me if I am wrong.
Thanks,
Vengal Rao.
Maybe you are looking for
-
hi... my v3753au is wonderfully running on 32 bit win7. lately the bios cannot detect the internal dvdrom & kinda hard to detect (longer than usual) the internal hdd during startup. i've tried with the other dvdrom & it's still the same. however,
-
GoLive CS2 won't set background color
I have GoLive CS2 by way of investing in the whole CS2 package, so it wasn't a standalone installation. I have installed all of the recent updates. I go to Properties to set the background color. It sets it to "Black" in the HTML code, but it doesn't
-
1) If you run install_cluster in the latest S10(sparc) recommended set, the first time through it will install most of the patches. If you run it again, it will install another one (maybe two). How odd is that? 2) The main kernal patch 118833-36 won'
-
I bought today a new apple keyboard with wire. The old keyboard had a broken button, but the control keys f1-f12 all worked with both os mac or os both windows. Now I change the keyboard, but I do not work anymore keys f1-f12 under Windows XP, but th
-
No Batch Input for Screen 0300
Hello I am doing an inter-company asset transfer using ABT1(Call Transaction). However for few assets its giving me the error as 'No Batch input found for screen' '0300' even though the message type in MESSTAB table is 'S'.And one I run the pro