13 Replies Latest reply: Jun 3, 2009 2:55 PM by vijay chavan RSS

upload data to bdc report from excel instead of notepad

ahmed shaik
Currently Being Moderated

Hi,

 

In BDC report i need to upload the data from excel to BDC .  while doing it i am getting one error message saying that " Wrong value of the parameter FILETYPE " . But if i use the notepad its working fine.

 

Please tell me the necessary modifications that i need to implement.

 

Thank,

Ahmed.

  • Re: upload data to bdc report from excel instead of notepad
    vijay chavan
    Currently Being Moderated

    Dear Ahmed.,

     

    Save excel file as CSV format. Then it should work.

     

    Regards,

    Vijay

    • Re: upload data to bdc report from excel instead of notepad
      ahmed shaik
      Currently Being Moderated

      I tried as per suggestion but still it is not working .

      • Re: upload data to bdc report from excel instead of notepad
        vijay chavan
        Currently Being Moderated

        Hi ahmed again,

        a small doubt, make sure that while uploading your csv file must be closed.

        one more thing is the parameter you are passing to FM should be of type String.

         

        Check this point and come back.

         

        Regards,

        Vijay

      • Re: upload data to bdc report from excel instead of notepad
        Avinash Kodarapu
        Currently Being Moderated

        HI,

         

        Check this code to upload data from excel sheet to internal table..

         

        DATA l_count TYPE sy-tabix.
        
           CONSTANTS: lc_begin_col TYPE i VALUE '1',
                      lc_begin_row TYPE i VALUE '2',
                      lc_end_col   TYPE i VALUE '2',
                      lc_end_row   TYPE i VALUE '3000'.
        
        * Begin of CALK912848 - Carlos Werberich - 16Sep08
          CLEAR p_i_excel_data. REFRESH p_i_excel_data.
        * End   of CALK912848 - Carlos Werberich - 16Sep08
        
        * Function module to read excel file and convert it into internal table
           CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
             EXPORTING
               filename                = p_p_file
               i_begin_col             = lc_begin_col
               i_begin_row             = lc_begin_row
               i_end_col               = lc_end_col
               i_end_row               = lc_end_row
             TABLES
               intern                  = i_data
             EXCEPTIONS
               inconsistent_parameters = 1
               upload_ole              = 2
               OTHERS                  = 3.
        * Error in file upload
           IF sy-subrc NE 0 .
             MESSAGE text-006 TYPE 'E'.
             EXIT.
           ENDIF.
           IF i_data[] IS INITIAL .
             MESSAGE text-007 TYPE 'E'.
             EXIT.
           ELSE.
             SORT i_data BY row col .
        * Loop to fill data in Internal Table
             LOOP AT i_data .
               MOVE i_data-col TO l_count .
               ASSIGN COMPONENT l_count OF STRUCTURE p_i_excel_data TO <fs_source> .
               MOVE i_data-value TO <fs_source> .
               AT END OF row .
        * Append data into internal table
                 APPEND p_i_excel_data.
                 CLEAR p_i_excel_data.
               ENDAT .
             ENDLOOP .
           ENDIF .

         

  • Re: upload data to bdc report from excel instead of notepad
    Kishore Babu
    Currently Being Moderated

    which FM u r using?

  • Re: upload data to bdc report from excel instead of notepad
    Shiva Tirumalasetty
    Currently Being Moderated

    Hi,

     

    If you are uploading the data from XLS use the below FM:

     

    From Presentation server:

     

    CALL FUNCTION 'FAA_FILE_UPLOAD_EXCEL'

        EXPORTING

          i_filename           = <filepath/name>

          i_delimiter          = gc_tab

        TABLES

          et_filecontent       = gt_rec

     

    If you are uploading file from application server you can use the below FM

     

     

      CALL FUNCTION GUI_UPLOAD'

        EXPORTING

          iv_file_name     = <filename/path>

          iv_separator     = space

          iv_location      = 'A'

        CHANGING

          ct_tab_data      = gt_rec

     

     

    Regards

    Shiva

  • Re: upload data to bdc report from excel instead of notepad
    ahmed shaik
    Currently Being Moderated

    This is my report.

     

    report ZTESTDF

           no standard page heading line-size 255.

     

     

    DATA: gv_fname TYPE string.

     

    PARAMETERS: p_fname TYPE RLGRAP-FILENAME OBLIGATORY.

     

     

    DATA:   MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

     

     

     

    data : begin of itab occurs 0,

     

     

          PARGE TYPE  KNVK-PARGE ,

          ABTNR TYPE  KNVK-ABTNR,

          PAFKT TYPE  KNVK-PAFKT,

          FAMST TYPE  KNVK-FAMST,

          TITLE_MEDI TYPE  SZA5_D0700-TITLE_MEDI,

          NAME_LAST TYPE  ADDR3_DATA-NAME_LAST,

          NAME_FIRST TYPE  ADDR3_DATA-NAME_FIRST,

          FUNCTION TYPE  ADDR3_DATA-FUNCTION,

          DEPARTMENT TYPE  ADDR3_DATA-DEPARTMENT,

          LANGU_P TYPE  ADDR3_DATA-LANGU_P,

          TEL_NUMBER TYPE  SZA5_D0700-TEL_NUMBER,

          MOB_NUMBER TYPE  SZA5_D0700-MOB_NUMBER,

          SMTP_ADDR TYPE  SZA5_D0700-SMTP_ADDR,

     

     

          END OF ITAB ,

     

          bdcdata like  bdcdata occurs 0 with header line.

     

     

    *include bdcrecx1.

     

     

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME.

     

    CALL FUNCTION 'F4_FILENAME'

    EXPORTING

    PROGRAM_NAME = SY-REPID

    • DYNPRO_NUMBER = SYST-DYNNR

    FIELD_NAME = 'P_FNAME'

    IMPORTING

    FILE_NAME = P_FNAME

    .

     

     

     

    start-of-selection.

     

    GV_FNAME = P_FNAME.

     

    • CALL FUNCTION 'GUI_UPLOAD'

    •    EXPORTING

    •    FILENAME                      = GV_FNAME   

    •     FILETYPE                      = 'XLS'

    •    TABLES

    •      DATA_TAB                      = itab

    •            .

     

     

    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

      EXPORTING

        FILENAME                      = GV_FNAME

        I_BEGIN_COL                   = 1

        I_BEGIN_ROW                   = 1

        I_END_COL                     = 13

        I_END_ROW                     = 1

      TABLES

        INTERN                        = itab

    • EXCEPTIONS

    •   INCONSISTENT_PARAMETERS       = 1

    •   UPLOAD_OLE                    = 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.

     

     

      LOOP AT ITAB.

     

    if itab is not initial.

        REFRESH BDCDATA.

     

    *perform open_group.

     

        perform bdc_dynpro      using 'SAPMF02D' '0036'.

        perform bdc_field       using 'BDC_CURSOR'

                                      'RF02D-KUNNR'.

        perform bdc_field       using 'BDC_OKCODE'

                                      '/00'.

        perform bdc_field       using 'RF02D-KUNNR'

                                      'T001'.

        perform bdc_field       using 'USE_ZAV'

                                      'X'.

        perform bdc_dynpro      using 'SAPMF02D' '1361'.

        perform bdc_field       using 'BDC_OKCODE'

                                      '=UPDA'.

        perform bdc_field       using 'KNVK-PARGE'

                                      ITAB-PARGE.

        perform bdc_field       using 'KNVK-ABTNR'

                                      ITAB-ABTNR.

        perform bdc_field       using 'KNVK-PAFKT'

                                      ITAB-PAFKT.

        perform bdc_field       using 'KNVK-FAMST'

                                      ITAB-FAMST.

        perform bdc_field       using 'BDC_CURSOR'

                                      'SZA5_D0700-SMTP_ADDR'.

        perform bdc_field       using 'SZA5_D0700-TITLE_MEDI'

                                      ITAB-TITLE_MEDI.

        perform bdc_field       using 'ADDR3_DATA-NAME_LAST'

                                      ITAB-NAME_LAST.

        perform bdc_field       using 'ADDR3_DATA-NAME_FIRST'

                                      ITAB-NAME_FIRST.

        perform bdc_field       using 'ADDR3_DATA-FUNCTION'

                                      ITAB-FUNCTION.

        perform bdc_field       using 'ADDR3_DATA-DEPARTMENT'

                                      ITAB-DEPARTMENT.

        perform bdc_field       using 'ADDR3_DATA-LANGU_P'

                                      ITAB-LANGU_P.

        perform bdc_field       using 'SZA5_D0700-TEL_NUMBER'

                                      ITAB-TEL_NUMBER.

        perform bdc_field       using 'SZA5_D0700-MOB_NUMBER'

                                      ITAB-MOB_NUMBER.

        perform bdc_field       using 'SZA5_D0700-SMTP_ADDR'

                                      ITAB-SMTP_ADDR.

    *perform bdc_transaction using 'VAP1'.

     

        CALL TRANSACTION 'VAP1' USING BDCDATA

                            MODE 'A'

                         UPDATE 'S'

                         MESSAGES INTO MESSTAB.

    endif.

     

      endloop.

     

    *perform close_group.

     

     

    ----


    •        Start new screen                                              *

    ----


    FORM BDC_DYNPRO USING PROGRAM DYNPRO.

      CLEAR BDCDATA.

      BDCDATA-PROGRAM  = PROGRAM.

      BDCDATA-DYNPRO   = DYNPRO.

      BDCDATA-DYNBEGIN = 'X'.

      APPEND BDCDATA.

    ENDFORM.

     

    ----


    •        Insert field                                                  *

    ----


    FORM BDC_FIELD USING FNAM FVAL.

    • IF FVAL <> NODATA.

        CLEAR BDCDATA.

        BDCDATA-FNAM = FNAM.

        BDCDATA-FVAL = FVAL.

        APPEND BDCDATA.

    • ENDIF.

     

  • Re: upload data to bdc report from excel instead of notepad
    Abdul Sathar
    Currently Being Moderated

    Hi

     

    Try this FM for uploading from an excel file.

     

    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING
          i_tab_raw_data       = gv_raw
          i_line_header        = 'X'
          i_filename           = p_file
        TABLES
          i_tab_converted_data = gt_upload
        EXCEPTIONS
          conversion_failed    = 1
          OTHERS               = 2.
      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

    Sathar

  • Re: upload data to bdc report from excel instead of notepad
    ahmed shaik
    Currently Being Moderated

    Hi,

     

    Just one doubt

    for every FM it throws same runtime error that is

     

    The function module interface allows you to specify only

    fields of a particular type under "I_FILENAME".

    The field "GV_FNAME" specified here is a different

    field type

    .

     

     

    The below code am using to pass the filename to the FM

     

    PARAMETERS: p_fname TYPE RLGRAP-FILENAME OBLIGATORY.

     

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME.

     

    CALL FUNCTION 'F4_FILENAME'

    EXPORTING

    PROGRAM_NAME = SY-REPID

    • DYNPRO_NUMBER = SYST-DYNNR

    FIELD_NAME = 'P_FNAME'

    IMPORTING

    FILE_NAME = P_FNAME.

     

    start-of-selection.

     

    GV_FNAME = P_FNAME.

    • Re: upload data to bdc report from excel instead of notepad
      vijay chavan
      Currently Being Moderated

      Hi again,

      Try this ..

       

      CALL FUNCTION 'GUI_UPLOAD'

          EXPORTING

            FILENAME                      = V_FILE

      •     FILETYPE                      = 'ASC'

      •     HAS_FIELD_SEPARATOR           = 'X'

      •   HEADER_LENGTH                 = 0

      •   READ_BY_LINE                  = 'X'

      •   DAT_MODE                      = ' '

      •   CODEPAGE                      = ' '

      •   IGNORE_CERR                   = ABAP_TRUE

      •   REPLACEMENT                   = '#'

      •   CHECK_BOM                     = ' '

      •   VIRUS_SCAN_PROFILE            =

      •   NO_AUTH_CHECK                 = ' '

      • IMPORTING

      •   FILELENGTH                    =

      •   HEADER                        =

          TABLES

            DATA_TAB                      = I_DFILE

         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.

       

      separate  I_DFILE at ',' and append into internal table.

       

      Regards,

      Vijay

Actions