Posted: Thu Jan 17, 2008 4:08 pm Post subject: Проблема open dataset
Доброго денёчка,
пытаюсь прочитать в буфер содержимое бинарного файла (Excel) и сохранить в другой директории. Создаваемый файл получается большей длины и при открытии возникает ошибка. Вот код, можете подсказать, в чем проблема?
Code:
DATA: ls_filename TYPE rlgrap-filename,
lt_content TYPE sdokcntbin OCCURS 0 WITH HEADER LINE.
MOVE '1.xls' TO ls_filename.
OPEN DATASET ls_filename FOR INPUT IN BINARY MODE.
CHECK sy-subrc IS INITIAL.
DO.
READ DATASET ls_filename INTO lt_content-line.
IF NOT sy-subrc IS INITIAL.
EXIT.
ENDIF.
APPEND lt_content.
ENDDO.
CLOSE DATASET ls_filename.
*DELETE DATASET ls_filename.
DATA: ls_filename TYPE rlgrap-filename,
lt_content TYPE sdokcntbin OCCURS 0 WITH HEADER LINE,
len TYPE i,
pos TYPE i.
MOVE '1.xls' TO ls_filename.
OPEN DATASET ls_filename FOR INPUT IN BINARY MODE.
CHECK sy-subrc IS INITIAL.
*vvvvvvvvvvv
* Get length of the file
SET DATASET ls_filename POSITION END-OF-FILE.
GET DATASET ls_filename POSITION pos.
SET DATASET ls_filename POSITION 0.
*^^^^^^^^^^^
DO.
READ DATASET ls_filename INTO lt_content-line ACTUAL LENGTH len.
IF NOT sy-subrc IS INITIAL.
EXIT.
ENDIF.
APPEND lt_content.
ENDDO.
CLOSE DATASET ls_filename.
DELETE DATASET ls_filename.
CLEAR: ls_filename.
MOVE '2.xls' TO ls_filename.
OPEN DATASET ls_filename FOR OUTPUT IN BINARY MODE.
CHECK sy-subrc IS INITIAL.
LOOP AT lt_content.
AT LAST.
TRANSFER lt_content-line TO ls_filename LENGTH len.
EXIT.
ENDAT.
TRANSFER lt_content-line TO ls_filename.
ENDLOOP.
CLOSE DATASET ls_filename.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.