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

Upload data from excel grid into an internal table

Former Member
0 Likes
1,356

I have an excel grid which looks like the following

DI D2 D3

O1 1 1 2

O2 1 1 1

O3 2 2 2

I need to get the crosssection of the D and the O Lines to give the following output in an internal table .

O1,D1,1

O1,D2,1

O1,D3,2

O2,D1,1

O2.D2,1

and so on .

Any suggestions on how to proceed with this .Also the D and the O cloums and rows can vary in number

Thanks in advance.

I have an excel grid which looks like the following

DI D2 D3

O1 1 1 2

O2 1 1 1

O3 2 2 2

I need to get the crosssection of the D and the O Lines to give the following output in an internal table .

O1,D1,1

O1,D2,1

O1,D3,2

O2,D1,1

O2.D2,1

and so on .

Any suggestions on how to proceed with this .Also the D and the O cloums and rows can vary in number

Thanks in advance.

9 REPLIES 9
Read only

Former Member
0 Likes
1,312

Hi Anjali Panday,

Your question is not clear...

However an offer might be such a thing that you prepare your data through excel and create a clear structure there.

Later is easy, you can use ALSM_EXCEL_TO_INTERNAL_TABLE function...

Or create a .txt file from your excel file and then uploading your data into itab.

Hope helps.

deniz.

Read only

0 Likes
1,312

I dont have access to ALSM_EXCEL_TO_INTERNAL_TABLE .

Thanks

Read only

0 Likes
1,312

hi.

wat you mean by " you dont have access to ALSM_EXCEL_TO_INTERNAL_TABLE".

its a function module and you can call that FM from ur se38 editor.

revert back if ay issues.

Regards

Naveen

Read only

0 Likes
1,312

Hi,

You can use then

GUI_UPLOAD function.

But first save your excel file as tab delimeted text file(.txt) file

and use this file with this function.

deniz.

Read only

Former Member
0 Likes
1,312

as i know if you want to upload you excel file........

you have to do two things....firstly you use ALSM_EXCEL_TO_INERNAL_TABLE function module then after you use field symbol to display file content in proper manner,....if you are not using concept of field symbols,your excel file will not display in proper row and column.

Read only

0 Likes
1,312

>

>if you are not using concept of field symbols,your excel file will not display in proper row and column.

Completely nonsence

Read only

Former Member
0 Likes
1,312

Do you want this..

REPORT  ztest_transpose.

DATA: BEGIN OF itab OCCURS 0,
       col(2),
       d1 TYPE n,
       d2 TYPE n,
       d3 TYPE n,
      END OF itab.

DATA: BEGIN OF it_final OCCURS 0,
       col(2),
       col2(2),
       d TYPE n,
      END OF it_final.

itab-col = 'O1'.
itab-d1 = 1.
itab-d2 = 1.
itab-d3 = 2.
APPEND itab.
itab-col = 'O2'.
itab-d1 = 1.
itab-d2 = 1.
itab-d3 = 1.
APPEND itab.
itab-col = 'O3'.
itab-d1 = 2.
itab-d2 = 2.
itab-d3 = 2.
APPEND itab.

SORT itab BY col.
FIELD-SYMBOLS:  <fs>.
DATA: ind TYPE n,
      val(10).

LOOP AT itab.
  it_final-col = itab-col.
  ind = 1.
  DO 3 TIMES.
    CONCATENATE 'ITAB-D' ind INTO val.
    ASSIGN (val) TO <fs>.

    it_final-d = <fs>.
    it_final-col2 = val+5(2).
    APPEND it_final.
    WRITE:/ it_final.
    ind = ind + 1.

  ENDDO.

ENDLOOP.

Read only

Former Member
0 Likes
1,312

Hi,

My suggestion would be u save the excel content as .txt file

and use the FM - GUI_upload.

This will upload the data in ur internal table.

All the best.

Regards,

Mohammadi.

Read only

Former Member
0 Likes
1,312

Hi,

Any ways there are also a couple of alternatives which use fucntion modules 'KCD_EXCEL_OLE_TO_INT_CONVERT'

and 'ALSM_EXCEL_TO_INTERNAL_TABLE' but the method below is the simplest method to used.

And these are all SAP standard function modules so you will have all of them.

plz check this example :

TYPE-POOLS: truxs.

PARAMETERS: p_file TYPE  rlgrap-filename.

TYPES: BEGIN OF t_datatab,
      col1(30)    TYPE c,
      col2(30)    TYPE c,
      col3(30)    TYPE c,
      END OF t_datatab.
DATA: it_datatab type standard table of t_datatab,
      wa_datatab type t_datatab.

DATA: it_raw TYPE truxs_t_text_data.

* At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  CALL FUNCTION 'F4_FILENAME'
    EXPORTING
      field_name = 'P_FILE'
    IMPORTING
      file_name  = p_file.


***********************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.

  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
*     I_FIELD_SEPERATOR        =
      i_line_header            =  'X'
      i_tab_raw_data           =  it_raw       " WORK TABLE
      i_filename               =  p_file
    TABLES
      i_tab_converted_data     = it_datatab[]    "ACTUAL DATA
   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.


***********************************************************************
* END-OF-SELECTION.
END-OF-SELECTION.
  LOOP AT it_datatab INTO wa_datatab.
    WRITE:/ wa_datatab-col1,
            wa_datatab-col2,
            wa_datatab-col3.
  ENDLOOP.

thanx.