SAP Function /DSD/BAPI_VP_CREATEFROMDATA - Create or Copy Visit Plan

Parameter Reference Type Length Default Optional Text
SIMULATION BAPIFLAG-BAPIFLAG C 1 X Indicator Simulation Mode
VPH_IN /DSD/BAPI_VC_VPH u 177 X Visit Plan: Header Data
VPID_EXTERN /DSD/BAPI_VC_VP-VISITPLAN_ID C 10 X External Visit Plan ID
VPID_FOR_COPY /DSD/BAPI_VC_VP-VISITPLAN_ID C 10 X Visit Plan ID as Copy Template
VPID_FOR_CRULE /DSD/BAPI_VC_VP-VISITPLAN_ID C 10 X Copy Template ID for Date Rules Item
VPID_FOR_HRULE /DSD/BAPI_VC_VP-VISITPLAN_ID C 10 X Copy Template ID for Date Rule Header

Parameter Reference Type Length Text
VISITPLAN_ID /DSD/BAPI_VC_VP-VISITPLAN_ID C 10 Visit Plan ID
VPH_OUT /DSD/BAPI_VC_VPHOUT u 184 Visit Plan: Header Data (Export)

Parameter Reference Length Optional Text
EXTENSIONIN BAPIPAREX 990 X Customer Enhancements for Visit Plan
RETURN BAPIRET2 548 X Error Messages
VPP_IN /DSD/BAPI_VC_VPP 70 X Visit Plan: Customer Data (Import)
VPTEXT_IN /DSD/BAPI_VC_VP_TEXT 157 X Visit Plan: Texts (Import)

Functionality
You can use this method to create a visit plan.
With the VPID_FOR_COPY import parameter, you can use an existing visitplan as a copy template for the new visit plan. If you enter a visitplan ID in this import parameter, the system copies all the header dataand item data of that visit plan to the new visit plan. You can updatethe new visit plan with the import parameter VPH_IN. You must define anew validity period for the new visit plan at this point. If you enter atemplate in parameter VPID_FOR_HRULE with a Date Rule - Headerthat is not the same as the copy template, this is also updated in thenew visit plan. Customer data, however, is copied from the copy templateand not updated by additional entries in other import parameters.
If you create a new visit plan without a template, you must at leastenter the header data (VPH_IN) as an import parameter. The sequence inwhich you add the customers to the visit plan determines the sequence inwhich the customers are visited.
You can use the VPID_FOR_HRULE and VPID_FOR_CRULE import parameters tocopy date rules at header and item level from an existing visit plan toa new visit plan.
You can use the VPTEXT_IN import structure to assign texts at header anditem level to the new visit plan.
You can use the SIMULATION parameter to specify that you only want thenew visit plan to be created in simulation mode, that is, that the datashould not initially be written to the database.
The document number of the new visit plan is returned by the system as akey field of the document.
Customer Enhancements
To add customer fields to the tables for the visit plan, you can use thefollowing BAPI Table Extensions:

  • Structure /DSD/BAPI_VC_TE_VPH for additional fields at header level

  • Structure /DSD/BAPI_VC_TE_VPP for additional fields at item level

  • If customer fields are added to the item data table, these fields mustalso be added to the structure /DSD/VC_VP_TREE.
    You can assign the relevant values to customer fields with theEXTENSIONIN table.
    All data transferred to the BAPI is checked for consistency beforefurther processing. By implementing the BAdI methodVP_CHECK_CONSISTENCY, you can add your own checks or check theconsistency of customer fields in the visit plan tables.
    Return Messages
    Messages are returned in the Return parameter. See the parameterdocumentation for the return values and their meanings.

    Notes
    The following authorization object is checked with the activity 01(Create): /DSD/VC_VP.

    Further information
    For more information, see the parameter documentation.

    Description
    This export parameter contains the ID of the new visit plan.

    Description
    This export parameter contains the header data of the new visit plan.
    INCLUDE BAPI_DATAELEMENT OBJECT DOKU ID TX

    Description
    This parameter indicates whether or not a visit plan should initially becreated in simulation mode. If the indicator is set, the visit plan iscreated in simulation mode, and the data is not written to the database.

    Value range
    Blank = Document is saved.
    x = Document is not saved.

    Description
    This import parameter contains the header data of the new visit plan youwant to create, such as visit plan type, route, and validity period.
    INCLUDE BAPI_DATAELEMENT OBJECT DOKU ID TX

    Description
    If the new visit plan is not allocated a key using internal numberassignment, you can use this import parameter to assign it an externalkey (alphanumeric, for example).

    Description
    This import parameter contains the ID of a visit plan that you can useas a copy template for creating a new visit plan. If you enter an IDhere, all the data from the relative visit plan is copied to the newvisit plan.

    • You can update the visit plan header data, in particular the
    • validity period, with the import parameter VPH_IN. If you enter atemplate in parameter VPID_FOR_HRULE with a Date Rule -
      Header that is not the same as the copy template, this is alsoupdated in the new visit plan.
      • The visit plan customer data is taken from the copy template and
      • is not updated by additional entries in the import parametersVPP_IN and VPID_FOR_CRULE. This means that you cannotoverwrite customer data and Date Rules - Item that have beencopied to the new visit plan by entering data in additional importparameters.

        Description
        This import parameter contains the ID of the visit plan that you use tocopy the Date Rule - Item to the new visit plan. When you enteran ID here, the system compares the customer list for the template withthat of the new visit plan, and copies the relevant Date Rule - Item
        from the template for all customers in the new visit plan. You canuse this import parameter to enter a customer's company vacation datesas non-dates in all visit plans.
        The system does not copy any other data of the template to the new visitplan.

        Description
        This import parameter contains the ID of a visit plan that you use tocopy the Date Rule - Header to the new visit plan. If you enteran ID here, the system copies the Date Rule - Header to the newvisit plan and overwrites a date rule that may already have beenassigned. The system does not copy any other data of the template to thenew visit plan.

        Description
        The ExtensionIn table allows you to enhance the BAPI import parameterswithout making modifications.
        If you have added your own fields to the header or item data of thevisit plan, you can assign appropriate values to these fields using theExtensionIn table.

        Description
        INCLUDE BAPI_TABLE OBJECT DOKU ID TX

        Value range
        Type,, ID,, Number,, Message
        E,, BAPI,, 100,, One or more errors occurred when the BAPI was called
        S,, BAPI,, 000,, &1 &2 &3 has been created; external reference: &4
        Messages relating to the consistency checks are also output.

        Description
        This import structure contains customer data for the new visit plan youwant to create. You enter the customer numbers, for example, and alsothe unloading point, waiting time, and travel duration. The sequence inwhich the customers are visited corresponds to the sequence in which youcreate the items in the visit plan. In addition, you can flag specificcustomers as "inactive" so that the system does not take them intoaccount when creating visit plans.
        Note:
        If you use the VPID_FOR_COPY import parameter to copy customerdata from another visit plan, the system copies the customer data fromthe copy template regardless of the values that you have entered in theVPP_IN import structure.

        Value range
        For items to which you want to assign texts with the import structureVLTEXT_IN, you assign a temporary item number with the value800 or higher in the VISITLIST_POS field. You assign theitem number to the relevant text ID in the import structureVPTEXT_IN. The temporary item numbers are only used to assigntexts to items. The item numbers are always assigned by the system whena new visit plan is created.
        The sequence in which you add the customers to the visit plan determinesthe sequence in which the customers are visited. The system enters therelevant values (003 for a customer to be visited in third place,for example) in the VISIT_SEQUENCE field. If you enter your ownvalues in this field, the system des not take them into account forprocessing. You can make changes to the sequence using the BAPI/DSD/BAPI_VP_CHANGEFROMDATA.

        Description
        This import structure contains texts for the new visit plan at header oritem level. If you want to import texts for the individual items, assignthe corresponding text ID of the temporary item number with a value of800 or higher, which you have assigned in the VISITPLAN_POS
        field of the VPP_IN import structure.