‎2009 Feb 09 8:50 AM
Hi All,
I have a text file which contains few records delimited by tab.
I am trying to upload the contents of the file into an internal table using the FM GUI_UPLOAD
But, I am getting run time error 'Type conflict when calling a function module'.
The code that I had written is shown below.
Please let me know where I went wrong.
REPORT Z84364BDC .
TYPES : BEGIN OF ITAB_TP,
MATNR TYPE MARA-MATNR,
EAN11 TYPE MARA-EAN11,
END OF ITAB_TP.
DATA : FILE_ITAB TYPE STANDARD TABLE OF ITAB_TP.
DATA : ITAB_WA TYPE ITAB_TP.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-T01.
PARAMETERS : P_FILE TYPE RLGRAP-FILENAME DEFAULT 'D:\Example.txt'.
SELECTION-SCREEN END OF BLOCK B1.
***FILLING THE INTERNAL TABLE****
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = P_FILE
FILETYPE = 'ASC'
has_field_separator = ','
tables
data_tab = FILE_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.
‎2009 Feb 09 9:10 AM
Thanks one and all. Finally I got it.
But, there seems to be a problem in internal table.
My File contents are as below:
20,7000001
36,7255355
58,7252335
59,7250253
68,5235213
78,2533558
88,7285283
89,7250552
90,7253353
98,7022525
170,7225352
But, after running the above program the first field of internal table(file_itab-mara) is filled with all the above values.The second field has got nothing in it.
What could be the problem?
‎2009 Feb 09 8:52 AM
Hello,
Its because of
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = P_FILE "--> Should be type STRING
Suhas
‎2009 Feb 09 8:53 AM
Then,
Could you please tell me how do I select the file name from the Selection screen.
Can you give me an example please?
‎2009 Feb 09 8:55 AM
hi,
use it as parameter itself..
once after getting filename into p_file...
declare one variable of type string..i.e., v_file type string..
v_file = p_file.
in function gui_upload..
pass v_file..
Rgds.,
subash
‎2009 Feb 09 8:56 AM
Hello,
Try like this:
DATA: V_FILE TYPE STRING.
V_FILE = P_FILE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = V_FILE
BR,
Suhas
‎2009 Feb 09 9:12 AM
HI,
Using the F4 help option u can select the file name and path..
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
program_name = syst-repid
dynpro_number = syst-dynnr
field_name = ' '
CHANGING
file_name = p_file.
IF sy-subrc <> 0.
ENDIF.
hope this will help u.. use thsi one..
let me know if u face any more probs..
Regards
Vijay
‎2009 Feb 09 8:55 AM
Hi,
REPORT Z84364BDC .
TYPES : BEGIN OF ITAB_TP,
MATNR TYPE MARA-MATNR,
EAN11 TYPE MARA-EAN11,
END OF ITAB_TP.
DATA : FILE_ITAB TYPE STANDARD TABLE OF ITAB_TP.
DATA : ITAB_WA TYPE ITAB_TP.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-T01.
PARAMETERS : P_FILE TYPE RLGRAP-FILENAME DEFAULT 'D:\Example.txt'.
SELECTION-SCREEN END OF BLOCK B1.
DATA : g_file type string.
****FILLING THE INTERNAL TABLE*****
g_file = p_file
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = G_FILE " Change
FILETYPE = 'ASC'
has_field_separator = ','
tables
data_tab = FILE_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.If you are looking for F4 help..
at selection-screen on value-request for filename.
call method CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
exporting
MULTISELECTION = abap_false
FILE_FILTER = '*.slnk'
DEFAULT_EXTENSION = 'slnk'
changing
FILE_TABLE = retFileTable
rc = retRc
user_Action = retUserAction.
read table retFileTable into fileName index 1.Edited by: Avinash Kodarapu on Feb 9, 2009 2:25 PM
‎2009 Feb 09 8:55 AM
Hi,
the function module gui_upload, accepts the filename as a string variable....
hence do the following
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-T01.
PARAMETERS : P_FILE TYPE RLGRAP-FILENAME DEFAULT 'D:\Example.txt'.
SELECTION-SCREEN END OF BLOCK B1.
data : w_file type string.
w_file = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = W_FILE
FILETYPE = 'ASC'
has_field_separator = ','
tables
data_tab = FILE_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.
‎2009 Feb 09 8:56 AM
Hi,
'Type conflict when calling a function module'.
-
Which means the filename should be of type "string"
parameter: P_file type string default'D:....'
try this one.
Regards
Vijay
‎2009 Feb 09 8:57 AM
hi ..
take
parameters p_file type string default'.....'
regards
‎2009 Feb 09 9:01 AM
‎2009 Feb 09 9:01 AM
Hi,
While using variable which you will pass it to a FM, declare them according to the parameters of the FM.
If you check like that for gui_upload the file name is 'STRING' type.
w_file type string.
...
w_file = p_file.
"Now pass w_file to the FM
Regards,
Manoj Kumar P
‎2009 Feb 09 9:02 AM
Hi,
filename should be of type "string"
Declare like this
g_file type string.
Regards,
Jyothi CH.
Edited by: Jyothi Chinnabathuni on Feb 9, 2009 2:34 PM
Edited by: Jyothi Chinnabathuni on Feb 9, 2009 2:36 PM
‎2009 Feb 09 9:07 AM
Hi,
you need to maintain 'X' in has_field_seperator instead of ',' , y becoz it is tab delimited..
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'P_FILE'
FILETYPE = 'ASC'
has_field_separator = 'X' " File is TAB DELIMITED
tables
data_tab = FILE_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.
Regards
Kiran
Edited by: Kiran Saka on Feb 9, 2009 10:08 AM
‎2009 Feb 09 9:10 AM
Thanks one and all. Finally I got it.
But, there seems to be a problem in internal table.
My File contents are as below:
20,7000001
36,7255355
58,7252335
59,7250253
68,5235213
78,2533558
88,7285283
89,7250552
90,7253353
98,7022525
170,7225352
But, after running the above program the first field of internal table(file_itab-mara) is filled with all the above values.The second field has got nothing in it.
What could be the problem?
‎2009 Feb 09 9:12 AM
hi,
in function moudle...put field separator as...
has_field_separator = 'X' " File is TAB DELIMITED
rgds.,
subash
‎2009 Feb 09 9:14 AM
The file is delimited by Comma field as mentioned above.
Below is the code that I had written. But, I face the same problem
REPORT Z84364BDC .
TYPES : BEGIN OF ITAB_TP,
MATNR TYPE MARA-MATNR,
EAN11 TYPE MARA-EAN11,
END OF ITAB_TP.
DATA : FILE_ITAB TYPE STANDARD TABLE OF ITAB_TP.
DATA : ITAB_WA TYPE ITAB_TP.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-T01.
PARAMETERS : P_PATH TYPE RLGRAP-FILENAME DEFAULT 'D:\Example.txt'.
SELECTION-SCREEN END OF BLOCK B1.
DATA : P_FILE TYPE STRING.
P_FILE = P_PATH.
****FILLING THE INTERNAL TABLE*****
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = P_FILE
FILETYPE = 'ASC'
has_field_separator = 'X'
tables
data_tab = FILE_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.
***Displaying the Material*****
LOOP AT FILE_ITAB INTO ITAB_WA.
WRITE:/ ITAB_WA-MATNR.
ENDLOOP.
‎2009 Feb 09 9:20 AM
‎2009 Feb 09 9:25 AM
Hello Suhas,
Yes the contents of the file has been sepearated by ','.
Let me reiterate my requirement.
The file contents are shown below:
20,7000001
36,7255355
58,7252335
59,7250253
68,5235213
78,2533558
88,7285283
89,7250552
90,7253353
98,7022525
170,7225352
After executinng the program that I had mentioned, I wanted to display only the very first filed
So, the output should be as shown below
20
36
58
59
68
78
88
89
90
98
170
I dont know what went wrong. I could see the internal table's first field value as 20,7000001.
Please let me know the issue here. <<text removed>>
Edited by: Matt on Feb 10, 2009 5:07 PM
‎2009 Feb 09 9:26 AM
‎2009 Feb 09 9:28 AM
Hi,
please separate the contents of the file by tab, because to upload the file, the fields in them should either be separated by TAB or by SAPCE.
Please replace , with TAB and then use the upload it will work for sure...
Regards,
Siddarth
‎2009 Feb 09 9:30 AM
Thanks Suhas.That was helpful post.
I made the file delimited by tab and ran the program and I got the output what I wanted.
Thanks a lot for the help.
@ Sravanthi,
It works if you use TYPES. No Big deal
Edited by: Babu Kilari on Feb 9, 2009 3:00 PM
‎2009 Feb 09 9:13 AM
Hi,
You should write file type as string .
see the bellow example.
DATA : FILE_ITAB TYPE STANDARD TABLE OF ITAB_TP.
DATA : ITAB_WA TYPE ITAB_TP.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-T01.
PARAMETERS : P_FILE TYPE RLGRAP-FILENAME DEFAULT 'D:\Example.txt'.
SELECTION-SCREEN END OF BLOCK B1.
DATA : g_file type string.
***FILLING THE INTERNAL TABLE****
if p_file is not initial.
g_file = p_file
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = G_FILE " Change
FILETYPE = 'ASC'
has_field_separator = ','
tables
data_tab = FILE_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.
Thanks,
Rajendra
‎2009 Feb 09 9:15 AM
Hi,
its a common problem with this FM "GUI_IPLAOD" i.e type conflict while passing parameters. U just need declare a string variable like:
DATA: T_FILE type STRING.
and then before calling function Module "GUIOUpload" assign your parameter value to this string variable.
T_FILE = P_FILE.
and then call function module like :
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = T_FILE " ***** passing parameter should type string (T_FILE)**************
FILETYPE = 'ASC'
has_field_separator = ','
tables
data_tab = FILE_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
‎2009 Feb 09 9:17 AM
Hi,
Write like this
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = P_FILE
FILETYPE = 'ASC'
has_field_separator = 'X' "Tab delimited
Regards,
Jyothi CH,
‎2009 Feb 09 9:19 AM
Hi babu,
Donot use types...
DATA :
BEGIN OF ITAB_TP,
MATNR like MARA-MATNR,
EAN11 like MARA-EAN11,
END OF ITAB_TP.
DATA : FILE_ITAB TYPE STANDARD TABLE OF ITAB_TP.
DATA : ITAB_WA TYPE ITAB_TP.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-T01.
PARAMETERS : P_PATH TYPE RLGRAP-FILENAME DEFAULT 'D:\Example.txt'.
SELECTION-SCREEN END OF BLOCK B1.
DATA : P_FILE TYPE STRING.
P_FILE = P_PATH.
****FILLING THE INTERNAL TABLE*****
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = P_FILE
FILETYPE = 'ASC'
has_field_separator = 'X'
tables
data_tab = FILE_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.
***Displaying the Material*****
LOOP AT FILE_ITAB INTO ITAB_WA.
WRITE:/ ITAB_WA-MATNR.
ENDLOOP.
Regards,
Sravanthi