10-19-2007 4:12 AM
Hi,
My requirement is to upload the data from excel file to ztable(zrb_hdr).In the internal table(t_zrb_hdr) i have changed the data types of date,time and currency fields to char type.I have used fm 'ALSM_EXCEL_TO_INTERNAL_TABLE' to read the excel file.To upload the data to ztable i haveused insert zrb_hdr from table t_zrb_hdr.But here zrb_hdr and t_zrb_hdr don't have the same structure.so it is giving error.Now how can I upload data to ztable?
Regards,
Hema
10-19-2007 4:13 AM
Hi,
Declare the internal table t_zrb_hdr as the structure ZRB_HDR.
Thanks
Naren
10-19-2007 4:15 AM
Hi Hema,
Both structures should be same if you want to upload using internal table.
Regards,
Atish
10-19-2007 4:17 AM
HI Hema ,
When you upload from the internal table, both the table structures should be the same.
Reward if Useful.
Regards,
Chitra
10-19-2007 4:23 AM
Hi,
IF i don't change the crrency field to char type i am getting dump error as 'unable to interpret 146,51 as a number'.In this case what can i do?
10-19-2007 4:25 AM
Hi Hema,
Define two internal tables. One for uploading data from excel sheet and other of type DB table which will be used to move data to the DB table.
Regards,
Atish
10-19-2007 4:54 AM
Hi,
I have declared the new internal table and moved all the contents of old internal table to new internal table.Even then at the currency field it is giving dump error as 'unable to interpret '146,51' as number'
10-19-2007 4:25 AM
Hi,
Remove the , in the character field and then move it to the currency field..
TRANSLATE v_char USING ', '.
This will remove the , in the character string..
Thanks,
Naren
10-19-2007 4:38 AM
hi,
use modify statemnt,
check this code
This program uploads material number from excel sheet and does
******modifications to material number if required by the user
******and updates the table zmatnr with new material against the old material number
*************************************************************************
TYPE-POOLS truxs.
TABLES:zmatnr.
DATA : itab LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.
DATA row LIKE alsmex_tabline-row.
data : g_matnr like mara-matnr.
data : count type i.
data : itab_count type i.
data : gi_final like zmatnr occurs 0 with header line.
*data : begin of gi_final occurs 0,
mat_old like mara-matnr,
mat_new like mara-matnr,
end of gi_final.
***********************Selection Screen*************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETER : pfname LIKE rlgrap-filename OBLIGATORY.
select-options : records for count.
SELECTION-SCREEN END OF BLOCK b1.
*******************************************************************
*********************At Selection Screen*************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pfname.
PERFORM search.
*******************************************************************
START-OF-SELECTION.
perform process.
form process.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = pfname
i_begin_col = 1
i_begin_row = 2
i_end_col = 12
i_end_row = 65000
TABLES
intern = itab
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.
describe table itab lines itab_count.
row = 1.
loop at itab.
if itab-row <> row.
append gi_final.
clear gi_final.
endif.
case itab-col.
when '1'.
CLEAR G_MATNR.
gi_final-OLD_MATNR = itab-value.
CONCATENATE 'NEW' gi_final-old_matnr INTO itab-value.
gi_final-new_MATNR = itab-value.
endcase.
row = itab-row.
endloop.
append gi_final.
clear gi_final.
CALL FUNCTION 'PROGRESS_INDICATOR'
EXPORTING
I_TEXT = 'File Has Been Successfully Uploaded from Workstation ' .
if not gi_final[] is initial.
if not records-low is initial .
if not records-high is initial.
records-high = records-high + 1.
DESCRIBE TABLE gi_final LINES count.
IF records-high < count.
DELETE gi_final FROM records-high TO count.
ENDIF.
IF records-low <> 1.
IF records-low <> 0.
DELETE gi_final FROM 1 TO records-low.
ENDIF.
ENDIF.
endif.
endif.
endif.
IF NOT GI_FINAL[] IS INITIAL.
CALL FUNCTION 'PROGRESS_INDICATOR'
EXPORTING
I_TEXT = 'Processing zmatnr table'
I_OUTPUT_IMMEDIATELY = 'X'.
if itab_count <> count.
*
message i000 with 'records are not matching'.
*
exit.
*
else.
modify zmatnr from table gi_final.
message i000 with 'data base table modified successfully'.
endif.
endif.
endform.
&----
*& Form search
&----
text
----
--> p1 text
<-- p2 text
----
FORM search .
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
static = 'X'
CHANGING
file_name = pfname.
ENDFORM. " search
regards
siva
10-19-2007 4:55 AM
Hi,
Please check my reply..You have to remove , from the character field and assign to the currency field..You can TRANSLATE for removing ,
Thanks
Naren