Wednesday, 10 March 2021

Extra sub segment E1EDP05 for Idoc Type ORDERS05

So when one requirement needs to show only one extra price from the sales order item’s specific price condition (which has a statistics flag), I jump into the solution by extension of IDoc type ORDERS05 directly with inserting the new customized segment under item segment E1EDP01.

SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Career, SAP ABAP Preparation

The new item sub-segment means structure changes of whole Idoc, and the Idoc receiver side not willing to do the adaptation for sure. Then they notice that if the new extra price follows the sub-segment type E1EDP05 will be acceptable. So just find where to enhance this standard sub-segment will do. 

SD10 is the standard Process code for Sales order confirmation used by outbound Idoc ORDERS05 in my case. The processing flow is very clear and well organized inside the Function module “IDOC_OUTPUT_ORDRSP”. It’ll be quicker to find correct user-exit by CMOD, but take this FM as a start point to is an excellent experience to understand standard Idoc data filling process which will increase efficiency no matter Idoc debugging or write your own Idoc data filling logic.

SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Career, SAP ABAP Preparation

1. Routine ‘fill_idoc_inttab’ is a data filling procedure that contains all Idoc-segments;

SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Career, SAP ABAP Preparation

 2. ‘fill_item_segment’ is data filling for all item levels segment which type like EDEDP*

SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Career, SAP ABAP Preparation

3. ‘fill_e1edp01′ is data filling for segment type E1DP01

which is the parent level of item price condition. If I use customize segments like the first screenshot, just add code to populate customize segment field at EXIT_SAPLVEDC_002 which inside routine ‘customer_function ‘ contains the CUSTOMER-FUNCTION ‘002’.

SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Career, SAP ABAP Preparation

4, ‘fill_item_cond’ is data filling for price conditions at the item level which I want to enhance. And ‘fill_e1edp05′ obvious is for filling data for sub-segment e1edp05.

SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Career, SAP ABAP Preparation

5. The extra item price condition needs to be added inside routine ‘get_item_prices’ instead of ‘fill_e1edp05′.

Because ‘fill_e1edp05′ just fill the data structure of segments with system filtered item price conditions. My extra item price condition is not there, need using CUSTOMER-FUNCTION ‘008’ inside ‘GET_ITEM_PRICES’ which provide user exits EXIT_SAPLVEDC_008 to add extra price conditions.

SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Career, SAP ABAP Preparation

Just add code to fetch item price condition from DIKOMV with the order number, item number, and specific condition type name; then append to table dikomvd which contains all item price conditions against IKOMVD at ‘GET_ITEM_PRICES’.

if edidc-mestyp eq 'ZIDOC_TYPE'. "your Idoc type
  read table dikomv with key knumv = dxvbak-knumv
                            kposn  = dxvbap-posnr
                            kschl = 'ZXXX'. "your item price condition type
 if sy-subrc = 0.
   move-corresponding dikomv to dikomvd.
   dikomvd-kwert = dikomv-kbetr.
   append dikomvd.
   clear dikomvd.
 endif.
endif.

6. One point that needs to pay attention to is the skip condition before populate data into e1edp05.

SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Career, SAP ABAP Preparation

The item price condition skips logic is:

◉ condition type must be not statistical
◉ condition type is active status
◉ condition value is not zero

SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Career, SAP ABAP Preparation

My extra price condition needs to be added at Idoc ORDERS05 is statistical which is for reference purposes only and will not impact any price calculation that’s why the standard code has above skip logic by default when send Sales order out by outbound Idoc .

SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Career, SAP ABAP Preparation

As it’s not wise to change standard code at this include LVEDCF0F, we just need to remove the statistical flag for our extra price condition inside EXIT_SAPLVEDC_008 by clear this statistical flag.

if edidc-mestyp eq 'ZIDOC_TYPE'. "your Idoc type
  read table dikomv with key knumv = dxvbak-knumv
                            kposn  = dxvbap-posnr
                            kschl = 'ZXXX'. "your item price condition type
 if sy-subrc = 0.
   move-corresponding dikomv to dikomvd.
   dikomvd-kwert = dikomv-kbetr.
   clear dikomvd-KSTAT. "remove statistical flag here!
   append dikomvd.
   clear dikomvd.
 endif.
endif.

Fortunately, this IKOMVD table is Price Determination Communication–Condition Record for Printing : ) It’s been refreshed per sales order item at IDoc data filling process which shouldn’t impact any price determination procedure after we remove its statistical flag.

SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Career, SAP ABAP Preparation

SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Career, SAP ABAP Preparation

Finally, I get this extra condition value at sub-segment E1EP05 under E1EDP01 without Idoc extension. It’s much clear to go through this standard Idoc data filling steps than modify the found user-exit directly for me. Just need to do this once to familiar with this procedure, but sometimes I’ll forget that’s why I record this for myself

SAP ABAP Exam Prep, SAP ABAP Certification, SAP ABAP Career, SAP ABAP Preparation

No comments:

Post a Comment