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: 

upload

Former Member
0 Kudos

Hi.

in my upload program its giving runtime error , its showing this message. conflict when calling a function module.

please help me . how to solve this , please give me code for upload .

1 ACCEPTED SOLUTION

Former Member
0 Kudos

GUI_UPLOAD

p_file is ur input parameter for File.

types:

begin of ty_text,

rec(1000) type c,

end of ty_text.

data:

t_text type STANDARD TABLE OF ty_text initial size 0.

PARAMETERS:P_FILE LIKE RLGRAP-FILENAME ,

data l_file type string.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

PERFORM get_file_from_present_server.

Start-of-selection.

Perform upload_file.

FORM get_file_from_present_server .

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

program_name = sy-repid

dynpro_number = sy-dynnr

CHANGING

file_name = P_FILE

EXCEPTIONS

mask_too_long = 1

OTHERS = 2.

ENDFORM. " get_file_from_present_server

Form upload_file.

CLEAR: l_file.

l_file = P_FILE.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = L_FILE

filetype = 'ASC'

  • HAS_FIELD_SEPARATOR = ','

TABLES

data_tab = t_text

EXCEPTIONS

file_open_error = 1

file_read_error = 2

header_too_long = 11

disk_full = 15

dp_timeout = 16

OTHERS = 17.

IF sy-subrc <> 0.

WRITE: / text-006, l_file , sy-subrc.

ENDIF.

Endform.

9 REPLIES 9

Former Member
0 Kudos

Hi prajwal,

place your code. Then we can help you out.

Regards

Azad.

former_member181962
Active Contributor
0 Kudos

Check the declaration of the parameter being passed to the FM against the type of the parameter in the Function MOdule.

Both should be the same.

Regards,

Ravi

0 Kudos

this is my code

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 ITAB OCCURS 0,

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 ITAB.

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 = 'ASC'

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.

Former Member
0 Kudos

hi,

check the sample code

INCLUDE Z_CUSTOMER_BDC_R02.

*-----AT SELECTION-SCREEN

AT SELECTION-SCREEN.

IF SY-UCOMM = 'ONLI'.

*-----group and user must be filled to create a session

IF SESSION = 'X' AND

GROUP = SPACE OR USER = SPACE.

MESSAGE E613(MS).

ENDIF.

*----Presentation File name should be entered

IF SESSION = 'X' AND RB_PRE = 'X'

AND P_FILE = '' .

MESSAGE E004(ZROJA).

ELSEIF CTU = 'X' AND RB_PRE = 'X'

AND P_FILE = '' .

MESSAGE E004(ZROJA).

ENDIF.

*----Application File name should be entered

IF SESSION = 'X' AND RB_APP = 'X'

AND P_FILE_A = '' .

MESSAGE E004(ZROJA).

ELSEIF CTU = 'X' AND RB_APP = 'X'

AND P_FILE_A = '' .

MESSAGE E004(ZROJA).

ENDIF.

ENDIF.

*-----AT SELECTION-SCREEN OUTPUT

AT SELECTION-SCREEN OUTPUT.

*----When file from Presentation server is selected

IF RB_PRE = 'X'.

*----To make the application server inactive

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'AAA'.

SCREEN-ACTIVE = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ELSE.

*----When file from Presentation server is selected

RB_APP = 'X'.

*----To make the application server inactive

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'BBB'.

SCREEN-ACTIVE = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

*

*-----AT SELECTION-SCREEN ON VALUE-REQUEST

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE_A.

CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'

EXPORTING

I_LOCATION_FLAG = 'A'

I_SERVER = ' '

FILEOPERATION = 'R'

IMPORTING

O_PATH = P_FILE_A

EXCEPTIONS

RFC_ERROR = 1

ERROR_WITH_GUI = 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.

*-----AT SELECTION-SCREEN ON VALUE-REQUEST

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

*-----Function module for value-request

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

FIELD_NAME = ' '

IMPORTING

FILE_NAME = V_FILE_NAME.

*----Assigning the flatfile to parameter

P_FILE = V_FILE_NAME.

*-----START-OF-SELECTION

START-OF-SELECTION.

DATA: FILENAME TYPE STRING.

*----When file from Presentation Server is selected

IF RB_PRE = 'X'.

FILENAME = P_FILE.

*-----Function module to upload data from the presentation server

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = FILENAME

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = IT_KNA1

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.

ELSE.

*----Upload the File from Application Server

OPEN DATASET P_FILE_A FOR INPUT IN TEXT MODE ENCODING DEFAULT.

*-----to display an error if the file is not in application server

IF SY-SUBRC NE 0.

MESSAGE E006(ZROJA).

ELSE.

DO.

READ DATASET P_FILE_A INTO X_KNA1.

IF SY-SUBRC EQ 0.

APPEND X_KNA1 TO IT_KNA1.

ELSE.

EXIT.

ENDIF.

ENDDO.

ENDIF.

CLOSE DATASET P_FILE_A.

ENDIF.

*-----To open a batchinput session

IF SESSION = 'X'.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

CLIENT = SY-MANDT

GROUP = GROUP

KEEP = KEEP

USER = USER

PROG = SY-CPROG

EXCEPTIONS

CLIENT_INVALID = 1

DESTINATION_INVALID = 2

GROUP_INVALID = 3

GROUP_IS_LOCKED = 4

INTERNAL_ERROR = 6

QUEUE_ERROR = 7

RUNNING = 8

SYSTEM_LOCK_ERROR = 9

USER_INVALID = 10

OTHERS = 11.

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.

*-----Filling the BDCDATA using the Internal Table

LOOP AT IT_KNA1 INTO X_KNA1.

PERFORM BDC_DYNPRO USING 'SAPMF02D' '0100'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'RF02D-KTOKD'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_FIELD USING 'RF02D-KUNNR'

X_KNA1-KUNNR.

PERFORM BDC_FIELD USING 'RF02D-KTOKD'

X_KNA1-KTOKD.

PERFORM BDC_DYNPRO USING 'SAPMF02D' '0110'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'KNA1-SPRAS'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_FIELD USING 'KNA1-NAME1'

X_KNA1-NAME1.

PERFORM BDC_FIELD USING 'KNA1-SORTL'

X_KNA1-SORTL.

PERFORM BDC_FIELD USING 'KNA1-ORT01'

X_KNA1-ORT01.

PERFORM BDC_FIELD USING 'KNA1-PSTLZ'

X_KNA1-PSTLZ.

PERFORM BDC_FIELD USING 'KNA1-LAND1'

X_KNA1-LAND1.

PERFORM BDC_FIELD USING 'KNA1-SPRAS'

X_KNA1-SPRAS.

PERFORM BDC_DYNPRO USING 'SAPMF02D' '0120'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'KNA1-LZONE'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_FIELD USING 'KNA1-LZONE'

X_KNA1-LZONE.

PERFORM BDC_DYNPRO USING 'SAPMF02D' '0125'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'KNA1-NIELS'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_DYNPRO USING 'SAPMF02D' '0130'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'KNBK-BANKS(01)'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=ENTR'.

PERFORM BDC_DYNPRO USING 'SAPMF02D' '0340'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'RF02D-KUNNR'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=ENTR'.

PERFORM BDC_DYNPRO USING 'SAPMF02D' '0370'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'RF02D-KUNNR'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=ENTR'.

PERFORM BDC_FIELD USING 'KNA1-CIVVE'

'X'.

PERFORM BDC_DYNPRO USING 'SAPMF02D' '0360'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'KNVK-NAMEV(01)'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=ENTR'.

*----If Session is selected

IF SESSION = 'X'.

*----To insert data into batch input session

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'XD01'

TABLES

DYNPROTAB = IT_BDCDATA.

REFRESH IT_BDCDATA.

AT LAST.

SKIP.

WRITE:/ TEXT-001.

ENDAT.

ELSE.

*----Calling the transaction

CALL TRANSACTION 'XD01' USING IT_BDCDATA

MODE CTUMODE

UPDATE CUPDATE

MESSAGES INTO IT_BDCMSGCOLL.

CLEAR IT_BDCDATA.

REFRESH IT_BDCDATA.

ENDIF.

ENDLOOP.

*----If Session is Selected

IF SESSION = 'X'.

*----To close the session

CALL FUNCTION 'BDC_CLOSE_GROUP'

EXCEPTIONS

NOT_OPEN = 1

QUEUE_ERROR = 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.

ENDIF.

*-----END-OF-SELECTION

END-OF-SELECTION.

*----To display the success messages

LOOP AT IT_BDCMSGCOLL INTO X_BDCMSGCOLL WHERE MSGTYP = 'S' .

*-----If Message Type Differs

ON CHANGE OF X_BDCMSGCOLL-MSGTYP.

WRITE:/ TEXT-002.

SKIP.

ULINE (58).

WRITE:/01 SY-VLINE,02 TEXT-003,

14 SY-VLINE,15 TEXT-004,

21 SY-VLINE,22 TEXT-005,

35 SY-VLINE,36 TEXT-006,

58 SY-VLINE,/01 SY-ULINE(58).

ENDON.

WRITE:/01 SY-VLINE,02 X_BDCMSGCOLL-MSGTYP,

14 SY-VLINE,15 X_BDCMSGCOLL-TCODE,

21 SY-VLINE,22 X_BDCMSGCOLL-MSGV1,

35 SY-VLINE,36 TEXT-007,

58 SY-VLINE,/01 SY-ULINE(58).

ENDLOOP.

SKIP 2.

*----To display the error messages

LOOP AT IT_BDCMSGCOLL INTO X_BDCMSGCOLL WHERE MSGTYP = 'E'.

*-----If Message Type Differs

ON CHANGE OF X_BDCMSGCOLL-MSGTYP.

WRITE:/ TEXT-008.

SKIP.

ULINE (58).

WRITE:/01 SY-VLINE,02 TEXT-003,

14 SY-VLINE,15 TEXT-004,

21 SY-VLINE,22 TEXT-005,

35 SY-VLINE,36 TEXT-006,

58 SY-VLINE,/01 SY-ULINE(58).

ENDON.

WRITE:/01 SY-VLINE,02 X_BDCMSGCOLL-MSGTYP,

14 SY-VLINE,15 X_BDCMSGCOLL-TCODE,

21 SY-VLINE,22 X_BDCMSGCOLL-MSGV1,

35 SY-VLINE,36 'Customer Already Exits',

58 SY-VLINE,/01 SY-ULINE(58).

ENDLOOP.

*-----FORM fill_bdcdata

FORM FILL_BDCDATA USING L_DYNPRO TYPE ANY

L_FNAME TYPE ANY

L_FVALUE TYPE ANY.

CLEAR X_BDCDATA.

IF L_DYNPRO = 'X'.

X_BDCDATA-DYNBEGIN = 'X'.

X_BDCDATA-PROGRAM = L_FNAME.

X_BDCDATA-DYNPRO = L_FVALUE.

ELSE.

X_BDCDATA-FNAM = L_FNAME.

X_BDCDATA-FVAL = L_FVALUE.

ENDIF.

APPEND X_BDCDATA TO IT_BDCDATA.

ENDFORM. "BDC_FIELD

*-----Start new screen

FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR IT_BDCDATA.

IT_BDCDATA-PROGRAM = PROGRAM.

IT_BDCDATA-DYNPRO = DYNPRO.

IT_BDCDATA-DYNBEGIN = 'X'.

APPEND IT_BDCDATA.

ENDFORM. "BDC_DYNPRO

*-----Insert field

FORM BDC_FIELD USING FNAM FVAL.

IF FVAL <> SPACE.

CLEAR IT_BDCDATA.

IT_BDCDATA-FNAM = FNAM.

IT_BDCDATA-FVAL = FVAL.

APPEND IT_BDCDATA.

ENDIF.

ENDFORM. "BDC_FIELD

Former Member
0 Kudos

GUI_UPLOAD

p_file is ur input parameter for File.

types:

begin of ty_text,

rec(1000) type c,

end of ty_text.

data:

t_text type STANDARD TABLE OF ty_text initial size 0.

PARAMETERS:P_FILE LIKE RLGRAP-FILENAME ,

data l_file type string.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

PERFORM get_file_from_present_server.

Start-of-selection.

Perform upload_file.

FORM get_file_from_present_server .

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

program_name = sy-repid

dynpro_number = sy-dynnr

CHANGING

file_name = P_FILE

EXCEPTIONS

mask_too_long = 1

OTHERS = 2.

ENDFORM. " get_file_from_present_server

Form upload_file.

CLEAR: l_file.

l_file = P_FILE.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = L_FILE

filetype = 'ASC'

  • HAS_FIELD_SEPARATOR = ','

TABLES

data_tab = t_text

EXCEPTIONS

file_open_error = 1

file_read_error = 2

header_too_long = 11

disk_full = 15

dp_timeout = 16

OTHERS = 17.

IF sy-subrc <> 0.

WRITE: / text-006, l_file , sy-subrc.

ENDIF.

Endform.

Former Member
0 Kudos

Hi,

IT HAPPENS WHEN YOUR IMPORT, EXPORT , TABLES PARAMETERS

DOES NOT MATCHES WITH THE DEFINED ONE.

SO GO TO SE37 AND CHECK PARAMETERS TYPE.

NOW DEFINE THAT TYPE IN YOUR PROGRAM VARIABLE ALSO.

<b>Reward points</b>

Regards

0 Kudos

Hi prajwal,

Here is sample code. Check it.

Do reward man if helpful.

TYPES: BEGIN OF t_infile,

pernr(8),

begda(8),

lgart(4),

betrg(16),

kostl(10),

remark(20),

preas(2),

END OF t_infile.

DATA: wa_file TYPE t_file,

it_file TYPE STANDARD TABLE OF t_file,

it_infile TYPE STANDARD TABLE OF t_infile,

wa_infile TYPE t_infile.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file. "F4

CALL FUNCTION 'F4_FILENAME'

EXPORTING

  • PROGRAM_NAME = SY-CPROG

  • DYNPRO_NUMBER = SY-DYNNR

field_name = 'P_FILE'

IMPORTING

file_name = p_file

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

  • CODEPAGE = ' '

filename = p_file

filetype = 'DAT'

  • HEADLEN = ' '

  • LINE_EXIT = ' '

  • TRUNCLEN = ' '

  • USER_FORM = ' '

  • USER_PROG = ' '

  • DAT_D_FORMAT = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

data_tab = it_infile

  • EXCEPTIONS

  • CONVERSION_ERROR = 1

  • FILE_OPEN_ERROR = 2

  • FILE_READ_ERROR = 3

  • INVALID_TYPE = 4

  • NO_BATCH = 5

  • UNKNOWN_ERROR = 6

  • INVALID_TABLE_WIDTH = 7

  • GUI_REFUSE_FILETRANSFER = 8

  • CUSTOMER_ERROR = 9

  • NO_AUTHORITY = 10

  • OTHERS = 11

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

You will get data in it_infile.

regards

Azad.

Former Member
0 Kudos

hi,

follow this sample code for uploading the data......

CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename                = <specifies the file path>
        filetype                =  <specifies the file type> " 'ASC' default
        has_field_separator     = <specifies the field separator>
      TABLES
        data_tab                = <output table> "internal table
      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.

<b>or:</b>

DATA: i_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.  
DATA: begin of it_datatab occurs 0,
  row(500) type c,
 end of it_datatab.
 
  CALL FUNCTION 'GUI_UPLOAD'
       EXPORTING
            filename        = i_file
            filetype        = 'ASC'
       TABLES
            data_tab        = it_datatab  "ITBL_IN_RECORD[]
       EXCEPTIONS
            file_open_error = 1
            OTHERS          = 2.

for sample programs follow these links..

http://abap4.tripod.com/Upload_and_Download_ABAP_Source_Code.html

regards,

Ashok reddy

Former Member
0 Kudos

Hi Prajwal,

Check out whether the text file that u want to upload is in edit/change/open mode.

kiran