Skip to Content

pass string longer than 255 characters to a single line of internal table

Hi,

I am facing issue while moving string having around 1000 characters to internal table.

It is only transferring first 255 charcters to internal table. In loop if I concatenate and append to internal after 255 characters it appends it to next line.

I tried using string data type and other data types (like edid4-sdata or idocline). It is not wroking.

Thanks,

Sanjana

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

8 Answers

  • avatar image
    Former Member
    Jul 04, 2013 at 09:33 PM

    Hi Sanjana,

    Could you elaborate more your issue; perhaps you could post some code or tell us why do you think it is not working.

    I've done something similar to what you need and it has worked.

    Martin

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 04, 2013 at 10:56 PM

    Hi,

    Please give the code looks like very basic issue of string getting truncated may be the internal table field to which you are trying to copy is not 1000 characters long. 😊

    itab-field = your_str.

    This would work provided both have 1000 characters length.

    Cheers,

    Arindam

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 05, 2013 at 01:57 AM

    HI,

    With below test code, i can see that variable length is 1000 in both lv_text and lv_text1. I've used data type EDI_SDATA and it worked for me.

    DATA lv_text TYPE edi_sdata. DATA lv_text1 TYPE edi_sdata. DATA lv_len TYPE i. DO 1024 TIMES.   CONCATENATE '1' lv_text1 INTO lv_text1. ENDDO. lv_len = strlen( lv_text1 ). lv_text = lv_text1. CLEAR: lv_len. lv_len = strlen( lv_text1 ). WRITE lv_text.

    Just make sure that both fields (field containing string and filed in which string needs to be passed) is of data type with than 1000 characters.

    Regards,

    Ravi

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 05, 2013 at 03:51 AM

    Hi Sanjana,

    See this code, it may help you

    data : a type string,
               b type string,
               lenth type i.

    do 167 times.
    CONCATENATE 'ramesh' a into a.
    ENDDO.

    lenth = strlen( a ).

    write : / 'a - Length', lenth.
    write : / a.
    b = a.

    clear:  a, lenth.

    lenth = strlen( b ).

    write : / 'b - Length', lenth.
    write : / b.

    OutPut



    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 05, 2013 at 05:47 AM

    Hi Sanjana,

    if you have long description more than  3000 to append it to an internal table

    do likewise

    DATA: long_text(3000).

    DATA: Lv_len(2000).

    first get the Length of the long_text

      Lv_len  = strlen(long_text).

       MOVE: Lv_len                TO Itab-long_field,

                  long_text         TO Itab- long_field.

    APPEND ITab.

    TO INSERT INTO TABLE

    Thanks,

    Asit

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 05, 2013 at 02:42 PM

    I need to pass one row having approx. 1000 characters to a single line of internal table.

    When I try to do that characters more than 255 chars. are truncated and line gets appended.

    I need all characters in single line of internal table and not splited.

    Any idea will be helpful.

    Thanks.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Sanjana,

      I presume you are passing some kind of long text into internal table! Well you are right, more than 255 Characters will get truncated in internal table.

      What you can do is - concatenate the whole 1000 characters or more into a string, and then break the string using a function module - SWA_STRING_SPLIT. In this function module you can set the length as to where it should break, 132, 500, 1000 respectively i.e., if you pass length as 132 then internal table will store a records having 132 characters respectively.

      Do find a sample code for you reference -

      DATA : GV_INPUT_STRING TYPE STRING,      " STRING VARIABLE

                  GIT_SWASTRTAB   TYPE STANDARD TABLE OF SWASTRTAB,
                 GWA_SWASTRTAB   TYPE SWASTRTAB.

      CLEAR GV_INPUT_STRING.

      CONCATENATE text_line           " TEXT_LINE HAVING YOUR N NUMBER OF CHARACTERS
              INTO   gv_input_string.

         CALL FUNCTION 'SWA_STRING_SPLIT'
           EXPORTING
             input_string                                = gv_input_string   " or you can directly pass your string no need for CONCATENATE st.
             max_component_length              = '132'                   " SET YOUR LENGTH for splitting
      *     TERMINATING_SEPARATORS   =
      *     OPENING_SEPARATORS         =
           TABLES
             string_components                     = GIT_SWASTRTAB     " INTERNAL TABLE
           EXCEPTIONS
             max_component_length_invalid = 1
             OTHERS                       = 2.

         IF sy-subrc <> 0.
           MESSAGE ID sy-msgid
                 TYPE sy-msgty
               NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2.

         ELSE.

           CLEAR GWA_SWASTRTAB.

           LOOP AT GIT_SWASTRTAB INTO GWA_SWASTRTAB.

           " DO YOUR EXTRACTION

                GWA_FINAL-TEXT = GWA_SWASTRTAB-STR. " Appending REQUIRED LENGTH INTO FINAL TABLE

                APPEND GWA_FINAL TO GIT_FINAL.

           ENDLOOP.

      Do ping if any.

      Rgds,

      Varun Sahu

  • Jul 05, 2013 at 03:36 PM

    May be just try this:

    Assign field symbol to the value of 1000 chars and append the field symbol as a line of internal table.

    Add comment
    10|10000 characters needed characters exceeded

    • When I append this field symbol to internal table , I am not able to do it only first 255 characters are transferred to internal table.

      Even if field symbol or work area contains 1000 characters , after appending a row to internal table only 255 characters are getting transferred and rest data is truncated.

      I have tried internal table of type string, edid4-sdata and idocline.

      but none of the above worked, also in debug mode if I try to enter more than 255 characters in a line of internal table , it gives me warning only 255 characters will be transferred.

      Thanks,

      Sanjana

  • avatar image
    Former Member
    Jul 06, 2013 at 06:40 AM

    hi sanjana,

         check this sample code.

    REPORT  ZSCN_TEST3 LINE-SIZE 1023.

    TYPES: begin of ty_tab,
            name TYPE string,
            END OF ty_tab.

      data : it_tab TYPE STANDARD TABLE OF ty_tab,
             wa_tab TYPE ty_tab.

          DATA : name TYPE string.


    do 250 times.

    concatenate 'A' 'B' 'C' 'D' name into name.

    enddo.

    wa_tab-name = name.
    APPEND wa_tab to it_tab.

    LOOP at it_tab INTO wa_tab.
       WRITE : / wa_tab-name.
       ENDLOOP.


    In this 'name' field in internal table 'it_tab' stores 1000 character in single line .

    Reward points if it's helpful.

    Regards,

    PRABHAKARAN

    Moderator Message - Asking for points is against the forums' RoE. Please read the RoE before posting.

    Message was edited by: Suhas Saha

    Add comment
    10|10000 characters needed characters exceeded