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

String bigger than 255 char

Former Member
0 Likes
2,973

Hi All,

I have a file on application server which has got ; as seperator. I can read that file using following

   OPEN DATASET p_servfn FOR INPUT IN TEXT MODE ENCODING DEFAULT.

   READ DATASET p_servfn INTO s_itab.         (Where a_itab is defined as DATA : s_itab type string.)

I am spliting above into two fields - 1st field is of 16 Char which is ok but my next field is not getting populated properly

   SPLIT s_itab AT ';' INTO s_filedata-con_num
                                              s_filedata-message_text.

s_filedata-message_text is only getting first 255 char but I know that S_ITAB has got more than 255 char. I have tried defining my s_itab differently but it didn't help. And if I use same field s_itab to transfer data to different location on application server then it is transferring everything correctly ex

   OPEN DATASET l_arch FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

  TRANSFER s_itab TO l_arch.     - this is transferring data successfully

I also tried writing content of s_itab, it is just writing 255char. Can someone please help me?

thanks,

Sanjay

Hi All,

I have a file on application server which has got ; as seperator. I can read that file using following

   OPEN DATASET p_servfn FOR INPUT IN TEXT MODE ENCODING DEFAULT.

   READ DATASET p_servfn INTO s_itab.         (Where a_itab is defined as DATA : s_itab type string.)

I am spliting above into two fields - 1st field is of 16 Char which is ok but my next field is not getting populated properly

   SPLIT s_itab AT ';' INTO s_filedata-con_num
                                              s_filedata-message_text.

s_filedata-message_text is only getting first 255 char but I know that S_ITAB has got more than 255 char. I have tried defining my s_itab differently but it didn't help. And if I use same field s_itab to transfer data to different location on application server then it is transferring everything correctly ex

   OPEN DATASET l_arch FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

  TRANSFER s_itab TO l_arch.     - this is transferring data successfully

I also tried writing content of s_itab, it is just writing 255char. Can someone please help me?

thanks,

Sanjay

8 REPLIES 8
Read only

TuncayKaraca
Active Contributor
0 Likes
1,751

What is s_filedata-message_text  type?

Read only

0 Likes
1,751

s_filedata-message_text is type STRING. I have also tried to define like xstring.

In order to make things simple I have kept both variable s_filedata-message_text and s_itab as same type. I have tried using long char fields which are availavble in system like 1000 char long field but it is still truncating at 255 char.

Read only

0 Likes
1,751

Where is it truncating, in the debugger?

If yes, then I think the display is constrained to 255 chars. there is an option in the variable display to show as table in which case it displays the constants as a table with 255 chars per line in the table.

if not can you either post the bit where you define s_filedata or post a screenshot of the domain that is used to s_filedata-message_text. Also of interested is the how s_itab is defined.

Ideal would be posting a little report that shows the behaviour.

Cheers

   Adi

Read only

0 Likes
1,751

Following are my data definitions :-

   TYPES : BEGIN OF t_type,
        "con_number(16) type c,
        input TYPE CUKN-KNBLK"/wcg/cms_db_tag_data.  "string.   "ZTEST_CHAR3000-text.
TYPES : END OF t_type.

TYPES : BEGIN OF t_filedata,
        con_num(16) TYPE c,
        message_text TYPE /wcg/cms_db_tag_data"xstring.  " /wcg/cms_db_tag_data.
TYPES : END OF t_filedata.

TYPES : BEGIN OF t_message,
        text TYPE string.
TYPES : END OF t_message.

DATA : i_itab TYPE STANDARD TABLE OF t_type, "/wcg/cms_db_tag_data,  "string,  "t_type,
       "s_itab type string,
       "s_itab type /wcg/cms_db_tag_data,   CUKN-KNBLK
       s_itab like line of i_itab,
       it_filedata TYPE STANDARD TABLE OF t_filedata,
       s_filedata TYPE t_filedata,
       i_table TYPE TABLE OF string.

DATA : it_message TYPE STANDARD TABLE OF t_message,
       s_message LIKE LINE OF it_message.

DATA : lt_filedata TYPE STANDARD TABLE OF t_filedata,
       ls_filedata TYPE t_filedata,
       lt1_filedata TYPE STANDARD TABLE OF t_filedata
       .

And following is the code

    DATA : lv_check_arch TYPE c.

  OPEN DATASET p_servfn FOR INPUT IN TEXT MODE ENCODING DEFAULT.
  IF sy-subrc <> 0.
    CONCATENATE text-005 p_servfn INTO s_message-text SEPARATED BY space.
    APPEND s_message TO it_message.
    CLEAR s_message.
  ELSE.
    CONCATENATE text-006 p_servfn INTO s_message-text SEPARATED BY space.
    APPEND s_message TO it_message.
    CLEAR s_message.

*get the file name and copy into archive directory
    SPLIT p_servfn AT '/' INTO TABLE i_table.
    DESCRIBE TABLE i_table LINES l_count.
    READ TABLE i_table INDEX l_count INTO l_fname1.
    CONCATENATE p_arch l_fname1 INTO l_arch" SEPARATED BY '/'.
    CONCATENATE l_arch sy-datum sy-uzeit INTO l_arch SEPARATED BY '_'.

*open DATASET l_arch to save file in archive directory
    OPEN DATASET l_arch FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    IF sy-subrc = 0.
      CONCATENATE text-007 l_arch INTO s_message-text SEPARATED BY space.
      APPEND s_message TO it_message.
      CLEAR s_message.
    ELSE.
      CONCATENATE text-008 l_arch INTO s_message-text SEPARATED BY space.
      APPEND s_message TO it_message.
      CLEAR s_message.
      lv_check_arch = 'X'.
    ENDIF.

"commit work AND WAIT.

    DO.
      READ DATASET p_servfn INTO s_itab.   " MAXIMUM LENGTH 1000.

      IF sy-subrc = 0.

        SPLIT s_itab AT p_sep INTO s_filedata-con_num
                                 s_filedata-message_text.
        APPEND s_filedata TO it_filedata.
        CLEAR s_filedata.

*        transfer data to archive directory
        write :/ s_filedata-message_text.
        TRANSFER s_itab TO l_arch.
      ELSE.
        EXIT.
      ENDIF.
    ENDDO.

    IF lv_check_arch = abap_false.
      DELETE DATASET p_servfn.
      CLOSE DATASET l_arch.
    ENDIF.

-------------------------------------------------------------------------------------------------------------------------------------------

Please note that if I transfer s_itab to some other directory on the application server then it is transferring whole string. But the problem is only when I am assiging s_itab to some other variable it is getting truncated and also for test purpose I have tried to write s_itab directly but it is still getting truncated.

Read only

0 Likes
1,751

try replacing s_itab by s_itab-input. s_itab is a structure and you probably only want to write in to the input field.

Read only

SujeetMishra
Active Contributor
0 Likes
1,751

Hello Sanjay,

first download the file using tcode CG3Z and check whether you are getting more than 255 char length data or not?

where exactly data is missing? Did you check the s_itab after below read statement?

READ DATASET p_servfn INTO s_itab

Is message-text is coming correct?

Regards,

Sujeet Mishra

Read only

0 Likes
1,751

Funny...CG3Z will not handle more than 255 characters. 

Read only

Former Member
0 Likes
1,751

Why do you think you are missing anything?  The fact that it is not fully visible means nothing.  What is the length of the string after you have imported it? Try something like (or adapt your code):

Types: begin of gtyp_dat,

              con_num        type string,

              message_text type string,

         end of gtyp_dat.

data: gt_tab type table of gtyp_dat,

        gs_tab type           gtyp_dat,

        lv_line(1024) type c,

        lv_len type i.

DO.

      READ DATASET p_servfn INTO lv_line.  

      IF sy-subrc <> 0.  "end of line encountered.

       exit.

     endif.

        SPLIT lv_line AT p_sep

          INTO gs_tab-con_num

                  gs_tab-message_text.

       

    lv_len = strlen( gs_tab-message_text ). 

    write :/ 'text is', lv_len, 'characters.'.

  

     APPEND gs_tab TO gt_tab.

*  transfer data to archive directory

        TRANSFER gs_tab TO l_arch.  ""what is this...an open dataset?

        clear gs_tab.

     ENDDO.