cancel
Showing results for 
Search instead for 
Did you mean: 

Value Mapping - I don't want an error returned if not found

robphelan
Participant
0 Kudos

For each record I'm bringing in through AIF, I'm running it through a Value Mapping that will convert a Plant Code to a different value. The problem is that this, right now it is only applicable for 1 certain Plant so I only have 1 entry in my Value Mapping.

For instance, if the plant code is AAAA, I want to overwrite that with BBBB. So, I have created that entry in my Value Mapping table.

The problem is that when my message has a plant code of CCCC, the message errors out because CCCC doesn't exist in the Value Mapping table.

I need the message to retain CCCC since no mapping value was found and continue processing.

What would be the best way to accomplish that?

Thanks,

Robert.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Robert,

if you want to use the normal value mapping maintained in transaction /AIF/VMAP and for all plants that are not included the source value only should be passed thru as CCCC -> CCCC, you can implement a value mapping function module with "value_out = value_in" and add it to the existing value mapping customizing object. The function module will be processed in case that the the normal value mapping (maintained in VMAP) does not find a value. Then you are able add in your function module source code all additional logic you need.

Please note that the error message is looking different. To get the same error message as before have a look into this thread http://scn.sap.com/thread/3629440.

Perhaps this could also help.

Kind regards

Christoph

Former Member
0 Kudos

Hi Robert,

additional information to my comment:

In the AIF documentation (cookbook and F1-Help) there are following information:

1. The function module is always executed. Values derived from internal mapping tables or

select statements can be overwritten.

2. Define Value Mapping Function Module: Importing parameter VALUE_FOUND allows you to evaluate if a previous mapping (selection from database or values entered in transaction /AIF/VMAP) was successful.

My experience shows that the function module is only executed when the previous value mapping does not find a value.

Kind regards

Christoph

thomaselsaesser
Advisor
Advisor
0 Kudos

Hi Christoph,

happy new year! 🙂

The value mapping function module (defined in the value mapping) should always be called, even if the previous mapping found a value; do you have an example where it does not?

Best regards,

Thomas

Former Member
0 Kudos

Hi Thomas,

Thanks for your help.

@AIF Community: I used RAISE exception in the function module. This does not work (at the moment).

Correct is "MESSAGE ennn RAISING no_value_found".

Best regards

Christoph

robphelan
Participant
0 Kudos

Hi Christoph.. getting back to your reply..

In order to preserve the original external value and with the intent to NOT raise an error if a mapped value is not found, I've created a FM where the code states VALUE_OUT = VALUE_IN

When my external value does NOT find a value in /AIF/VMAP it does enter the new FM. However, the IMPORTING parameter  VALUE_FOUND = abap_false and cannot be changed.

Consequently, my message still fails & returns an error.

Our goal is to have 100% of the messages to come into our workbench - from there, the users will be able to correct.

robphelan
Participant
0 Kudos

Offhand, does AIF have any public method I can use to select from the VMAP tables? I could just do the Map Select within the FM myself.

From the basic research I've done, those VMAP values are all stored in the same 1 or 2 tables with different key fields.

Former Member
0 Kudos

Hi Robert,

try Class /AIF/CL_DB_ACCESS_VMAPS method READ_VALUE.

Kind regards

Christoph

Former Member
0 Kudos

Hi Robert,

try to enter your FM ZAIF_MARS_MATNR into your value mapping MARS_TO_SAP_PRODUCT definition instead of into the field mapping definition.

Then VALUE_FOUND can be used:

IF value_found <> abap_true.
       value_out = value_in.
ENDIF.

I implemented in case that the source value is initial set value_out on initial. This works.

Kind regards

Christoph

robphelan
Participant
0 Kudos

Hi Christoph. This did indeed work. I never thought of putting the FM in the Mapping Definition but it makes sense.

thanks!

Answers (3)

Answers (3)

thomaselsaesser
Advisor
Advisor
0 Kudos

Hi Robert,

I have another solution without ABAP-Coding:

Define in the value mapping a DB table lookup on T001 (select field BUKRS with where condition BUKRS = '$1'), and in addition allow values with "Single" and "Master Data".

Then AIF will first check if the value is an existing company code, and if not, check in the values (maintained in /AIF/VMAP, also allowing wildcards like "1*").

Finally, a value mapping function will be called (if maintained). The function will be called in both cases, when a value was determined before, and also if no value was determined.

You see, there are many ways to implement; maybe this one is the easiest, without ABAP coding and without conditional field mapping.

Best regards,

Thomas

YapingGao
Employee
Employee
0 Kudos

If your use case is that, most plant codes are to be converted into another codes via Value Mapping, but some other plant codes are not to be convered or event to be converted via a different Value Mapping, AND, it is possible to identify those plant codes accordingly a certain logic. For example,

only plant code starting with 1* should not converted, but simply copied from source to target.

In such case, you may consider to use Conditional Field Mapping as another option.

former_member486744
Discoverer
0 Kudos

Try adding a wild card entry in your value mapping table such as *  for the external value. But then you'll need some dummy internal value corresponding to those entries that you don't have value mappings for. This will allow you to bypass the error  but then you'll always get the dummy value mapped.

But wouldn't you want this since there's no plant value mapping?

Remember that you can make the raw field holding the plant changeable.

So a user can go into transaction /AIF/ERR, note the error and then update the plant accordingly prior to restarting the message etc...

Hope this helps.

Thanks.