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

ABAP Program to split the records

Former Member
0 Likes
1,891

Hi Experts,

As i am new to ABAP please update me with the required ABAP Code or atlease with the skeleton Code

Source & target fields

Emp_ID ZEMP_ID (CHAR)

Start Date: ZESTA_DT (DATS)

End Date : ZEEND_DT (DATS)

My requirment is to write a start routine that split the record in to 2

Emp_ID-Start_Date-Termination Date

0001----01/01/2005---01/01/2008

0002----01/01/2007---

(Termination date will be blank if emp is still working)

As per my requirment i would like to see data in DSO as

Emp_ID-Start_Date-Termination Date

0001----01/01/2005---

0001----01/01/2005---01/01/2008

0002----01/01/2007---

I want to split the records of an employee

Please let me know if u need any information

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,331

Loop at itab.

if itab-ZEEND_DT is initial.

itab1 = itab.

append itab1.

else. " split the records ... based on termination ..

itab1 = itab.

clear itab1-ZEEND_DT

append itab1.

itab1 = itab.

append itab1.

endif.

endloop.

9 REPLIES 9
Read only

Former Member
0 Likes
1,331

Hello,

Use SPLIT Statement.

Regards,

Amit G.

Read only

Former Member
0 Likes
1,331

hiii

use code like below

data:
 w_locate     TYPE thead-tdname,   " Location of File
     w_ext        TYPE thead-tdname VALUE 'xls',
                                       " File Extension
     w_del(2)     TYPE c VALUE '.x'.   " Split Charactor

SPLIT p_data AT w_del
               INTO w_locate
                    w_ext.

<REMOVED BY MODERATOR>

thx

twinkal

Edited by: Alvaro Tejada Galindo on Jun 20, 2008 9:35 AM

Read only

0 Likes
1,331

please update

Read only

Former Member
0 Likes
1,332

Loop at itab.

if itab-ZEEND_DT is initial.

itab1 = itab.

append itab1.

else. " split the records ... based on termination ..

itab1 = itab.

clear itab1-ZEEND_DT

append itab1.

itab1 = itab.

append itab1.

endif.

endloop.

Read only

0 Likes
1,331

Hi Srinivas,

Thanks for the update....

Please correct me my if i was wrong

Data:

Emp_ID-Start date------Termination Date

0001----01/01/2005---01/01/2008

0002------01/01/2005

Loop at itab.

if itab-ZEEND_DT is initial.

itab1 = itab.

append itab1.

else. " split the records ... based on termination ..

itab1 = itab.

clear itab1-ZEEND_DT

append itab1.

itab1 = itab.

append itab1.

endif.

endloop.

My requirment is for the above example data

For the employee 0001 as Termination date is not initial i need that record to be split in to 2

Emp_ID-Start date------Termination Date

0001------01/01/2005

0001----01/01/2005---01/01/2008

Please update

Read only

0 Likes
1,331

On what dates should the record be split up ...

For every record U'll have begda and endda .. so on what it

should be split ...

Emp_ID-Start date------Termination Date

0001------01/01/2005 <- U want to split this record?

0001----01/01/2005---01/01/2008 <- or this

Read only

0 Likes
1,331

Hi Srinivas

Sorry to confuse you

For every record U'll have begda and endda .. so on what it

should be split ...

Emp_ID-Start date------Termination Date

0001------01/01/2005 <- U want to split this record?

0001----01/01/2005---01/01/2008 <- or this

If Endda is blank i don't want to split

If Endda is not blank the i want to split

0001----01/01/2005---01/01/2008 <- or this

In this case endda (01/01/2008) is not blank i want to split is like

0001------01/01/2005

0001----01/01/2005---01/01/2008

thanks

Read only

0 Likes
1,331

The code what I gave will work perfectly ...

Loop at itab.

if itab-ZEEND_DT is initial. <-- this is the endda/termination date

itab1 = itab.

append itab1.

else. " split the records ...

itab1 = itab.

clear itab1-ZEEND_DT

append itab1.

itab1 = itab.

append itab1.

endif.

endloop.

Read only

Former Member
0 Likes
1,331

do like this....

select pernr

begda

endda

dar01

dat01

from pa0041

into table itab

where pernr in s_pernr .

loop at itab into wa_itab.

if wa-dat01 is initial.

do nothing.

else.

append wa to itab1 .

endif.

*-----declate the itab1 with the desired fields in the output

loop at itab1.

write:/ itab1-pernr .

endloop.