2013 Jun 15 7:34 AM
Hi All,
I have created a custom tab in XD01 to capture additional customer details at the time of Customer Creation.
But I could not get the details captured in any part fo the screen even after entering the values in the respective field's textboxes.
To accomplish this, I have used the following.
1. SPRO
2. Badi Implementation
i. CUSTOMER_ADD_DATA
ii. CUSTOMER_ADD_DATA_CS
2013 Jun 15 8:06 AM
Hi Harish,
Please refer the example given here http://saptechnical.com/Tutorials/ABAP/XD01/XD01.htm.
Revert in case of further questions.
BR,
Ankit.
2013 Jun 15 8:06 AM
Hi Harish,
Please refer the example given here http://saptechnical.com/Tutorials/ABAP/XD01/XD01.htm.
Revert in case of further questions.
BR,
Ankit.
2013 Jun 15 8:12 AM
Hi Ankit,
I have used the same tutorial to create the Custom Tab in XD01.
But then I could only display the custom tab with the fields but could not save the fields to the table in KNA1.
I have even created a function module to to map the custom tab with the required fields.
I m doubtful about how to use the function module in the BADI Implementation namely CUSTOMER_ADD_DATA_CS.
Thanks & Regards
Harish
2013 Jun 16 6:03 AM
Hi Harish,
Some steps are missed in the link.
BADI CUSTOMER_ADD_DATA has CHECK_DATA_CHANGED method.
Implement it as shown,
METHOD if_ex_customer_add_data~check_data_changed.
*-- To make it mandatory to call SAVE DATA Method
e_changed = 'X'.
ENDMETHOD
Now code the saving Logic in SAVE_DATA method.
It should work then.
BR.
2013 Jun 16 7:29 AM
Hi Ankit,
I have tried the way you have suggested but the control is not even coming to that place at all.
Both the functions in the BADI Customer_Add_Data are not triggered. I tried them keeping the break points.
Harish
2013 Jun 16 4:38 PM
Hi Harish,
I had worked on a similar requirement where my need was to have a custom tab with a table control and update the values present there to a custom/Z table.
I achieved it through the mentioned steps -
2. Implement Check ADD_ON_ACTIVE method as,
METHOD if_ex_customer_add_data~check_add_on_active.
* -- Screen group as maintained in the configuration.
IF i_screen_group = 'ZC'.
e_add_on_active = 'X'.
ENDIF.
ENDMETHOD.
3. Implement Check DATA_CHANGED as,
METHOD if_ex_customer_add_data~check_data_changed.
*-- To make it mandatory to call SAVE DATA Method
e_changed = 'X'.
ENDMETHOD.
4. Implement SAVE_DATA Method as,
DATA :
*-- Internal table with Status Data
gt_status_1 TYPE STANDARD TABLE OF zmdm_status,
*-- Internal table with Status Data
gt_ztab TYPE STANDARD TABLE OF zmdm_status,
*-- Work Area for internal table with status data
gs_stat1 TYPE zmdm_status.
*-- Function Module to export the global table from Module Pool
CALL FUNCTION 'Z_TAB_EXP'
TABLES
t_ztab = gt_status_1.
*-- Check whether Custom Tab is clicked or not
CHECK gt_status_1 IS NOT INITIAL.
*-- If custom tab 'Marketing Tier Attributes' is clicked ,proceed
LOOP AT gt_status_1 INTO gs_stat1.
*-- if internal number ranges were used, the customer number needs to be populated here
IF gs_stat1-customer_number IS INITIAL.
gs_stat1-customer_number = i_kunnr.
MODIFY gt_status_1 FROM gs_stat1.
ENDIF.
CLEAR gs_stat1.
ENDLOOP.
CLEAR gs_stat1.
*Delete all the existing values for the mentioned customer from Z table.
READ TABLE gt_status_1 INTO gs_stat1 INDEX 1.
IF sy-subrc EQ 0.
DELETE FROM zmdm_status WHERE customer_number = gs_stat1-customer_number.
ELSE.
DELETE FROM zmdm_status WHERE customer_number = i_kunnr.
ENDIF.
CLEAR gs_stat1.
**-- Update the Custom Table
LOOP AT gt_status_1 INTO gs_stat1.
MODIFY zmdm_status FROM gs_stat1.
ENDLOOP.
ENDMETHOD.
5. Created a FM to export Table Control Data such that it can be used in BADI exits as,
FUNCTION z_tab_exp.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" TABLES
*" T_ZTAB STRUCTURE ZMDM_STATUS
*"----------------------------------------------------------------------
*-- This Function Module exports the Global Table outside the Module Pool
*-- for the exits to use the table.
*************************************************************************
FIELD-SYMBOLS : <fs_stat> TYPE gty_status.
DATA : ls_stat TYPE zmdm_status.
LOOP AT gt_status ASSIGNING <fs_stat>.
IF <fs_stat> IS ASSIGNED.
ls_stat-customer_number = <fs_stat>-customer_number.
ls_stat-type = <fs_stat>-type.
ls_stat-start_date = <fs_stat>-start_date.
ls_stat-end_date = <fs_stat>-end_date.
ls_stat-status = <fs_stat>-status.
APPEND ls_stat TO t_ztab.
ENDIF.
CLEAR ls_stat.
ENDLOOP.
UNASSIGN : <fs_stat>.
ENDFUNCTION.
6. Implement the method GET_TAXI_SCREEN as,
METHOD if_ex_customer_add_data_cs~get_taxi_screen.
CASE i_taxi_fcode.
*-- Check for Function Code of subscreen as maitained in configuration
WHEN 'MKT_TIER'. " Cretaed in step 1
*-- Subscreen Number
e_screen = '9999'.
*-- Subscreen Program
e_program = 'SAPLZ_MDM_CUST_STATUS'. " Module Pool Program whihc you would have created for your tab
*-- Subscreen header
e_headerscreen_layout = ' '.
ENDCASE.
ENDMETHOD.
7. The Module Pool Program's ( SAPLZ_MDM_CUST_STATUS ) code would be like -
PROCESS BEFORE OUTPUT.
*-- PBO FLOW LOGIC FOR TABLECONTROL 'GTC_STATUS'
MODULE gtc_status_change_tc_attr.
*-- MODULE GTC_STATUS_CHANGE_COL_ATTR.
LOOP AT gt_status
INTO gs_status
WITH CONTROL gtc_status
CURSOR gtc_status-current_line.
MODULE gtc_status_get_lines.
*-- module to make a single line as editable
MODULE edit_single_rec.
ENDLOOP.
*-- Checks the mode in which the transaction is called
MODULE tcode_check.
PROCESS AFTER INPUT.
*-- PAI FLOW LOGIC FOR TABLECONTROL 'GTC_STATUS'
*-- Loop at the internal table of table control
MODULE clear.
LOOP AT gt_status.
CHAIN.
FIELD gs_status-type.
FIELD gs_status-start_date.
FIELD gs_status-end_date.
FIELD gs_status-status.
*-- Validations for Invalid Vaue
MODULE gtc_status_modify ON CHAIN-REQUEST.
*-- Validations for Overlapping Date Ranges
MODULE validate_overlap ON CHAIN-REQUEST.
ENDCHAIN.
*-- check for initial row on 'Enter' Press
MODULE check_data.
FIELD gs_status-mark
*-- Populate the mark table with the row selected
MODULE gtc_status_mark ON REQUEST.
ENDLOOP.
*-- Check the User Command
MODULE gtc_status_user_command.
*-- Check for Initial Value on 'Save' Press
MODULE check_initial_row.
PROCESS ON VALUE-REQUEST.
*-- F4 help for Status Field
FIELD gs_status-status MODULE get_f4_help.
*-- F4 help for Type of Provider Field
FIELD gs_status-type MODULE get_list.
8. The declarations in top include should be -
*-- Custom Table storing the Marketing Tier Status Data
TABLES : zmdm_status.
TYPES : BEGIN OF gty_status,
*-- A mark field to enable table control's record selection
mark TYPE char1,
*-- Customer Number
customer_number TYPE kna1-kunnr,
*-- Type of Provider - (Solution Provider/Regional Market) or (Channel Provider/Industry Code 1)
type TYPE char2,
*-- Start date for the Status
start_date TYPE sy-datum,
*-- End date for the Status
end_date TYPE sy-datum,
*-- Status, can be blank, SLT,PMR or ELT
status TYPE char10,
END OF gty_status.
DATA :
*-- Internal table for holding the all status details
gt_status TYPE STANDARD TABLE OF gty_status,
*-- Unsorted Internal table for holding the all status details
gt_temp TYPE STANDARD TABLE OF gty_status,
*-- Work area for the internal table of all details
gs_status TYPE gty_status.
*-- Decalartion of Table control
CONTROLS: gtc_status TYPE TABLEVIEW USING SCREEN 9999.
*-- Lines of table control
DATA: g_gtc_status_lines LIKE sy-loopc. "#EC NEEDED
*-- Ok Code
DATA: ok_code LIKE sy-ucomm.
DATA :
*-- To check for First Run.
gv_first_run TYPE char1 VALUE space,
*-- Flag set to make the first record editable.
gv_edit TYPE char1 VALUE space,
*-- Flag to prevent from saving empty editable rows
gv_save TYPE char1 VALUE space,
*-- Flag to have Type of provider F4 help triggered only once
gv_f4_type TYPE char1,
*-- Flag to have Status of provider F4 help triggered only once
gv_f4_status TYPE char1.
9. The Modules mentioned above i coded in PBO & PAI.
10 Implement the method GET_DATA as,
METHOD if_ex_customer_add_data_cs~get_data.
DATA :
*-- Internal table with Status Data
gt_status_1 TYPE STANDARD TABLE OF zmdm_status,
*-- Work Area for Status Internal Table
gs_stat2 TYPE zmdm_status,
*-- Work Area for Status Internal Table
gs_stat3 TYPE zmdm_status,
*-- Internal table for Channel Provider
gt_cp TYPE STANDARD TABLE OF zmdm_status,
*-- Internal table for Solution Provider
gt_sp TYPE STANDARD TABLE OF zmdm_status,
*-- 6/8/2012
*-- flag set for the record having the current date for CP Type
lv_cp_fg TYPE char1,
*-- flag set for the record having the current date for SP Type
lv_sp_fg TYPE char1.
*-- 6/8/2012
*-- Function module to export the global table from Module Pool
CALL FUNCTION 'Z_TAB_EXP'
TABLES
t_ztab = gt_status_1.
gt_cp = gt_status_1.
gt_sp = gt_status_1.
DELETE gt_cp WHERE type = 'SP'.
DELETE gt_sp WHERE type = 'CP'.
*-- Sort the tables to get the latest values
SORT gt_cp BY customer_number type start_date DESCENDING.
SORT gt_sp BY customer_number type start_date DESCENDING.
*--- 6/8/2012
*If Channel provider
CLEAR gs_stat2.
IF gt_cp IS NOT INITIAL.
LOOP AT gt_cp INTO gs_stat2.
**-- Update the Industry Code 1
IF gs_stat2 IS NOT INITIAL.
IF sy-datum BETWEEN gs_stat2-start_date AND gs_stat2-end_date.
s_kna1-bran1 = gs_stat2-status.
lv_cp_fg = 'X'.
ENDIF.
ENDIF.
CLEAR gs_stat2.
ENDLOOP.
ENDIF.
*-- if no corresponding record was found for current date range then set the status as blank.
IF lv_cp_fg IS INITIAL.
s_kna1-bran1 = space.
ENDIF.
CLEAR : gs_stat2, lv_cp_fg.
*If Solution Provider
CLEAR gs_stat3.
IF gt_sp IS NOT INITIAL.
LOOP AT gt_sp INTO gs_stat3.
**-- Update the Industry Code 1
IF gs_stat3 IS NOT INITIAL.
IF sy-datum BETWEEN gs_stat3-start_date AND gs_stat3-end_date.
s_kna1-rpmkr = gs_stat3-status.
lv_sp_fg = 'X'.
ENDIF.
ENDIF.
CLEAR gs_stat3.
ENDLOOP.
ENDIF.
*-- if no corresponding record was found for current date range then set the status as blank.
IF lv_sp_fg IS INITIAL.
s_kna1-rpmkr = space.
ENDIF.
CLEAR : gs_stat3, lv_sp_fg.
ENDMETHOD.
Please skim across all these steps and see what you have done and what is skipped by you. Also since you are updating in KNA1 itself i think you need not code and follow all these steps but still you verify once.
Please revert in case of further questions.
BR.
2013 Jun 15 4:50 PM
have you created module or function pool for your additional screen? Instead of creating "module/ function pool" try creating executable program.(Type 'E") program and check.
in method "GET_TAXI_SCREEN', where you assign screen and program name, use
e_screen = '1111'.
e_program = 'ZXD01_ADD'.
Then, go to SE38, create an executable program named 'ZXD01_ADD' and create screen '1111' in that program.
Regards
2013 Jun 16 8:02 AM
Check this answered thread which uses the methods (SET_DATA and GET_DATA) in the BADI to enable the flow of data between table and screen fields. Hope it will be useful.