Skip to Content
Technical Articles
Author's profile photo Autumn Yu

Flexible Proposal of Requested Delivery Dates or Pricing Dates: Enabling Sales Document Header Fields as Input Parameters

In SAP S/4HANA Sales, you can flexibly propose requested delivery dates and pricing dates by using the Configurable Parameters and Formulas (CPF) framework. The CPF framework enables you to create as complex a set of conditions for your business needs. Assignments can be made freely on combinations of values of a set of pre-defined sales document header fields, custom fields on sales document header, and other sales document header fields defined in your own data source.

This blog post, you will learn to create your data source. The following steps and sample codes will guide you to add sales document header fields (fields from table VBAK) as input parameters by using your Business Add-In (BAdI) implementation.

Instruction

  1. Create your class.

    1. In transaction SE24, create a class by inheriting from interface IF_CPF_DATA_SOURCE.

      For example, create a class “ZCL_SDOC_CPF_S02_BLOGEXAMPLE”

    2. In the newly created class, implement the inherited BAdI method IF_CPF_DATA_SOURCE~GET_VALUE.

      For example, if you want to add sold-to party (filed KUNNR in table VBAK) as a parameter named ‘ZSOLDTOPARTY’, you can use the following sample codes:

      • For the implementation of the flexible proposal for requested delivery dates:

        METHOD if_cpf_data_source~get_value.
            DATA: lv_component_name TYPE cpf_parameter_name,
                  lv_length         TYPE I.
            FIELD-SYMBOLS: <fs_param> TYPE cpfs_dtsrc_parameter,
                           <fs_vbak>  TYPE vbak,
                           <fv_value> TYPE any,
                           <fs_name>  TYPE any.
            DATA(lr_data) = cl_sd_sls_va_factory=>get_reqd_deliv_date( )->get_source_data( ).
            CHECK lr_data IS BOUND.
            ASSIGN lr_data->* TO <fs_vbak>.
        
            LOOP AT it_dtsrc_param ASSIGNING <fs_param>.
                CASE <fs_param>-parameter_name.
                    WHEN ‘ZSOLDTOPARTY’.
                    ASSIGN <fs_param>-parameter_value->* TO <fv_value>.
                           <fv_value> = <fs_vbak>-KUNNR.
        	ENDCASE.
        	APPEND <fs_param> TO et_dtsrc_param.
            ENDLOOP.
        ENDMETHOD.​
      • For the implementation of the flexible proposal for pricing dates:

        METHOD if_cpf_data_source~get_value.
            DATA: lv_component_name TYPE cpf_parameter_name,
                  lv_length         TYPE I.
            FIELD-SYMBOLS: <fs_param> TYPE cpfs_dtsrc_parameter,
                           <fs_vbak>  TYPE vbak,
                           <fv_value> TYPE any,
                           <fs_name>  TYPE any.
            DATA(lr_data) = cl_sd_sls_va_factory=>get_reqd_deliv_date( )->get_source_data( ).
            CHECK lr_data IS BOUND.
            ASSIGN lr_data->* TO <fs_vbak>.
        	
            LOOP AT it_dtsrc_param ASSIGNING <fs_param>.
        	CASE <fs_param>-parameter_name.
        		WHEN ‘ZSOLDTOPARTY’.
        		ASSIGN <fs_param>-parameter_value->* TO <fv_value>.
                               <fv_value> = <fs_vbak>-KUNNR.
        	ENDCASE.
        	APPEND <fs_param> TO et_dtsrc_param.
            ENDLOOP.
        ENDMETHOD.​
  2. Create your BAdI implementation.

    1. In transaction SE18, navigate to the enhancement implementation:
      • For the implementation of flexible proposal for requested delivery dates, open enhancement spot ES_SDOC_CPF_S02, and then open in enhancement implementation EI_SDOC_CPF_S02.

      • For the implementation of flexible proposal for pricing dates, open enhancement spot ES_SDOC_CPF_S03, and then open in enhancement implementation EI_SDOC_CPF_S03.
    2. Create a BAdI implementation and assign the class that you’ve just created as the implementing class.
      • For the implementation of flexible proposal for requested delivery dates, create the BAdI implementation for BAdI definition BADI_SDOC_CPF_S02_DATA_SOURCE.
        For example, create BAdI implementation ‘ZBDII_CPF_S02_BLOGEXAMPLE_000’ (BLOG EXAMPLE).

      • For the implementation of flexible proposal for requested delivery dates, create the BAdI implementation for BAdI definition BADI_SDOC_CPF_S03_DATA_SOURCE.

    3. In the newly created BAdI implementation, edit filter values by add a filter combination for filter CPF_ROUNTINE.
      For example, add filter combination ‘3=CPF_ROUTINE’ so that the data source routine is ‘3’.
  3. Create your data source.

    1. In transaction code SM34, maintain view cluster CPFVC_DS_ROUTINE and choose a usage
      • For the implementation of flexible proposal for requested delivery dates, choose usage S02.

      • For the implementation of flexible proposal for pricing dates, choose usage S03

    2. In the data source routine, create a new data source by choosing the newly created BAdI implementation from the value help (F4).
    3. In the newly created data source routine, append data source parameters.

  4. In the Customizing activity for defining parameter catalog, add desired fields that have been defined as your data source parameters by entering the parameter name and reference data type, and choosing your data source routine.
    • For the flexible proposal of requested delivery dates, add input parameters in the Customizing activity Define Parameter Catalog for Requested Delivery Date under Sales > Configurable Parameters and Formulas in Sales > Requested Delivery Date in Sales Documents.
      Example:
    • For the flexible proposal of pricing dates, add input parameters in the Customizing activity Define Parameter Catalog for Pricing Date under Sales > Configurable Parameters and Formulas in Sales > Pricing Date in Sales Documents.

Then, you can use the sales document header fields as input parameters in your CPF implementations.

For more details on the implementation, see the following topics:

If you have any questions about SAP S/4HANA, please submit them via Ask a Question.

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Ashok Kumar Gupta
      Ashok Kumar Gupta

      Hi

      Can I also use the item table vbap in the custom routine. My requirement is for billing.

      Suggest

      Thanks

      Ashok

      Author's profile photo Autumn Yu
      Autumn Yu
      Blog Post Author

      Hi Ashok,

      Item table vbap is not supported in this case.

       

      Best,

      Autumn