Skip to Content
0
Jun 15, 2006 at 06:45 AM

couple of issues regarding abap oo

16 Views

Hello experts,

1. My file_open_dialog seems not to work. when I browse for the file it seems that it doesnt process it.

2. I want to put my structures and itabs in my class but it seems not to work fine. How do I go about this?

Anyway, below is my practice code. Again, thank you guys and take care!

REPORT z_aris_bdc_practice_1

NO STANDARD PAGE HEADING

LINE-SIZE 0

LINE-COUNT 0.

TYPES: t_bdctab TYPE bdcdata,

t_bdcmsg TYPE bdcmsgcoll.

TYPES: BEGIN OF t_data,

user TYPE usr02-bname,

title TYPE sza5_d0700-title_medi,

lastname TYPE addr3_data-name_last,

firstname TYPE addr3_data-name_first,

language TYPE addr3_data-langu_p,

email TYPE sza5_d0700-smtp_addr,

comm_type TYPE addr3_data-deflt_comm,

alias TYPE usrefus-useralias,

password1(8),

password2(8),

END OF t_data.

DATA: it_bdctab TYPE STANDARD TABLE OF t_bdctab,

it_bdcmsg TYPE STANDARD TABLE OF t_bdcmsg,

it_data TYPE STANDARD TABLE OF t_data.

DATA: i_filetable TYPE filetable,

i_rc TYPE i.

----


  • CLASS itab DEFINITION

----


  • ........ *

----


CLASS itab DEFINITION.

PUBLIC SECTION.

METHODS: open,

upload IMPORTING value(v_filename) TYPE c.

PROTECTED SECTION.

ENDCLASS.

----


  • CLASS itab IMPLEMENTATION

----


  • ........ *

----


CLASS itab IMPLEMENTATION.

METHOD open.

ENDMETHOD.

METHOD upload.

FIELD-SYMBOLS: <fs_data> LIKE LINE OF it_data.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = v_filename

filetype = 'DAT'

TABLES

data_tab = it_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.

ENDMETHOD.

ENDCLASS.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS: p_file LIKE rlgrap-filename.

SELECTION-SCREEN END OF BLOCK b1.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL METHOD cl_gui_frontend_services=>file_open_dialog

EXPORTING

window_title = 'Import from a local file'

default_extension = 'DAT'

initial_directory = 'C:\'

CHANGING

file_table = i_filetable

rc = i_rc

EXCEPTIONS

file_open_dialog_failed = 1

cntl_error = 2

error_no_gui = 3

OTHERS = 4.

IF sy-subrc <> 0.

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

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

ENDIF.

START-OF-SELECTION.

DATA: itab TYPE REF TO itab.

CREATE OBJECT itab.

CALL METHOD itab->upload EXPORTING v_filename = p_file.

CHECK NOT it_data[] IS INITIAL.