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

Doubt about function ALSM_EXCEL_TO_INTERNAL_TABLE.

ronaldo_aparecido
Contributor
0 Likes
1,500

Hy Guys.

I am using the function ALSM_EXCEL_TO_INTERNAL_TABLE a file. 'Csv' the Structure is :

7034-0040-13.000,00CD9999.99.99

Four columns.

Why the return of function returns:?

   Row  Column   Value


000100017034-0040-1;3.000
0001000200;CD;9999.99.99

should be correct is:

7034-0040-1

3.000

....

...

.....Etc.

My code is

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

     EXPORTING

       filename                = p_file

       i_begin_col             = 1

       i_begin_row             = 2

       i_end_col               = 4

       i_end_row               = 65000

     TABLES

       intern                  = t_itab

     EXCEPTIONS

       inconsistent_parameters = 1

       upload_ole              = 2

       OTHERS                  = 3.

   IF sy-subrc <> 0.

See attacheds:

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,347

That function module only returns all the values in the cell. The we have to loop at it.

    LOOP AT T_Itab.

     AT END OF ROW.


          COLLECT LW_structure INTO T_structure.



      ENDAT.

endloop.

If you have a CSV file, then I believe, you could use something as simple as GUI_UPLOAD, which would format the file according to your needs.

5 REPLIES 5
Read only

Former Member
0 Likes
1,348

That function module only returns all the values in the cell. The we have to loop at it.

    LOOP AT T_Itab.

     AT END OF ROW.


          COLLECT LW_structure INTO T_structure.



      ENDAT.

endloop.

If you have a CSV file, then I believe, you could use something as simple as GUI_UPLOAD, which would format the file according to your needs.

Read only

venkateswaran_k
Active Contributor
0 Likes
1,347

Please update your t_itab structure.

it should have four columns.

Example,

Create internal table

DATA: BEGIN OF IT_TABLE OCCURS 0,
          COLUMN1  TYPE C LENGTH 10,
          COLUMN2  TYPE C LENGTH 10,
          COLUMN3  TYPE C LENGTH 10,
          COLUMN4  TYPE C LENGTH 10,
      END OF IT_TABLE.

transfer the vaue to internal table


LOOP AT T_ITAB.
CASE T_ITAB-COL.
  WHEN '0001.
     MOVE T_ITAB-VALUE TO IT_TABLE-COLUMN1.
  WHEN '0002'.
     MOVE T_ITAB-VALUE TO IT_TABLE-COLUMN2.

  WHEN '0003'.
     MOVE T_ITAB-VALUE TO IT_TABLE-COLUMN3.
  WHEN '0004'.
     MOVE T_ITAB-VALUE TO IT_TABLE-COLUMN4.

  AT END OF ROW.
    APPEND IT_TABLE.
ENDLOOP.

Regards,Venkat

Read only

0 Likes
1,347

Hi,

If you dont't want to use that then use this FM - TEXT_CONVERT_XLS_TO_SAP. It will put the the data as per the required structure - no extra processing is required.

  TYPE-POOLS:truxs.

  DATA: l_it_raw      TYPE  truxs_t_text_data. " for Excel file

  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

    EXPORTING

      i_line_header        = 'X'

      i_tab_raw_data       = l_it_raw      "This is blank internal table

      i_filename           = p_file   "File Name with path

    TABLES

      i_tab_converted_data = pc_it_map_data       "In this internal table data will be uploaded

    EXCEPTIONS

      conversion_failed    = 1

      OTHERS               = 2.

Read only

Former Member
0 Likes
1,347

HI,

Try this one

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

     EXPORTING

       filename                = p_file

       i_begin_col             = '1'

       i_begin_row             = '2'

       i_end_col               = '256'

       i_end_row               = '65000'

     TABLES

       intern                  = t_itab

     EXCEPTIONS

       inconsistent_parameters = 1

       upload_ole              = 2

       OTHERS                  = 3.

   IF sy-subrc <> 0.

   ENDIF.


Or  check the below image and remove the check box in excel format and run ur program.

Read only

former_member209120
Active Contributor
0 Likes
1,347

Hi

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

     EXPORTING

       filename                = p_file

       i_begin_col             = 1

       i_begin_row             = 2

       i_end_col               = 4

       i_end_row               = 65000

     TABLES

       intern                  = t_itab

     EXCEPTIONS

       inconsistent_parameters = 1

       upload_ole              = 2

       OTHERS                  = 3.

   IF sy-subrc <> 0.


Your code is ok

See this wiki page to know about ALSM_EXCEL_TO_INTERNAL_TABLE  for better understanding.

http://wiki.scn.sap.com/wiki/display/Snippets/How+to+use++FM+ALSM_EXCEL_TO_INTERNAL_TABLE