2013 Aug 22 3:13 PM
Hi gurus,
I'm working with the bapi /DSD/BAPI_VP_CREATEFROMDATA to create a new Visit Plan. When I execute this bapi the Visit plane is created well but without data in the popup data of "Date Rule - Header" and "Date Rule - Item". I'm loading the table extensionin with the data of the days (Monday, Tuesday, etc) and times (08:00:00 to 05:00:00) but nothing happend. I need to load the checkboxs of the days and load times of this days.
I was searching the solution in the web, in sdn forum, and Sap notes but I didn't find it.
I call the bapi with the next tables and structures loaded:
*#Create Visit Plan
call function '/DSD/BAPI_VP_CREATEFROMDATA'
exporting
vph_in = fp_wa_vph_in "Load with the header data
tables
vpp_in = fp_i_vpp_in[] "Load the customer number only
vptext_in = fp_i_vptext_in[] "Load the customer number only
extensionin = i_extensionin "Load with the data of the days and time
return = l_i_return[]
exceptions
error_message = 1
others = 2.
I hope that someone help me.
Best regards,
Marcelo.
P.S: If you need more detail, I can do that.
1-
2013 Sep 06 3:03 PM
I solved the issue. I didn't find the solution using the bapi. Instead of this, I used the function
/DSD/VC_MAINT2FCODE_SAVE. With this function I was able to create the data "Date rules - Ítems" and "Date rules - header". I had load data in the table ct_vprules into the field ruletab of this function.
Best regards,
Marcelo.2013 Aug 22 11:35 PM
Hi Marcelo,
I hope the documentation provided in the BAPI is clear enough.
You can use this method to create a visit plan.
With the VPID_FOR_COPY import parameter, you can use an existing visit plan as a copy template for the new visit plan. If you enter a visit plan ID in this import parameter, the system copies all the header data and item data of that visit plan to the new visit plan. You can update the new visit plan with the import parameter VPH_IN. You must define a new validity period for the new visit plan at this point. If you enter a template in parameter VPID_FOR_HRULE with a Date Rule - Header that is not the same as the copy template, this is also updated in the new visit plan. Customer data, however, is copied from the copy template and not updated by additional entries in other import parameters.
If you create a new visit plan without a template, you must at least enter the header data (VPH_IN) as an import parameter. The sequence in which you add the customers to the visit plan determines the sequence in which the customers are visited.
You can use the VPID_FOR_HRULE and VPID_FOR_CRULE import parameters to copy date rules at header and item level from an existing visit plan to a new visit plan.
You can use the VPTEXT_IN import structure to assign texts at header and item level to the new visit plan.
You can use the SIMULATION parameter to specify that you only want the new visit plan to be created in simulation mode, that is, that the data should not initially be written to the database.
The document number of the new visit plan is returned by the system as a key field of the document.
Customer Enhancements
To add customer fields to the tables for the visit plan, you can use the following BAPI Table Extensions:
You can assign the relevant values to customer fields with the EXTENSIONIN table.
All data transferred to the BAPI is checked for consistency before further processing. By implementing the BAdI method VP_CHECK_CONSISTENCY, you can add your own checks or check the consistency of customer fields in the visit plan tables.
Return Messages
Messages are returned in the Return parameter. See the parameter documentation for the return values and their meanings.
If you feel you had missed anything or do you need more info pls do ping me.
2013 Aug 23 2:30 PM
Hi Raja, thanks for your answer but one of my tasks to try to solve my problem was read the documentation of the bapi at first. It's clear but not solve my issue.
I must create a new Visit plan without a template so, I load the parameter and tables: VPH_IN, VPP_IN, VPTEXT_IN and EXTENSIONIN.
Maybe I forgot to load some data, so I show you how I populated the parameter and tables of the bapi.
I load the parameter VPH_IN with the next lines of code:
fp_wa_vph_in-visitdoc_text = fp_wa_input-name.
fp_wa_vph_in-sales_org = fp_wa_input-sales_org.
fp_wa_vph_in-dist_channel = fp_wa_input-dist_channel.
fp_wa_vph_in-division = fp_wa_input-division.
fp_wa_vph_in-visitplantype = fp_wa_input-visit_plan_type.
fp_wa_vph_in-starttimezone_vc = fp_wa_input-time_zone.
fp_wa_vph_in-route = fp_wa_input-route.
fp_wa_vph_in-visitgroup = fp_wa_input-visit_group.
*#Convert text
perform f_convert_text using fp_wa_input-vehicle
changing fp_wa_vph_in-vehicle_dsd.
* CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
* EXPORTING
* input = fp_wa_input-vehicle
* IMPORTING
* output = fp_wa_vph_in-vehicle_dsd.
perform f_convert_text using fp_wa_input-trailer
changing fp_wa_vph_in-trailer_dsd.
perform f_convert_text using fp_wa_input-start_point
changing fp_wa_vph_in-startpoint_vc.
perform f_convert_text using fp_wa_input-end_point
changing fp_wa_vph_in-endpoint_vc.
perform f_convert_text using fp_wa_input-driver1
changing fp_wa_vph_in-driver_dsd.
perform f_convert_text using fp_wa_input-driver2
changing fp_wa_vph_in-codriver_dsd.
*#Convert date
perform f_convert_date using fp_wa_input-valid_from
changing fp_wa_vph_in-datefrom_vp.
perform f_convert_date using fp_wa_input-valid_to
changing fp_wa_vph_in-dateto_vp.
perform f_convert_date using fp_wa_input-from_restr
changing fp_wa_vph_in-datefromlimit_vp.
perform f_convert_date using fp_wa_input-to_restr
changing fp_wa_vph_in-datetolimit_vp .
*#Convert time
perform f_convert_time using fp_wa_input-start_time
changing fp_wa_vph_in-starttime_vc.
I load the table VPP_IN and VPTEXT_IN with the next lines of code:
data: l_wa_vpp_in type /dsd/bapi_vc_vpp,
l_wa_vptext_in type /dsd/bapi_vc_vp_text.
*#Convert text
perform f_convert_text using fp_wa_input-customer
changing l_wa_vpp_in-customer_vc.
* CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
* EXPORTING
* input = fp_wa_input-customer
* IMPORTING
* output = l_wa_vpp_in-customer_vc.
*#Convert text
perform f_convert_text using fp_wa_input-customer
changing l_wa_vptext_in-visitplan_id.
append l_wa_vpp_in to fp_i_vpp_in.
append l_wa_vptext_in to fp_i_vptext_in.
Note: I only load the customer number in both tables.
I load the table EXTENSIONIN with the next lines of code:
data: l_wa_vc_te_vph type /dsd/bapi_vc_te_vph,
l_wa_vc_te_vphx type /dsd/bapi_vc_te_vphx.
move '01' to l_wa_vc_te_vph-weeks.
move c_on to l_wa_vc_te_vphx-weeks.
if fp_wa_input-scrule_w_monday eq c_on.
move fp_wa_input-scrule_w_monday to l_wa_vc_te_vph-monday.
move c_on to l_wa_vc_te_vphx-monday.
move c_on to l_wa_vc_te_vphx-monda_from.
move c_on to l_wa_vc_te_vphx-monday_to.
perform f_convert_time using fp_wa_input-monday_time_from
changing l_wa_vc_te_vph-monda_from.
perform f_convert_time using fp_wa_input-monday_time_to
changing l_wa_vc_te_vph-monday_to.
endif.
if fp_wa_input-scrule_w_tuesday eq c_on.
move fp_wa_input-scrule_w_tuesday to l_wa_vc_te_vph-tuesday.
move c_on to l_wa_vc_te_vphx-tuesday.
move c_on to l_wa_vc_te_vphx-tuesd_from.
move c_on to l_wa_vc_te_vphx-tuesday_to.
perform f_convert_time using fp_wa_input-tuesday_time_from
changing l_wa_vc_te_vph-tuesd_from.
perform f_convert_time using fp_wa_input-tuesday_time_to
changing l_wa_vc_te_vph-tuesday_to.
endif.
if fp_wa_input-scrule_w_wednesday eq c_on.
move fp_wa_input-scrule_w_wednesday to l_wa_vc_te_vph-wednesday.
move c_on to l_wa_vc_te_vphx-wednesday.
move c_on to l_wa_vc_te_vphx-wedne_from.
move c_on to l_wa_vc_te_vphx-wednesd_to.
perform f_convert_time using fp_wa_input-wednesday_time_from
changing l_wa_vc_te_vph-wedne_from.
perform f_convert_time using fp_wa_input-wednesday_time_to
changing l_wa_vc_te_vph-wednesd_to.
endif.
if fp_wa_input-scrule_w_thursday eq c_on.
move fp_wa_input-scrule_w_thursday to l_wa_vc_te_vph-thursday.
move c_on to l_wa_vc_te_vphx-thursday.
move c_on to l_wa_vc_te_vphx-thurs_from.
move c_on to l_wa_vc_te_vphx-thursda_to.
perform f_convert_time using fp_wa_input-thursday_time_from
changing l_wa_vc_te_vph-thurs_from.
perform f_convert_time using fp_wa_input-thursday_time_to
changing l_wa_vc_te_vph-thursda_to.
endif.
if fp_wa_input-scrule_w_friday eq c_on.
move fp_wa_input-scrule_w_friday to l_wa_vc_te_vph-friday.
move c_on to l_wa_vc_te_vphx-friday.
move c_on to l_wa_vc_te_vphx-frida_from.
move c_on to l_wa_vc_te_vphx-friday_to.
perform f_convert_time using fp_wa_input-friday_time_from
changing l_wa_vc_te_vph-frida_from.
perform f_convert_time using fp_wa_input-friday_time_to
changing l_wa_vc_te_vph-friday_to.
endif.
i_extensionin-structure = c_struct. "/DSD/BAPI_VC_TE_VPH
concatenate l_wa_vc_te_vph-weeks
l_wa_vc_te_vph-monday l_wa_vc_te_vph-tuesday l_wa_vc_te_vph-wednesday
l_wa_vc_te_vph-thursday l_wa_vc_te_vph-friday l_wa_vc_te_vph-saturday
l_wa_vc_te_vph-sunday l_wa_vc_te_vph-monda_from l_wa_vc_te_vph-tuesd_from
l_wa_vc_te_vph-wedne_from l_wa_vc_te_vph-thurs_from l_wa_vc_te_vph-frida_from
l_wa_vc_te_vph-satur_from l_wa_vc_te_vph-sunda_from l_wa_vc_te_vph-monday_to
l_wa_vc_te_vph-tuesday_to l_wa_vc_te_vph-wednesd_to l_wa_vc_te_vph-thursda_to
l_wa_vc_te_vph-friday_to l_wa_vc_te_vph-saturda_to l_wa_vc_te_vph-sunday_to
into i_extensionin-valuepart1+10
respecting blanks.
append i_extensionin.
clear: i_extensionin.
i_extensionin-structure = c_struct2. "/DSD/BAPI_VC_TE_VPHX
concatenate l_wa_vc_te_vphx-weeks
l_wa_vc_te_vphx-monday l_wa_vc_te_vphx-tuesday l_wa_vc_te_vphx-wednesday
l_wa_vc_te_vphx-thursday l_wa_vc_te_vphx-friday l_wa_vc_te_vphx-saturday
l_wa_vc_te_vphx-sunday l_wa_vc_te_vphx-monda_from l_wa_vc_te_vphx-tuesd_from
l_wa_vc_te_vphx-wedne_from l_wa_vc_te_vphx-thurs_from l_wa_vc_te_vphx-frida_from
l_wa_vc_te_vphx-satur_from l_wa_vc_te_vphx-sunda_from l_wa_vc_te_vphx-monday_to
l_wa_vc_te_vphx-tuesday_to l_wa_vc_te_vphx-wednesd_to l_wa_vc_te_vphx-thursda_to
l_wa_vc_te_vphx-friday_to l_wa_vc_te_vphx-saturda_to l_wa_vc_te_vphx-sunday_to
into i_extensionin-valuepart1+10
respecting blanks.
append i_extensionin.
The structure with the extensión have the next fields:
The other structure have the same fields but with character one (as a checkbox).
I'm working in ECC 6.0.
Did you create visit plan with this bapi? Do you have an example to show me how I must load the tables and structures?
I don't know what I do bad.
Best regards,
Marcelo.
2013 Sep 06 3:03 PM
I solved the issue. I didn't find the solution using the bapi. Instead of this, I used the function
/DSD/VC_MAINT2FCODE_SAVE. With this function I was able to create the data "Date rules - Ítems" and "Date rules - header". I had load data in the table ct_vprules into the field ruletab of this function.
Best regards,
Marcelo.2013 Nov 06 8:57 AM
Hi Marcelo,
I have a requirement to creating Visit plan, For this particular purpose I found a BAPI (/DSD/BAPI_VP_CREATEFROMDATA).
Could you please send me the list of steps & screen shot's(Examples) which needs to be follow for creating visit plan with the above BAPI?
BAPI Name: /DSD/BAPI_VP_CREATEFROMDATA
T.Code : /DSD/VC_VP
By using the above BAPI I am able to create the Visit Plan but am not able to pass the Weekdays(Mon,Tue,Wed,Thu,Fri,Sat,Sun) information as checkbox.
Could you please explain me how to create the Visit Plan by using /DSD/VC_MAINT2FCODE_SAVE(Function Module) and at the same time how can i pass the weekdays(Mon,Tue,Wed,Thu,Fri,Sat,Sun) information.
Please find the screen shot as well...
2013 Nov 06 2:06 PM
I didn't used this bapi. I used the other function /DSD/VC_MAINT2FCODE_SAVE. I explained before how I loaded the parameters of the function. I paste part of the code at next:
*//////////////////////////////////////////////////////////////////////*
* CONSTANTS *
*//////////////////////////////////////////////////////////////////////*
constants: c_information type char01 value 'I',
c_on type char01 value 'X',
c_forward_slash type char01 value '/',
c_colon type char01 value ':',
c_initial_directory type string value 'C:\',
c_container type scrfname value 'CC_LOG_ALV',
c_style type sdydo_attribute value 'ALV_GRID',
c_vccode(2) type c value 'VP',
c_nodekey_init(12) type n value '00000000001',
c_flag_rule type char01 value 'N',
c_initial_pos type /dsd/vc_vppos value '000',
c_id_temp type /dsd/vc_vpid value '$TMP000010',
c_daily_rule type sc_rulewno value '01',
c_weekly_rule type sc_rulewno value '02',
c_monthly_rule type sc_rulewno value '03',
c_additional_rule type sc_rulewno value '04',
c_no_rule type sc_rulewno value '05',
c_underscore type char01 value '_'.
*&---------------------------------------------------------------------*
*& Form F_PROCESS_INPUT_DATA
*&---------------------------------------------------------------------*
* Processing input data and load the log.
*----------------------------------------------------------------------*
* <--FP_I_INPUT text
* <--FP_I_LOG text
* <--FP_V_TOT_REG text
* <--FP_V_TOT_REG_SUC text
* <--FP_V_TOT_REG_ERR text
*----------------------------------------------------------------------*
form f_process_input_data changing fp_i_input type ty_t_input
fp_i_log type ty_t_log
fp_v_tot_reg type i
fp_v_tot_reg_suc type i
fp_v_tot_reg_err type i.
data: l_v_first_header type char01 value 'X',
l_v_fields_empty type char01,
l_i_vp_tree type /dsd/vc_vp_it_tree,
l_i_vp_rules type /dsd/vc_it_vprules,
l_wa_vp_tree type /dsd/vc_vp_tree.
field-symbols: <l_wa_input> type ty_input.
loop at fp_i_input assigning <l_wa_input>.
*# If the "Column ID" has the value...
case <l_wa_input>-columnid.
*# ..."Header"
when text-006.
*# If it's the first header for process
if l_v_first_header eq c_on.
clear l_v_first_header.
*# Process current Header
perform f_process_header using <l_wa_input>
changing l_v_fields_empty
l_wa_vp_tree
l_i_vp_tree
l_i_vp_rules
fp_i_log
fp_v_tot_reg.
else.
*# Create Visit Plan of the previus header
perform f_create_visit_plan changing l_v_fields_empty
l_wa_vp_tree
l_i_vp_tree
l_i_vp_rules
fp_i_log
fp_v_tot_reg_suc
fp_v_tot_reg_err.
*# Process current Header
perform f_process_header using <l_wa_input>
changing l_v_fields_empty
l_wa_vp_tree
l_i_vp_tree
l_i_vp_rules
fp_i_log
fp_v_tot_reg.
endif.
*#..."Line Item"
when text-007.
*# Process Item
perform f_process_item using <l_wa_input>
changing l_i_vp_tree
l_i_vp_rules
l_wa_vp_tree.
when others.
*# Do nothing
endcase.
endloop.
*#Create Visit Plane of the last line.
perform f_create_visit_plan changing l_v_fields_empty
l_wa_vp_tree
l_i_vp_tree
l_i_vp_rules
fp_i_log
fp_v_tot_reg_suc
fp_v_tot_reg_err.
endform. " F_PROCESS_INPUT_DATA
*&---------------------------------------------------------------------*
*& Form F_PROCESS_HEADER
*&---------------------------------------------------------------------*
* Process current Header
*----------------------------------------------------------------------*
* -->FP_WA_INPUT text
* <--FP_V_FIELDS_EMPTY text
* <--FP_WA_VP_TREE text
* <--FP_I_VP_TREE text
* <--FP_I_VP_RULES text
* <--FP_I_LOG text
* <--FP_V_TOT_REG text
*----------------------------------------------------------------------*
form f_process_header using value(fp_wa_input) type ty_input
changing fp_v_fields_empty type char01
fp_wa_vp_tree type /dsd/vc_vp_tree
fp_i_vp_tree type /dsd/vc_vp_it_tree
fp_i_vp_rules type /dsd/vc_it_vprules
fp_i_log type ty_t_log
fp_v_tot_reg type i.
data: l_wa_log type ty_log,
l_v_tot_reg type char10,
l_wa_wrule type scrule_w,
l_v_rule1 type char200.
*#Initialization of counters of position of the current Visit Plan
clear: v_nodekey_c, v_vpos, v_vppos.
v_nodekey_c = c_nodekey_init.
*#Add the text "Visit Plan number &number" in the log
add 1 to fp_v_tot_reg.
l_v_tot_reg = fp_v_tot_reg.
concatenate text-010 l_v_tot_reg into l_wa_log-text_message
separated by space.
append l_wa_log to fp_i_log.
*#Load data in the table of tree where appears the header and item position of the new VP.
fp_wa_vp_tree-vctext = fp_wa_input-name.
fp_wa_vp_tree-vpid = c_id_temp.
*#If the obligatory field "Visit Plan Type" is empty.
if fp_wa_input-visit_plan_type is initial.
*# Load in the log an error message: "The field Visit Plan Type is empty".
l_wa_log-status_icon = icon_red_light.
l_wa_log-text_message = text-020.
append l_wa_log to fp_i_log.
fp_v_fields_empty = c_on.
else.
*# Load the value to the table tree
fp_wa_vp_tree-vptyp = fp_wa_input-visit_plan_type.
endif.
*#If the obligatory field "Route" is empty.
if fp_wa_input-route is initial.
*# Load in the log an error message: "The field Route is empty".
l_wa_log-status_icon = icon_red_light.
l_wa_log-text_message = text-021.
append l_wa_log to fp_i_log.
fp_v_fields_empty = c_on.
else.
*# Load the value to the table tree
fp_wa_vp_tree-route = fp_wa_input-route.
endif.
*#If the obligatory field "Time Zone" is empty.
if fp_wa_input-time_zone is initial.
*# Load in the log an error message: "The field Time Zone is empty".
l_wa_log-status_icon = icon_red_light.
l_wa_log-text_message = text-022.
append l_wa_log to fp_i_log.
fp_v_fields_empty = c_on.
else.
*# Load the value to the table tree
fp_wa_vp_tree-stimezone = fp_wa_input-time_zone.
endif.
*#If the obligatory field "Visit Group" is empty.
if fp_wa_input-visit_group is initial.
*# Load in the log an error message: "The field Visit Group is empty".
l_wa_log-status_icon = icon_red_light.
l_wa_log-text_message = text-023.
append l_wa_log to fp_i_log.
fp_v_fields_empty = c_on.
else.
*# Load the value to the table tree
fp_wa_vp_tree-auth = fp_wa_input-visit_group.
endif.
*#If the obligatory field "Sales Organization" is empty.
if fp_wa_input-sales_org is initial.
*# Load in the log an error message: "The field Sales Organization is empty".
l_wa_log-status_icon = icon_red_light.
l_wa_log-text_message = text-024.
append l_wa_log to fp_i_log.
fp_v_fields_empty = c_on.
else.
*# Load the value to the table tree
fp_wa_vp_tree-sales_org = fp_wa_input-sales_org.
endif.
*#If the obligatory field "Distribution Channel" is empty.
if fp_wa_input-dist_channel is initial.
*# Load in the log an error message: "The field Distribution Channel is empty".
l_wa_log-status_icon = icon_red_light.
l_wa_log-text_message = text-025.
append l_wa_log to fp_i_log.
fp_v_fields_empty = c_on.
else.
*# Load the value to the table tree
fp_wa_vp_tree-dist_channel = fp_wa_input-dist_channel.
endif.
*#If the obligatory field "Division" is empty.
if fp_wa_input-division is initial.
*# Load in the log an error message: "The field Division is empty".
l_wa_log-status_icon = icon_red_light.
l_wa_log-text_message = text-026.
append l_wa_log to fp_i_log.
fp_v_fields_empty = c_on.
else.
*# Load the value to the table tree
fp_wa_vp_tree-division = fp_wa_input-division.
endif.
fp_wa_vp_tree-vppos = c_initial_pos.
fp_wa_vp_tree-sequ = c_initial_pos.
fp_wa_vp_tree-nodekey = v_nodekey_p.
fp_wa_vp_tree-root_node_flag = c_on.
*#Convert text
perform f_convert_text using fp_wa_input-vehicle
changing fp_wa_vp_tree-truck.
perform f_convert_text using fp_wa_input-trailer
changing fp_wa_vp_tree-trail.
perform f_convert_text using fp_wa_input-start_point
changing fp_wa_vp_tree-spoint.
perform f_convert_text using fp_wa_input-end_point
changing fp_wa_vp_tree-epoint.
perform f_convert_text using fp_wa_input-driver1
changing fp_wa_vp_tree-driver1.
perform f_convert_text using fp_wa_input-driver2
changing fp_wa_vp_tree-driver2.
*#If the obligatory field "Valid From" is empty.
if fp_wa_input-valid_from is initial.
*# Load in the log an error message: "The field Valid From is empty".
l_wa_log-status_icon = icon_red_light.
l_wa_log-text_message = text-027.
append l_wa_log to fp_i_log.
fp_v_fields_empty = c_on.
else.
*# Convert date and load the value to the table tree
perform f_convert_date using fp_wa_input-valid_from
changing fp_wa_vp_tree-datfr.
endif.
*#If the obligatory field "Valid To" is empty.
if fp_wa_input-valid_to is initial.
*# Load in the log an error message: "The field Valid to is empty".
l_wa_log-status_icon = icon_red_light.
l_wa_log-text_message = text-028.
append l_wa_log to fp_i_log.
fp_v_fields_empty = c_on.
else.
*# Convert date and load the value to the table tree
perform f_convert_date using fp_wa_input-valid_to
changing fp_wa_vp_tree-datto.
endif.
*#Convert date
perform f_convert_date using fp_wa_input-from_restr
changing fp_wa_vp_tree-limfr.
perform f_convert_date using fp_wa_input-to_restr
changing fp_wa_vp_tree-limto.
*#Convert time
perform f_convert_time using fp_wa_input-start_time
changing fp_wa_vp_tree-stime.
fp_wa_vp_tree-erdat = sy-datum.
fp_wa_vp_tree-erzet = sy-uzeit.
fp_wa_vp_tree-ernam = sy-uname.
fp_wa_vp_tree-aedat = sy-datum.
fp_wa_vp_tree-aezet = sy-uzeit.
fp_wa_vp_tree-aenam = sy-uname.
*#Load information of the popup header
perform f_load_info_popup using fp_wa_input
changing l_wa_wrule
fp_wa_vp_tree
l_v_rule1.
*#Load table of rules header
perform f_load_rules using fp_wa_input-valid_from
fp_wa_input-valid_to
changing fp_i_vp_rules
l_wa_wrule
l_v_rule1.
*#Append the line in the line of the tree
append fp_wa_vp_tree to fp_i_vp_tree.
*#Build the textid of the items
clear v_textstr.
concatenate fp_wa_vp_tree-sales_org fp_wa_vp_tree-dist_channel
fp_wa_vp_tree-division fp_wa_vp_tree-auth
into v_textstr separated by c_underscore.
condense v_textstr.
endform. " F_PROCESS_HEADER
*&---------------------------------------------------------------------*
*& Form F_CONVERT_TEXT
*&---------------------------------------------------------------------*
* Convert text
*----------------------------------------------------------------------*
* -->FP_V_INPUT text
* <--FP_V_OUTPUT text
*----------------------------------------------------------------------*
form f_convert_text using value(fp_v_input) type any
changing fp_v_output type any.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = fp_v_input
importing
output = fp_v_output.
endform. " F_CONVERT_TEXT
*&---------------------------------------------------------------------*
*& Form F_CONVERT_DATE
*&---------------------------------------------------------------------*
* Convert date
*----------------------------------------------------------------------*
* -->FP_V_INPUT_DATE text
* <--FP_V_OUTPUT_DATE text
*----------------------------------------------------------------------*
form f_convert_date using value(fp_v_input_date) type char10
changing fp_v_output_date type /dsd/vc_datfr.
data: l_v_day type char02,
l_v_month type char02,
l_v_year type char04.
split fp_v_input_date at c_forward_slash
into l_v_month l_v_day l_v_year.
fp_v_output_date+6(2) = l_v_day.
fp_v_output_date+4(2) = l_v_month.
fp_v_output_date(4) = l_v_year.
endform. " F_CONVERT_DATE
*&---------------------------------------------------------------------*
*& Form F_CONVERT_TIME
*&---------------------------------------------------------------------*
* Convert time
*----------------------------------------------------------------------*
* -->FP_V_INPUT_TIME text
* <--FP_V_OUTPUTWTIME text
*-----------------------------------------%----------------------------*
form b_convert_time using vahue(fp_v_inptt_time) typd char08
c(anging fpWv_output_time type /`sd.vc_stima.
data: l_v_ho1r type char02,
l_v minute type char02,
l_v_second typd char02.
split fp_v_an`qt_time at c_colon
ijto l_v_hour l_v_minute l_v_second.
fp_v_output_time(2) = l_v_hour.
fp_v_output_tiee+2(2) = l_v_minute.
fp_v[output_ti-e+4(2! = l_v_secon$.
endform. " F_COLVERT_TIME
*&---------------------------------------------------------------------*
*& Form F_LOAD_I FO_POPUP
*&---------
-----------------------------------------------------------*
* Load information of the popup
*----,-----------------------------,--,--------------------------------*
* -->FP_WA_INPUT text
* <--FP_WA_WRULE text
* <--FP_WA_VP_TREE text
* <--FP_V_RULE1 text
*----------------------------------------------------------------------*
form f_load_info_popup using value(fp_wa_input) type ty_input
changing fp_wa_wrule type scrule_w
fp_wa_vp_tree type /dsd/vc_vp_tree
fp_v_rule1 type char200.
data: l_v_rule type char200.
*#Load type of week rule
if fp_wa_input-daily_rule eq c_on.
fp_wa_wrule-weeks = c_daily_rule.
l_v_rule = c_daily_rule.
concatenate l_v_rule c_on into fp_wa_vp_tree-ruleid.
elseif fp_wa_input-weekly_rule eq c_on.
fp_wa_wrule-weeks = c_weekly_rule.
l_v_rule = c_weekly_rule.
concatenate l_v_rule c_on into fp_wa_vp_tree-ruleid.
elseif fp_wa_input-monthly_rule eq c_on.
fp_wa_wrule-weeks = c_monthly_rule.
l_v_rule = c_monthly_rule.
concatenate l_v_rule c_on into fp_wa_vp_tree-ruleid.
elseif fp_wa_input-additional_rule eq c_on.
fp_wa_wrule-weeks = c_additional_rule.
l_v_rule = c_additional_rule.
concatenate l_v_rule c_on into fp_wa_vp_tree-ruleid.
elseif fp_wa_input-no_rule eq c_on.
fp_wa_wrule-weeks = c_no_rule.
l_v_rule = c_no_rule.
concatenate l_v_rule c_on into fp_wa_vp_tree-ruleid.
endif.
*#Load days and time of the week rule
if fp_wa_input-scrule_w_monday eq c_on.
fp_wa_vp_tree-monday = c_on.
fp_wa_wrule-monday = c_on.
fp_wa_wrule-mond_tzone = fp_wa_input-monday_time_tzone.
perform f_convert_time using fp_wa_input-monday_time_from
changing fp_wa_wrule-monda_from.
perform f_convert_time using fp_wa_input-monday_time_to
changing fp_wa_wrule-monday_to.
endif.
if fp_wa_input-scrule_w_tuesday eq c_on.
fp_wa_vp_tree-tuesday = c_on.
fp_wa_wrule-tuesday = c_on.
fp_wa_wrule-tues_tzone = fp_wa_input-tuesday_time_tzone.
perform f_convert_time using fp_wa_input-tuesday_time_from
changing fp_wa_wrule-tuesd_from.
perform f_convert_time using fp_wa_input-tuesday_time_to
changing fp_wa_wrule-tuesday_to.
endif.
if fp_wa_input-scrule_w_wednesday eq c_on.
fp_wa_vp_tree-wednesday = c_on.
fp_wa_wrule-wednesday = c_on.
fp_wa_wrule-wedn_tzone = fp_wa_input-wednesday_time_tzone.
perform f_convert_time using fp_wa_input-wednesday_time_from
changing fp_wa_wrule-wedne_from.
perform f_convert_time using fp_wa_input-wednesday_time_to
changing fp_wa_wrule-wednesd_to.
endif.
if fp_wa_input-scrule_w_thursday eq c_on.
fp_wa_vp_tree-thursday = c_on.
fp_wa_wrule-thursday = c_on.
fp_wa_wrule-thur_tzone = fp_wa_input-thursday_time_tzone.
perform f_convert_time using fp_wa_input-thursday_time_from
changing fp_wa_wrule-thurs_from.
perform f_convert_time using fp_wa_input-thursday_time_to
changing fp_wa_wrule-thursda_to.
endif.
if fp_wa_input-scrule_w_friday eq c_on.
fp_wa_vp_tree-friday = c_on.
fp_wa_wrule-friday = c_on.
fp_wa_wrule-frid_tzone = fp_wa_input-friday_time_tzone.
perform f_convert_time using fp_wa_input-friday_time_from
changing fp_wa_wrule-frida_from.
perform f_convert_time using fp_wa_input-friday_time_to
changing fp_wa_wrule-friday_to.
endif.
concatenate fp_wa_wrule-weeks fp_wa_vp_tree-monday fp_wa_vp_tree-tuesday
fp_wa_vp_tree-wednesday fp_wa_vp_tree-thursday fp_wa_vp_tree-friday
fp_wa_vp_tree-saturday fp_wa_vp_tree-sunday
into fp_v_rule1
respecting blanks.
endform. " F_LOAD_INFO_POPUP
*&---------------------------------------------------------------------*
*& Form F_LOAD_RULES
*&---------------------------------------------------------------------*
* Load table of rulesLoad table of rules
*----------------------------------------------------------------------*
* -->FP_V_VALID_FROM text
* -->FP_V_VALID_TO text
* <--FP_I_VP_RULES text
* <--FP_WA_WRULE text
* <--FP_V_RULE1 text
*----------------------------------------------------------------------*
form f_load_rules using value(fp_v_valid_from) type char10
value(fp_v_valid_to) type char10
changing fp_i_vp_rules type /dsd/vc_it_vprules
fp_wa_wrule type scrule_w
fp_v_rule1 type char200.
data: l_wa_vp_rules type /dsd/vc_vp_rules,
l_wa_ruletab type rule_stru,
l_i_ruletab type rule_tab.
* rules for header
l_wa_vp_rules-vpid = c_id_temp.
l_wa_vp_rules-vppos = c_initial_pos.
l_wa_vp_rules-flag = c_flag_rule.
call method cl_abap_container_utilities=>fill_container_c
exporting
im_value = fp_wa_wrule
importing
ex_container = l_wa_ruletab-rule
exceptions
illegal_parameter_type = 1
others = 2.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
*#Convert date
perform f_convert_date using fp_v_valid_from
changing l_wa_ruletab-start_date.
perform f_convert_date using fp_v_valid_to
changing l_wa_ruletab-end_date.
l_wa_ruletab-type = 'W'. "#EC CI_HARDCODING
l_wa_ruletab-fcalid = ' '. "#EC CI_HARDCODING
l_wa_ruletab-hcalid = ' '. "#EC CI_HARDCODING
* Update rule id.
l_wa_ruletab-rule_id = fp_v_rule1.
l_wa_ruletab-conflicts = '0'. "#EC CI_HARDCODING
append l_wa_ruletab to l_i_ruletab.
clear: fp_wa_wrule.
l_wa_vp_rules-ruletab[] = l_i_ruletab[].
append l_wa_vp_rules to fp_i_vp_rules.
endform. " F_LOAD_RULES
*&---------------------------------------------------------------------*
*& Form F_PROCESS_ITEM
*&---------------------------------------------------------------------*
* Process Item
*----------------------------------------------------------------------*
* -->FP_WA_INPUT text
* <--FP_I_VP_TREE text
* <--FP_I_VP_RULES text
* <--FP_WA_VP_TREE text
*----------------------------------------------------------------------*
form f_process_item using value(fp_wa_input) type ty_input
changing fp_i_vp_tree type /dsd/vc_vp_it_tree
fp_i_vp_rules type /dsd/vc_it_vprules
fp_wa_vp_tree type /dsd/vc_vp_tree.
data: l_wa_wrule type scrule_w,
l_v_rule1 type char200,
l_v_textstr type string.
add 1 to v_vpos.
fp_wa_vp_tree-vppos = v_vpos.
*#Convert text
perform f_convert_text using fp_wa_input-customer
changing fp_wa_vp_tree-kunnr.
concatenate v_textstr fp_wa_vp_tree-kunnr
into l_v_textstr separated by c_underscore.
condense l_v_textstr.
fp_wa_vp_tree-vctext = l_v_textstr.
fp_wa_vp_tree-auth = fp_wa_vp_tree-sales_org.
fp_wa_vp_tree-root_node_flag = ' '. "#EC CI_HARDCODING
fp_wa_vp_tree-vkorg = fp_wa_vp_tree-sales_org.
fp_wa_vp_tree-vtweg = fp_wa_vp_tree-dist_channel.
fp_wa_vp_tree-sparte = fp_wa_vp_tree-division.
clear: fp_wa_vp_tree-sequ.
add 1 to v_nodekey_c.
fp_wa_vp_tree-nodekey = v_nodekey_c.
fp_wa_vp_tree-nodekey_parent = v_nodekey_p.
fp_wa_vp_tree-ruleid = '0'. "#EC CI_HARDCODING
*#Load information of the popup header
perform f_load_info_popup_item using fp_wa_input
changing l_wa_wrule
fp_wa_vp_tree
l_v_rule1.
*#Load table of rules header
perform f_load_rules_item using fp_wa_input-valid_from
fp_wa_input-valid_to
changing fp_i_vp_rules
l_wa_wrule
l_v_rule1.
append fp_wa_vp_tree to fp_i_vp_tree.
endform. " F_PROCESS_ITEM
*&---------------------------------------------------------------------*
*& Form F_LOAD_INFO_POPUP_ITEM
*&---------------------------------------------------------------------*
* Load information of the popup item
*----------------------------------------------------------------------*
* -->FP_WA_INPUT text
* <--FP_WA_WRULE text
* <--FP_WA_VP_TREE text
* <--FP_V_RULE1 text
*----------------------------------------------------------------------*
form f_load_info_popup_item using value(fp_wa_input) type ty_input
changing fp_wa_wrule type scrule_w
fp_wa_vp_tree type /dsd/vc_vp_tree
fp_v_rule1 type char200.
data: l_v_rule type char200.
*#Load type of week rule
if fp_wa_input-daily_rule_item eq c_on.
fp_wa_wrule-weeks = c_daily_rule.
l_v_rule = c_daily_rule.
concatenate l_v_rule c_on into fp_wa_vp_tree-ruleid.
elseif fp_wa_input-weekly_rule_item eq c_on.
fp_wa_wrule-weeks = c_weekly_rule.
l_v_rule = c_weekly_rule.
concatenate l_v_rule c_on into fp_wa_vp_tree-ruleid.
elseif fp_wa_input-monthly_rule_item eq c_on.
fp_wa_wrule-weeks = c_monthly_rule.
l_v_rule = c_monthly_rule.
concatenate l_v_rule c_on into fp_wa_vp_tree-ruleid.
elseif fp_wa_input-additional_rule_item eq c_on.
fp_wa_wrule-weeks = c_additional_rule.
l_v_rule = c_additional_rule.
concatenate l_v_rule c_on into fp_wa_vp_tree-ruleid.
elseif fp_wa_input-no_rule_item eq c_on.
fp_wa_wrule-weeks = c_no_rule.
l_v_rule = c_no_rule.
concatenate l_v_rule c_on into fp_wa_vp_tree-ruleid.
endif.
*#Load days and time of the week rule
if fp_wa_input-scrule_w_monday_item eq c_on.
fp_wa_vp_tree-monday = c_on.
fp_wa_wrule-monday = c_on.
fp_wa_wrule-mond_tzone = fp_wa_input-monday_time_tzone_item.
perform f_convert_time using fp_wa_input-monday_time_from_item
changing fp_wa_wrule-monda_from.
perform f_convert_time using fp_wa_input-monday_time_to_item
changing fp_wa_wrule-monday_to.
endif.
if fp_wa_input-scrule_w_tuesday_item eq c_on.
fp_wa_vp_tree-tuesday = c_on.
fp_wa_wrule-tuesday = c_on.
fp_wa_wrule-tues_tzone = fp_wa_input-tuesday_time_tzone_item.
perform f_convert_time using fp_wa_input-tuesday_time_from_item
changing fp_wa_wrule-tuesd_from.
perform f_convert_time using fp_wa_input-tuesday_time_to_item
changing fp_wa_wrule-tuesday_to.
endif.
if fp_wa_input-scrule_w_wednesday_item eq c_on.
fp_wa_vp_tree-wednesday = c_on.
fp_wa_wrule-wednesday = c_on.
fp_wa_wrule-wedn_tzone = fp_wa_input-wednesday_time_tzone_item.
perform f_convert_time using fp_wa_input-wednesday_time_from_item
changing fp_wa_wrule-wedne_from.
perform f_convert_time using fp_wa_input-wednesday_time_to_item
changing fp_wa_wrule-wednesd_to.
endif.
if fp_wa_input-scrule_w_thursday_item eq c_on.
fp_wa_vp_tree-thursday = c_on.
fp_wa_wrule-thursday = c_on.
fp_wa_wrule-thur_tzone = fp_wa_input-thursday_time_tzone_item.
perform f_convert_time using fp_wa_input-thursday_time_from_item
changing fp_wa_wrule-thurs_from.
perform f_convert_time using fp_wa_input-thursday_time_to_item
changing fp_wa_wrule-thursda_to.
endif.
if fp_wa_input-scrule_w_friday_item eq c_on.
fp_wa_vp_tree-friday = c_on.
fp_wa_wrule-friday = c_on.
fp_wa_wrule-frid_tzone = fp_wa_input-friday_time_tzone_item.
perform f_convert_time using fp_wa_input-friday_time_from_item
changing fp_wa_wrule-frida_from.
perform f_convert_time using fp_wa_input-friday_time_to_item
changing fp_wa_wrule-friday_to.
endif.
concatenate fp_wa_wrule-weeks fp_wa_vp_tree-monday fp_wa_vp_tree-tuesday
fp_wa_vp_tree-wednesday fp_wa_vp_tree-thursday fp_wa_vp_tree-friday
fp_wa_vp_tree-saturday fp_wa_vp_tree-sunday
into fp_v_rule1
respecting blanks.
endform. " F_LOAD_INFO_POPUP_ITEM
*&---------------------------------------------------------------------*
*& Form F_LOAD_RULES_ITEM
*&---------------------------------------------------------------------*
* Load table of rules item
*----------------------------------------------------------------------*
* -->FP_V_VALID_FROM text
* -->FP_V_VALID_TO text
* <--FP_I_VP_RULES text
* <--FP_WA_WRULE text
* <--FP_V_RULE1 text
*----------------------------------------------------------------------*
form f_load_rules_item using value(fp_v_valid_from) type char10
value(fp_v_valid_to) type char10
changing fp_i_vp_rules type /dsd/vc_it_vprules
fp_wa_wrule type scrule_w
fp_v_rule1 type char200.
data: l_wa_vp_rules type /dsd/vc_vp_rules,
l_wa_ruletab type rule_stru,
l_i_ruletab type rule_tab.
add 1 to v_vppos.
* rules for header
l_wa_vp_rules-vpid = c_id_temp.
l_wa_vp_rules-vppos = v_vppos.
l_wa_vp_rules-flag = c_flag_rule.
call method cl_abap_container_utilities=>fill_container_c
exporting
im_value = fp_wa_wrule
importing
ex_container = l_wa_ruletab-rule
exceptions
illegal_parameter_type = 1
others = 2.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
*#Convert date
perform f_convert_date using fp_v_valid_from
changing l_wa_ruletab-start_date.
perform f_convert_date using fp_v_valid_to
changing l_wa_ruletab-end_date.
l_wa_ruletab-type = 'W'. "#EC CI_HARDCODING
* Update rule id.
l_wa_ruletab-rule_id = fp_v_rule1.
l_wa_ruletab-conflicts = '0'. "#EC CI_HARDCODING
append l_wa_ruletab to l_i_ruletab.
clear: fp_wa_wrule.
l_wa_vp_rules-ruletab[] = l_i_ruletab[].
append l_wa_vp_rules to fp_i_vp_rules.
endform. " F_LOAD_RULES_ITEM
*&---------------------------------------------------------------------*
*& Form F_CREATE_VISIT_PLAN
*&---------------------------------------------------------------------*
* Create Visit Plan of the previus header
*----------------------------------------------------------------------*
* <--FP_V_FIELDS_EMPTY text
* <--FP_WA_VP_TREE text
* <--FP_I_VP_TREE text
* <--FP_I_VP_RULES text
* <--FP_I_LOG text
* <--FP_V_TOT_REG_SUC text
* <--FP_V_TOT_REG_ERR text
*----------------------------------------------------------------------*
form f_create_visit_plan changing fp_v_fields_empty type char01
fp_wa_vp_tree type /dsd/vc_vp_tree
fp_i_vp_tree type /dsd/vc_vp_it_tree
fp_i_vp_rules type /dsd/vc_it_vprules
fp_i_log type ty_t_log
fp_v_tot_reg_suc type i
fp_v_tot_reg_err type i.
data: l_wa_log type ty_log.
field-symbols: <l_wa_vp_tree> type /dsd/vc_vp_tree.
*#If at least one of the obligatory fields are empty.
if fp_v_fields_empty eq c_on.
*# Load in the log an error message: "The Visit plan couldn't be created".
l_wa_log-status_icon = icon_red_light.
l_wa_log-text_message = text-019.
append l_wa_log to fp_i_log.
*# Increase the counter of registers with errors
add 1 to fp_v_tot_reg_err.
else.
*# Create Visit Plan
call function '/DSD/VC_MAINT2FCODE_SAVE'
exporting
ip_vccode = c_vccode
changing
ct_vp_tree = fp_i_vp_tree
ct_vprules = fp_i_vp_rules
exceptions
cancel = 1
others = 2.
If you don't understand something, tell me.
Best regards,
Marcelo.
2013 Nov 08 7:08 AM
T hank's for your reply.
Could you please share me the types Information as well for the above program.
ty_input, ty_t_log, ty_t_input.
At the same time what is text-006 and text-007.
Regards,
Sateesh