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

Merging rows

Former Member
0 Likes
531

Hi experts my problem is

II have a database table and i need read this data base table in to an internal .Here for same time period(one week time period ) and same personnal number there may exists two different reccords i.e with type of time entry :

a)over time or

b)paid time offs

After this i need compare records in this internal table in such way that

Records having Same personnal number ,same time period but with different time entry procedure

i.e Over time and paid time off in my case (Diffrentiation done with this type of time entry)

should be diplayed in one row with two columns for Overtime and paid time off

thanks

3 REPLIES 3
Read only

Former Member
0 Likes
498

Hi Prashant,

Use the followign logic.

Loop at Itab1.

Initialise the sum.

sum = sum + Time

on change of Personal No.

update ITAB2 with new record and put in teh new time there.

endon.

End loop.

This will work.

Regards,

Guru

Read only

raja_thangamani
Active Contributor
0 Likes
498

Here are the steps:

DATA: BEGIN OF WA,
        OVER_TIME type yourtype
        PAID_TIME type yourtype,
      END OF WA.

DATA: I_FINAL TABLE OF WA

.

1. Select both the records over time and paid time offs from Database table into Itab.

2. READ table itab for over time.

   if sy-subrc EQ 0.
    Assign the value to wa-OVER_TIME.
 endif.

3. READ table itab for paind time

   if sy-subrc EQ 0.
    Assign the value to wa-PAID_TIME.
 endif.

append wa to I_FINAL.

Here I_FINAL will have the both over & Paid time in the same column.

Raja T

Read only

Former Member
0 Likes
498

Try something like:



REPORT ztest MESSAGE-ID 00.

DATA: BEGIN OF raw_itab OCCURS 0,
        pno  type ...,
        proc type ...,
        amt  type ...,
      end   of raw_itabr.

DATA: BEGIN OF sum_itab OCCURS 0.
        pno  type ...,
        ot   type ...,
        pto  type ...,
DATA: END   OF sum_itab.

SELECT pno proc amt
  INTO TABLE raw_itab
  WHERE...
  
loop at raw_itab.
  sum_itab-pno = raw_itab-pno.
  
  if raw_itab-proc = 'OT'.
    sum_itab-ot  = raw_itab-amt.
  elseif raw_itab-proc = 'PTO'.
    sum_itab-pto = raw_itab-amt.
  endif.
  
  collect sum_itab.
endloop.

Rob