REPORT ytestdp60
NO STANDARD PAGE HEADING
LINE-SIZE 256
LINE-COUNT 65
.
DATA: BEGIN OF his_tab OCCURS 0,
vbeln(10),
item(10),
price(15),
END OF his_tab.
DATA: wa_upload LIKE his_tab.
DATA: wa_upload1 LIKE his_tab.
PARAMETERS: file LIKE rlgrap-filename DEFAULT 'D:\Corn 2007-12.xls'.
DATA : gt_intern TYPE alsmex_tabline OCCURS 0 WITH HEADER LINE.
FIELD-SYMBOLS : <fs>.
DATA: v_idx TYPE i VALUE '1'.
DATA: v_idx1 TYPE i VALUE '1'.
DATA: bdiff(10) TYPE p DECIMALS 2.
DATA: sdif1(10) TYPE p DECIMALS 2.
DATA: sdif2(10) TYPE p DECIMALS 2.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR file.
PERFORM get_filename USING file.
START-OF-SELECTION.
* Upload the Excel file .
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = file
i_begin_col = 1
i_begin_row = 1
i_end_col = 29
i_end_row = 9999
TABLES
intern = gt_intern
* 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.
* format the data and upload into the itab.
LOOP AT gt_intern.
MOVE gt_intern-col TO v_idx.
ASSIGN COMPONENT v_idx OF STRUCTURE wa_upload TO <fs>.
MOVE gt_intern-value TO <fs>.
AT END OF row.
MOVE wa_upload TO his_tab.
APPEND his_tab. CLEAR his_tab.
ENDAT.
ENDLOOP.
*&---------------------------------------------------------------------*
*& Form get_filename
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_FNAME text
*----------------------------------------------------------------------*
FORM get_filename USING p_fname.
***To read the file from Presentation Server
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
program_name = sy-repid
dynpro_number = syst-dynnr
field_name = p_fname
* STATIC = ' '
* mask = '*.XLS'
CHANGING
file_name = p_fname
EXCEPTIONS
mask_too_long = 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.
ENDFORM. " get_filename
No comments:
Post a Comment