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 upload Text File to Custom Table.

former_member601753
Discoverer
0 Kudos

SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S31 { font-style: italic; color: #808080; } .L0S32 { color: #3399FF; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; } .L0S70 { color: #808080; }

I have uploaded excel file for custom table by using FM ' CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP' and it executed successfully but when iam trying to upload text file by using FM ' CALL FUNCTION 'TEXT_CONVERT_TXT_TO_SAP' it is not executing,can plz some one help with out :

REPORT ZDEMO12.
tables : zabhi1.
type-pools : truxs,slis.

* Selection screen

PARAMETERS : p_file type rlgrap-filename DEFAULT 'c:\users\abhishek.jagtap\downloads\export_vbap.TXT'.

types : begin of ty_zabhi1,
vbeln type zabhi1-vbeln,
posnr type zabhi1-posnr,
matnr type zabhi1-matnr,
matkl type zabhi1-matkl,
makt type zabhi1-makt,
pstyv type zabhi1-pstyv,
kunnr type zabhi1-kunnr,
land1 type zabhi1-land1,
name1 TYPE zabhi1-name1,
ort01 type zabhi1-ort01,
end of ty_zabhi1.

data : it_zabhi1 type STANDARD TABLE OF ty_zabhi1,
wa_zabhi1 type ty_zabhi1,
wa_zabhi type zabhi1
.

data : it_type TYPE truxs_t_text_data.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
* PROGRAM_NAME = SYST-REPID
* DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
* STATIC = ' '
* MASK = ' '
* FILEOPERATION = 'R'
* PATH =
CHANGING
file_name = p_file.

* LOCATION_FLAG = 'P'
* EXCEPTIONS
* MASK_TOO_LONG = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

START-OF-SELECTION.
* Uploading the data in the file into internal table

CALL FUNCTION 'TEXT_CONVERT_TXT_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
* I_LINE_HEADER = 'X'
i_tab_raw_data = it_type
I_FILENAME = p_file
tables
i_tab_converted_data = it_zabhi1[]
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

end-of-SELECTION.




* Uploading the data into the database table

loop at it_zabhi1 into wa_zabhi1.
wa_zabhi-vbeln = wa_zabhi1-vbeln.
wa_zabhi-posnr = wa_zabhi1-posnr.
wa_zabhi-matnr = wa_zabhi1-matnr.
wa_zabhi-matkl = wa_zabhi1-matkl.
wa_zabhi-makt = wa_zabhi1-makt.
wa_zabhi-pstyv = wa_zabhi1-pstyv.
wa_zabhi-kunnr = wa_zabhi1-kunnr.
wa_zabhi-land1 = wa_zabhi1-land1.
wa_zabhi-name1 = wa_zabhi1-name1.
wa_zabhi-ort01 = wa_zabhi1-ort01.
MODIFY zabhi1 FROM wa_zabhi.
Clear : wa_zabhi , wa_zabhi1.
endloop.

3 REPLIES 3

nabheetscn
Active Contributor
0 Kudos

What does debugger show after the call of the function module? What is your sample file?

Sandra_Rossi
Active Contributor
0 Kudos

I guess you are talking about TEXT_CONVERT_TEX_TO_SAP (not TEXT_CONVERT_TXT_TO_SAP)

The input must be a CSV file whose lines must have fields separated with semicolon (;), open your file with notepad to make sure...

Sandra_Rossi
Active Contributor

Please use the button CODE to format your code.