Application Development 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: 

runtime error

Former Member
0 Kudos

Hi ...

please look at this code it showing runtime error like this , Type conflict when calling a function module. please help me to correct this

REPORT ZPR_TEST01 line-size 500 message-id aod.

*DATA : BEGIN OF itab OCCURS 0.

  • INCLUDE STRUCTURE zporder.

*DATA : END OF itab.

*

data : BEGIN OF record,

ZSER_NO(15),

SLNO(15),

CUST(15) ,

MATNR(15),

WERKS(15) ,

PURNO(15) ,

ORDTYPE(15) ,

PODATE(15),

BILL(15) ,

PRICE(15) ,

MEINS(15) ,

QTY1(15) ,

QTY2(15) ,

QTY3(15) ,

END OF record.

TYPES wa_itab LIKE record OCCURS 0 .

DATA: itab TYPE wa_itab WITH HEADER LINE,

total type p .

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS: p_slno(50) TYPE c OBLIGATORY.

  • p as checkbox.

SELECTION-SCREEN END OF BLOCK b1.

data : file TYPE string.

  • CONCATENATE 'C:\BDC_UPLOAD_' p_slno INTO file.

  • CONCATENATE file '.txt' INTO file.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_slno.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

def_filename = 'C:\Order'

def_path = 'e:\'

mask = ',.,..'

mode = 'O'

title = 'OPEN'

IMPORTING

filename = file

EXCEPTIONS

inv_winsys = 1

no_batch = 2

selection_cancel = 3

selection_error = 4

OTHERS = 5.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = p_slno

filetype = 'txt'

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.

write : itab-zser_no.

endloop.

5 REPLIES 5

former_member491305
Active Contributor
0 Kudos

Hi,

Pass file variable into the FM GUI_UPLOAD in importin parameter.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

def_filename = 'C:\Order'

def_path = 'e:\'

mask = ',.,..'

mode = 'O'

title = 'OPEN'

IMPORTING

filename = file

EXCEPTIONS

inv_winsys = 1

no_batch = 2

selection_cancel = 3

selection_error = 4

OTHERS = 5.

Start-of-selection.

if file is not initial.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

<b>filename = file</b>

filetype = 'txt'

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.

Endif.

former_member189059
Active Contributor
0 Kudos

you are passing the wrong parameter to your function

pass the <b>file</b> parameter

Former Member
0 Kudos

Hi

Try like this

CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
def_filename = 'C:Order'
def_path = 'e:'
mask = ',*.*,*.*.'
mode = 'O'
title = 'OPEN'
IMPORTING
filename = file
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.



CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file
filetype = 'txt'
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. 

Reward all helpfull answers

Regards

Pavan

Former Member
0 Kudos

Problem might be internal table declaration,so try to use internal table properly then pass internal table to gui_upload

See the below code and try to make it as is :

REPORT zuploadtab .

PARAMETERS: p_infile LIKE rlgrap-filename

OBLIGATORY DEFAULT '/usr/sap/'..

*DATA: ld_file LIKE rlgrap-filename.

DATA: gd_file type string.

*Internal tabe to store upload data

TYPES: BEGIN OF t_record,

name1 LIKE pa0002-vorna,

name2 LIKE pa0002-name2,

age TYPE i,

END OF t_record.

DATA: it_record TYPE STANDARD TABLE OF t_record INITIAL SIZE 0,

wa_record TYPE t_record.

*Internal table to upload data into

DATA: BEGIN OF it_datatab OCCURS 0,

row(500) TYPE c,

END OF it_datatab.

*Text version of data table

TYPES: BEGIN OF t_uploadtxt,

name1(10) TYPE c,

name2(15) TYPE c,

age(5) TYPE c,

END OF t_uploadtxt.

DATA: wa_uploadtxt TYPE t_uploadtxt.

*String value to data in initially.

DATA: wa_string(255) TYPE c.

CONSTANTS: con_tab TYPE x VALUE '09'.

*If you have Unicode check active in program attributes then you will

*need to declare constants as follows:

*class cl_abap_char_utilities definition load.

*constants:

  • con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB.

************************************************************************

*AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_INFILE.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_infile.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

def_filename = p_infile

mask = ',*.txt.'

mode = 'O'

title = 'Upload File'(078)

IMPORTING

filename = p_infile

EXCEPTIONS

inv_winsys = 1

no_batch = 2

selection_cancel = 3

selection_error = 4

OTHERS = 5.

************************************************************************

*START-OF-SELECTION

START-OF-SELECTION.

gd_file = p_infile.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = gd_file

has_field_separator = 'X' "file is TAB delimited

TABLES

data_tab = it_record

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 NE 0.

write: 'Error ', sy-subrc, 'returned from GUI_UPLOAD FM'.

skip.

endif.

  • Alternative method, where by you split fields at each TAB after you

  • have returned the data. No point unless you dont have access to

  • GUI_UPLOAD but just included for information

*

  • CALL FUNCTION 'GUI_UPLOAD'

  • EXPORTING

  • filename = gd_file

  • filetype = 'ASC'

  • TABLES

  • data_tab = it_datatab "ITBL_IN_RECORD[]

  • EXCEPTIONS

  • file_open_error = 1

  • OTHERS = 2.

  • IF sy-subrc NE 0.

  • ELSE.

  • LOOP AT it_datatab.

  • CLEAR: wa_string, wa_uploadtxt.

  • wa_string = it_datatab.

  • SPLIT wa_string AT con_tab INTO wa_uploadtxt-name1

  • wa_uploadtxt-name2

  • wa_uploadtxt-age.

  • MOVE-CORRESPONDING wa_uploadtxt TO wa_record.

  • APPEND wa_record TO it_record.

  • ENDLOOP.

  • ENDIF.

************************************************************************

*END-OF-SELECTION

END-OF-SELECTION.

*!! Text data is now contained within the internal table IT_RECORD

  • Display report data for illustration purposes

LOOP AT it_record INTO wa_record.

WRITE:/ sy-vline,

(10) wa_record-name1, sy-vline,

(10) wa_record-name2, sy-vline,

(10) wa_record-age, sy-vline.

ENDLOOP.

Thanks

Seshu

rodrigo_paisante3
Active Contributor
0 Kudos

Ok, try this, its working fine now.

REPORT zpr_test01 LINE-SIZE 500 MESSAGE-ID aod.

*DATA : BEGIN OF itab OCCURS 0.

  • INCLUDE STRUCTURE zporder.

*DATA : END OF itab.

*

DATA : BEGIN OF record,

zser_no(15),

slno(15),

cust(15) ,

matnr(15),

werks(15) ,

purno(15) ,

ordtype(15) ,

podate(15),

bill(15) ,

price(15) ,

meins(15) ,

qty1(15) ,

qty2(15) ,

qty3(15) ,

END OF record.

TYPES wa_itab LIKE record OCCURS 0 .

DATA: itab TYPE wa_itab WITH HEADER LINE,

total TYPE p .

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS: p_slno(50) TYPE c OBLIGATORY.

  • p as checkbox.

SELECTION-SCREEN END OF BLOCK b1.

DATA : file TYPE string.

  • CONCATENATE 'C:\BDC_UPLOAD_' p_slno INTO file.

  • CONCATENATE file '.txt' INTO file.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_slno.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

def_filename = 'C:\Order'

def_path = 'e:\'

mask = ',.,..'

mode = 'O'

title = 'OPEN'

IMPORTING

filename = file

EXCEPTIONS

inv_winsys = 1

no_batch = 2

selection_cancel = 3

selection_error = 4

OTHERS = 5.

<b> p_slno = file.</b>

<b>START-OF-SELECTION.</b>

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

<b> filename = file</b>

<b> filetype = 'ASC'</b>"Not txt

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.

WRITE : itab-zser_no.

ENDLOOP.

Reward if useful!!

Regards

RP

Message was edited by:

RP