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

how to use split command for value in field

Former Member
0 Likes
5,829

dear guys,

i just want to know how to use split command for value in field.

actually i have one field name zevent which is have 100 char.

i want to divide the text to two part since i want to display it at my form.

which is my form has a limited space to display the long text.

thanks..

1 ACCEPTED SOLUTION
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
2,231

Hi,

Suppose you want to split that into two 50 chars.

its as follows.

DATA: char(100) type c,

char1(50) type c,

char2(50) type c.

char1 = char+0(50).

char2 = char+51(50).

else assuming you have a delimiter as ':'

SPLIT char AT ':' INTO char1 char2.

Regards

Sesh

7 REPLIES 7
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
2,232

Hi,

Suppose you want to split that into two 50 chars.

its as follows.

DATA: char(100) type c,

char1(50) type c,

char2(50) type c.

char1 = char+0(50).

char2 = char+51(50).

else assuming you have a delimiter as ':'

SPLIT char AT ':' INTO char1 char2.

Regards

Sesh

Read only

Former Member
0 Likes
2,231

DATA: str1 TYPE string,

str2 TYPE string,

str3 TYPE string,

itab TYPE TABLE OF string,

text TYPE string.

text = `What a drag it is getting old`.

SPLIT text AT space INTO: str1 str2 str3,

TABLE itab.

Read only

Former Member
0 Likes
2,231

Hi Nadya,

The syntax for SPLIT is the following :

SPLIT field1 AT separator INTO field2 field3 field4 ...

The SPLIT command searches field 1 for separator and put the result into the different output fields (field2 field3 field4 ...).

In your case I don't think you nedd to use this command. Just use WRITE with length and offset as below :

Write input_field(100) to output_field1.

Write input_field+100 to output_field2.

Reward if this helps.

Regards,

Nicolas.

Read only

0 Likes
2,231

thanks for the answer

but i have to loop at internal table first for that field

how to use the syntax in the loop?

Read only

0 Likes
2,231

loop at itab.

write 😕 itab-field(n).

write 😕 itab-field+n.

endloop.

"/" will create a new line for writing on your report.

N is the max length you want to write from itab-field.

Regards,

Nicoals.

Read only

0 Likes
2,231

See the below code to use a split with in a loop


types : begin of TY_UPLOADF,
          STRING type STRING,
        end of TY_UPLOADF.

types : begin of TY_UPLOAD,
          I_FIELD1 type CHAR23,
          I_FIELD2 type CHAR8,
          I_FIELD3 type CHAR8,
          I_FIELD4 type CHAR8,
          I_FIELD5 type CHAR8,
          I_FIELD6 type CHAR8,
          I_FIELD7 type CHAR8,
        end of TY_UPLOAD.

data : IT_UPLOADF type table of TY_UPLOADF,
       IS_UPLOADF type TY_UPLOADF.

data : IT_UPLOAD type table of TY_UPLOAD,
       IS_UPLOAD type TY_UPLOAD.

    loop at IT_UPLOADF into IS_UPLOADF.
      split IS_UPLOADF-STRING at '+' into IS_UPLOAD-I_FIELD1
                                          IS_UPLOAD-I_FIELD2
                                          IS_UPLOAD-I_FIELD3
                                          IS_UPLOAD-I_FIELD4
                                          IS_UPLOAD-I_FIELD5
                                          IS_UPLOAD-I_FIELD6
                                          IS_UPLOAD-I_FIELD7.
      append IS_UPLOAD to IT_UPLOAD.
      clear : IS_UPLOADF, IS_UPLOAD.
    endloop.

Regards

Gopi

Read only

Former Member
0 Likes
2,231

  TYPES:
        BEGIN OF t_itab_split ,
           value(255) ,
        END OF t_itab_split .

  DATA:
        itab_split TYPE STANDARD TABLE OF t_itab_split .

...
...

    SPLIT str AT ';' INTO TABLE itab_split .


In the rows of the table contain splitted data, in the field 'value'.