cancel
Showing results for 
Search instead for 
Did you mean: 

Error in CSV upload

Former Member
0 Kudos

Hi Gurus,

while uploading data from csv file, at one field i am getting error, it is of type BETRG(CURR) and value in file is 500, but while i checked in debug 500 is added with # i.e., 500# '#' tabking automatically.. why it is taking #?? any help please...

Thanks and regards,

venky.

Accepted Solutions (1)

Accepted Solutions (1)

gill367
Active Contributor
0 Kudos

Can you paste the code you are using for separating the content.

also 500 is in the end of the line ?

thanks

sarb

Former Member
0 Kudos

Hi singh

Thanks for your reply,

Yes 500 field is the last field in the CSV file.

Thanks,

venkat.

gill367
Active Contributor
0 Kudos

hi

can i have a look at your code.

thanks

Former Member
0 Kudos

Hi

Here is the code

wd_context->get_attribute(

EXPORTING

name = 'LABOUR_DATASOURCE'

IMPORTING

value = l_labour_datasource ).

DATA : conv TYPE REF TO CL_ABAP_CONV_IN_CE.

  • Creates a Conversion Instance

CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE

EXPORTING

INPUT = l_labour_datasource

ENCODING = 'UTF-8'

REPLACEMENT = '?'

IGNORE_CERR = ABAP_TRUE

RECEIVING

CONV = conv.

conv2->READ( importing data = l_labour_string ).

  • get the data of file

split l_labour_string at cl_abap_char_utilities=>newline

into TABLE lt_labour_data.

  • delete the header

DELETE lt_labour_data INDEX 1.

LOOP AT lt_labour_data into lw_labour_string.

SPLIT lw_labour_string at ',' into table lt_labour_field.

READ TABLE lt_labour_field INTO lv_labour_field INDEX 1.

ls_labour_context-DEALER_CODE = lv_labour_field.

READ TABLE lt_labour_field INTO lv_labour_field INDEX 2.

ls_labour_context-CLAIM_TYPE = lv_labour_field.

READ TABLE lt_labour_field INTO lv_labour_field INDEX 3.

ls_labour_context-CLAIM_SI_NO = lv_labour_field.

READ TABLE lt_labour_field INTO lv_labour_field INDEX 4.

ls_labour_context-REP_OPERATION_CODE = lv_labour_field.

READ TABLE lt_labour_field INTO lv_labour_field INDEX 5.

ls_labour_context-LABOUR_CLAIMED = lv_labour_field.

append ls_labour_context to lt_labour_context.

  • append wa_context to lt_context.

ENDLOOP.

  • bind table

lo_node_labour = wd_context->get_child_node( 'LABOUR_TABLE' ).

  • lo_node->bind_table( lt_context ).

lo_node_labour->bind_table( lt_labour_context ).

I interchanged last fields, then uploading data successfully, but last field aslo added #, but no error.

Thanks,

Venkat

gill367
Active Contributor
0 Kudos

yes i was thinking this only,

instead of newline use linefeed

in the code use

cl_abap_char_utilities=>CR_LF

instead of

cl_abap_char_utilities=>newline

thanks

sarb

Answers (2)

Answers (2)

Former Member
0 Kudos

this will help u...

SPLIT l_labour_string AT CL_ABAP_CHAR_UTILITIES=>CR_LF INTO TABLE lt_labour_data.

instead of this one....

split l_labour_string at cl_abap_char_utilities=>newline

into TABLE lt_labour_data.

Former Member
0 Kudos

@venkatt....this might help u

DATA LO_EL_CONTEXT TYPE REF TO IF_WD_CONTEXT_ELEMENT.

DATA LS_CONTEXT TYPE WD_THIS->ELEMENT_CONTEXT.

DATA ITEM_FILE TYPE WD_THIS->ELEMENT_CONTEXT-EXCEL_UPLOAD.

  • get element via lead selection

LO_EL_CONTEXT = WD_CONTEXT->GET_ELEMENT( ).

  • @TODO handle not set lead selection

IF LO_EL_CONTEXT IS INITIAL.

ENDIF.

  • get single attribute

LO_EL_CONTEXT->GET_ATTRIBUTE(

EXPORTING

NAME = `EXCEL_UPLOAD`

IMPORTING

VALUE = ITEM_FILE ).

DATA S_CONT TYPE STRING.

DATA CONVT TYPE REF TO CL_ABAP_CONV_IN_CE.

CONSTANTS: c_encoding TYPE abap_encoding VALUE '8404'. "optional

CALL METHOD cl_abap_conv_in_ce=>create

EXPORTING

encoding = c_encoding "optional

input = ITEM_FILE

RECEIVING

conv = CONVT.

CALL METHOD CONVT->read

IMPORTING

data = S_CONT.

CONVT = CL_ABAP_CONV_IN_CE=>CREATE( INPUT = ITEM_FILE ).

CONVT->READ( IMPORTING DATA = S_CONT ).

TYPES: BEGIN OF TY_TAB,

NAME_CHAR TYPE STRING,

DESCR_CHAR TYPE STRING,

NUMBER_DIGITS TYPE STRING,

END OF TY_TAB.

DATA: FIELDS TYPE STRING_TABLE.

DATA: LV_FIELD TYPE STRING.

DATA: S_TABLE TYPE STRING_TABLE.

DATA: ITAB TYPE TABLE OF TY_TAB.

DATA: STR_ITAB TYPE TY_TAB.

.

*splits string based on new line

SPLIT S_CONT AT CL_ABAP_CHAR_UTILITIES=>CR_LF INTO TABLE S_TABLE.

FIELD-SYMBOLS: <WA_TABLE> LIKE LINE OF S_TABLE.

LOOP AT S_TABLE ASSIGNING <WA_TABLE>.

  • splits string on basis of tabs

SPLIT <WA_TABLE> AT ',' INTO

STR_ITAB-NAME_CHAR

STR_ITAB-DESCR_CHAR

STR_ITAB-NUMBER_DIGITS.

APPEND STR_ITAB TO ITAB.

ENDLOOP.

DATA: IT_ALV_STYLE TYPE STANDARD TABLE OF ZMTCD_ALV_CHARACT_STYLE,

WA_ALV_STYLE LIKE LINE OF IT_ALV_STYLE.

DATA : IT_CHARACTERISTIC TYPE ZMTCD_CHAR_T ,

IT_TEMP_CHARACTERISTIC TYPE ZMTCD_CHAR_T,

WA_CHAR LIKE LINE OF IT_CHARACTERISTIC,

WA_TEMP_CHARACTERISTIC LIKE LINE OF IT_TEMP_CHARACTERISTIC.

REFRESH IT_ALV_STYLE.

LOOP AT ITAB INTO STR_ITAB.

MOVE-CORRESPONDING STR_ITAB TO WA_ALV_STYLE.

APPEND WA_ALV_STYLE TO IT_ALV_STYLE.

ENDLOOP.

DATA CONTEXT_NODE TYPE REF TO IF_WD_CONTEXT_NODE.

DATA LO_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .

LO_INTERFACECONTROLLER = WD_THIS->WD_CPIFC_ALV1( ).

CONTEXT_NODE = WD_CONTEXT->GET_CHILD_NODE( NAME = 'CTX_VN_ALV1' ).

LO_INTERFACECONTROLLER->SET_DATA(

  • only_if_new_descr = " wdy_boolean

R_NODE_DATA = CONTEXT_NODE " ref to if_wd_context_node

).

CONTEXT_NODE->BIND_TABLE( IT_ALV_STYLE ).

in the above program....first data is taken in a xstring variable....

then it is passed to classes / methods to decrypt it...

then it is divided properly....depending on rows n colums...

later it is binded to internal table and displayed in the output

Former Member
0 Kudos

Hi All,

How can i insert csv fields in to database

any code help?

Thanks & Regards

Madhan

Edited by: MadhanSAP on Jan 19, 2011 7:27 AM