2009 May 18 11:02 AM
Hi
Please let me know the code to read a xls or csv file from the SAP application unix server.I had written the code,but in case of xls file the output is junk values.
OUTPUT:###########3 OK &&&&&&&&&&&&&
is coming like this.
code:
DATA:BEGIN OF itab OCCURS 0,
matl_type(4) TYPE c,
matl_group(9) TYPE c,
matl_desc(40) TYPE c,
char_prof(18) TYPE c,
END OF itab.
DATA:wa LIKE itab.
DATA file TYPE string VALUE `/sap/inbound/master.xls`.
BREAK-POINT.
OPEN DATASET file FOR INPUT IN binary MODE.
IF sy-subrc = 0.
WRITE:'ok'.
ENDIF.
DO.
READ DATASET file INTO wa.
IF sy-subrc = 0.
itab = wa.
WRITE: / wa-matl_type,
wa-matl_group,
wa-matl_desc,
wa-char_prof.
APPEND itab.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET file.
please help me to correct this error.
in case of cvs file,when i comes to read dataset,my subrc = 4.
regds
vipin
2009 May 18 11:28 AM
Hi Vipin ,
I have made some changes tour code , now please check this code - -
DATA:BEGIN OF itab OCCURS 0,
matl_type(4) TYPE c,
matl_group(9) TYPE c,
matl_desc(40) TYPE c,
char_prof(18) TYPE c,
END OF itab.
DATA:wa LIKE itab.
DATA file TYPE string VALUE `/sap/inbound/master.xls`.
OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
BREAK-POINT.
IF sy-subrc = 0.
* WRITE:'ok'.
DO.
READ DATASET file INTO wa.
IF sy-subrc = 0.
itab = wa.
WRITE: / wa-matl_type,
wa-matl_group,
wa-matl_desc,
wa-char_prof.
APPEND itab.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
CLOSE DATASET file.Regards
Pinaki
after reading the dataset,you have to SPLIT the data that is got from the file so that the fields
are placed correctly into the corresponding fields..
2009 May 18 11:21 AM
after reading the dataset,you have to SPLIT the data that is got from the file so that the fields
are placed correctly into the corresponding fields..
2009 May 18 11:28 AM
Hi Vipin ,
I have made some changes tour code , now please check this code - -
DATA:BEGIN OF itab OCCURS 0,
matl_type(4) TYPE c,
matl_group(9) TYPE c,
matl_desc(40) TYPE c,
char_prof(18) TYPE c,
END OF itab.
DATA:wa LIKE itab.
DATA file TYPE string VALUE `/sap/inbound/master.xls`.
OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
BREAK-POINT.
IF sy-subrc = 0.
* WRITE:'ok'.
DO.
READ DATASET file INTO wa.
IF sy-subrc = 0.
itab = wa.
WRITE: / wa-matl_type,
wa-matl_group,
wa-matl_desc,
wa-char_prof.
APPEND itab.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
CLOSE DATASET file.Regards
Pinaki
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |