cancel
Showing results for 
Search instead for 
Did you mean: 

CRM_ORDER_READ in loop gives memory dump

Former Member
0 Kudos

Hi,

I created one custom function module in which i am using CRM_ORDER_READ in the loop and reading the requested start date of the service order which is given by the user as a selection parameter.

LOOP AT t_itm_srvo INTO ds_itm_srvo. " this table contains the records of the crmd_orderadm_h

REFRESH lt_guid.

CLEAR: lt_guid ." ds_itm_srvo.

APPEND ds_itm_srvo-guid TO lt_guid.

REFRESH: lt_pricing_i, lt_partner, lt_appointment,lt_orgman,lt_status.

CLEAR: ds_pricing_i, ds_partner, ds_appointment,ds_orgman,ds_status.

CALL FUNCTION 'CRM_ORDER_READ'

EXPORTING

it_header_guid = lt_guid

  • it_item_guid = lt_guid

IMPORTING

et_pricing_i = lt_pricing_i

et_appointment = lt_appointment

et_partner = lt_partner

et_orgman = lt_orgman

et_status = lt_status.

LOOP AT lt_appointment INTO ds_appointment WHERE ref_guid = ds_itm_srvo-guid AND

appt_type = 'SRV_CUST_BEG'.

  • ( appt_type = 'SRV_CUST_BEG' OR

  • appt_type = 'VALIDFROM').

EXIT.

ENDLOOP.

IF sy-subrc = 0.

date_from = ds_appointment-date_from.

IF NOT r_st_date[] IS INITIAL.

IF ds_appointment-date_from NOT IN r_st_date.

CONTINUE.

ENDIF.

ELSE.

gs_result-valid_from = date_from.

ENDIF.

ENDIF.

ENDLOOP.

I don't have to consider those records where requested start date is not in selection parameter. This function module runs for ever and at the end it gives short dump TSV_LIN_ALLOC_FAILED.

Could anyone please suggest me why this is taking long time or is their any better alternative so that i can avoid using this FM.

Regards,

Kamesh Bathla

Accepted Solutions (0)

Answers (1)

Answers (1)

BGarcia
Active Contributor
0 Kudos

Hi Kamesh,

How many guid/documents do you have in table t_itm_srvo?

If you have tons of them, maybe the system will not have the memory/capacity needed to perform your calculations.

Also, you can accelerate the CRM_ORDER_READ processing time. Just declare the objects that you want to read in importing parameter it_requested_objects. Here's an example that I had here:


  INCLUDE crm_direct.
  INSERT gc_object_name-appointment INTO TABLE lt_req_objects.
  INSERT gc_object_name-orderadm_h  INTO TABLE lt_req_objects.
  INSERT gc_object_name-doc_flow    INTO TABLE lt_req_objects.
  INSERT gc_object_name-activity_h  INTO TABLE lt_req_objects.

  CALL FUNCTION 'CRM_ORDER_READ'
    EXPORTING
      it_header_guid       = lt_header_guid
      it_requested_objects = lt_req_objects
   ...

You can check also how the system will behave if you call only once this function. Put all guids into lt_guid table, and call it. This also may improve your performance issue. Something like this:


   LOOP AT t_itm_srvo INTO ds_itm_srvo. " this table contains the records of the crmd_orderadm_h
     APPEND ds_itm_srvo-guid TO lt_guid.
   ENDLOOP.

   REFRESH: lt_pricing_i, lt_partner, lt_appointment,lt_orgman,lt_status.
   CLEAR: ds_pricing_i, ds_partner, ds_appointment,ds_orgman,ds_status.

   CALL FUNCTION 'CRM_ORDER_READ'
     EXPORTING
       it_header_guid = lt_guid
     IMPORTING
       et_pricing_i   = lt_pricing_i
       et_appointment = lt_appointment
       et_partner     = lt_partner
       et_orgman      = lt_orgman
       et_status      = lt_status.

**** YOU SHOULD TREAT THE EXCEPTIONS, OR A SHORTDUMP MAY OCCUR.


   LOOP AT t_itm_srvo INTO ds_itm_srvo.
   LOOP AT lt_appointment INTO ds_appointment WHERE ref_guid = ds_itm_srvo-guid AND
                                                     appt_type = 'SRV_CUST_BEG'.
*                                                      ( appt_type = 'SRV_CUST_BEG' OR
*                                                        appt_type = 'VALIDFROM').
      EXIT.
    ENDLOOP.
    IF sy-subrc = 0.
      date_from = ds_appointment-date_from.
       IF NOT r_st_date[] IS INITIAL.
        IF ds_appointment-date_from NOT IN r_st_date.
          CONTINUE.
        ENDIF.
      ELSE.
        gs_result-valid_from = date_from.
      ENDIF.
    ENDIF.
  ENDLOOP.

Hope that this may help you a little further.

Kind regards,

Garcia

Former Member
0 Kudos

Hi,

Thanks for the reply, my internal table has 8000 records, i will try to follow the suggestions which you gave and will see if it makes a difference.

Regards,

Kamesh Bathla

Former Member
0 Kudos

Also try to use the FM CRM_ORDER_INITIALIZE after every read. Pass the guid that you have used to read the CRM_ORDER_READ. This will clear the memory.

CALL FUNCTION 'CRM_ORDER_INITIALIZE'

EXPORTING

IT_GUIDS_TO_INIT = LIT_OBJ

EXCEPTIONS

OTHERS = 2.

Former Member
0 Kudos

Hi,

I tried by passing lt_req_objects

CALL FUNCTION 'CRM_ORDER_READ'

EXPORTING

it_header_guid = lt_guid

it_requested_objects = lt_req_objects

  • it_item_guid = lt_guid

IMPORTING

et_pricing_i = lt_pricing_i

et_appointment = lt_appointment

et_partner = lt_partner

et_orgman = lt_orgman

et_status = lt_status

EXCEPTIONS

DOCUMENT_NOT_FOUND = 1

ERROR_OCCURRED = 2

DOCUMENT_LOCKED = 3

NO_CHANGE_AUTHORITY = 4

NO_DISPLAY_AUTHORITY = 5

NO_CHANGE_ALLOWED = 6

OTHERS = 7

.

i am also using initialize after the read

CALL FUNCTION 'CRM_ORDER_INITIALIZE'

EXPORTING

IT_GUIDS_TO_INIT = lt_guid

  • IV_INITIALIZE_WHOLE_BUFFER =

  • IV_INIT_FRAME_LOG =

  • IV_LOG_HANDLE =

  • IV_KEEP_LOCK = FALSE

IMPORTING

ET_INITIALIZED_OBJECTS = lt_guid1

EXCEPTIONS

ERROR_OCCURRED = 1

OTHERS = 2

.

still its giving the same dump.

does it related to table space or shall i ask basis people to look over the dump?

Regards,

Kamesh Bathla

Former Member
0 Kudos

If you are passing all the 8000 guid's once , i think you will get the dump.pass limited amount numbre or Pass one by one and use CRM_ORDER_INIT*.

Former Member
0 Kudos

Hi,

I am not passing 8000 guids at once, i am passing it one at a time.

Regards,

Kamesh Bathla

Former Member
0 Kudos

Hi,

I am using CRM_ORDER_READ just to filter out my result table on the basis of appointment date i.e et_appointment appt_type = 'SRV_CUST_BEG'. is there any way i can filter the record in my select query itself on the basis of appointment date, in that case i don't have to go to CRM_ORDER_READ.

Regards,

Kamesh Bathla

BGarcia
Active Contributor
0 Kudos

Hi Kamesh,

Just to share one more idea:

You can build a table vision based on the conditions that you've learned in this thread:

Then, to search with timestamps, you have to transform your dates into timestamps.

Example:

Date from = 01.01.2009

Date to = 31.01.2009


DATA lv_timestamp_from TYPE timestamp.
DATA lv_timestamp_to   TYPE timestamp.
DATA lv_date_from      TYPE udate VALUE '20090101'.
DATA lv_date_to        TYPE udate VALUE '20090131'.

*- Conversions
CONVERT DATE lv_date_from TIME '000000' INTO TIME STAMP lv_timestamp_from TIME ZONE sy-zonlo.
CONVERT DATE lv_date_to TIME '235959' INTO TIME STAMP lv_timestamp_to TIME ZONE sy-zonlo.

Then use the timestamp variables and the table vision, to filter the documents guids that you want to use.

Kind regards,

Garcia

Former Member
0 Kudos

Hi Bruno,

The problem I am facing is that date_to and date_from are select options and not parameter field.

Regards,

Kamesh Bathla