2014 Feb 07 9:15 AM
Hi Experts,
itab1 is header table & itab2 is line itam table.we dontknow how many entries in both the
tables.Here for each header i need to pick max 9 line items(morethan 9 line items not
supportd for FM) then i need to pass these header and 10 line items to FM...
But at the end of the below process still there some line items remaining in the itab which are not
processed...
sort itab1 by key1. "(itab1 is header table)
sort itab2 by key1. "(itab2 is line item table)
loop at itab1 into wa1.
loop at itab2 into wa2 where key1 = wa1-key1.
append wa2 to itab3.
if sy-tfill eq 9.
delete itab1 from index 1 to 9.
call <..function module...>
{
wa1 & itab3(9 line items) "here our fm supports max 9 line items eventhough
} " if we have 100 line items for heade1 in itab1
endif.
endloop.
endloop.
Please help me ...thanks in advance....
Regards,
kranthi
Hi Sriram,Harsh Bansal,Nabheet and all others thank you for ur suggestions..
Sriram Iam doing lit bit modification for ur code jst have a look is it fine
DO.
LOOP AT itab2.
itab3 = itab2.
APPEND itab3.
CLEAR itab3.
DESCRIBE TABLE itab3 LINES n.
DELETE itab2 INDEX sy-index.
IF n EQ 9.
EXIT.
ENDIF.
ENDLOOP.
*FM logic
REFRESH itab3[].
CLEAR :lv_flag,n.
IF itab2[] IS INITIAL.
EXIT.
ENDIF.
ENDDO.
Regards,
Kranthi,
2014 Feb 07 9:34 AM
Hi Kranthi,
The sy-tfill will have the number of total entries in itab2. I don't think it will help you here. Use Describe table itab3 and then sy-tfill will have number of rows in itab3.
Regards,
Harsh Bansal
2014 Feb 07 10:38 AM
sort itab1 by key1. "(itab1 is header table)
sort itab2 by key1. "(itab2 is line item table)
loop at itab1 into wa1.
loop at itab2 into wa2 where key1 = wa1-key1.
append wa2 to itab3.
if lines (itab3) eq 9.
delete itab2 from index 1 to 9.
call <..function module...>
{
wa1 & itab3(9 line items) "here our fm supports max 9 line items eventhough
} " if we have 100 line items for heade1 in itab1
endif.
endloop.
endloop.
2014 Feb 07 11:28 AM
Hi Nabheet and others thanks
I tried what u said but it is not wotking fine....
If we have 1 header and 30 line items
we can process bunch of line items like this 1-9 with header1,10-18 with header1 and 19-27 with header1,
then after condition failed (if sy-tfill eq 9 ) fm not called and am unable to pass header 1 and remaining 3 line items to fm
So finally each header there are some unprocessed line items are still remininag in line item table
Please suggest any idea for this....
Regards,
kranthi
2014 Feb 07 11:35 AM
2014 Feb 07 11:58 AM
change the original code as this -
loop at itab1 into wa1.
loop at itab2 into wa2 where key1 = wa1-key1.
Clear lv_index.
lv_index = sy-tabix.
append wa2 to itab3.
if lines (itab3) EQ 9.
delete itab2 from index 1 to 9.
call <..function module...>
{
wa1 & itab3(9 line items) "here our fm supports max 9 line items eventhough
} " if we have 100 line items for heade1 in itab1
elseif lines( itab3 [] ) LT 9.
lv_index = lv_index + 1.
READ TABLE ITAB2 INTO WA2 INDEX lv_index.
if sy-subrc EQ 0 AND wa2-key1 NE wa1-key1.
PROCESS YOUR LOGIC
endif.
endif.
endloop.
endloop.
Thanks, Abhinab
2014 Feb 07 12:33 PM
Hi,
Please proceed as follows -
DATA: lv_count TYPE i.
sort itab1 by key1. "(itab1 is header table)
sort itab2 by key1. "(itab2 is line item table)
loop at itab1 into wa1.
REFRESH: lt_temp.
lt_temp = itab2.
DELETE FROM lt_temp WHERE key1 NE wa1-key1.
DESCRIBE lt_temp.
lv_count = sy-tfill / 9.
lv_count = lv_count + 1.
DO lv_count TIMES.
DESCRIBE lt_temp.
REFRESH: lt_final.
IF sy-tfill GE 9.
INSERT LINES OF lt_temp FROM 1 TO 9 INTO lt_final.
DELETE lt_temp FROM INDEX 1 TO 9.
ELSE.
INSERT LINES OF lt_temp FROM 1 TO sy-tfill INTO lt_final.
ENDIF.
call <..function module...>
{
Use lt_final here for your processing.
}
ENDDO.
endloop.
Hope it is clear now.
Regards,
Harsh bansal
2014 Feb 07 10:58 AM
Hi Kranthi,
May be you can do something like this.
Modify it as per your need.
data: lv_line type int4,
lv_div type int4,
lv_mod type int4,
lv_from type i,
lv_to type i.
loop at itab1 into lstab1.
read table itab2 into lstab2 with key key1 = lstab1-key1.
if sy-subrc = 0.
append lstab2 to itab3.
endif.
endloop.
describe itab3 into lv_line.
lv_div = lv_line div 9.
lv_rem = lv_line mod 9.
if lv_rem is not initial.
lv_div = lv_div + 1.
endif.
do lv_div times.
lv_from = ( sy-index - 1 ) * 9 + 1.
lv_to = lv_to + 9.
loop at itab3 into wa3 from lv_from to lv_to.
append wa3 to itab4.
read table itab1 into ls_tab1 with key key1 = wa3-key1.
call the function with itab4 and the lstab1.
endloop.
enddo.
Regards.
Dhananjay
2014 Feb 07 11:15 AM
Hi Kranthi,
You can use sy-index instead of sy-tfill.
Hope this will solve ur issue
Regards
Rounak
2014 Feb 07 12:34 PM
Hi,
Please proceed as follows -
DATA: lv_count TYPE i.
sort itab1 by key1. "(itab1 is header table)
sort itab2 by key1. "(itab2 is line item table)
loop at itab1 into wa1.
REFRESH: lt_temp.
lt_temp = itab2.
DELETE FROM lt_temp WHERE key1 NE wa1-key1.
DESCRIBE lt_temp.
lv_count = sy-tfill / 9.
lv_count = lv_count + 1.
DO lv_count TIMES.
DESCRIBE lt_temp.
REFRESH: lt_final.
IF sy-tfill GE 9.
INSERT LINES OF lt_temp FROM 1 TO 9 INTO lt_final.
DELETE lt_temp FROM INDEX 1 TO 9.
ELSE.
INSERT LINES OF lt_temp FROM 1 TO sy-tfill INTO lt_final.
ENDIF.
call <..function module...>
{
Use lt_final here for your processing.
}
ENDDO.
endloop.
Hope it is clear now.
Regards,
Harsh bansal
2014 Feb 07 1:21 PM
2014 Feb 08 6:22 AM
Hi Sriram,Harsh Bansal,Nabheet and all others thank you for ur suggestions..
Sriram Iam doing lit bit modification for ur code jst have a look is it fine
DO.
LOOP AT itab2.
itab3 = itab2.
APPEND itab3.
CLEAR itab3.
DESCRIBE TABLE itab3 LINES n.
DELETE itab2 INDEX sy-index.
IF n EQ 9.
EXIT.
ENDIF.
ENDLOOP.
*FM logic
REFRESH itab3[].
CLEAR :lv_flag,n.
IF itab2[] IS INITIAL.
EXIT.
ENDIF.
ENDDO.
Regards,
Kranthi,
2014 Feb 08 3:37 PM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |