cancel
Showing results for 
Search instead for 
Did you mean: 

CRM_ORDER_MAINTAIN: Unable to maintain HEADER level Pricing Conditions.

Former Member
0 Kudos

Hi Gurus,

I hope someone here can help me resolve this problem. Our release is CRM 4.0, patch level 8.

I'm basically trying to change existing pricing conditions on a CRM Order via an Action in a BADI method call.

Both Item level and Header level pricing conditions are to be updated by this Action.

I'm using CRM_ORDER_READ to first get the original Pricing Document data from the order. Then, I reformat and change the the data (only KBETR is changed) and call CRM_ORDER_MAINTAIN to maintain the conditions.

Now the strange thing is, all the ITEM level conditions are being changed correctly, as well as the FIRST condition in the header. All other conditions that should have been changed in the HEADER (about 10 more of them), were left unchanged.

Has anyone else had this problem before?

Also, it would be great if someone could post some sample code to change Header conditions in a CRM order. Thanks in advance!

Cheers,

Justin.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I think the best would be if you would debug this. First thing which you need to do is to call transaction CRMD_ORDER. Change the header level Pricing Conditions of the relevant order.

But before this, call transaction SE24 and go into detail of the class CL_CRM_1O_MAIN.

Go to method 'MAINTAIN_ORDER' and from there to method CALL METHOD me->maintain_1o.

If you jump into maintain_1o, then set a breakpoint at the function call CRM_ORDER_MAINTAIN.

If you change now the Pricing conditions of the order via transaction CRMD_ORDER, the program will stop there. You can then easily see, how the function module has to be filled (which fields in detail) in order to achieve what you mentioned (change of Pricing Conditions).Pass similar values to your FM also.

You will get the desirable output.

Hope it helps.

Regards,

Amit

Justin-Seow
Discoverer
0 Kudos

Hi,

Thanks for your reply Amit.

I have already debugged CRM_ORDER_MAINTAIN during change of conditions in CRMD_ORDER, but the call to the FM did not pass any values in IT_PRIDOC. Instead, a single record was passed in CT_INPUT_FIELDS for object PRIDOC. This (eventually) triggered an Event which then read the changed conditions from the buffer. That means the standard program somehow had earlier put the changed data into the buffer before the call to CRM_ORDER_MAINTAIN. I have no idea what was called to put the data there.

But that's not the problem. The problem is, I have so far been able to change all item level conditions without any problems, as well as the first condition in the header level. This was achieved by passing IT_PRIDOC into CRM_ORDER_MAINTAIN with the following contents:

- REF_KIND = 'A' (orderadm_h)

- REF_GUID = <my order guid>

- PRICING_TYPE = 'G'

- PRIC_COND populated with the condition records to be changed, copied "as is" from the output of CRM_ORDER_READ

- COND_CHANGE populated with my changes (move-corresponding from PRIC_COND, then KBETR is changed to the desired value).

My main question is, something about changing header conditions must be different from changing the item conditions, apart from the value of KPOSN in PRIC_COND (000000 for header conditions, item guid for item conditions). I need to know if there's anything else I need to do apart from that..

Or is this a known problem?

Former Member
0 Kudos

Hi Justin,

I think KPOSN is used to differentiate between header and item conditions.

Regards,

Amit

Answers (1)

Answers (1)

0 Kudos

Justin,

Send me the code what excatly you are doing after calling FM 'CRM_ORDER_READ'. May be I would be able to help or give some inputs.

Regards

VG

Former Member
0 Kudos

Hi Vaibhav,

Thanks for your reply, but I've actually fixed this myself a while ago.

[NOTE THAT THIS PROBLEM ONLY HAPPENS FOR HEADER CONDITIONS]

The cause of the problem was as follows:

- The data provided by CRM_ORDER_READ in ET_PRIDOC was taken from the DB tables for pricing documents in the CRM server (PRCD_* tables).

- However, when CRM_ORDER_MAINTAIN tries to maintain the pricing document, it makes a comparison of the data to be maintained with data stored in the IPC instead of CRM.

- For some reason, the Condition Counter field (ZAEHK) in CRM does not match the same field value in IPC. This failure results in the pricing document not being maintained. Strangely, no error messages were shown either. It can only be seen via debug.

To solve the problem:

- Read the header conditions directly from the IPC using function module PRC_PD_HEAD_SHOW.

- Amend the condition counter ZAEHK values from the IPC into the data returned by CRM_ORDER_READ.

- Amend the desired maintenance values (change condition values, etc.)

- Feed the amended data into CRM_ORDER_MAINTAIN.

There probably is a good explanation for the difference between the IPC condition counter and CRM condition counter (and a proper fix to it), but as it stood, i didn't have the time to investigate further, hence this "dodgy" solution.

I hope this might help some other poor souls affected by this problem. Cheers.

0 Kudos

Hi Justin,

I am not able to change itemlevel pricing condition using crm_order_maintain fm.

could you please help me.

Regards,

Indhra.E

Former Member
0 Kudos

Hi Justin,

I have a similar requirement like you to add a new condition type in the header level and change it as well. I tried many methods as suggested in SAP SCN but in vain. Finally I came across this post and made changes in my code as you specified it. But I couldnt add a new condition type. Please help me in fixing this issue and i have posted my code below for your reference.

SELECT SINGLE GUID OBJECT_ID PROCESS_TYPE

          FROM   CRMD_ORDERADM_H

          INTO   (LV_GUID,LV_OBJECT_ID,LV_PROCESS_TYPE )

          WHERE  GUID EQ IV_GUID.

    IF LV_PROCESS_TYPE EQ 'ZSQT' OR

      LV_PROCESS_TYPE EQ 'ZQIN' OR

      LV_PROCESS_TYPE EQ 'ZQIC'.

     APPEND LV_GUID TO IT_HEADER_GUID.

*Read the Pricing Document Conditions FROM CRM_ORDER_READ

*USING EXPORT PARAMETER ET_PRIDOC

     CALL FUNCTION 'CRM_ORDER_READ'

       EXPORTING

         IT_HEADER_GUID       = IT_HEADER_GUID

       IMPORTING

         ET_PRIDOC            = IT_PRIDOC

       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.

     IF SY-SUBRC <> 0.

* Implement suitable error handling here

     ENDIF.

      LOOP AT IT_PRIDOC INTO WA_PRIDOC.

       READ TABLE WA_PRIDOC-PRIC_COND INTO WA_PRIC_COND

                  WITH KEY KSCHL = 'ZAMP'.

       IF SY-SUBRC EQ 0.

         LV_ZAMP = 1.

         WA_ZAMP = WA_PRIC_COND.

        ENDIF.

       LOOP AT WA_PRIDOC-PRIC_COND INTO WA_PRIC_COND

               WHERE KSCHL = 'YAMP' AND

                     KBETR IS NOT INITIAL.

         LV_KBETR = LV_KBETR + WA_PRIC_COND-KBETR.

         LV_COUNT = LV_COUNT + 1.

       ENDLOOP.

     ENDLOOP.

     READ TABLE IT_PRIDOC INTO WA_PRIDOC INDEX 1.

     IF SY-SUBRC = 0.

       DELETE WA_PRIDOC-PRIC_COND WHERE KSCHL NE 'ZAMP'.

       IT_TEMP_COND[] = WA_PRIDOC-PRIC_COND[].

       LOOP AT IT_TEMP_COND INTO WA_PRIC_COND.

         MOVE-CORRESPONDING WA_PRIC_COND TO WA_COND_CHANGE.

         WA_COND_CHANGE-KBETR = LV_KBETR.

         INSERT WA_COND_CHANGE INTO TABLE IT_COND_CHANGE.

         CLEAR: WA_COND_CHANGE.

       ENDLOOP.

     ENDIF.

     IF LV_COUNT GT 0.

*  *Calculating the Average Mark up 'ZAMP' From YAMP item conditions

       LV_KBETR = LV_KBETR / LV_COUNT.

     ENDIF.

*Populate new condition rate

     CLEAR: ls_cond_h, WA_COND_ADD, LS_COND_H-COND_ADD,

            IT_PRI_DOC[].

     CLEAR: LS_INPUT_FIELDS, LS_INPUT_FIELDS-FIELD_NAMES,

            WA_FIELD_NAMES, IT_FIELD_NAMES[].

     REFRESH LT_INPUT_FIELDS.

      IF LV_ZAMP NE 1.

         ls_cond_h-ref_guid = IV_GUID.

         ls_cond_h-ref_kind = 'A'.

         LS_COND_H-PRICING_TYPE = 'B'.

         "LS_COND_H-PRIC_COND = IT_TEMP_COND.

         WA_COND_ADD-KSCHL = 'ZAMP'.

         WA_COND_ADD-KBETR = LV_KBETR.

         INSERT WA_COND_ADD INTO TABLE  LS_COND_H-COND_ADD.

         INSERT LS_COND_H INTO TABLE  IT_PRI_DOC.

      ELSEIF LV_ZAMP EQ 1.

         ls_cond_h-ref_guid = IV_GUID.

         ls_cond_h-ref_kind = 'A'.

         LS_COND_H-PRICING_TYPE = 'G'.

         LS_COND_H-PRIC_COND = IT_TEMP_COND.

         LS_COND_H-COND_CHANGE = IT_COND_CHANGE.

         INSERT LS_COND_H INTO TABLE  IT_PRI_DOC.

       ENDIF.

     CALL FUNCTION 'CRM_ORDER_MAINTAIN'

       EXPORTING

         IT_PRIDOC         = IT_PRI_DOC

       EXCEPTIONS

         ERROR_OCCURRED    = 1

         DOCUMENT_LOCKED   = 2

         NO_CHANGE_ALLOWED = 3

         NO_AUTHORITY      = 4

         OTHERS            = 5.

   ENDIF.