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

Split

Former Member
0 Likes
1,054

Please use a meaningful subject in future

Dear Abapers,

In my report the Purc.Order# 4500000275 and the PO#:

300000000323

300000000324

300000000328

300000000326

My requirements is it will come in one text field like: 300000000323/324/328/326/329/300/301/302

I applied:

SHIFT zpo_prod-aufnr LEFT DELETING LEADING '30'.

But Result coming :300000000323/24/25/26/27/28/29//1/2

Can anybody have the solution for that?

Thanks & B.Rgds

Bishnu

Edited by: Matt on Aug 18, 2009 1:12 PM

8 REPLIES 8
Read only

Former Member
0 Likes
956

Hi,

Use this FM STRING_SPLIT_AT_POSITION

Regards,

Shamma

Read only

Former Member
0 Likes
956

Hi,

Try something like this,


data: wa like itab.
data: v_ind type i.

loop at itab. 
v_ind = sy-tabix - 1.
if sy-tabix = 1.
concatenate itab-field1 '/ ' into temp.
else.
read itab into wa index v_ind.
if itab-field1+0(10) = wa-field1+0(10).
concatenate temp itab-field1+10(3) '/' into temp.
endif.
endif.
endloop.

write: temp.

Regards,

Vik

Read only

gaursri
Active Contributor
0 Likes
956

Hi Bishnu,

I am providing a small example give by SAP for this query.Hope it resolves your query.

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.

Have a best day ahead.

Read only

Former Member
0 Likes
956

Hi,

Try this. This one works. Use this on all your Po# inside a LOOP...ENDLOOP and put them in a seperate internal table. At the end, you can concatenate the values necessary.



DATA: lv_a TYPE char12 VALUE '300000000323'.
DATA: moff TYPE i,
      mlen TYPE i,
      off TYPE i,
      len TYPE i.
WHILE sy-subrc eq 0.
FIND '0' in SECTION OFFSET off of lv_a match OFFSET moff match LENGTH mlen.
if sy-subrc = 0.
off = moff + mlen.
ENDIF.
ENDWHILE.
WRITE: off.
len = strlen( lv_a ).
WRITE: len.
len = len - off.
lv_a = lv_a+9(len).
WRITE: lv_a.

Read only

Former Member
0 Likes
956

Hi Bishnu,

My requirements is it will come in one text field like: 300000000323/324/328/326/329/300/301/302

DO this as following,


Data: PO_string type String.
Loop at T_PO_TABALE into WA_PO.

if SY-TABIX = 1.
PO_string = WA_PO-PO_NO.
else.
Concatenate PO_string   WA_PO-PO_NO+9(3) into PO_string separated by '/'.
endif.

endloop.

Above code is tested its working Absolutely fine.

This will resolve ur issue

Regards,

Akash Rana

Read only

matt
Active Contributor
0 Likes
956

Please use a meaningful subject in future

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
956

types:begin of ty_it,
lines(128) type c,
end of ty_it.

data:pattern_string type char128 value '300000000323/324/328/326/329/300/301/302'.
data:it_val type table of ty_it.
data:wa_val type ty_it.
data:v_ebeln type ekpo-ebeln.

split pattern_string at '/' into table it_val.
read table it_val into wa_val index 1.
if sy-subrc = 0.
v_ebeln = wa_val(9).
concatenate  '/' v_ebeln into v_ebeln.
endif.
replace all OCCURRENCES OF '/' in pattern_string with v_ebeln.
split pattern_string at '/' into table it_val.


*Now it_val will have your values

Edited by: Keshu Thekkillam on Aug 18, 2009 4:46 PM

Read only

Former Member
0 Likes
956

HAi,

Please run Given below Program Once:

data: BEGIN OF it_data occurs 0,
      char(15) type c,
      end of it_data.

data: var(50) type c.
data: var1(3) type c.
it_data-char = '300000000323'.
append it_data.
it_data-char = '300000000324'.
append it_data.
it_data-char = '300000000325'.
append it_data.
it_data-char = '300000000326'.
append it_data.

loop at it_data.
if sy-tabix = '1'.
var = it_data-char.
else.
var1 = it_data-char+9(3).
concatenate var '/' var1 into var.
endif.
endloop.

write: var.