05-21-2009 1:20 PM
Hi ,
Iam using GUI_UPLOAD function module to upload file from desktop to the internal table .Iam using more than 1 rows of data in text TAB delimated file .But when iam using the function module , it always take first record from the file and put it into internal table.
************************************************************************
Start-of-selection
************************************************************************
START-OF-SELECTION.
IF p_ppath IS NOT INITIAL.
l_filenm = p_ppath.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_filenm
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = itab_item
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.
ENDIF.
Regards,
Sri
05-21-2009 1:24 PM
Hi ,
gui
whikle formating the table itab_item and moving into another internal table..
ignore the first line it contains header
loop at itab_item.
if sy-tabix > 1.
split and move into another internal table..
Endif.
endloop.
or pass...
"pass this field in exporting it will solve u r problem
HEADER_LENGTH = 1
Regards,
Prabhudas
Edited by: Prabhu Das on May 21, 2009 5:55 PM
05-21-2009 1:28 PM
Hi,
You can create a seperate work area in which you can populate the Table for the Data and then you can pass the same to the function module.
You need to loop the table. Example
Loop at itab into WA.
fill the data tab.
clear WA.
Endloop.
Hope this will help. Just fill the work area and the internal Table properly.
Thanks,
Samantak.
05-21-2009 1:34 PM
Hi Guys,
Iam dooing the same but iam still facing the problem .The code is as below
LOOP AT itab_item INTO wa_item.
MOVE-CORRESPONDING wa_item TO wa_final.
wa_final-zcre_date = sy-datum.
wa_final-zcre_by = sy-uname.
wa_final-zlast_chon = sy-datum.
wa_final-zlast_chby = sy-uname.
wa_final-d1= 'X'.
wa_final-d2 = 'X'.
wa_final-d3 = 'X'.
wa_final-d4 = 'X'.
wa_final-d5 = 'X'.
APPEND wa_final TO itab_final.
CLEAR: wa_item, wa_final.
Endloop.
Regards,
Sri
05-21-2009 1:38 PM
Try this code...
data : begin of itab_item occurs 0,
name(30),
address(30),
end of itab_item.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'c:\test.txt'
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = itab_item
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.
just take text file
Devolpment quality
production quality
05-21-2009 1:43 PM
05-21-2009 1:46 PM
Hi,
Can you debug your code and see what exactly is getting filled in the table that is being passed??
Hope that will tell you the true picture.
Thanks,
Samantak
05-21-2009 1:52 PM
can you able to show your declarations...
for me it is working fine.
please send your declarations data then we will with that structure only...
05-21-2009 1:54 PM
05-21-2009 2:03 PM
Hi Sekar,
Wether decleration is correct which i send ?
Regards,
Sri
05-21-2009 1:43 PM
Hi Sriram,
If you declared intenral table with header line then change data_tab under tables with body option.
TABLES
data_tab = itab_item[]
Otherwise, are you filling data in text file in a single row by tab delimited of entires records ?
Thanks,
Vinay
05-21-2009 1:56 PM
Hi ,
The decleration is as of below ,
TYPES: Begin of T_Record,
MANDT type MANDT,
ZITEM TYPE ZTEST_STAGING-ZITEM,
END OF ty_item.
Regards,
Sri
05-21-2009 2:05 PM
Look at this once...
Hope this clears your problem.
TYPES: Begin of ty_item,
MANDT type MANDT,
ZITEM TYPE ZTEST_STAGING-ZITEM,
END OF ty_item.
data : itab_item type standard table of ty_item.
************************************************************************
Start-of-selection
************************************************************************
START-OF-SELECTION.
IF p_ppath IS NOT INITIAL.
l_filenm = p_ppath.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_filenm
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = itab_item
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.
05-21-2009 2:25 PM
Hi ,
Still facing problem,
When iam chaning decleration of some other structure , it is working .But it is not working for my structure.
Regards,
Sri
05-21-2009 2:29 PM
05-21-2009 2:41 PM
Here is the code ,
TYPES: Begin of Ty_item,
MANDT type MANDT,
ZITEMrr TYPE Zdata-ZITEMrr,
ZMPNNtt TYPE Zdata-ZMPNNtt,
ZWERKSrr TYPE Zdata-ZWERKSrr,
ZCODErr TYPE Zdata-CODErr,
ZCODEgdg TYPE Zdata-ZCODEdg,
ZCODEdg1 TYPE Zdata-ZCODEdg1,
ZCODEdg TYPE Zdata-CODEdg,
ZNOdg TYPE Zdata-NOdg,
ZPERCENTdg TYPE Zdata-PERCENTdg,
ZACTIVEdg TYPE Zdata-activedg,
ZDATEdg TYPE SY-DATUM,
END OF Ty_item.
DATA: itab_item TYPE STANDARD TABLE OF ty_item INITIAL SIZE 0,
wa_item TYPE ty_item.
DATA: itab_final TYPE STANDARD TABLE OF ty_item INITIAL SIZE 0,
wa_final TYPE ty_item.
DATA: l_filenm TYPE string.
************************************************************************
Selection Screen
************************************************************************
PARAMETERS: p_ppath TYPE char128.
************************************************************************
At Selection screen on Value Request
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ppath.
PERFORM sub_get_filename CHANGING p_ppath.
************************************************************************
Start-of-selection
************************************************************************
START-OF-SELECTION.
IF p_ppath IS NOT INITIAL.
l_filenm = p_ppath.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_filenm
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = itab_item[]
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.
ENDIF.
LOOP AT itab_item INTO wa_item.
MOVE-CORRESPONDING wa_item TO wa_final.
.
APPEND wa_final TO itab_final.
CLEAR: wa_item, wa_final.
Endloop.
REFRESH itab_item.
IF NOT itab_final[] IS INITIAL.
MODIFY Zdata FROM TABLE itab_item.
COMMIT WORK.
ENDIF.
&----
*& Form sub_get_filename
&----
FORM sub_get_filename CHANGING p_file TYPE char128.
DATA : l_path TYPE string. " For Directory
DATA : l_path1 TYPE string. " For Directory
DATA : l_path2 TYPE string. " For Directory
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = sy-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = p_file.
05-22-2009 5:46 AM
Hi,
check ur declaration once as you have posted earlier as below,
TYPES: Begin of T_Record,
MANDT type MANDT,
ZITEM TYPE ZTEST_STAGING-ZITEM,
END OF ty_item.
The Begin of dosn't match with End of.
05-22-2009 6:18 AM
Hi Guys,
Fine now it is working.But header record (empty row ) is also updating into data base table .
Can any one tell me how can i skip this?
Regards,
Sri
05-26-2009 10:29 AM
Hi,
As you are clearing the work area dont think it will effect the database and seeing your code,
IF NOT itab_final[] IS INITIAL. MODIFY Zdata FROM TABLE itab_item. COMMIT WORK. ENDIF.
guess you should be using,
IF NOT itab_final[] IS INITIAL. MODIFY Zdata FROM TABLE itab_final. COMMIT WORK.ENDIF.
Thanks
Ramana
05-21-2009 2:02 PM
Hi,
Can you debug and check after calling functinal module,how many records are getting into internal table.
if only one record is getting fetched then, check the flat file, sometimes spaces in the flat file will make difference,in particular after the end of first record's last field value.
Thanks
Ramana
06-15-2009 8:18 AM
06-13-2019 2:40 PM
Hi,
I tried all your suggestions but it is not working. I am trying to upload an Excel sheet.
Thanks
Jean