We are using user exit EXIT_SAPLATPC_002 to modify ATP after determination by the system. However, when a material is listed multiple times on purchase order/STO, when reaching this user exit all the line items related to this material appear in the table T_ATPCSX.
When there are multiple materials (and no duplication of materials in the line items) this problem does not exist, as the user exit is run for each material individually and the table T_ATPCSX appears only for the given material.
The problem lies in modifying the availability/committed quantity via table T_MDVEX. There is no way to determine which line in T_MDVEX is for whichline in the STO/purchase order when there are multiple lines containing the same material - T_MDVEX contains no identifying information besides perhaps quantity and date - and that should not be the information you match up table T_ATPCSX with table T_MDVEX for, as it's pretty unreliable when you could have duplicate lines with the
same quantities and dates.
Does anybody have a solution for matching the data in T_ATPCSX with the data in table T_MDVEX for the purposes of modifying the committed quantities? Help is much appreciated as I'm tearing my hair out over this one.
I have checked this in debugging - was hoping for the same thing you did, or perhaps field XLINE in T_MDVEX. T_ATPCSX-XLINE does match up with T_MDVEX-BDCNT, but I don't believe this is a definitive match.
The reason I believe this is that if you enter a second line of the same material into the STO, you will get the first line of the material twice in the table T_ATPCSX - once for ATPing the current qty on the first line, the third to un-ATP the old qty on the first line (even if they are the same amounts). The second line would be the second line item in the STO.
The XLINE in T_ATPCSX is 1, 2, 3 correspondingly - even though there's only two lines in T_MDVEX to match up with.
Potentially we COULD do this where we only look at the ATP lines with values > 0, as these all appear to be the first lines in the table, and the un-ATP lines come last, but I'm not sure this is guaranteed (and it sounds kind of sketchy).
Any thoughts anybody?