Skip to Content

couple of issues regarding abap oo

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 15, 2006 at 07:00 AM

    are you getting a short dump?

    it could be because of-

    CALL FUNCTION 'GUI_UPLOAD'

    EXPORTING

    filename = <b>v_filename</b>

    filetype = 'DAT'

    TABLES

    data_tab = it_data

    EXCEPTIONS

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Aris Hidalgo

      HI Viray,

      Try this:

      • Retrieve data file from presentation server(Upload from PC)

      DATA: i_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.

      DATA: begin of it_datatab occurs 0,

      row(500) type c,

      end of it_datatab.

      CALL FUNCTION 'GUI_UPLOAD'

      EXPORTING

      filename = i_file

      filetype = 'ASC'

      TABLES

      data_tab = it_datatab "ITBL_IN_RECORD[]

      EXCEPTIONS

      file_open_error = 1

      OTHERS = 2.

      change the name of i_file as per your requirement and use the it_datatab contents for your further processing.

      Thanks & Regards,

      YJR.

  • author's profile photo Former Member
    Former Member
    Posted on Jun 15, 2006 at 07:22 AM

    Hi,

    <b>DATA: i_filetable TYPE filetable,</b>

    What does above command means...

    <b>it_data TYPE STANDARD TABLE OF t_data.</b>

    why are you defining internal table of standard type...

    kindly reqrds points

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 15, 2006 at 08:21 AM

    Hi,

    I have corrected ur code to get the file name.

    &----


    *& Report ZZTEST1223 *

    *& *

    &----


    *& *

    *& *

    &----


    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_fileline TYPE LINE OF 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. "itab DEFINITION

    ----


    • CLASS itab IMPLEMENTATION

    ----


    • ........ *

    ----


    CLASS itab IMPLEMENTATION.

    METHOD open.

    ENDMETHOD. "open

    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. "upload

    ENDCLASS. "itab IMPLEMENTATION

    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.

    ELSE.

    <b> READ TABLE i_filetable INTO i_fileline INDEX i_rc.

    IF sy-subrc EQ 0.

    p_file = i_fileline.

    ENDIF.</b>

    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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.