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

Splitting source record

Former Member
0 Likes
537

Hi Gurus,

I am not ABAP specilaist, I am trying to split source records(field xyz) to two fields (feild 1: xyz1, Field 2: xyz2) in target.

Basically source data filed will have values starting with J and Z.

Example: J001,Z010 etc..

Now in the transformation i want to split record based on the first character, for example if first character of source fields is J result will be J001 otherwise blank. if first character of source fields is Z result will be Z001 otherwise blank.

Any help greatly appreciated.

Regards,

Reddy.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
501

loop at the internal table where you have data into a work area.

if workarea-fieldname+0(1) = 'J'.

wa2-field1 = 'J001'.

elseif workarea-fieldname+0(1) = 'Z'.

wa2-field1 = 'Z010'.

endif.

append wa into itab2.

clear wa.

endloop.

let me know if you have any doubts.

3 REPLIES 3
Read only

Former Member
0 Likes
502

loop at the internal table where you have data into a work area.

if workarea-fieldname+0(1) = 'J'.

wa2-field1 = 'J001'.

elseif workarea-fieldname+0(1) = 'Z'.

wa2-field1 = 'Z010'.

endif.

append wa into itab2.

clear wa.

endloop.

let me know if you have any doubts.

Read only

uwe_schieferstein
Active Contributor
0 Likes
501

Hello

Another solution might look like this:


LOOP AT lt_itab INTO ls_record.
  CASE ls_record-field+0(1).
    WHEN 'J'.
      ls_record-field = 'J001'.

    WHEN 'Z'.
      ls_record-field = 'Z100'.

    WHEN others.
      ls_record-field = space.
    ENDCASE.

  APPEND ls_record TO lt_itab2.
ENDLOOP.

Regards

Uwe

Read only

0 Likes
501

Hi Uwe,

I was split the records using your code, But the date is appearing as below

Field A Field B Field C

J001 £ 100

Z001 £ 100

I want the data to be appeared in as single record.

Regards,

Reddy.