Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Runtime error while using GUI_UPLOAD

Former Member
0 Likes
3,079

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,512

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?

25 REPLIES 25
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,512

Hello,

Its because of

CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = P_FILE "--> Should be type STRING

Suhas

Read only

Former Member
0 Likes
2,512

Then,

Could you please tell me how do I select the file name from the Selection screen.

Can you give me an example please?

Read only

Former Member
0 Likes
2,512

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

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,512

Hello,

Try like this:


DATA: V_FILE TYPE STRING.

V_FILE = P_FILE.

CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = V_FILE

BR,

Suhas

Read only

Former Member
0 Likes
2,512

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

Read only

Former Member
0 Likes
2,512

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

Read only

Former Member
0 Likes
2,512

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.

Read only

Former Member
0 Likes
2,512

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

Read only

Former Member
0 Likes
2,512

hi ..

take

parameters p_file type string default'.....'

regards

Read only

Former Member
0 Likes
2,512

Hi Babu,

Declare P_FILE of TYPE STRING.

Regards,

Nitin.

Read only

Former Member
0 Likes
2,512

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

Read only

Former Member
0 Likes
2,512

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

Read only

Former Member
0 Likes
2,512

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

Read only

Former Member
0 Likes
2,514

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?

Read only

0 Likes
2,512

hi,

in function moudle...put field separator as...

has_field_separator = 'X' " File is TAB DELIMITED

rgds.,

subash

Read only

0 Likes
2,512

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.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,512

Hello Babu,

Are the contents of your file separated by ',' ?

That is why you are getting this type of data.

Plz see the following post for details: [Upload a comma separated text file frm presentation server|;

BR,

Suhas

Read only

0 Likes
2,512

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

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,512

Hello Babu,

Did you check the post i referred ?

BR,

Suhas

Read only

0 Likes
2,512

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

Read only

0 Likes
2,512

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

Read only

Former Member
0 Likes
2,512

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

Read only

Former Member
0 Likes
2,512

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

Read only

Former Member
0 Likes
2,512

Hi,

Write like this

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = P_FILE

FILETYPE = 'ASC'

has_field_separator = 'X' "Tab delimited

Regards,

Jyothi CH,

Read only

Former Member
0 Likes
2,512

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