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 TO Ti_TAB

Former Member
0 Likes
875

HI!!

I need to pass the content of string to an internal table in fields length 255.

And like string that I use is too long I require to him later to print, so that I need to keep it in an internal table.

Thanks. Regards.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
848

what's your requirement ..can you make it more clear please...

HI!!

I need to pass the content of string to an internal table in fields length 255.

And like string that I use is too long I require to him later to print, so that I need to keep it in an internal table.

Thanks. Regards.

6 REPLIES 6
Read only

Former Member
0 Likes
848

See if you can use the FM RKD_WORD_WRAP. If not, search in function modules using WORDWRAP* and you may be able to use one of them.

Read only

Former Member
0 Likes
849

what's your requirement ..can you make it more clear please...

Read only

0 Likes
848

OK!! It will use an example:

String contains this information:

zstring = //2.0 NCAR 253 2007-11-05T17:54:32 789087654312 2007 ingreso Pago en una solaexhibici#n 1223.60 1407.14 GEC681230QC6 GRUPO EMBOTELLADOR S.A. DE C.V. Minatitlan 10 Miraval Morelia Michoacan Morelos M#xico 62270 FAN962012L30 COMPA##A FLETERA DE LOS CIELOS,S.A. DE C.V. Minatitlan Morelia Michoacan MorelosTO DE ENERGETICOS MEXICANOS DE LAS HORAS DE TODOS LOS DIAS DEL A#O 2008 CON TODOS LOS RECURSOSNECESARIOS /61.18/ 1223.60 /IVA 15 183.54 //

suppose that they are 457 characters.

Then, I need to keep this information from string in a table, but the field of the table is single of 255 characters, so that, it keep in several fields until completing the 457 characters .

Finally I read the table and print this information .

Regards.

Read only

0 Likes
848

HI!!

The options of code that you provide to me, they show to me a dump:

CALL_FUNCTION_CONFLICT_GEN_TYP

CX_SY_DYN_CALL_ILLEGAL_TYPE

The reason is by the strig : DATA: v_string TYPE string, since the functions wait for it of type C.

Regards.

Read only

0 Likes
848

I don't think there is a function module that receives a string type variable and splits it for you.

Your best option is to assign your string to a char variable and then to pass it to one of the WORDWRAP* function modules.

Your next option is to write your own logic. It is tedious work, but not very hard.

Read only

Former Member
0 Likes
848

You can take one of the two approaches given below.

DATA: v_string TYPE string,
      v_position TYPE i,
      v_remaining_string TYPE string,
      v_string_length TYPE i.

DATA: BEGIN OF itab OCCURS 0,
        record(255).
DATA: END OF itab.

v_string_length = STRLEN( v_string ).

WHILE v_string_length > 255.

  CALL FUNCTION 'STRING_SPLIT_AT_POSITION'
    EXPORTING
      string                  = v_string
      pos                     = 254
*   LANGU                   = SY-LANGU
   IMPORTING
     string1                 = itab-record
     string2                 = v_remaining_string
*   POS_NEW                 =
   EXCEPTIONS
     string1_too_small       = 1
     string2_too_small       = 2
     pos_not_valid           = 3
     OTHERS                  = 4.
  IF sy-subrc <> 0.
    EXIT.
  ENDIF.
  v_string = v_remaining_string.
  v_string_length = STRLEN( v_string ).
  APPEND itab.
  CLEAR itab.

ENDWHILE.

or

DATA: v_string TYPE string.

DATA: BEGIN OF itab OCCURS 0,
        record(255).
DATA: END OF itab.

CALL FUNCTION 'RKD_WORD_WRAP'
  EXPORTING
    textline            = v_string
    delimiter           = ' '
    outputlen           = 255
*  IMPORTING
*    out_line1           = ''
*    out_line2           = ''
*    out_line3           = ''
  TABLES
    out_lines           = itab
  EXCEPTIONS
    outputlen_too_large = 1
    OTHERS              = 2.
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.