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

Uploading into database table from text file using tab (GUI_UPLOAD)

Former Member
0 Likes
1,136

i have small doubt

i have 3 fiels in text file using tab as separator

i need to update into database table 'ZABPSP_01'

from 's.txt' located in local disk.

My code is below.

Please let me know the correction.

Awaiting for ur response.

Thanks in advance

REPORT ZABPSPPRG_02.

TABLES: LFA1,MARA,KNA1,ZABPSP_01.

DATA: begin of itab occurs 0,

IKUNNR type zabpsp_01-kunnr,

IMATNR type zabpsp_01-matnr,

IADRNR type zabpsp_01-adrnr.

DATA:END OF ITAB.

DATA: FILENAME1 TYPE STRING.

FILENAME1 = 'C:/s.txt'.

*********

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = FILENAME1

  • FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = itab.

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_READ_ERROR = 2

  • NO_BATCH = 3

  • GUI_REFUSE_FILETRANSFER = 4

  • INVALID_TYPE = 5

  • NO_AUTHORITY = 6

  • UNKNOWN_ERROR = 7

  • BAD_DATA_FORMAT = 8

  • HEADER_NOT_ALLOWED = 9

  • SEPARATOR_NOT_ALLOWED = 10

  • HEADER_TOO_LONG = 11

  • UNKNOWN_DP_ERROR = 12

  • ACCESS_DENIED = 13

  • DP_OUT_OF_MEMORY = 14

  • DISK_FULL = 15

  • DP_TIMEOUT = 16

  • OTHERS = 17

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

********

IF sy-subrc EQ 0.

zabpsp_01-kunnr = ITAB-IKUNNR.

zabpsp_01-matnr = ITAB-IMATNR.

zabpsp_01-adrnr = ITAB-IADRNR.

WRITE : / ' UPLOAD SUCCESS ' .

ENDIF.

\[subject changed, don't write everything in upper case!\]

Edited by: Jan Stallkamp on Aug 6, 2008 2:39 PM

5 REPLIES 5
Read only

Former Member
0 Likes
733

Hi Doss,

you code will not update database table, but it will populate values in work area ZABPSP_01.

You have to add following code at the end

UPDATE ZABPSP_01 FROM ZABPSP_01.

Regards,

Mohaiyuddin

Read only

Former Member
0 Likes
733

Hi Doss,

Sorry . I have got it Wrong.

Regards,

Chandra Sekhar

Read only

0 Likes
733

i have added the code at last , its not working yet.....!!!!

Read only

vinod_vemuru2
Active Contributor
0 Likes
733

Hi,

After upload modify the code like below. Also change the file name as some one suggested already.

CALL GUI_UPLOAD FM.

IF sy-subrc EQ 0

IF NOT itab[] IS INITIAL.

MODIFY ZABPSP_01 FROM TABLE itab[].

WRITE : / ' UPLOAD SUCCESS ' .

ELSE.

WRITE 'No data in file'.

ENDIF.

ELSE.

WRITE 'Upload failure'.

ENDIF.

Thanks,

Vinod.

Read only

vinod_vemuru2
Active Contributor
0 Likes
733

Hi,

After upload modify the code like below. Also change the file name as some one suggested already. If u are still facing problems then check in debug mode what is happening after FM call.


CALL GUI_UPLOAD FM.
IF sy-subrc EQ 0 
IF NOT itab[] IS INITIAL.
MODIFY ZABPSP_01 FROM TABLE itab.
WRITE : / ' UPLOAD SUCCESS ' .
ELSE.
WRITE 'No data in file'.
ENDIF.
ELSE.
WRITE 'Upload failure'.
ENDIF.

Thanks,

Vinod.