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

Problem reading xls file from App Server

Former Member
0 Likes
712

Hi,

I am trying to read an excel file that is present in the app server.

Have downloaded the file from the SAP content server into an internal table using the FM BAPI_DOCUMENT_GETDETAIL2,

and also the FM  SCMS_R3DB_GET (this gets the data in binary form in the internal table data_bin)

Now I need this in regular text in an internal table, so I can manipulate and use the data,

I am also able to download this data into the app server as an xls file. But not sure how to read it , would be great if it can be read as a string.

Appreciate any input, to either convert the data_bin in the FM SCMS_R3DB_GET , or read an excel file from the app  server.

Thank you

Lalitha

3 REPLIES 3
Read only

Former Member
0 Likes
606

Hi,

     you can read the file from the application server by using the statements

        open dataset, read dataset and close dataset.

Regards,

Anvesh

Read only

Former Member
0 Likes
606

Hi,

Try this

OPEN DATASET 'file name' FOR INTPUT IN BINARY MODE ENCODING DEFAULT.

DO.

READ DATASET

IF SY-SUBRC NE 0.

EXIT.

ELSE.

  Fill to Internal table.

ENDIF.

ENDDO.

CLOSE DATASET.

Thanks&Regards,

Shankar Darbha

Read only

Former Member
0 Likes
606

Hi Lalitha i use this code to get the file data in string format and it is met with your problem i hope.

Thanks.

TYPES : BEGIN OF T_MAT,

         MATNR(18) TYPE C,

         MTART(4) TYPE C,

         MBRSH(1) TYPE C,

         MEINS(3) TYPE C,

        END OF T_MAT.

TYPES : TT_MAT TYPE STANDARD TABLE OF T_MAT.

DATA : LW_MAT TYPE T_MAT,

       LT_MAT TYPE TT_MAT.

DATA : V_DSN(100) TYPE C.

START-OF-SELECTION.

  PERFORM GET_DATA.

PERFORM WRITE_FILE_ON_APPL_SVR.

*&---------------------------------------------------------------------*

*&      Form  get_data

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*  -->  p1        text

*  <--  p2        text

*----------------------------------------------------------------------*

FORM GET_DATA .

  SELECT MATNR MTART MBRSH MEINS FROM MARA

                     INTO TABLE LT_MAT

UP TO 3 ROWS.

ENDFORM.                    " get_data

*&---------------------------------------------------------------------*

*&      Form  write_file_on_appl_svr

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*  -->  p1        text

*  <--  p2        text

*----------------------------------------------------------------------*

FORM WRITE_FILE_ON_APPL_SVR .

  V_DSN = '/usr/sap/LID/DVEBMGS00/work/material.txt'.

OPEN DATASET V_DSN FOR OUTPUT IN TEXT MODE

                             ENCODING DEFAULT.

  IF SY-SUBRC EQ 0.

    LOOP AT LT_MAT INTO LW_MAT.

      TRANSFER LW_MAT TO V_DSN.

CLEAR LW_MAT.

    ENDLOOP.

    WRITE : / 'File created ' , v_dsn.

  ELSE.

    WRITE : / 'File could not open'.

  ENDIF.

CLOSE DATASET V_DSN.

ENDFORM.