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

Binary table length

Former Member
0 Likes
4,147

hi,

i have an internal table it_content (it_content type standard table of sdokcntbin)

the lines in this are type raw.

I read a file from the appln server in binary mode and build this table .

I need to know the total length of this table . How do i get the total length of the table contents?

3 REPLIES 3
Read only

MarcinPciak
Active Contributor
0 Likes
1,874

Hi,

When you declare your internal table, its row type is fixed (here RAW type).

Determining the table's content size is probably not impossible, but somewhat difficult and is not effective.

I guess your goal is to get total size of read file. For this count the bytes while reading the file.


DATA: itab TYPE TABLE OF sdokcntbin WITH HEADER LINE.

DATA: file TYPE rlgrap-filename VALUE '/some_application_server_file.txt',
      curr_bytes TYPE i,
      tot_bytes TYPE i.

OPEN DATASET file FOR INPUT IN BINARY MODE.
IF sy-subrc = 0.
  DO.
    READ DATASET file INTO itab ACTUAL LENGTH curr_bytes.   "when reading the file obtain read bytes
    IF sy-subrc <> 0.
      EXIT.
    ELSE.
      APPEND itab.
      ADD curr_bytes TO tot_bytes.       "...and count them all
    ENDIF.
  ENDDO.

  "all data read in one shot 
  IF curr_bytes <> 0.     
    APPEND itab.
    ADD curr_bytes TO tot_bytes.
  ENDIF.

  WRITE: 'In table there are ', tot_bytes, ' bytes'.
  CLOSE DATASET file.
ENDIF.

Regards

Marcin

Read only

Former Member
0 Likes
1,874

to check the no of records in the table

use:

data: n type i .

Describe table Itab lines n.

and check the system variable.

sy-tfill and sy-tleng.

Regds

Sachhi

Read only

Former Member
0 Likes
1,874

Resolved myself. But the help is equally useful