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 tp split

Former Member
0 Likes
1,019

Hi all,

how to split

T149DBWTAR AS A T149DKKREF AS B T149D~ANY AS C ..........

so that we find

Qfield T149DBWTAR T149DKKREF T149D~ANY.....

value A B C.....

Regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
960

HI

I HVE A STRING 'T149DBWTAR AS A T149DKKREF AS B T149D~ANY AS C ..........'

but i want to divide these values in two string so how to do that

1 string ---> T149DBWTAR T149DKKREF T149D~ANY.....

2 string ---> A B C.....

regards,

8 REPLIES 8
Read only

RahulKeshav
Active Contributor
0 Likes
960

wt do u mean by split...

are looking for concatenate....

plz eleborate...

Read only

Former Member
0 Likes
961

HI

I HVE A STRING 'T149DBWTAR AS A T149DKKREF AS B T149D~ANY AS C ..........'

but i want to divide these values in two string so how to do that

1 string ---> T149DBWTAR T149DKKREF T149D~ANY.....

2 string ---> A B C.....

regards,

Read only

matt
Active Contributor
0 Likes
960

Split at space into an internal table

Every 1st, 4th, 7th... record will be your T149DBWTAR T149DKKREF T149D~ANY etc.

Every 3rd, 6th, 9th... record will be your A, B, C etc.

Throw other records away.

Read only

0 Likes
960

Hi Try this code.



DATA : gv_str TYPE string.

DATA : BEGIN OF gt_str OCCURS 0,
         sub(20),
       END OF gt_str.

DATA: gv_index TYPE i.

DATA: gv_str1 TYPE string.
DATA: gv_str2 TYPE string.


gv_str = 'T149D~BWTAR AS A T149D~KKREF AS B T149D~ANY AS C'.

SPLIT gv_str AT ' ' INTO TABLE gt_str.

LOOP AT gt_str.
  gv_index = sy-tabix MOD 3.
  CASE gv_index.
    WHEN 1.
      CONCATENATE gv_str1 gt_str-sub INTO gv_str1 SEPARATED BY space.
    WHEN 0.
      CONCATENATE gv_str2 gt_str-sub INTO gv_str2 SEPARATED BY space.
  ENDCASE.
ENDLOOP.

WRITE:/ gv_str1.
WRITE:/ gv_str2.


Regards,

Bhupal

Read only

matt
Active Contributor
0 Likes
960

Nice implementation, Bhupal

Read only

0 Likes
960

Thanks Matthew.

Read only

Former Member
0 Likes
960

Thanks bhupal.

u rocks!!!!!!!

Read only

Former Member
0 Likes
960

Hi all,

in bhupal case we are getting a syntax with a order of 1- 'T149D~BWTAR 2- AS 3- A ,so it's ok but it's generate a error if we have a input of mix type means

gv_str = 'T149DBWTAR T149DKKREF AS B T149D~ANY AS C'................

or

gv_str = 'T149DBWTAR AS A T149DKKREF T149D~ANY........... .

OR

gv_str = 'T149DBWTAR T149DKKREF T149D~ANY......

or

-


REGARDS,