cancel
Showing results for 
Search instead for 
Did you mean: 

Checking product exists in location before creating quota

Former Member
0 Kudos

Hi,

We have a custom program which creates the QUOTA via BAPI BAPI_QTASRVAPS_SAVEMULTI2 using entries from a flat file.

Somehow this program is incorretcly creating entries for products which do not exist in the target location.As aresult,when I run tcode /sapapo/scc_tq1,and then select a material to view details ,it displays error message “PRODUCT XXXX does not exist in location XXX’.

Hence I need to perform a check in the program to see if the product exists in that location.

I want to do a similar chekc as in the standard error message /SAPAPO/OO_TR 183.

I debugged this error mesage and found that the check was done via FM /SAPAPO/DM_MATLOC_GET_DATA to which the MAT ID(GUID) and LOC ID(GUID) is passed,but when I ruin this FM in Se37 with the MAT ID,LOC ID and version values,I see the error message "Location does not exist".

Please let me know how do Check if the product is existing in a location ?Is there any FM available?

Accepted Solutions (1)

Accepted Solutions (1)

rajkj
Active Contributor
0 Kudos

Hi,

The specified FM is used to get the location product data. However, the quota creation program is written to trigger the message 183 if SY-SUBRC > 0. Probably, you may use the following FM to filter out existing and non-existing location products.

/SAPAPO/DM_MATLOC_EXIST_CHECK

This is a very simple FM that checks buffer for existence of given mat id and loc id combination. If the combination is not found, it executes a simple SQL query on /sapap/matloc table and retrieve the record.

Thanks,

Rajesh

Former Member
0 Kudos

Thanks Rajesh.

Also in std tarsanction when creating the quota entries,if the material doesn't exist in the location,then does the system show the error message

“PRODUCT XXXX does not exist in location XXX’ and does not create the entries?

Another problem I'm facing with the BAPI is that it creates the quota entries but w/o the item details?What could be the probable reasons why the BAPIO doesnt create the item details?

NOTE:I'm passing the ITEM details to the BAPI but only the header structure gets created.

Any pointers?

rajkj
Active Contributor
0 Kudos

From your response, I assume that you might be trying to create inbound quotas through BAPI as outbound quota creation checks the location product existence before creating header entry.

In case of inbound quotas, header entry usually checks product level existence at global level. However, when you get into item level, you need to specify the location, source of supply, quota percentage, etc. That's the reason, your BAPI execution creates header entry but fails to create entries at item level.

Thanks,

Rajesh

Former Member
0 Kudos

Yes,I'm creating inbound quota in APO from flat file for the entries which are already created in ECC.So you mean in the item table which is passed to the BAPI,I need to pass the location, source of supply, quota percentage to make sure the items are created?

Also in the standard the system issues an error message if the product doesnt exists in the location for which the quota is being created but if I use BAPI,the system still goes ahead and create the quota netries with both header and item and only when I go and check the details in tcode /sapapo/scc_tq1,I see the error message

“PRODUCT XXXX does not exist in location XXX’.

I'm thinking to add logic to check if the product exists for the location before creating the quota so that no quota is created for these invalid products whcih do not even exists in the location.

rajkj
Active Contributor
0 Kudos

Quite often BAPI's won't execute the preconditions or checks similar to interactive execution depending on how they were programmed.

In your case, the specified BAPI populate the quota table with the data from flat file. However, when you access this data at item level, the background consistency check that executes before showing up the data fails and hence, you get the error.

It makes perfect sense to check the location product existence before executing the BAPI to create inbound quota arrangements.

rajkj
Active Contributor
0 Kudos

I have just checked another FM "/sapapo/dm_matloc_show" that has useful code to check the location products based on their numbers rahter than their GUID. You can define your own function module by reusing that code that queries the view "/sapapo/v_matmod".

- Rajesh

Former Member
0 Kudos

Thanks rajesh.

Can you please let me know what data to pass to whcih parameter in the FM sapapo/dm_matloc_show?

Also i tried executing the FM /SAPAPO/DM_MATLOC_EXIST_CHECK but couldnt find how to enter the values for tyhe import parameter IT_ID.

Thanks for your time.I'm also somehow not able to reaward points to your responses but will check again.

rajkj
Active Contributor
0 Kudos

Please refer the FM /SAPAPO/TR_TP_CHK_MATLOC (from line # 106) to get an idea on calling the required FM /SAPAPO/DM_MATLOC_EXIST_CHECK.

Thanks,
Rajesh

Answers (0)