1. Dbf tab містить ВСІ 67-68 полів,
Ztab - тільки ті 25-45 полів що використовуються в продовженні ресурсів, їх і копіюємо
Dbf не редагувати.
1. Dbf tab містить ВСІ 67-68 полів,
Ztab - тільки ті 25-45 полів що використовуються в продовженні ресурсів, їх і копіюємо
Dbf не редагувати.
*-- 1. Define your internal table structure (All fields MUST be type C)
DATA: BEGIN OF ty_record,
field1(10) TYPE c, " Length 10
field2(5) TYPE c, " Length 5
field3(8) TYPE c, " Length 8
END OF ty_record.
DATA: itab LIKE ty_record OCCURS 0 WITH HEADER LINE.
*-- 2. Variables for file reading
DATA: lv_header_size TYPE i,
lv_record_size TYPE i,
lv_dummy(2000) TYPE c, " Large buffer to skip header
lv_buffer(1000) TYPE c. " Must match your exact DBF record size
*-- 3. Calculate your offsets manually based on DBF layout
*-- Remember: The first byte of every DBF record is the 1-byte "Deleted Flag"
lv_record_size = 24. " Example: 1 (flag) + 10 + 5 + 8 = 24 bytes
lv_header_size = 129. " Example: 32 + (32 * 3 fields) + 1 = 129 bytes
*-- 4. Open the file on the Application Server
OPEN DATASET 'your_file.dbf' FOR INPUT IN BINARY MODE.
IF sy-subrc <> 0.
EXIT.
ENDIF.
*-- 5. Move the file pointer past the header
READ DATASET 'your_file.dbf' INTO lv_dummy MAXIMUM LENGTH lv_header_size.
*-- 6. Loop through the records (approx 70,000 iterations)
DO.
" Read exactly one record into the flat buffer
READ DATASET 'your_file.dbf' INTO lv_buffer MAXIMUM LENGTH lv_record_size.
" Exit the loop if End of File is reached or EOF byte (0x1A) is found
IF sy-subrc <> 0 OR lv_buffer(1) = '#'. " Use hex representation of 0x1A if needed
EXIT.
ENDIF.
" Check deleted flag (0x20 / space = active, 0x2A / * = deleted)
IF lv_buffer(1) = ' '.
" Use ABAP offsets to slice the flat string into the itab structure
" Syntax: lv_buffer+OFFSET(LENGTH)
itab-field1 = lv_buffer+1(10). " Skip byte 0 (deleted flag), take 10 bytes
itab-field2 = lv_buffer+11(5). " Offset is 1 + 10 = 11, take 5 bytes
itab-field3 = lv_buffer+16(8). " Offset is 11 + 5 = 16, take 8 bytes
APPEND itab.
ENDIF.
ENDDO.
CLOSE DATASET 'your_file.dbf'.
TYPES: BEGIN OF ty_dbf_record,
field1 TYPE char10, " Char
field2 TYPE n LENGTH 5, " Numc (Always numeric char internally)
field3 TYPE d, " Date (DBF saves dates as 'YYYYMMDD')
field4 TYPE p DECIMALS 2, " Dec (Maps to plain decimal string)
" Define all remaining 60 fields here in identical data sequence
END OF ty_dbf_record.
DATA: lt_target_table TYPE STANDARD TABLE OF ty_dbf_record,
ls_target_row TYPE ty_dbf_record.
DATA: lv_filepath TYPE string VALUE '/usr/sap/trans/yourfile.dbf',
lv_header_bin TYPE x LENGTH 32,
lv_header_len TYPE i,
lv_record_len TYPE i,
lv_raw_record TYPE string. " Record container
" 1. Open the file strictly in binary mode to accurately handle byte structures
OPEN DATASET lv_filepath FOR INPUT IN BINARY MODE.
IF sy-subrc <> 0.
MESSAGE 'Failed to open application server file.' TYPE 'E'.
ENDIF.
" 2. Read the first 32 bytes to dynamically capture file boundaries
READ DATASET lv_filepath INTO lv_header_bin.
" Extract Header Length from Bytes 8-9 (Convert Little-Endian Hex to ABAP Integer)
lv_header_len = lv_header_bin+8(1) + ( lv_header_bin+9(1) * 256 ).
" Extract Record Length from Bytes 10-11
lv_record_len = lv_header_bin+10(1) + ( lv_header_bin+11(1) * 256 ).
" 3. Skip past the rest of the metadata header directly to record start
SET DATASET lv_filepath POSITION lv_header_len.
" 4. Loop to process 70,000 lines line-by-line (Zero impact on heap memory)
DO.
" Read one precise record package at a time using its length property
READ DATASET lv_filepath INTO lv_raw_record MAXIMUM LENGTH lv_record_len.
IF sy-subrc <> 0.
EXIT. " End of file reached smoothly
ENDIF.
" Skip records flagged as deleted (First byte is '*')
IF lv_raw_record+0(1) = '*'.
CONTINUE.
ENDIF.
" 5. Populate your fields using offset mapping (+Position(Length))
" NOTE: Remember offset 0 is the deletion flag, so field 1 starts at 1
ls_target_row-field1 = lv_raw_record+1(10). " Mapping a 10-char text field
ls_target_row-field2 = lv_raw_record+11(5). " Mapping a 5-digit NUMC
ls_target_row-field3 = lv_raw_record+16(8). " DBF Dates 'YYYYMMDD' map perfectly to DATS
ls_target_row-field4 = lv_raw_record+24(12). " ABAP natively casts raw decimals '1540.50' to P/DEC fields
" ... map remaining 56 fields based on your DBF field specifications ...
APPEND ls_target_row TO lt_target_table.
CLEAR ls_target_row.
ENDDO.
CLOSE DATASET lv_filepath.
1. Теорія бухобліку (Фундамент)
ОбработкаПроведения, яка ці записи генерує. Це найшвидший спосіб зрозуміти зв'язок між кодом і обліком.1. Передумови: Базові модулі та підручники
Монтень Досліди
Ф Ніцше
Кнут Гамсун
Вільям Фолкнер
Джером К. Джером
Стефан Цвейг
Сомерсет Моэм
Джон Голсуорси
Эрнест Хемингуэй
1. Dbf tab містить ВСІ 67-68 полів, Ztab - тільки ті 25-45 полів що використовуються в продовженні ресурсів, їх і копіюємо Dbf не редагува...