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: 

How to use Function Module KCD_CSV_FILE_TO_INTERN_CONVERT?

Former Member
0 Kudos

How to convert an .CSV file to an internal table format .Please give me any sample code for the same

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

type-pools: KCDE.

parameters: p_file like rlgrap-filename default 'C:\STOCK.csv'.

data: it_data type KCDE_INTERN .

CALL FUNCTION 'KCD_CSV_FILE_TO_INTERN_CONVERT'

EXPORTING

I_FILENAME = p_file

I_SEPARATOR = ','

TABLES

E_INTERN = it_data

EXCEPTIONS

UPLOAD_CSV = 1

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

regards,

keerthi

4 REPLIES 4

Former Member
0 Kudos
DATA: BEGIN OF itab OCCURS 0,
        vbeln LIKE vbak-vbeln,
        ernam LIKE vbak-ernam,
      END OF itab.
 
DATA itab2 LIKE TABLE OF KCDE_CELLS WITH HEADER LINE.
 
CALL FUNCTION 'KCD_CSV_FILE_TO_INTERN_CONVERT'
  EXPORTING
    i_filename            = 'D:dataupl.txt'
    i_separator           = ','
  tables
    e_intern              = itab2
* EXCEPTIONS
*   UPLOAD_CSV            = 1
*   UPLOAD_FILETYPE       = 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 itab2.
  SPLIT itab2-value AT ',' INTO itab-vbeln itab-ernam.
  APPEND itab.
  CLEAR itab.
ENDLOOP.

Former Member
0 Kudos

Have a look at below code:

DATA: BEGIN OF itab OCCURS 0,

vbeln LIKE vbak-vbeln,

ernam LIKE vbak-ernam,

END OF itab.

DATA itab2 LIKE TABLE OF <b>KCDE_CELLS</b> WITH HEADER LINE.

CALL FUNCTION <b>'KCD_CSV_FILE_TO_INTERN_CONVERT'</b>

EXPORTING

i_filename = 'D:\data\upl.txt'

i_separator = '|'

tables

e_intern = itab2

  • EXCEPTIONS

  • UPLOAD_CSV = 1

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

I hope it helps.

Best Regards,

Vibha

*Please mark all the helpful answers

I tried to edit so that it is displyed it readable format but dnt know what the problem is. I hope u can read it and understand hoe to use it.

Message was edited by:

Vibha Deshmukh

Former Member

Former Member
0 Kudos

Hi,

type-pools: KCDE.

parameters: p_file like rlgrap-filename default 'C:\STOCK.csv'.

data: it_data type KCDE_INTERN .

CALL FUNCTION 'KCD_CSV_FILE_TO_INTERN_CONVERT'

EXPORTING

I_FILENAME = p_file

I_SEPARATOR = ','

TABLES

E_INTERN = it_data

EXCEPTIONS

UPLOAD_CSV = 1

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

regards,

keerthi