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

Upload a text file in database

Former Member
0 Likes
722

Hi Experts

In dialog programming, am using table control inwhich i want to upload a text file for each row in a particular field. How to store the text file for a field in the database.

Pls explain me with the example also.

Thanks in advance.

Regards

Rajaram

Hi Experts

In dialog programming, am using table control inwhich i want to upload a text file for each row in a particular field. How to store the text file for a field in the database.

Pls explain me with the example also.

Thanks in advance.

Regards

Rajaram

5 REPLIES 5
Read only

Former Member
0 Likes
655

Hi Raja,

You just need to use GUI_UPLOAD function module.

There give the path of your .txt file and in tables give the internal table name which you used in the screen.

Thats enough. thing is that, In screen internal tbales values only will display. Thats it.

Example:

DATA: BEGIN OF g_t_itab OCCURS 0,

matnr LIKE mara-matnr,

maktx LIKE makt-maktx,

END OF g_t_itab.

DATA: g_t_bdcdata TYPE TABLE OF bdcdata.

DATA: path TYPE string,

path1 type string.

path = 'C:\Documents and Settings\ssr3kor\Desktop\TEST\test.txt'.

path1 = 'C:\Documents and Settings\ssr3kor\Desktop\TEST\test1.txt'.

**************************

*contents of test.txt *

*

*TEST1 ,BOT *

*TEST2 ,BOT *

*TEST3 ,BUT *

**************************

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = path

TABLES

data_tab = g_t_itab.

LOOP AT g_t_itab.

WRITE:/1(18) g_t_itab-matnr, 20(40) g_t_itab-maktx.

ENDLOOP.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = path1

filetype = 'ASC'

TABLES

data_tab = g_t_itab.

Reward If Helpful.

Regards

--

Sasidhar Reddy Matli.

Edited by: Sasidhar Reddy Matli on Jan 24, 2008 2:47 PM

Read only

0 Likes
655

Can you pls provide me the example code for the same.

Regards

Rajaram

Read only

0 Likes
655

Hello Raja,

Please find the example code.

Example:

DATA: BEGIN OF g_t_itab OCCURS 0,

matnr LIKE mara-matnr,

maktx LIKE makt-maktx,

END OF g_t_itab.

DATA: g_t_bdcdata TYPE TABLE OF bdcdata.

DATA: path TYPE string,

path1 type string.

path = 'C:\Documents and Settings\ssr3kor\Desktop\TEST\test.txt'.

**************************

*contents of test.txt *

*

*TEST1 ,BOT *

*TEST2 ,BOT *

*TEST3 ,BUT *

**************************

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = path

TABLES

data_tab = g_t_itab.

LOOP AT g_t_itab.

WRITE:/1(18) g_t_itab-matnr, 20(40) g_t_itab-maktx.

ENDLOOP.

*CALL FUNCTION 'GUI_DOWNLOAD'

*EXPORTING

*filename = path1

*filetype = 'ASC'

*TABLES

*data_tab = g_t_itab.

Reward If Helpful.

Regards

--

Sasidhar Reddy Matli.

Edited by: Sasidhar Reddy Matli on Jan 24, 2008 2:53 PM

Read only

0 Likes
655

how to load the text file into a table field and store it.

Read only

0 Likes
655

Hello Raja,

You should have text file in local disk. You have to give the path of that text file to the function module.

The have given the contents of the text file also in the programs with comments. according to that code which i sent, the text file name should be TEST.txt . In this contents are: material nnumber and description seperated by comma. as matnr having 18 length you shoud give comma after after 18 character along including matnr.

The data will be saved automatically into the internal table through FM. This internal table contents only u r displaying in the screen right...?

Regards

--

Sasidhar Reddy Matli.