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

Error Uploading Excel File

zubair_914
Discoverer
0 Likes
1,475

Hello ABAPers.

After executing the upload program i am getting an error of type conflict type P.

I am doing it for the first time help me out please.

I have attached the code below.

*&---------------------------------------------------------------------*
*& Report ZDB_UPLOAD_PROGRAM
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZDB_UPLOAD_PROGRAM.

type-POOLs truxs.

TABLES : zemployees.

PARAMETERS p_file type rlgrap-filename.

TYPES: BEGIN OF t_tab,
emp_id type zemployees-emp_id,
first_name type zemployees-first_name,
last_name type zemployees-last_name,
email type zemployees-email,
phone_no type zemployees-phone_no,
salary type zemployees-salary,
job_id type zemployees-job_id,
man_id type zemployees-man_id,
dep_id type zemployees-dep_id,
end of t_tab.

data:
t_upload type STANDARD TABLE OF t_tab,
wa_upload type t_tab,
it_type type truxs_t_text_data.
* it_zemployees type table of zemployees,
* wa_employees type zemployees.

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'
IMPORTING
FILE_NAME = p_file.

START-OF-SELECTION.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
* I_LINE_HEADER =
i_tab_raw_data = it_type
i_filename = p_file
TABLES
i_tab_converted_data = t_upload[]
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
.
IF sy-subrc = 0.
* Implement suitable error handling here
MESSAGE 'DATA Entered successfully!' type 'S'.

else.
Message id sy-msgid
TYPE sy-msgty
NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

end-of-SELECTION.

LOOP AT t_upload into wa_upload.

zemployees-emp_id = wa_upload-emp_id.
zemployees-first_name = wa_upload-first_name.
zemployees-last_name = wa_upload-last_name.
zemployees-email = wa_upload-email.
zemployees-phone_no = wa_upload-phone_no.
zemployees-salary = wa_upload-salary.
zemployees-job_id = wa_upload-job_id.
zemployees-man_id = wa_upload-man_id.
zemployees-dep_id = wa_upload-dep_id.

update zemployees.
ENDLOOP.

How to resolve it?

2 REPLIES 2
Read only

FredericGirod
Active Contributor
1,000

Use the beautiful button [CODE] it will format the source code.

When you have an error, SAP indicates the line of the error, maybe you could provide this information

Read only

vipinsaraika
Participant
0 Likes
1,000

Hi Zubair,

Please check the data type you have assigned for each field in your table ZEMPLOYEES, if possible share the snapshot of your table.

This type of conflict will occur only because of the data type defined mismatch for each field, best is for your testing purpose is to define all the database fields as char 50.

Try with below it will work.

REPORT zdb_upload_program.


TYPES:BEGIN OF ty_record,
        emp_id     TYPE char50,
        first_name TYPE char50,
        last_name  TYPE char50,
        email      TYPE char50,
        phone_no   TYPE char50,
        salary     TYPE char50,
        job_id     TYPE char50,
        man_id     TYPE char50,
        dep_id     TYPE char50,
      END OF ty_record.

DATA:wa_record    TYPE ty_record.


DATA:lt_raw    TYPE truxs_t_text_data,
     lt_record TYPE STANDARD TABLE OF ty_record INITIAL SIZE 0.

DATA:wa_employees TYPE zemployees.

SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-000.
PARAMETERS: p_file  TYPE localfile,
            p_fhead AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK block1.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  PERFORM input_help.

START-OF-SELECTION.
  DATA:l_fhead TYPE char01.
  l_fhead = p_fhead.

  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
*     I_FIELD_SEPERATOR    =
      i_line_header        = l_fhead
      i_tab_raw_data       = lt_raw
      i_filename           = p_file
    TABLES
      i_tab_converted_data = lt_record
    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.

  LOOP AT lt_record INTO wa_record.

    wa_employees-emp_id = wa_record-emp_id.
    wa_employees-first_name = wa_record-first_name.
    wa_employees-last_name = wa_record-last_name.
    wa_employees-email = wa_record-email.
    wa_employees-phone_no = wa_record-phone_no.
    wa_employees-salary = wa_record-salary.
    wa_employees-job_id = wa_record-job_id.
    wa_employees-man_id = wa_record-man_id.
    wa_employees-dep_id = wa_record-dep_id.

    INSERT zemployees FROM wa_employees.

  ENDLOOP.
*&---------------------------------------------------------------------*
*&      Form  INPUT_HELP
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM input_help .

  CALL FUNCTION 'F4_FILENAME'
    EXPORTING
      field_name = 'P_FILE'            " Field to get file Name
    IMPORTING
      file_name  = p_file.

ENDFORM.