Skip to Content
author's profile photo Former Member
Former Member

Formula in an update rule

I'm trying to update a characteristic in the update rule with the value of a date field. The problem is that there are many records being read in the update rule, and only one has the value that needs to be overwritten.

My formula is:

IF( User Status = 'I0045', Update Status, ??? )

I need to know what I should put in place of the ???. If the User Status is anything other than I0045, I don't want the rule to overwrite anything. I've tried using SKIP_RECORD(), but then none of the other update rules are engaged for that record either.

I use some key figures doing this same logic, but I have had to use MAXIMUM to get the rules to work. Does anyone know how to set a formula to overwrite or no update based on the value of a field?

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jan 26, 2007 at 10:15 PM

    Hi Adam,

    I'm not as familiar with formulas, but you can easily do this using ABAP. The rule would look something like:

    IF COMM_STRUCTURE-UserStatus = 'I0045'.

    RESULT = new_value.

    ELSE.

    RESULT = COMM_STRUCTURE-FieldName.

    ENDIF.

    You'd need to replace the fields of COMM_STRUCTURE and the value you're replacing to. The key is the the value of RESULT is what gets stored during the update.

    hope this helps.

    Adam

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      I think a lightbulb is turning on for me. I reread your posts and now I see the picture. You're trying to essentially change an account based model to a key figure based model. I've done things like this before by parsing out the fields in the start routine.

      The key to do it that way is that the data package structure has to have the extra fields that live in your communication structure. The way to do that is to add the missing fields in your transfer structure of your InfoSource and set them to No Update in the transfer rules.

      Next, you parse out the records to your comm_structure in the start routine. If you use additive updates, it's pretty straightforward. If it's an overwrite, it's a bit trickier since you need to compile the record all at once. I'll show that one below since it works for both cases. I'm trying this on the fly, so please forgive any minor syntatictical errors. The general idea is to keep parse out the data to a new table and then replace the DATA_PACKAGE with it at the end.

      DATA: lt_data type standard table of DATA_PACKAGE,

      ls_data like line of lt_data,

      current_order like DATA_PACKAGE-ORDER,

      ls_data_package like line of DATA_PACKAGE,

      first_loop type c value 'X'.

      clear: ls_data, lt_data, current_order.

      • sort data by ORDER

      sort DATA_PACKAGE by ORDER ascending.

      loop at DATA_PACKAGE into ls_data_package.

      • Check if new ORDER

      if ls_data_package-order <> current_order and first_loop <> 'X'.

      append ls_data to lt_data.

      clear: ls_data.

      endif.

      • copy key fields over (move-corresponding may work as well)

      ls_data-key1 = ls_data_package-key1.

      ...

      • parse out special data fields

      case ls_data_package-status.

      when 'I0002'.

      <logic>

      when 'I0003'.

      <logic>

      when 'I0045'.

      <logic>

      endcase.

      • set order number

      current_order = ls_data_package-order.

      • not first loop anymore

      first_loop = ''.

      endloop.

      append ls_data to lt_data.

      • replace DATA_PACKAGE with formatted data

      clear DATA_PACKAGE.

      append lines of lt_data to DATA_PACKAGE.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.