‎2005 Nov 07 7:23 AM
Hi All,
I have a record that needs to be inserted into ztable before inserting i need to check if total exceeds more then 8hrs then i need to split that record into two,
first with 8hrs and rest of the hours in the second record and then insert the record.
Any suggestion abt FM or any logic would be appreciated.
Regards,
Aima.
‎2005 Nov 07 7:28 AM
Aima,
The questions is not clear. No clue about the 8 hrs that you are talking about. Example records with some explanation would help.
Regards,
Ravi
‎2005 Nov 07 7:38 AM
Hi RaviKumar,
let me go in this way...
For Example i have a record like
eno ename worktime .
100 xyz 12
The total time here is 12 now i need to split up the record in to two.
eno ename shft worktime
100 xyz 01 8
100 xyz 02 4
Based on start time i decide which shift the record sits.
Hope i am clear .
Regards,
Aima
‎2005 Nov 07 7:36 AM
I am assuming that the records are stored in an internal table , not coming from file.
REPORT ztest_table.
data: begin of itab occurs 0,
hours type p,
data1(50),
data2(60),
end of itab.
data: wa like line of itab.
data: rest_hours type p.
*----populate itab..
loop at itab into wa.
if wa-hours > '8.00'.
rest_hours = wa-hours - 8.
endif.
insert into ztable values wa. "first record.
wa-hour = rest_hour.
insert into ztable values wa. "second record.
endloop.
‎2005 Nov 07 7:41 AM
Hi,
You can manually calculate the total and if the total exceeds 8hrs, you can use COPI_STRING_SPLIT function module to split the string and populate an internal table, use the internal table to insert into dbtable.
Hope this helps,
Rgds,
‎2005 Nov 07 7:56 AM
Hi,
use function <b>ceil</b>-
here's a sample:
DATA hmenge TYPE ekpo-menge.
DATA x TYPE p DECIMALS 0.
LOOP AT itab.
x = ceil( itab-menge / 8 ).
*gt 8
IF x > 1.
hmenge = itab-menge.
WHILE hmenge > 0.
ztab = itab.
IF hmenge > 8.
ztab-menge = 8.
APPEND ztab.
ELSE.
*end
ztab-menge = hmenge.
APPEND ztab.
EXIT.
ENDIF.
SUBTRACT 8 FROM hmenge.
ENDWHILE.
ELSE.
APPEND itab TO ztab.
ENDIF.
ENDLOOP.regards Andreas
‎2005 Nov 07 5:05 PM
Hi,
Since this was the continuation of the same problem, i attached my querie in the same thread,
Do we have the concept of Recurrsive call in ABAP,
I mean i would like to call same loop if condition is not satisfied.
ex loop at itab.
.....
if x ne y
<b>Can i again call the same loop</b>.
endloop
Regards,
Aima.
‎2005 Nov 07 5:08 PM
‎2005 Nov 07 5:13 PM
Hi Rich,
yes u r true i would like to go for that coz every time when i loop my values for the loop get changed, hence would like to go for tat.
Any other suggestion then plz...
Regards,
Aima
‎2005 Nov 07 5:37 PM
‎2005 Nov 07 6:12 PM
Hi
I don't know if you have integer numbers, if it's so:
LOOP AT ITAB WHERE SHFT = '00'.
CHECK ITAB-WORKTIME > 8.
TIMES = ITAB-WORKTIME DIV 8.
REST = ITAB-WORTIME MOD 8.
DO TIMES TIMES.
ITAB-WORKTIME = 8.
MOVE SY-INDEX TO ITAB-SHFT.
APPEND ITAB.
ENDDO.
ITAB-SHFT = ITAB-SHFT + 1.
ITAB-WORKTIME = REST.
MODIFY ITAB.
ENDLOOP.
Max
Message was edited by: max bianchi