Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Reading TIME from excel to internal table

Hi,

I have to upload data from an excelsheet to internal table and display as list using a report.

The code is as mentioned below:


REPORT  zpm_upload_seat_allocation.

TYPES: BEGIN OF t_exceldata,

         equnr(10)     TYPE c,
         qmnum(18)     TYPE c,
         kostl(12)     TYPE c,
         status(4)     TYPE c,
         startdate(8)  TYPE c,
         enddate(8)    TYPE c,
         starttime(12) TYPE c,
         endtime(12)   TYPE c,

       END OF t_exceldata.

TYPE-POOLS: truxs.

PARAMETERS: p_file TYPE rlgrap-filename.

DATA: lt_exceldata TYPE STANDARD TABLE OF t_exceldata,
          ls_exceldata TYPE t_exceldata.

DATA: lt_raw TYPE truxs_t_text_data.

* At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

  CALL FUNCTION 'F4_FILENAME'
   EXPORTING
*   PROGRAM_NAME        = SYST-CPROG
*   DYNPRO_NUMBER       = SYST-DYNNR
     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             = lt_raw
      i_filename                 = p_file
    TABLES
      i_tab_converted_data       = lt_exceldata[]
   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 lt_exceldata INTO ls_exceldata.
    WRITE:/ ls_exceldata-equnr,
            ls_exceldata-qmnum,
            ls_exceldata-kostl,
            ls_exceldata-status,
            ls_exceldata-startdate,
            ls_exceldata-enddate,
            ls_datatab-starttime,
            ls_datatab-endtime.

  ENDLOOP.

Excel sheet has last two fields for Starttime and Endtime with values for eg:

Starttime 5:39:51 and

Endtime 17:39:53 .

In debuging when I check the internal table lt_exceldata has

Starttime 0.2360069444 and

Endtime 0.7360300925

And the same is printed as list output.

How to display time in proper format in list output?

Regards,

Anubhav

Former Member replied

Hi,

You may try using the FM ALSM_EXCEL_TO_INTERNAL_TABLE

See if it solves your problem.

Regards.

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question