There is a new capability in SAP now to price multi Items in a single shot, unlike the existing “PRICING” FM which is used to price single item at a time.
There is no much help as to how to use this FM to price multi items.
CALL FUNCTION 'PIQ_CALCULATE' EXPORTING IV_CALLER_ID = 'PL' / 'STD' IS_CONTROL = LS_CONTROL IS_GLOBAL = LS_GLOBAL IT_HEAD = LT_HEAD IT_ITEM = LT_ITEM IMPORTING ET_RESULT_EXT = LT_RESULT_EXT ET_MESSAGE = LT_MESSAGE.
Here are the steps:
- How to pass the KOMK and KOMP fields? Here is the sample
DATA: GT_CALLER_DATA_HEAD TYPE PIQT_NAME_VALUE, GT_CALLER_DATA_ITEM TYPE PIQT_NAME_VALUE, GT_RESULT_EXT TYPE PIQT_CALCULATE_RESULT_EXT. GT_CALLER_DATA_HEAD = VALUE #( ( NAME = 'INCO1' VALUE = IV_INCTRM ) ( NAME = 'WAERK' VALUE = IV_CURR ) ( NAME = 'LAND1' VALUE = IV_CNTRY ) ( NAME = 'ZZKDKG5' VALUE = IV_CNTRY ) ( NAME = 'HWAER' VALUE = IV_CURR ) ( NAME = 'KURRF_DAT' VALUE = IV_DATE ) ( NAME = 'PRSDT' VALUE = IV_DATE ) INSERT VALUE #( VBELN = IV_VBELN KUNNR = IV_KUNNR CALLER_DATA = GT_CALLER_DATA_HEAD ) INTO TABLE LT_HEAD. GT_CALLER_DATA_ITEM = VALUE #( ( NAME = 'VARCOND' VALUE = LS_MATNR-VARCOND ) ( NAME = 'USE_MULTIVAL_ATTR' VALUE = iv_multi ) ( NAME = 'USE_PREREAD_COND' VALUE = ABAP_FALSE ) ( NAME = 'PMATN' VALUE = LS_MATNR-MATNR ) ( NAME = 'MGLME' VALUE = LS_MATNR-MENGE ) ( NAME = 'MGAME' VALUE = LS_MATNR-MENGE ) ( NAME = 'PRSFD' VALUE = ABAP_TRUE ) INSERT VALUE #( KPOSN = LS_MATNR-KPOSN MATNR = LS_MATNR-MATNR CALLER_DATA = GT_CALLER_DATA_ITEM ) INTO TABLE LT_ITEM.
In the above manner we can pass any ZFields of KOMK and KOMP structures to the caller Data.
2. The KOMK and KOMP fields would not be activated by just passing them in the code.
We need to add them in configuration too.
SPRO->BASIC FUNTIONS->PRICING-> PRICE LISTS -> PRICE ENQUIRY->Define sources for price communication structures->define customer specific sources
The fields entered here would appear in the table “PIQC_PREP_FLD_S”
3. Even though we do the required configuration by entering them in the above mentioned table, some fields values would not be picked up. The reason being, those fields are never used in any of the access sequences, Like in the above screen, IX_KOMK.
These type of fields need to be entered through a BAPI implementation.
Implement the BADI “BADI_PIQ_PREPARE” to maintain the relevant fields with filter value
Caller id = ‘PL/STD’.
After BADI is implemented, go to SE 38 and run the report “SDPIQRELATTRUE” and maintain the relevant fields (This is only specific to the fields which are never used in any of the condition tables/access sequences)
4. Now, all set for PIQ_CALCULATE to execute and return pricing for multi items, But still it wont return the condition types which have access sequences :). This is the final twist in the story. The reason being, the FM is setting KOMP-USE_PRECOND_READ = ‘X’ in the middle. With this being set the FM is not returning all the condition records. Use a proper enhancement place and clear this value and finally you could see the required result.
This looks like a standard SAP bug, we may need to wait for note or reach out SAP for help.
Hoping this blog is helpful!!