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

gui_upload

Former Member
0 Likes
558

hi friends,

how can i upload the data from notepad to database table...send me a sample code...help me please....

4 REPLIES 4
Read only

Former Member
0 Likes
528

First...Try to do it yourself...If you get stucked...Post your code and we will help you...

Greetings,

Blag.

Read only

Former Member
0 Likes
528

This is a sample program -

TYPE-POOLS: truxs.

DATA: i_text_data TYPE truxs_t_text_data,

v_filename_string TYPE string.

DATA: BEGIN OF itab OCCURS 0,

Name(30),

Phone(15),

Fax(500).

DATA: END OF itab.

PARAMETERS: p_file LIKE rlgrap-filename.

START-OF-SELECTION.

v_filename_string = p_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = v_filename_string

filetype = 'ASC'

has_field_separator = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

dat_mode = ''

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

data_tab = i_text_data

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.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

i_field_seperator = 'X'

  • I_LINE_HEADER =

i_tab_raw_data = i_text_data

i_filename = p_file

TABLES

i_tab_converted_data = itab

EXCEPTIONS

conversion_failed = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

In your case file structure should be same as database table structure. You need to make sure that file is uploaded correctly.

It is not advisable to updated db tables directly (except they are custom tables).

Read only

Former Member
0 Likes
528

Use FM GUI_upload .....to copy data from notepad to internal table....

Use insert/update/modify statements ...to update data from internal table to database table....

Regards

Vasu

Read only

Former Member
0 Likes
528
  • Input file structure

TYPES: BEGIN OF ty_input,

drcrk, " Debit/Credit Indicator

poper(3), " Posting Perid

kostl(10), " cost centre "+sonalis04042007

rprctr(10), " Profit Center

racct(10), " Account number

hsl(18), " Amount

sgtxt(50), " Text

flag(1), " flag for pc n cc "+sonalis04042007

refdocnr(10), " FI Doc. No. "+sonalis28022007

END OF ty_input.

TYPE-POOLS: pcpp.

SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-t01.

PARAMETERS: pr_kokrs TYPE lips-kokrs OBLIGATORY, "+sonalis27032007

" Controlling Area

pr_bukrs TYPE bukrs OBLIGATORY, " Company Code

pr_gjahr TYPE gjahr OBLIGATORY, " Business year

pr_date TYPE budat OBLIGATORY, " Posting Date

pr_docct TYPE docct OBLIGATORY, " Document Category

pr_lines TYPE i OBLIGATORY, " Lines per document

pr_file TYPE rlgrap-filename OBLIGATORY , " File name

pr_docty TYPE rglsi-docty DEFAULT 'LO'. " Document Type

SELECTION-SCREEN END OF BLOCK blk1.

*FOR F4 HELP

AT SELECTION-SCREEN ON VALUE-REQUEST FOR pr_file. "-sonalis27032007

PERFORM f001_f4_filename CHANGING pr_file.

FORM f001_f4_filename CHANGING exp_file TYPE ibipparms-path.

CALL FUNCTION 'F4_FILENAME'

IMPORTING

file_name = exp_file.

ENDFORM. " F001_F4_FILENAME

TO UPLOAD DATA IN INTERNAL TABLE

FORM f002_upload_data .

DATA: l_filenm TYPE string.

l_filenm = pr_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = l_filenm

has_field_separator = 'X'

TABLES

data_tab = it_input

EXCEPTIONS

OTHERS = 1.

IF sy-subrc <> 0.

MESSAGE e208(00) WITH text-e01.

ENDIF.

ENDFORM. " F002_UPLOAD_DATA