Steps to upload budgeted excel through KPF6
Hi
Can any one please tell me step by step process to upload budgeted values through Tcode KPF6.
Do we need to create any template before executing this or we can do with standard templates?
Format we are trying to upload is
<b>Internal order number- cost element-- periods
XXXX XXXX 1 to 12</b>
Is there any difference between planned upaload or budgeted upload procedure?
regards
Hinfi
Hi
I am thinking of trying standard template it self similar to KP06.There is step by step document for KP06 where it takes directly to macro enables excel where we fill the values and upload.
I am trying to find that procedure if works for KPF6.Our data is simple format and not complex.
Can I please get detailed steps in case if I want to try with standard.
regards
Hinfi
Similar Messages
-
To upload a excel file to dB table through webdynpro ABAP
HI,
I am unable to upload a excel file directly by using func module "HR_KR_XSTRING_TO_STRING".
If file is in tab delimited then only, I am able to upload.
Suggest me if there are any other options to upload a excel file.Hi,
The below link gives you an explanation of how you can upload an excel file to web dynpro.
http://www.****************/Tutorials/WebDynproABAP/Upload/Page1.htm
Kindly read go through the below link, as this issue have been brought up before
http://forums.sdn.sap.com/thread.jspa?threadID=1831838
Thanks and regards.
Edited by: Suraj Ravindran Nair on Feb 24, 2012 6:24 AM -
Upload the excel file in oracle db through oracle forms
Hi all,
I want to upload the excel file in oracle db through oracle forms...I am new to oracle forms .
I have searched a lot but not getting exact solution
Is there anyone who will help me out with this .....
Any help will be appriciatedI'm trying to move data from excel into an Oracle forms field. This involves coping 2 columns of data cells in excel and pasting it into an Oracle forms field. I can get the date pasted into the Oracle forms field but there is a invisible character that separates the 2 columns of data coming from Excel. I do not know what this character is but it is causing the error 'Line 1 is invalid. Check forms'.
Any ideas how to get pass this?
Thank you -
Upload the Excel shet through BPM
Hi,
I have a kind of functionality that client user can upload a excel sheet and create the instance based on the excel sheet records. So from the JSP side I am uploading the file and I have given the file type as a BINARY, then I am able to check the file. Length(). But if I am using Java.Io.File or Fueog.Io.File then this value is assigned to NULL
So I have done coding like this.
Binary io = adhocCreation.attachment;
logMessage("file length is = " + Binary(data : io).length());
ByteArrayInputStream bis = ByteArrayInputStream(arg1 : io);
logMessage("bis is = " + bis);
InputStream s = bis;
FileOutputStream outStream = FileOutputStream(arg1 : Fuego.Server.homeDir + "check.xls");
outStream.write(arg1 : io);
outStream.flush();
logMessage("outStream is = " + outStream);
ExternalClasses.Jxl.Write.WritableWorkbook workBook = Workbook.createWorkbook(os : outStream);
logMessage("numberOfSheets are " + workBook.numberOfSheets);
ExternalClasses.Jxl.Write.WritableSheet writableSheet = workBook.getSheet(arg1 : 0);
logMessage("writableSheet = " + writableSheet);
Cell[] cells = writableSheet.getRow(arg1 : 0);
if (cells != null || cells.length() == 0) {
logMessage("result2 = " + cells[0].contents);
And getting the output like this:
file length is = 30208
bis is = java.io.ByteArrayInputStream@35834c
outStream is = java.io.FileOutputStream@13efefe
numberOfSheets are 0
but what ever the file I am uploading that is having 3 sheets on excel sheet
any idea why it is not able to read that.
Thanks
Brijesh Kumar SinghI'm trying to move data from excel into an Oracle forms field. This involves coping 2 columns of data cells in excel and pasting it into an Oracle forms field. I can get the date pasted into the Oracle forms field but there is a invisible character that separates the 2 columns of data coming from Excel. I do not know what this character is but it is causing the error 'Line 1 is invalid. Check forms'.
Any ideas how to get pass this?
Thank you -
How to Upload the excel flat file in LSMW
Hi all,
Can any one plz Help me,
How to Upload a excel file format by suing the lsmw .
Regadrs.
[email protected]
Upender..
Edited by: Upender Reddy on Sep 12, 2008 8:37 AMHi,
In 7 th step of LSMW we need to specify the file ie flat file.
In this step you describe all files to be used in the following steps:
· Your legacy data on the PC and/or R/3 server
· The file for the read data
· The file for the converted data.
As your legacy data is on the PC: ie your excel file that is tab delimited or comma delimited.
here give ur file name, description , click data from one src structure, then delimiter is tabulator if so, in file structure click both check boxes if in ur flat file ur first row is column, file type is record end indicator, code page ASCII and conitnue that's it.
you can go through this link very useful :
****************/Tutorials/LSMW/LSMWMainPage.htm.
thanx. -
Standard program for uploading budget values in expenses
Hi Experts,
can u please tell me the standard program to upload budget values in Expenses
thanks & regards..
NarendraHi,
This is a sample program to upload through excel sheet.
Check this code to upload vendor master through SHDB transaction.
report ZVEND_MST no standard page heading line-size
255.
*include bdcrecx1.
*parameters: dataset(132) lower case default
'c:\vend.mst'.
DO NOT CHANGE - the generated data section - DO
NOT CHANGE ***
If it is nessesary to change the data section use
the rules:
1.) Each definition of a field exists of two lines
2.) The first line shows exactly the comment
'* data element: ' followed with the data
element
which describes the field.
If you don't have a data element use the
comment without a data element name
3.) The second line shows the fieldname of the
structure, the fieldname must consist of
a fieldname and optional the character '_' and
three numbers and the field length in brackets
4.) Each field must be type C.
Generated data section with specific formatting -
DO NOT CHANGE ***
data: begin of record,
data element: LIF16
LIFNR_001(016),
data element: BUKRS
BUKRS_002(004),
data element: EKORG
EKORG_003(004),
data element: KTOKK
KTOKK_004(004),
data element: NAME1_GP
NAME1_005(035),
data element: SORTL
SORTL_006(010),
data element: LAND1_GP
LAND1_007(003),
data element: SPRAS
SPRAS_008(002),
data element: BSTWA
WAERS_009(005),
end of record.
End generated data section ***
DATA : ITAB TABLE OF RECORD WITH HEADER LINE.
start-of-selection.
*perform open_dataset using dataset.
*perform open_group.
*do.
*read dataset dataset into record.
*if sy-subrc <> 0. exit. endif.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:\VENDOR.TXT'
"TEXT FILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = ITAB
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT ITAB.
*In Loop Change Record With ITAB
like record-lifnr_001 with itab-lifnr_001
perform bdc_dynpro using 'SAPMF02K' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RF02K-KTOKK'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02K-LIFNR'
record-LIFNR_001.
perform bdc_field using 'RF02K-BUKRS'
record-BUKRS_002.
perform bdc_field using 'RF02K-EKORG'
record-EKORG_003.
perform bdc_field using 'RF02K-KTOKK'
record-KTOKK_004.
perform bdc_dynpro using 'SAPMF02K' '0110'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-SPRAS'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFA1-NAME1'
record-NAME1_005.
perform bdc_field using 'LFA1-SORTL'
record-SORTL_006.
perform bdc_field using 'LFA1-LAND1'
record-LAND1_007.
perform bdc_field using 'LFA1-SPRAS'
record-SPRAS_008.
perform bdc_dynpro using 'SAPMF02K' '0120'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-KUNNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-BANKS(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPMF02K' '0210'.
perform bdc_field using 'BDC_CURSOR'
'LFB1-AKONT'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0215'.
perform bdc_field using 'BDC_CURSOR'
'LFB1-ZTERM'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0220'.
perform bdc_field using 'BDC_CURSOR'
'LFB5-MAHNA'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0310'.
perform bdc_field using 'BDC_CURSOR'
'LFM1-WAERS'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFM1-WAERS'
record-WAERS_009.
perform bdc_dynpro using 'SAPMF02K' '0320'.
perform bdc_field using 'BDC_CURSOR'
'RF02K-LIFNR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_transaction using 'XK01'.
endLOOP..
Check It, Activate it and process in SM35. -
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 -
Upload and Download through the same button toolbar Spreadsheet
Hello,
Does anyone know if I can set up the two processes: Uploading and downloading Data Inside the Excel toolbar?
Web ADI defines the Oracle tap where the Upload and Download options are. Where Web ADI defines the Oracle tap?
Can I modify that menu and unify in the same button the upload and download processes.
My client wants to see the refreshed data inside Oracle without pushing Uploading Data and pushing again Downloading Data.
Thanks in advance,
Carmen.Duplicate as this thread:
Upload and Download through same Excel Sheet
//Nitin -
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. -
How to Upload Budget in KP06 ?
Hi All,
I want to Upload Budget from Excel to KP06.
The Budget is Suppose to be Uploaded both Cost Center and Cost Element wise.
As m doing it for the 1st time Pls help.
Question : -
How Can i Upload Budget Directly From my Excel File to SAP though KP06 or any other T-code ?
Thks & Regards,
Vishal ShahThe procedure to upload datas is simple on condition you made appropriate settings before:
- first define a specific layout by copying a standard one via KP65 Tcode
- second, assign the new layout to the planning profile via Controlling > Cost Center Accounting > Planning > Manual Planning > Define User-Defined Planner Profiles
In the assignment of the layout you define the layout with the box "integrated excel" marked. You just have to navigate to layouts for controlling.
-thirdly you define default parameters of the layout: there you have to select a generic name for the files you will import. As an example if you define the file name like " planning* ", the future files will be named " "planning2008", or "planning2009"....
save : the structure of the xls file on your desk, save the settings
- then you make your planning in your excel sheet. Save it in a ".txt" format and don't forget to suppress the last line of the file: the line "total" can't be readen by the system.
- return to KP06 Tcode, choose the right layout : go to extra > excel planning > upload, select the "planning.txt" file and execute.
I think you have the elements to succeed.
thanks for reawarding points
Pascal Cuenin -
Please send detail steps for uploading legacy data
Hi friends,
please send detail steps for uploading legacy data
Thanking u in advance,
Diwa.HI U CAN USE LSMW TO UPLOAD LEGACY DATA
LSMW is used for migrating data from a legacy system to SAP system, or from one SAP system to another.
Apart from standard batch/direct input and recordings, BAPI and IDocs are available as additional import methods for processing the legacy data.
The LSMW comprises the following main steps:
Read data (legacy data in spreadsheet tables and/or sequential files).
Convert data (from the source into the target format).
Import data (to the database used by the R/3 application.
But, before these steps, you need to perform following steps :
Define source structure : structure of data in the source file.
Define target structure : structure of SAP that receives data.
Field mapping: Mapping between the source and target structure with conversions, if any.
Specify file: location of the source file
Of all the methods used for data migration like BDC, LSMW , Call Transaction which one is used most of the time?
How is the decision made which method should be followed? What is the procedure followed for this analysis?
All the 3 methods are used to migrate data. Selection of these methods depends on the scenario, amount of data need to transfer. LSMW is a ready tool provided by SAP and you have to follow some 17 steps to migrate master data. While in BDCs Session method is the better choice because of some advantages over call transaction. But call transaction is also very useful to do immediate updation of small amout of data. (In call transaction developer has to handle errors).
SO Bottom line is make choice of these methods based of real time requirements.
These methods are chosen completely based on situation you are in. Direct input method is not available for all scenario, else, they are the simplest ones. In batch input method ,you need to do recording for the transaction concerned. Similarly, IDoc, and BAPI are there, and use of these need to be decided based on the requirement.
Try to go through the some material on these four methods, and implement them. You will then have a fair idea about when to use which.
LSMW Steps For Data Migration
How to develop a lsmw for data migration for va01 or xk01 transaction?
You can create lsmw for data migration as follows (using session method):
Example for xk01 (create vendor)
Initially there will be 20 steps but after processing 1 step it will reduced to 14 for session method.
1. 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 -
Budget Control through User status
Dear all,
I am implementing the budget process through user status as follows
step1 User has to do the Cost planning first, So that time system does not allow to do direct budget allocation through cj30 and stop all the process like Release,PR,PO,GRN FI posting.
Step 2 approval of cost planning by HOD from this process only system allow the budget allocation.
step 3 budget approval by GM, So afer the approval of budget system should allow PR process.
Step 4 Budget Release by MD throuch CJ32 and set the user status budget released,After this status system system should allow all the process like Release,PO,GRN,MIRO,FI posting.
I did all the required configration as per requirement for above process in WBS user status, But my problem is that if suppose MD set the user status Budget released without doing the budget release through cj32 then system allowing all the process because my AVAC is not activited.
Please provide me the solution
thanks
abhijeetyou need to check you budget profile your availability control should get checked against Release budget mostly for overall release ( A/c to your scenario ) . So when you does CJ32 and give budget at that time AVAC status will be on WBS and if you giving less budget in CJ32 system will not allow your approver ( MD ) to save transaction.
Ind. 'Overall' Ind. 'Releases' Avail. control against ...
X X Overall budget released
Make setting shown as below in your budget profile with activation type 1 .
With Regards
Nitin P. -
Export data to Excel through a ABAP program run in batch mode
Dear Experts,
The requirement is that a ABAP report should run through background job, which will do the followiing :
1) Collect data from predifined CRM tables ( Activity , Order for example ).
2) Create a Excel file in a Application Server ( physical file server location ) location.
3) Push the data collected in the step 1 to the Excel file.
I have found 2 function modules which does the export to Excel after creating the Excel file. They are :
a) XXL_FULL_API
b) MS_EXCEL_OLE_STANDARD_DAT
But it seems that the ABAP report needs to run in the foreground ( correct me if i am wrong ) in order to create the Excel file.
Please can anyone suggest a possible ABAP code to achieve OR how to use these FMs in background mode ?
The excel creation needs to be automated and send to a administrator email id every day, so the need of exporting the data in background mode arises.
Thanks and regards,
Sudiptahi,
In SM36, you can create a job(give your report prog name)..
call the fun. module by storing all the values into final int. table it_data.
but u need to open one excel file in your desktop...
v_file = 'C:\file.xls'. " path should be like this...
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = v_file
filetype = 'xls'
has_field_separator = 'X'
HEADER_LENGTH = 0
read_by_line = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
IMPORTING
FILELENGTH =
HEADER =
TABLES
data_tab = it_data
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
regards
vijay -
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 an excel file to table data
Hi ,
I could succesfully develope an application for uploading an excel file and displaying the data in tabular format (i.e through table display ) . But on Action <<Export TO Table>> it is not showing the details in tabular format . After uploadinfg file it is providing successful msg but when i m clicking on Export to table it is not displaying table data .
Its a demo WD program in java given below
Could anybody please guide me in this approach ?
public void onActionUploadFileData(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
InputStream text = null;
int temp = 0 ;
String path ;
try
File file = new File(wdContext.currentContextElement().getResource().getResourceName().toString());
FileOutputStream output = new FileOutputStream(file);
if (wdContext.currentContextElement().getResource()!= null )
text = wdContext.currentContextElement().getResource().read(false);
while ((temp=text.read())!= -1)
output.write(temp);
output.flush();
output.close();
path = file.getAbsolutePath();
wdComponentAPI.getMessageManager().reportSuccess(path);
catch (Exception ex)
ex.printStackTrace();
public void onActionExport_To_Table(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
//@@begin onActionExport_To_Table(ServerEvent)
try {
Workbook workbook = Workbook.getWorkbook(new File(path));
Sheet sheet = workbook.getSheet(0);
int columns = sheet.getColumns();
int rows = sheet.getRows();
int i=0;
int j;
for (j=1;j<=rows;j++)
element = wdContext.nodeTableData().createTableDataElement();
Cell cell1 = sheet.getCell(i,j);
element.setEmpId(cell1.getContents());
Cell cell2 = sheet.getCell(i+1,j);
element.setFirstname(cell2.getContents());
Cell cell3 = sheet.getCell(i+2,j);
element.setLastname(cell3.getContents());
wdContext.nodeTableData().addElement(element);
catch (Exception ex)
ex.printStackTrace();
Edited by: Trina_Saheli on Feb 26, 2010 4:22 PMHi Trina,
Check onAction method(onActionExporttotable) of "Export to Table ". Print the c1.getContents(), c2.getContents,c3.getContents value with MessageManager while setting vaule to node attribute.
Once the all the attribute added to node TableData, print the table attribute in onActionExporttotable method itself.
Also check the TableData node properties which is bind to table of displaying in the screen.
Hopt it helps
Regards,
Arun
Maybe you are looking for
-
How can two iPads be synced ?
-
XSLT-Mapping Exception: Prefix not mapped:
Hi all, I try to make a mapping using XSLT and get the exception: Prefix not mapped: ns0. I wrote a simple xslt-script: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="h
-
ITunes sync hangs only when syncing photos to Apple TV
I just got an Apple TV, and updated it to the last software v2.4; iTunes is also running latest v 9x. I have a large library and the first sync took a long time but it got done successfully. But when I select images I want to sync in the 'photos' tab
-
HEY NEED SOME HELP I GOT A SANDISK AND IT CAME WITH A 3 MONTH FREE ADOBE PHOTOSHOP CC AND LIGHTROOM
NEED HELP
-
Why some extra XML tags are created when viewed a XML in Adobe Illustrator with Esko plugin?
We see some extra XML tags are created when viewing a XML in Adobe Illustrator with Esko plugin. Why these extra lines are created ? Screenshot of XML and XML viewed in AI below(the extra XML tags outlined in red):