Skip to Content
author's profile photo Former Member
Former Member

data uploading frm excel sheet to itab thr FM "ALSM_EXCEL_TO_INTERNAL_TABLE

hi all,

I am uploading the data from excel sheet to an internal table using the FM 'ALSM_EXCEL_TO_INTERNAL_TABLE' but its getting dumped, please let me know what all decleration i have to do before using this FM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 22, 2008 at 06:31 AM

    Hi Pavan,

    use the FM ALSM_EXCEL_TO_INTERNAL_TABLE.

    codePARAMETERS:

    P_INFL like RLGRAP-FILENAME.

    DATA:

    BEGIN OF T_DATA1 OCCURS 0,

    RESOURCE(25) TYPE C,

    DATE(10) TYPE C,

    DURATION TYPE P DECIMALS 2,

    ACTIVITY(25) TYPE C,

    B_NBILL(1) TYPE C,

    END OF T_DATA1,

    T_DATA TYPE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.

    BEGIN OF T_FINAL OCCURS 0,

    RESOURCE(25) TYPE C,

    DATE(10) TYPE C,

    DURATION(15) TYPE C,

    ACTIVITY(25) TYPE C,

    B_NBILL(10) TYPE C,

    END OF T_FINAL.

    DATA : HEADER TYPE XSTRING.

    Work Variables Declaration.

    CONSTANTS:

    W_Y TYPE C VALUE 'Y',

    W_N TYPE C VALUE 'N'.

    Work area.

    DATA:

    WA_DATA LIKE T_FINAL.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_INFL.

    PERFORM GET_FILENAME CHANGING P_INFL.

    -


    START-OF-SELECTION.

    -


    PERFORM UPLOAD_DATA_FROMEXCEL.

    FORM UPLOAD_DATA_FROMEXCEL.

    Downloading the data from presentation server

    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

    EXPORTING

    FILENAME = p_infl

    I_BEGIN_COL = 1

    I_BEGIN_ROW = 2

    I_END_COL = 8

    I_END_ROW = 1000

    TABLES

    INTERN = T_DATA

    EXCEPTIONS

    INCONSISTENT_PARAMETERS = 1

    UPLOAD_OLE = 2

    OTHERS = 3.

    IF SY-SUBRC 0.

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

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

    ENDIF.

    ENDFORM. " upload_data_fromexcel

    &----


    *& Form process_data

    &----


    text

    -


    FORM PROCESS_DATA .

    T_FINAL-RESOURCE = 'Resource'.

    T_FINAL-DATE = 'Date'.

    T_FINAL-DURATION = 'Duration'.

    T_FINAL-ACTIVITY = 'Activity'.

    T_FINAL-B_NBILL = 'Billable'.

    APPEND T_FINAL.

    SORT T_DATA BY ROW COL.

    LOOP AT T_DATA.

    CASE T_DATA-COL.

    WHEN 3.

    T_DATA1-RESOURCE = T_DATA-VALUE.

    WHEN 4.

    T_DATA1-DATE = T_DATA-VALUE.

    WHEN 5.

    T_DATA1-DURATION = T_DATA-VALUE.

    WHEN 6.

    t_data1-activity = t_data-value.

    WHEN 7.

    T_DATA1-B_NBILL = T_DATA-VALUE.

    ENDCASE.

    AT END OF ROW.

    COLLECT T_DATA1.

    ENDAT.

    ENDLOOP.

    LOOP AT T_DATA1.

    T_FINAL-RESOURCE = T_DATA1-RESOURCE.

    T_FINAL-DATE = T_DATA1-DATE.

    T_FINAL-DURATION = T_DATA1-DURATION.

    T_FINAL-ACTIVITY = T_DATA1-ACTIVITY.

    T_FINAL-B_NBILL = T_DATA1-B_NBILL.

    APPEND T_FINAL.

    ENDLOOP.

    ENDFORM. " process_data

    &----


    *& Form get_filename

    &----


    FORM GET_FILENAME CHANGING P_FILENAME.

    CALL FUNCTION 'WS_FILENAME_GET'

    EXPORTING

    DEF_FILENAME = SPACE

    DEF_PATH = P_FILENAME

    MASK = ',. ,..'

    MODE = 'O' " O = Open, S = Save

    TITLE = BOX_TITLE

    IMPORTING

    FILENAME = P_FILENAME

    EXCEPTIONS

    INV_WINSYS = 1

    NO_BATCH = 2

    SELECTION_CANCEL = 3

    SELECTION_ERROR = 4

    OTHERS = 5.

    *

    CASE SY-SUBRC.

    WHEN 1.

    MESSAGE I999 WITH

    'File selector not available on this windows system'(046).

    WHEN 2.

    MESSAGE E999 WITH

    'Frontend function cannot be executed in background'(047).

    WHEN 3.

    MESSAGE I999 WITH 'Selection was cancelled'(048).

    WHEN 4.

    MESSAGE E999 WITH 'Communication error'(049).

    WHEN 5.

    MESSAGE E999 WITH 'Other error'(050).

    ENDCASE.

    ENDFORM. " get_filename[/code]

    Regards,

    Shiva Kumar

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 22, 2008 at 09:20 AM

    hi

    Check this sample code.

    FIELD-SYMBOLS:  <fs_mara> TYPE ANY.
    
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = p_file
          i_begin_col             = 1
          i_begin_row             = 1
          i_end_col               = 5
          i_end_row               = 4
        TABLES
          intern                  = t_tab
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          OTHERS                  = 3.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    
      LOOP AT t_tab.
        ASSIGN COMPONENT t_tab-col OF STRUCTURE t_mara TO <fs_mara>.
        WRITE t_tab-value TO <fs_mara>.
        AT END OF row.
          APPEND t_mara.
        ENDAT.
    
      ENDLOOP.

    regards

    padma

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 22, 2008 at 06:55 AM

    code is :---

    data: it_upload type ALSMEX_TABLINE occurs 0 with header line.

    PARAMETERS:

    p_file type RLGRAP-FILENAME.

    Data: p_file1 type RLGRAP-FILENAME.

    *break-point.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

    CALL FUNCTION 'F4_FILENAME'

    EXPORTING

    program_name = syst-cprog

    dynpro_number = syst-dynnr

    field_name = ''

    IMPORTING

    file_name = p_file.

    start-of-selection.

    perform upload_data1.

    p_file1 = p_file.

    " upload_data

    &----


    *& Form upload_data1

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form upload_data1 .

    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

    EXPORTING

    filename = p_file1

    i_begin_col = 1

    i_begin_row = 1

    i_end_col = 15

    i_end_row = 4

    tables

    intern = it_upload

    • EXCEPTIONS

    • INCONSISTENT_PARAMETERS = 1

    • UPLOAD_OLE = 2

    • OTHERS = 3

    .

    IF sy-subrc <> 0.

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

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

    ENDIF.

    endform. " upload_data1

    please help me.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 22, 2008 at 06:58 AM

    Hi,

    Check this sample code

    REPORT  z_file3.
    
    DATA: fname(40),
          w_line TYPE i VALUE 1,
          w_file TYPE rlgrap-filename.
    
    DATA:
      t_tab LIKE
      TABLE OF ALSMEX_TABLINE
      WITH HEADER LINE.
    
    DATA: fs_tab LIKE LINE OF t_tab.
    
    
    w_file = 'C:\Documents and Settings\ABC\Desktop\Book1.xls'.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        filename                      = w_file
        i_begin_col                   = 1
        i_begin_row                   = 1
        i_end_col                     = 10
        i_end_row                     = 100
      tables
        intern                        = t_tab
     EXCEPTIONS
       INCONSISTENT_PARAMETERS       = 1
       UPLOAD_OLE                    = 2
       OTHERS                        = 3
              .
    IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ELSE.
      WRITE: 'UPLOAD SUCCESSFUL'.
    ENDIF.
    
    fname = '.\z_file.xls'.
    OPEN DATASET fname FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    LOOP AT t_tab INTO fs_tab.
      TRANSFER fs_tab TO fname.
    ENDLOOP.
    
    IF sy-subrc EQ 0.
      WRITE: / 'FILE OPENED ON APPS SERVER'.
    ELSE.
      WRITE: / 'FILE COULD NOT BE OPENED'.
    ENDIF.
    

    Regards

    Abhijeet

    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.