Application Development 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: 

Internal Table - logic for Chunk

amit_khare
Active Contributor
0 Kudos

Hi,

I have an internal table with n records.

I want to use at a time say max of 20 records .

This is calling a BDC.

i.e.

loop at n record.

take 20 records.

call BDC.

then next set of recrds.

repeat process till all records processed.

Thanks in Advance.

Amit

1 ACCEPTED SOLUTION

marcelo_ramos
Active Contributor
0 Kudos

Hi,

try this way.


data: count type i.

loop at table
  if count LE 20. 
    add 1 to count.
  else.
    clear count.
    call bdc.
    "refresh all the concerned tables and variables for the next 20 records.
  endif.
endloop.

Or.

loop ...

 WHILE count le 20.   
   ADD 1 TO count.
   ...            
 ENDWHILE.                    
    clear count.
    call bdc.
    "refresh all the concerned tables and variables for the next 20 records.

endloop

Regards.

Marcelo Ramos

5 REPLIES 5

Former Member
0 Kudos

Try something like this

data: remainder type i.

loop at itab.

remainder = sy-tabix mod 20.

if remainder = 0.

*-- twenty records are accumulated

call bdc.

refresh all the concerned tables and variables for the next 20 records.

else.

accumulate the records until you have 20 records.

endif.

endloop.

Former Member
0 Kudos

Hi Amit,

Maintain a counter to take 20 records to process and repeat the process still all records are completed.

DATA V_COUNT TYPE I.

DATA C_COUNT TYPE I VALUE '20'.

LOOP AT ITAB.

V_COUNT = V_COUNT + 1.

IF V_COUNT = 20.

CALL TRANSACTION ....for 20 records

REFRESH BDCDATA.

CLEAR V_COUNT.

ENDIF.

ENDLOOP.

IF V_COUNT IS NOT INITIAL AND V_COUNT < C_COUNT.

CALL TRANSACTION ....for 20 records

REFRESH BDCDATA.

ENDIF.

Thanks,

Vinay

former_member194669
Active Contributor
0 Kudos

Hi,


data : v_index like sy-tabix
loop at itab
  move corresponding itab to itab_t.
  append itab_t
  if v_index <= 20.
     v_index = v_index + 1.
     continue.
  else.
    clear v_index .
    perform BDC using itab_t.
    refresh itab_t 
  endif.
endloop.

aRs

marcelo_ramos
Active Contributor
0 Kudos

Hi,

try this way.


data: count type i.

loop at table
  if count LE 20. 
    add 1 to count.
  else.
    clear count.
    call bdc.
    "refresh all the concerned tables and variables for the next 20 records.
  endif.
endloop.

Or.

loop ...

 WHILE count le 20.   
   ADD 1 TO count.
   ...            
 ENDWHILE.                    
    clear count.
    call bdc.
    "refresh all the concerned tables and variables for the next 20 records.

endloop

Regards.

Marcelo Ramos

former_member182346
Active Contributor
0 Kudos

I hope this may be alternative....

loop at itab

count = count + 1.

if count = 20.

call BDC. "Using itab1 which holds 20 records

clear count.

refresh itab1.

else.

APPEND LINES OF itab TO itab1

endif.

Reward all usefuls

Thanks & Regards

vinsee