‎2006 Dec 15 10:38 AM
hello everybody
im getting a short dump of memory storage not available when double looping
loop at idatafile into wa_datafile.
refresh i_update_bef.
refresh i_old_bef.
refresh i_old_after.
date = sy-datum.
concatenate date6(2) date4(2) date+0(4) into date2
separated by '.' .
concatenate '31' '12' '9999' into end_date
separated by '.' .
concatenate '9999' '12' '31' into end_date2.
refresh icustomer.
select * from knvh into
corresponding fields of table icustomer
where hkunnr = wa_datafile-kunnr
and hvkorg = wa_datafile-old_vkorg
and hvtweg = wa_datafile-old_vtweg
and hspart = wa_datafile-old_spart.
loop at icustomer into wa_customer.
clear datab.
datab = wa_customer-datab.
CALL FUNCTION 'BAPI_CUSTOMER_GET_CHILDREN'
EXPORTING
VALID_ON = wa_customer-datab
CUSTHITYP = wa_customer-hityp
NODE_LEVEL = '00'
CUSTOMERNO = wa_datafile-kunnr
IMPORTING
RETURN = return
TABLES
SALES_AREA = isales
NODE_LIST = inode.
loop at inode into wa_node.
if wa_node-parent_customer is initial.
wa_update-parent_customer = wa_node-customer.
wa_update-parent_sales_org = wa_datafile-new_vkorg.
wa_update-parent_distr_chan = wa_datafile-new_vtweg.
wa_update-parent_division = wa_datafile-new_spart.
wa_update-custhityp = wa_node-custhityp.
wa_update-valid_to = end_date2.
wa_update-valid_from = wa_customer-datab.
append wa_update to i_update_after.
wa_update-parent_customer = wa_node-customer.
wa_update-parent_sales_org = wa_datafile-old_vkorg.
wa_update-parent_distr_chan = wa_datafile-old_vtweg.
wa_update-parent_division = wa_datafile-old_spart.
wa_update-custhityp = wa_node-custhityp.
wa_update-valid_to = wa_node-valid_to.
wa_update-customer = space.
wa_update-salesorg = wa_datafile-old_vkorg.
wa_update-distr_chan = wa_datafile-old_vtweg.
wa_update-division = wa_datafile-old_spart.
wa_update-custhityp = wa_node-custhityp.
wa_update-valid_from = wa_node-valid_from.
append wa_update to i_old_bef.
else.
clear date3.
concatenate date0(4) date4(2) date+6(2) into date3.
wa_update-parent_customer = wa_node-parent_customer.
wa_update-parent_sales_org = wa_datafile-old_vkorg.
wa_update-parent_distr_chan = wa_datafile-old_vtweg.
wa_update-parent_division = wa_datafile-old_spart.
wa_update-custhityp = wa_node-custhityp.
wa_update-valid_to = wa_node-valid_to.
wa_update-customer = wa_node-customer.
wa_update-salesorg = wa_datafile-old_vkorg.
wa_update-distr_chan = wa_datafile-old_vtweg.
wa_update-division = wa_datafile-old_spart.
wa_update-custhityp = wa_node-custhityp.
wa_update-valid_from = wa_node-valid_from.
append wa_update to i_old_bef.
*check if customer exist in new sales area
*if it exits check in table knvh
*if it does not exist, insert
select single *
into wa_knvv
from knvv
where kunnr = wa_node-customer
and vkorg = wa_datafile-new_vkorg
and vtweg = wa_datafile-new_vtweg
and spart = wa_datafile-new_spart.
if sy-subrc ne 0.
*if customer doesnt exist in new sales area, create it in new_sales area
select single
ktokd into ktokd
from kna1
where kunnr = wa_node-customer.
if ktokd = c_h_acc_group.
perform copy_sales_area_hierarchy
using wa_node-customer wa_datafile-new_vkorg
wa_datafile-new_vtweg wa_datafile-new_spart
wa_datafile-old_vkorg wa_datafile-old_vtweg
wa_datafile-old_spart.
else.
perform copy_sales_area
using wa_node-customer wa_datafile-new_vkorg
wa_datafile-new_vtweg wa_datafile-new_spart
wa_datafile-old_vkorg wa_datafile-old_vtweg
wa_datafile-old_spart.
endif.
endif.
select single *
into wa_knvh
from knvh
where hityp = wa_node-custhityp
and hkunnr = wa_node-parent_customer
and hvkorg = wa_datafile-new_vkorg
and hvtweg = wa_datafile-new_vtweg
and hspart = wa_datafile-new_spart
and datab = wa_node-valid_from.
if sy-subrc ne 0.
wa_update-parent_customer = wa_node-parent_customer.
wa_update-parent_sales_org = wa_datafile-new_vkorg.
wa_update-parent_distr_chan = wa_datafile-new_vtweg.
wa_update-parent_division = wa_datafile-new_spart.
wa_update-custhityp = wa_node-custhityp.
wa_update-valid_to = end_date2.
wa_update-customer = wa_node-customer.
wa_update-salesorg = wa_datafile-new_vkorg.
wa_update-distr_chan = wa_datafile-new_vtweg.
wa_update-division = wa_datafile-new_spart.
wa_update-custhityp = wa_node-custhityp.
wa_update-valid_to = wa_node-valid_to.
wa_update-valid_from = wa_customer-datab.
append wa_update to i_update_after.
else.
concatenate 'customer' wa_node-customer
'does not exist in sales area'
wa_datafile-new_vkorg wa_datafile-new_vtweg
wa_datafile-new_spart into wa_error-message_v1.
append wa_error to return4.
endif.
endif. "if wa_node-parent_customer is initial.
endloop.
endloop.
can i use a free memory ?
will this affect the contents of the internal table?
should i use this command at the end of ecah loop?
‎2006 Dec 15 11:21 AM
Hi ,
I don't think Free Memory will help you in preventing the run-time dump. But i guess strucuturing your program in a better way will certainly will.
Remove the following statement from within the loop.
<b>select * from knvh into
corresponding fields of table icustomer
where hkunnr = wa_datafile-kunnr
and hvkorg = wa_datafile-old_vkorg
and hvtweg = wa_datafile-old_vtweg
and hspart = wa_datafile-old_spart.</b>
You can select all data from KNVH table based on the entries in your internal table idatafile using for all entries instead of using a loop-endloop construct.
This would help you to reduce the no: of loops from 3 to 2.
Get the field kunnr into the structure of internal table icustomer so that you can select using the above statment & use it in your loop.
Regards,
Chetan.
PS:Reward points if this helps.
‎2006 Dec 15 10:41 AM
Hi,
I can see only two endloop but 3 loops.
Try avoiding more complicated nested loops.
‎2006 Dec 15 10:44 AM
yea there are 3 loops, i forgot to put the endloop for the 3rd one, but tell me can i use the free memory?
‎2006 Dec 15 11:04 AM
Hi Sia,
Free memory statement releases an area in ABAP memory that was previously created with EXPORT TO MEMORY. An IMPORT ... FROM MEMORY .
reward points if it is helpful.
Regards,
Kirna I
‎2006 Dec 15 11:06 AM
‎2006 Dec 15 10:59 AM
Hi,
Free memory is nothing to do with internal table declared and used in the same program.It is used to free the ABAP memory.i.e. if you have used export memory ... somewhere,you cannot import the contents.
Check this link for more information.
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/free_mem.htm
‎2006 Dec 15 11:21 AM
Hi ,
I don't think Free Memory will help you in preventing the run-time dump. But i guess strucuturing your program in a better way will certainly will.
Remove the following statement from within the loop.
<b>select * from knvh into
corresponding fields of table icustomer
where hkunnr = wa_datafile-kunnr
and hvkorg = wa_datafile-old_vkorg
and hvtweg = wa_datafile-old_vtweg
and hspart = wa_datafile-old_spart.</b>
You can select all data from KNVH table based on the entries in your internal table idatafile using for all entries instead of using a loop-endloop construct.
This would help you to reduce the no: of loops from 3 to 2.
Get the field kunnr into the structure of internal table icustomer so that you can select using the above statment & use it in your loop.
Regards,
Chetan.
PS:Reward points if this helps.