2009 Oct 07 12:37 PM
OrderType Product Type Material Num Source Target Slocation 5/14/2009 5/15/2009
R SIMULATION PALM100HK 408415 1052 FIH1 2902 2349
above the excel file date i am using the FM ALSM_EXCEL_TO_INTERNAL_TABLE'
5/14/2009 is delivery date and 2902 is Quantity .Now how can i read the delivery date and Quanity separately , delivery date is in the header .
2009 Oct 07 1:01 PM
Hello
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_path
.......
TABLES
intern = Itab.
read table itab with key row = 1 col = 7. " <= delivery date
if sy-subrc = 0.
del_date = itab-value.
endif.
read table itab with key row = 2 col = 7. " <= quantity
if sy-subrc = 0.
quantity = itab-value.
endif.
2009 Oct 07 2:12 PM
Hi,
Try using Function Module:
DATA: it_raw TYPE truxs_t_text_data.
&----
*&Function module called to upload xls data into an internal table
&----
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
i_line_header = 'X'
i_tab_raw_data = it_raw
i_filename = p_file "file path browsed
TABLES
i_tab_converted_data = it_upload[] "int table populated having struc same as files data
EXCEPTIONS
conversion_failed = 1 "browsed file's data
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.
Hope it helps,
Regards,
Mansi
2009 Oct 12 12:20 PM
Example
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS: P_FILE LIKE RLGRAP-FILENAME.
SELECTION-SCREEN END OF BLOCK B1.
At selection-screen on value-request for P_FILE.
perform get_file_name.
FORM get_file_name.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
* EXPORTING
* PROGRAM_NAME = SYST-REPID
* DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = ' '
* STATIC = ' '
* MASK = ' '
CHANGING
file_name = P_FILE
* 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.
START-OF-SELECTION.
PERFORM upload_file TABLES itab
USING p_file.
FORM upload_file TABLES p_it_tab USING p_file.
FIELD-SYMBOLS : <fs>.
*BREAK DEVELOPER.
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 = '10000'
TABLES
intern = l_intern
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc NE 0.
FORMAT COLOR COL_BACKGROUND INTENSIFIED.
WRITE : / 'File Error'.
EXIT.
ENDIF.
IF l_intern[] IS INITIAL.
FORMAT COLOR COL_BACKGROUND INTENSIFIED.
WRITE : / 'No Data Uploaded'.
EXIT.
ELSE.
SORT l_intern BY row col.
LOOP AT l_intern.
MOVE l_intern-col TO l_index.
ASSIGN COMPONENT l_index OF STRUCTURE p_it_tab TO <fs>.
MOVE l_intern-value TO <fs>.
AT END OF row.
APPEND p_it_tab.
CLEAR p_it_tab.
ENDAT.
ENDLOOP.
ENDIF.
Edited by: krupa jani on Oct 12, 2009 1:27 PM
2010 Jun 10 5:35 PM