Wednesday, November 01, 2006

interesting problem

Eventhough you work for a long time in programming, say in ABAP, it is very difficult to keep in touch with all the evolving technoloagy and the concepts. and practical requirements are pretty simple and that do not need much of the complex programming techniques.

Most of the trivial programming requiremets are such as GUI operations, MS office interface, etc., can be easily built using the standard functions and can be kept as a tool kit. This will obviously be a effective methadology, as you don't have to dig over and over for the most common jobs.

Let me start posting the ABAP routines, I've developed, which can be used in any implementation.

The first posting will be a reading Excel file from the presentation server. This upload will take care of the excel files which contain macros as well.

Try and let's know if you are having fun

*&---------------------------------------------------------------------*
*& Report ZZ_TEST_EXCEL_LOAD *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*

REPORT ZZ_TEST_EXCEL_LOAD .

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.

No comments: