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: 

Re:type casting error in function module

Former Member
0 Kudos

Hi Expert,

I have written below code i am uploading data from .csv file to iternal table  in GUI_UPLOAD  function module i am getting error saying P_FILE specifiesd here

is a different field type.

Please any one can throw some light.

  SELECTION-SCREEN begin of block b1 with frame TITLE text-001.
*parameters: p_file type string default 'C:\ME22N.CSV' OBLIGATORY.
parameters: p_file type LOCALFILE.
SELECTION-SCREEN end of block b1.


AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.


  CALL FUNCTION 'F4_FILENAME'
   EXPORTING
     PROGRAM_NAME        = SYST-CPROG
     DYNPRO_NUMBER       = SYST-DYNNR
     FIELD_NAME          = 'P_FILE'             " 'P_FILE '
   IMPORTING
     FILE_NAME           =  P_FILE                      "P_FILE
            .

START-OF-SELECTION.

************* Function module to upload file from path***************

*data: p_file type string.
*data: v_file TYPE string.
*  v_file = P_file.


  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      FILENAME                      = p_file
     FILETYPE                      = 'ASC'

    TABLES
      DATA_TAB                      = gtab
* 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 REPLY 1

matt
Active Contributor
0 Kudos

Go to SE37. Look at GUI_UPLOAD. What type is p_file? Hint: it isn't LOCALFILE.

The answer to your query is in your question.  Very basic question. Locked.