Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

*&************************************************************************

* PROGRAM--INITIAL CREATION

* This report is run in the foreground to remove the product from the

* transportation lane once the products are obsoete. After this the

* program will also delete the products from the corresponding markets

* warehouses and production center locations.

************************************************************************

************************************************************************

* PROGRAM--Modification*MOD-1771404

* Program name : ZAXXPR_DELETE_MASTER_DATA

* Reference program (copied from) : na.

* Development specification ID :

* Date created : 15.02.2008

* Author : Aveek Ghose.

* Description :

*

* This report is run in the foreground to remove the product from the

* transportation lane once the products are obsoete. After this the

* program will also delete the products from the corresponding markets

* warehouses and production center locations.

************************************************************************

************************************************************************

* MOD-1887120

* Program name : ZAXXPR_DELETE_MASTER_DATA_F01

* Reference program (copied from) : na.

* Development specification ID :

* Date created : 10.03.2008

* Author : Aveek Ghose

* Description :

*

* This is the Form include that contains the local subroutines of the

* main program ZAXXPR_DELETE_MASTER_DATA.

************************************************************************REPORT zaxxpr_delete_master_data MESSAGE-ID zaxxp_sign_fpv.* Include for global data and constants declaration

* INCLUDE zaxxpr_delete_master_data_top.* include ZAXXPR_DEL_MASTER_DATA_TOP.*&---------------------------------------------------------------------*

*& Include ZAXXPR_DEL_MASTER_DATA_TOP

*&---------------------------------------------------------------------*

*&---------------------------------------------------------------------*

*& Include ZAXXPR_DELETE_MASTER_DATA_TOP

*&---------------------------------------------------------------------*

************************************************************************

* PROGRAM--INITIAL CREATION

* Description XXXXXXXXXX :

*

* This is the Top include that contains the global data declarations

* and the selection screen of the main program

* ZAXXPR_DELETE_MASTER_DATA

************************************************************************

************************************************************************

* PROGRAM--Modification: MOD-1771404

* Program name : ZAXXPR_DELETE_MASTER_DATA_TOP

* Reference program (copied from) : na.

* Development specification ID :

* Initial Change request number : PMI_SIGN_0002

* Author : Aveek Ghose..

* Description :

*

* This is the Top include that contains the global data declarations

* and the selection screen of the main program

* ZAXXPR_DELETE_MASTER_DATA

************************************************************************

************************************************************************

**********************TYPES DECLARATION***************************

************************************************************************

TYPE-POOLS: slis...

* Types dclaration for view table data.

TYPES: BEGIN OF s_view_data,

pcode TYPE matnr, " Product

maktx TYPE char40, " Prod Desc

markt TYPE char4, " Market

martx TYPE char20, " Market Desc

pdctr TYPE char2, " Product Center

pctxt TYPE char20, " Description

whse1 TYPE CHAR3, " Warehouse1

whse2 TYPE CHAR3, " Warehouse2

prvar TYPE CHAR18, " Product Variant

vartx TYPE CHAR30, " Variant Description

status TYPE CHAR1, " Status

END OF s_view_data,

t_view_data TYPE STANDARD TABLE OF s_view_data.

*MOD-1771404*****

TYPES: BEGIN OF l_view_data,

pcode TYPE matnr, " Product

markt TYPE CHAR4, " Market

pdctr TYPE CHAR2, " Product Center

whse1 TYPE CHAR3, " Warehouse1

whse2 TYPE CHAR3, " Warehouse2

prvar TYPE CHAR18, " Product Variant

status TYPE CHAR1, " Status

END OF l_view_data,

lv_view_data TYPE STANDARD TABLE OF s_view_data.

*MOD-1771404****

* Types declaration for F4 help Product data

TYPES: BEGIN OF s_f4_data_matnr,

pcode TYPE matnr, " Product

maktx TYPE maktx, " Description

END OF s_f4_data_matnr,

t_f4_data_matnr TYPE STANDARD TABLE OF s_f4_data_matnr.

* Types declaration for F4 help Location data

TYPES: BEGIN OF s_f4_data_loc,

locno TYPE /sapapo/locno, " Location

desc TYPE /sapapo/loc_descr40, " Description

pcode TYPE /sapapo/matnr, " Product

prvar TYPE /sapapo/matnr, " Product Variant

*MOD-012

pdctr TYPE CHAR2, "Production Center

*MOD-012

vartx TYPE CHAR30, " Variant Description

maktx TYPE CHAR40, " Prod Desc

status TYPE CHAR1, " Status

loctyp TYPE /sapapo/c_loctype, " Location Type

whse1 TYPE CHAR3,

whse2 TYPE CHAR3,

lv_exist TYPE I, " Variable

END OF s_f4_data_loc,

t_f4_data_loc TYPE STANDARD TABLE OF s_f4_data_loc.

* Types declaration for Warehouse description

TYPES: BEGIN OF s_whse,

whse TYPE CHAR3, " Location

whdesc TYPE CHAR30, " Description

END OF s_whse,

t_whse TYPE STANDARD TABLE OF s_whse.

* Types declaration for F4 help Location data

TYPES: BEGIN OF s_f4_loc,

locno TYPE /sapapo/locno, " Location

desc TYPE /sapapo/loc_descr40, " Description

END OF s_f4_loc,

t_f4_loc TYPE STANDARD TABLE OF s_f4_loc.

* Types declaration for SCREEN TABLE used in submit statement

TYPES: t_rsparams TYPE STANDARD TABLE OF rsparams.

* Types declaration for Transportation Lane data

TYPES: BEGIN OF s_tlane_data,

trpid TYPE /sapapo/tr_trpid, " Trip Id

locto TYPE /sapapo/locno, " Location to

matid TYPE matnr, " Material Id

locfr TYPE /sapapo/locno, " Location from

END OF s_tlane_data,

t_tlane_data TYPE STANDARD TABLE OF s_tlane_data.

* Types Declaration for Range Table

TYPES: BEGIN OF s_range_matid,

sign TYPE char1, " Sign

option TYPE char2, " Option

low TYPE /sapapo/matid, " Matid low

high TYPE /sapapo/matid, " Matid high

END OF s_range_matid,

t_matid_range TYPE STANDARD TABLE OF s_range_matid.

* Types Declaration for Range Table

TYPES: BEGIN OF s_range_locid,

sign TYPE char1, " Sign

option TYPE char2, " Option

low TYPE /sapapo/locid, " Locid low

high TYPE /sapapo/locid, " locid high

END OF s_range_locid,

t_locid_range TYPE STANDARD TABLE OF s_range_locid.

* Types Declaration for ALV Display

TYPES: BEGIN OF s_display,

prod TYPE /sapapo/matnr, " Product

p_des TYPE CHAR40, " Product Desc

loc TYPE /sapapo/locno, " Location

l_des TYPE /sapapo/loc_descr40, " Location Desc

status TYPE char15, " Deletion status

light TYPE iconname, " Light Indicator

END OF s_display,

t_display TYPE STANDARD TABLE OF s_display.

TYPES: BEGIN OF s_displayprd,

prod TYPE /sapapo/matnr, " Product

p_des TYPE CHAR40, " Product Desc

status TYPE char15, " Deletion status

light TYPE iconname, " Light Indicator

END OF s_displayprd,

t_displayprd TYPE STANDARD TABLE OF s_displayprd.

* Types Declaration for Product select options

TYPES: BEGIN OF s_range_product,

sign TYPE char1, " Sign

option TYPE char2, " Option

low TYPE matnr, " Product low

high TYPE matnr, " Product high

END OF s_range_product.

* Types Declaration for Location select option

TYPES: BEGIN OF s_range_location,

sign TYPE char1, " Sign

option TYPE char2, " Option

low TYPE /sapapo/locno, " Location low

high TYPE /sapapo/locno, " Location high

END OF s_range_location.

* Types Declaration for Matids for the Products

TYPES: BEGIN OF s_matid,

matid TYPE /sapapo/matid, " Matid

matnr TYPE matnr, " Product

END OF s_matid,

t_matid TYPE STANDARD TABLE OF s_matid.

* Types Declaration for Locid and Locations

TYPES: BEGIN OF s_locid,

locid TYPE /sapapo/locid, " Matid

locno TYPE /sapapo/locno, " Product

END OF s_locid,

t_locid TYPE STANDARD TABLE OF s_locid.

TYPES: BEGIN OF s_tlaneupd,

locfr TYPE /sapapo/locno,

locto TYPE /sapapo/locno,

matnr TYPE matnr,

matid type /SAPAPO/MATID,

msg TYPE /fre/bif_messagetext,

END OF s_tlaneupd,

t_tlaneupd TYPE STANDARD TABLE OF s_tlaneupd.

TYPES: BEGIN OF s_matloc,

matnr TYPE matnr,

locno TYPE /sapapo/locno,

END OF s_matloc,

t_matloc TYPE STANDARD TABLE OF s_matloc.

*MOD-1771404

TYPES: t_masterdata TYPE STANDARD TABLE OF ZAP_SCMPF,

s_tship type ZAP_TSHPT,

t_tship type standard table of s_tship,

t_log_table TYPE STANDARD TABLE OF bal_s_msg,

t_log_location TYPE STANDARD TABLE OF bal_s_msg,

t_log_product TYPE STANDARD TABLE OF bal_s_msg,

t_log_locprd TYPE STANDARD TABLE OF bal_s_msg,

t_log_tlane TYPE STANDARD TABLE OF bal_s_msg.

TYPES: BEGIN OF s_location,

locno TYPE /sapapo/locno,

loctp TYPE /sapapo/c_loctype,

locct TYPE char1,

END OF s_location,

t_location TYPE STANDARD TABLE OF s_location,

BEGIN OF s_product,

matnr TYPE /sapapo/matnr,

matct TYPE char1,

END OF s_product,

t_product TYPE STANDARD TABLE OF s_product,

BEGIN OF s_tlane,

locfr TYPE /sapapo/locno,

locto TYPE /sapapo/locno,

matnr TYPE /sapapo/matnr,

ltpfr TYPE /sapapo/c_loctype,

ltpto TYPE /sapapo/c_loctype,

lidfr TYPE /sapapo/locid,

lidto TYPE /sapapo/locid,

matid TYPE /sapapo/matid,

datfr TYPE timestamp,

datto TYPE timestamp,

crtyp TYPE flag,

lv_exist type i,

END OF s_tlane,

t_tlane TYPE STANDARD TABLE OF s_tlane,

BEGIN OF s_loc_extloc,

locno TYPE /sapapo/locno,

extloc TYPE /sapapo/loc_extlocno,

END OF s_loc_extloc,

t_loc_extloc TYPE STANDARD TABLE OF s_loc_extloc,

BEGIN OF s_prd_extprd,

matnr TYPE /sapapo/matnr,

extmat TYPE /sapapo/ext_matnr,

END OF s_prd_extprd,

t_prd_extprd TYPE STANDARD TABLE OF s_prd_extprd,

BEGIN OF s_locprd,

locno TYPE /sapapo/locno,

matnr TYPE /sapapo/matnr,

loctp TYPE /sapapo/c_loctype,

prctp TYPE /sapapo/beskz,

END OF s_locprd,

t_locprd TYPE STANDARD TABLE OF s_locprd.

DATA: t_sign type standard table of zap_sign.

DATA: t_sign1 type standard table of zap_sign.

DATA: IT_ZDU1002 type standard table of zdu1002.

DATA: it_zdm0705 type standard table of zdm0705.

*MOD-1771404

************************************************************************

******************CONSTANTS DECLARATION***************************

************************************************************************

CONSTANTS:

* Selection Screen field names

gc_prd_low TYPE dynfnam VALUE 'S_PRD-LOW',

gc_prd_high TYPE dynfnam VALUE 'S_PRD-HIGH',

gc_mkt_low TYPE dynfnam VALUE 'S_MKT-LOW',

gc_mkt_high TYPE dynfnam VALUE 'S_MKT-HIGH',

* Transaction Name and Program Names

gc_bp2 TYPE baltcode VALUE '/SAPAPO/BP2',

gc_slg1 TYPE baltcode VALUE 'SLG1',

gc_mode_e TYPE ctu_mode VALUE 'E',

gc_mode_n TYPE ctu_mode VALUE 'N',

gc_foreground TYPE char1 VALUE 'A',

gc_rscsel TYPE dynfnam VALUE 'RSCSEL-SLOW_I',

gc_l_brac TYPE char1 VALUE '(',

gc_r_brac TYPE char1 VALUE ')',

* Selection Screen Elements for /SAPAPO/RLCDELETE

gc_radio_btn TYPE rsscr_kind VALUE 'R',

gc_parameter TYPE rsscr_kind VALUE 'P',

gc_sel_optn TYPE rsscr_kind VALUE 'S',

gc_sign_i TYPE tvarv_sign VALUE 'I',

gc_option_eq TYPE tvarv_opti VALUE 'EQ',

gc_manual_sel TYPE rsscr_name VALUE 'SHUF_PA1',

gc_product TYPE rsscr_name VALUE 'SEL_PROD',

gc_location TYPE rsscr_name VALUE 'SEL_LOC',

gc_plan_vrsn TYPE rsscr_name VALUE 'P_VERSIO',

gc_fixed_ord TYPE rsscr_name VALUE 'P_FIXED',

gc_category TYPE rsscr_name VALUE 'RB_CAT',

gc_key_fig TYPE rsscr_name VALUE 'RB_KEYF',

gc_only_apo TYPE rsscr_name VALUE 'P_APO',

gc_test_run TYPE rsscr_name VALUE 'P_TEST',

gc_pvrsn_000 TYPE tvarv_val VALUE '000',

* Selection screen fields for /SAPAPO/DELETE_PP_ORDER

gc_pl_vrsn TYPE rsscr_name VALUE 'LV_SIMID',

gc_prod TYPE rsscr_name VALUE 'LT_MATAB',

gc_loc TYPE rsscr_name VALUE 'LT_LOTAB',

gc_plan_prod TYPE rsscr_name VALUE 'LV_EXT',

gc_contract TYPE rsscr_name VALUE 'LV_SUBCO',

gc_display_ord TYPE rsscr_name VALUE 'LV_LIST',

gc_delete_ord TYPE rsscr_name VALUE 'LV_DEL',

gc_send_delete TYPE rsscr_name VALUE 'LV_EVENT',

* ALV grid display fields

gc_pos_1 TYPE lvc_colpos VALUE '0001',

gc_pos_2 TYPE lvc_colpos VALUE '0002',

gc_pos_3 TYPE lvc_colpos VALUE '0003',

gc_pos_4 TYPE lvc_colpos VALUE '0004',

gc_pos_5 TYPE lvc_colpos VALUE '0005',

gc_pos_6 TYPE lvc_colpos VALUE '0006',

gc_prodct TYPE lvc_fname VALUE 'PROD',

gc_status TYPE lvc_fname VALUE 'STATUS',

gc_light TYPE lvc_fname VALUE 'LIGHT',

gc_prod_des TYPE lvc_fname VALUE 'P_DES',

gc_loctn TYPE lvc_fname VALUE 'LOC',

gc_loc_des TYPE lvc_fname VALUE 'L_DES',

gc_tabname TYPE lvc_tname VALUE 'LT_DISPLAY',

gc_left TYPE lvc_just VALUE 'L',

gc_center TYPE lvc_just VALUE 'C',

gc_len_prod TYPE lvc_outlen VALUE '18',

gc_len_p_des TYPE lvc_outlen VALUE '40',

gc_len_loc TYPE lvc_outlen VALUE '20',

gc_len_l_des TYPE lvc_outlen VALUE '30',

gc_len_stat TYPE lvc_outlen VALUE '20',

gc_len_lt TYPE lvc_outlen VALUE '5',

gc_set_pf TYPE slis_formname VALUE 'F_SET_PF',

gc_show_log TYPE slis_formname VALUE 'F_SHOW_LOG',

gc_lt_top TYPE slis_formname VALUE 'F_TOP_TL',

gc_tlupd_top TYPE slis_formname VALUE 'F_TOP_TLUPD',

gc_prd_top TYPE slis_formname VALUE 'F_TOP_PRD',

gc_td_log TYPE gui_code VALUE 'TD_LOG',

gc_tlane TYPE gui_code VALUE 'TLANE',

gs_type_s TYPE char1 VALUE 'S',

gs_type_h TYPE char1 VALUE 'H',

gs_type_a TYPE char1 VALUE 'A',

gc_save TYPE char1 VALUE 'A',

gc_red TYPE iconname VALUE ' (5C)',

gc_green TYPE iconname VALUE ' (5B)',

* ALV display for Tlane

gc_prod_tl TYPE lvc_fname VALUE 'MATID',

gc_locto TYPE lvc_fname VALUE 'LOCTO',

gc_locfr TYPE lvc_fname VALUE 'LOCFR',

gc_matnr TYPE lvc_fname VALUE 'MATNR',

gc_msg TYPE lvc_fname VALUE 'MSG',

gc_tl_tab TYPE lvc_tname VALUE 'GT_TLANE',

gc_tl_tabu TYPE lvc_tname VALUE 'IT_TLANEUPD',

* Others

gc_s TYPE ddbool_d VALUE 'S',

gc_inactive TYPE char1 VALUE 'I',

gc_set TYPE char1 VALUE 'X',

gc_set_val TYPE tvarv_val VALUE 'X',

gc_int_commit TYPE bapi10001commctrl VALUE 'E',

gc_bs_group TYPE /sapapo/logqs VALUE 'BSGAPO',

gc_error TYPE bapi_mtype VALUE 'E',

gc_abend TYPE bapi_mtype VALUE 'A',

gc_dot TYPE char1 VALUE '.',

gc_colon TYPE char1 VALUE ':',

gc_space TYPE char4 VALUE ' ',

gc_star TYPE char1 VALUE '*',

*MOD-1771404

gc_core TYPE char1 VALUE 'C',

gc_var TYPE char1 VALUE 'V',

* Message class name

gc_msgid TYPE symsgid VALUE 'ZAXXP_SIGN_FPV',

* Message types

gc_warn TYPE symsgty VALUE 'W',

gc_err TYPE symsgty VALUE 'E',

gc_succ TYPE symsgty VALUE 'S',

* Message nos

gc_msgno_021 TYPE symsgno VALUE '021',

gc_msgno_023 TYPE symsgno VALUE '023',

gc_msgno_024 TYPE symsgno VALUE '024',

gc_msgno_025 TYPE symsgno VALUE '025',

gc_msgno_026 TYPE symsgno VALUE '026',

gc_msgno_027 TYPE symsgno VALUE '027',

gc_msgno_028 TYPE symsgno VALUE '028',

gc_msgno_029 TYPE symsgno VALUE '029',

gc_msgno_030 TYPE symsgno VALUE '030',

gc_msgno_031 TYPE symsgno VALUE '031',

gc_msgno_032 TYPE symsgno VALUE '032',

gc_msgno_033 TYPE symsgno VALUE '033',

gc_msgno_034 TYPE symsgno VALUE '034',

gc_msgno_035 TYPE symsgno VALUE '035',

gc_msgno_037 TYPE symsgno VALUE '037',

gc_msgno_038 TYPE symsgno VALUE '038',

gc_msgno_039 TYPE symsgno VALUE '039',

gc_msgno_040 TYPE symsgno VALUE '040',

gc_msgno_041 TYPE symsgno VALUE '041',

gc_msgno_042 TYPE symsgno VALUE '042',

gc_msgno_043 TYPE symsgno VALUE '043',

gc_msgno_044 TYPE symsgno VALUE '044',

gc_msgno_050 TYPE symsgno VALUE '050',

gc_msgno_051 TYPE symsgno VALUE '051',

gc_msgno_052 TYPE symsgno VALUE '052',

gc_msgno_053 TYPE symsgno VALUE '053',

gc_msgno_054 TYPE symsgno VALUE '054',

gc_msgno_055 TYPE symsgno VALUE '055',

gc_msgno_061 TYPE symsgno VALUE '061',

gc_msgno_075 TYPE symsgno VALUE '075',

gc_msgno_076 TYPE symsgno VALUE '076',

gc_msgno_078 TYPE symsgno VALUE '078',

gc_msgno_087 TYPE symsgno VALUE '087',

gc_msgno_096 TYPE symsgno VALUE '096',

gc_msgno_98 TYPE symsgno VALUE '098',

gc_msgno_100 TYPE symsgno VALUE '100',

* Location types

gc_ltp_1001 TYPE /sapapo/c_loctype VALUE '1001', "For Prd centre

gc_ltp_1002 TYPE /sapapo/c_loctype VALUE '1002', "For Mkt/whouse

* Procurement types

gc_ptp_x TYPE /sapapo/beskz VALUE 'X', "For Prd centre

gc_ptp_f TYPE /sapapo/beskz VALUE 'F', "For Mkt/whouse

* Variant status

gc_stat_p TYPE char1 VALUE 'P',

gc_stat_a TYPE char1 VALUE 'A',

* Timestamps

gc_startti TYPE syuzeit VALUE '000000',

gc_endti TYPE syuzeit VALUE '235959',

* Default means of transport

gc_ttype_0001 TYPE /sapapo/tr_traty VALUE '0001',

* Business system grp

gc_bsgapo TYPE /sapapo/loc_logqs VALUE 'BSGAPO',

gc_utc TYPE timezone VALUE 'UTC'. "UTC time zome

*MOD-1771404

************************************************************************

**********************DATA DECLARATION****************************

************************************************************************

DATA: gv_flgstart type flag,

gv_prd TYPE matnr,

gv_mkt TYPE /sapapo/locno,

gv_date_before TYPE sy-datum,

gv_time_before TYPE sy-uzeit,

gv_flg_error TYPE char1,

gv_msg_error TYPE char1. " Flag for Call Tr fail

* Internal table declarations

DATA: gt_f4_data_matnr TYPE STANDARD TABLE OF s_f4_data_matnr,

gt_f4_data_loc TYPE STANDARD TABLE OF s_f4_data_loc,

gt_matloc TYPE t_matloc,

gt_prod_data TYPE STANDARD TABLE OF s_f4_data_loc,

gt_product TYPE STANDARD TABLE OF bapi10001key,

*MOD-1771404

gt_new_product TYPE STANDARD TABLE of s_product,

gt_location TYPE STANDARD TABLE OF s_location,

gt_new_tlane TYPE STANDARD TABLE OF s_tlane,

*MOD-1771404

gt_core_prod TYPE STANDARD TABLE OF s_f4_data_loc,

gt_prod_var TYPE STANDARD TABLE OF s_f4_data_loc,

gt_loc_data TYPE STANDARD TABLE OF s_f4_data_loc,

gt_tlane TYPE STANDARD TABLE OF s_tlane_data,

gt_matid_all TYPE STANDARD TABLE OF s_matid,

gt_view_data TYPE STANDARD TABLE OF s_view_data,

gt_bdc_tab TYPE STANDARD TABLE OF bdcdata,

gt_variant_table TYPE STANDARD TABLE OF rsparams,

gt_fcat TYPE STANDARD TABLE OF slis_fieldcat_alv,

gt_top_page TYPE slis_t_listheader,

gt_masterdata TYPE t_masterdata,

gt_tship type t_tship,

gt_whse type t_whse,

*MOD-1771404

gt_log_location TYPE t_log_location,

gt_log_product TYPE t_log_product,

gt_log_locprd TYPE t_log_locprd,

gt_log_tlane TYPE t_log_tlane.

DATA:

lt_tlane TYPE t_tlane,

lt_tlane_new TYPE t_tlane,

lt_tlane_dat TYPE t_tlane,

lt_location TYPE t_location,

lt_product TYPE t_product,

lt_prd_extprd TYPE t_prd_extprd,

lt_loc_extloc TYPE t_loc_extloc,

lt_locprd TYPE t_locprd.

DATA: L_WA_zdm0705 type zdm0705.

DATA: L_WA_ZDU1002 type zdu1002.

DATA: lv_prvar type CHAR40.

*MOD-1771404

************************************************************************

*****************SELECTION SCREEN DEFINITION**********************

************************************************************************

* Block to enter the product and location data

SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

* Option to delete master data

*************************************************************

*MOD-001

*************************************************************

* SELECTION-SCREEN: BEGIN OF LINE,

* COMMENT 5(27) text-033 FOR FIELD p_mdel.

* PARAMETERS: p_mdel RADIOBUTTON GROUP grp1 USER-COMMAND ucom

* DEFAULT 'X'.

*

PARAMETERS: p_mdel RADIOBUTTON GROUP grp1.

*

* PARAMETERS p_mdel AS CHECKBOX DEFAULT 'X'.

*

* SELECTION-SCREEN END OF LINE.

* SELECTION-SCREEN SKIP.

* selection-screen: begin of line,

* comment (79) text-043.

* selection-screen end of line.

* selection-screen: begin of line,

* comment (79) text-044.

* selection-screen end of line.

* SELECTION-SCREEN SKIP.

**************************************************************

*MOD-001

*************************************************************

PARAMETERS: p_log TYPE logsys OBLIGATORY MEMORY ID mid.

SELECT-OPTIONS:

s_prd FOR gv_prd OBLIGATORY, " Product variant

s_mkt FOR gv_mkt OBLIGATORY. " Market

SELECTION-SCREEN: SKIP.

SELECTION-SCREEN: BEGIN OF LINE.

SELECTION-SCREEN POSITION 33.

PARAMETERS: p_test AS CHECKBOX DEFAULT 'X'. "#EC *

* No Selection Text Maintained as we are displaying comment for it

SELECTION-SCREEN COMMENT 1(16) text-002 FOR FIELD p_test.

SELECTION-SCREEN: END OF LINE.

SELECTION-SCREEN PUSHBUTTON 5(10) text-042 USER-COMMAND wuf.

*MOD-1771404

* Option to update transportation lanes

SELECTION-SCREEN SKIP.

SELECTION-SCREEN: BEGIN OF LINE,

COMMENT 5(27) text-032 FOR FIELD p_tlan.

PARAMETERS: p_tlan RADIOBUTTON GROUP grp1.

SELECTION-SCREEN END OF LINE.

* Sourcing for tlane

SELECTION-SCREEN SKIP.

PARAMETERS: p_src TYPE /sapapo/locno OBLIGATORY,

p_des TYPE /sapapo/locno OBLIGATORY,

p_prd TYPE matnr OBLIGATORY.

* Radio button for validity date change

SELECTION-SCREEN SKIP.

SELECTION-SCREEN: BEGIN OF LINE,

COMMENT 5(27) text-028 FOR FIELD p_tdat.

PARAMETERS: p_tdat RADIOBUTTON GROUP grp USER-COMMAND ucom

MODIF ID mod DEFAULT 'X'.

SELECTION-SCREEN END OF LINE.

* Fields for dates

SELECTION-SCREEN: BEGIN OF LINE,

COMMENT 10(15) text-030 FOR FIELD p_frd.

PARAMETERS p_frd TYPE sydatum.

SELECTION-SCREEN: COMMENT 40(10) text-031 FOR FIELD p_tod.

PARAMETERS p_tod TYPE sydatum.

SELECTION-SCREEN: END OF LINE.

* Radio button for product removal

SELECTION-SCREEN SKIP.

SELECTION-SCREEN: BEGIN OF LINE,

COMMENT 5(27) text-029 FOR FIELD p_tprd.

PARAMETERS: p_tprd RADIOBUTTON GROUP grp.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN: END OF BLOCK b1.

*MOD-1771404

************************************************************************

**********************INITIALIZATION******************************

************************************************************************

INITIALIZATION.

CLEAR gv_flgstart.

* Gets Product and location data for populatiing the search helps

PERFORM f_get_f4_data CHANGING gt_f4_data_matnr

gt_f4_data_loc

gt_view_data.

* Adjusts screen fields

PERFORM f_adj_screen_flds.

***********************************************************************

****************SELECTION SCREEN EVENTS**************************

***********************************************************************

AT SELECTION-SCREEN ON s_prd.

* Validates product against the SIGN view

PERFORM f_validate_product.

AT SELECTION-SCREEN ON s_mkt.

* Validate market against the SIGN view

PERFORM f_validate_market.

* Custom search help for Product-Low

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_prd-low.

PERFORM f_f4_for_prodcentre USING gc_prd_low

gt_f4_data_matnr.

* Custom search help for Product-High

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_prd-high.

PERFORM f_f4_for_prodcentre USING gc_prd_high

gt_f4_data_matnr.

* Custom search help for Location-Low

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_mkt-low.

PERFORM f_f4_for_market USING gc_mkt_low

gt_f4_data_loc.

* Custom search help for Location-High

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_mkt-high.

PERFORM f_f4_for_market USING gc_mkt_high

gt_f4_data_loc.

* Adjusting the screen fields

AT SELECTION-SCREEN OUTPUT.

CLEAR gv_flgstart.

*mod-099

PERFORM f_clear_tables.

*mod-099

PERFORM f_adj_screen_flds.

AT SELECTION-SCREEN.

IF sy-ucomm = 'WUF'.

REFRESH gt_matloc.

PERFORM f_check_product_status USING gt_f4_data_loc

CHANGING gt_prod_data

gt_core_prod

gt_prod_var

gt_loc_data

gt_matloc.

* MOD-1887120 *

SORT gt_core_prod BY locno pcode.

DELETE ADJACENT DUPLICATES FROM gt_core_prod

COMPARING locno

pcode.

SORT gt_prod_var BY locno pcode prvar.

DELETE ADJACENT DUPLICATES FROM gt_prod_var

COMPARING locno

pcode

prvar.

* MOD-1887120 *

* Call the WUF transaction

PERFORM launch_wuf USING gt_core_prod

gt_prod_var.

ENDIF.

************************************************************************

**********************START OF SELECTION**************************

************************************************************************

START-OF-SELECTION.

gv_flgstart = 'X'.

IF p_mdel IS NOT INITIAL.

* Filter all the Products selected for deletion with status inactive

REFRESH gt_matloc.

* wait up to 5 seconds.

PERFORM f_check_product_status USING gt_f4_data_loc

CHANGING gt_prod_data

gt_core_prod

gt_prod_var

gt_loc_data

gt_matloc.

* Set the Date and Time before deleting the Data.

gv_date_before = sy-datum.

gv_time_before = sy-uzeit.

IF gt_core_prod IS INITIAL.

MESSAGE i085.

ENDIF.

IF gt_prod_var IS INITIAL.

MESSAGE i086.

LEAVE LIST-PROCESSING.

ENDIF.

IF p_test IS INITIAL.

* Delete the Transactional data for the Product and Location Combination

* Using the call transaction /SAPAPO/BP2

*MOD-1887120

SORT gt_core_prod BY locno pcode.

DELETE ADJACENT DUPLICATES FROM gt_core_prod

COMPARING locno

pcode.

SORT gt_prod_var BY locno pcode prvar.

DELETE ADJACENT DUPLICATES FROM gt_prod_var

COMPARING locno

pcode

prvar.

SORT gt_loc_data BY locno.

DELETE ADJACENT DUPLICATES FROM gt_loc_data

COMPARING locno.

*MOD-1887120

PERFORM f_delete_transactional_data USING gt_core_prod

gt_prod_var

gt_loc_data

CHANGING gt_prod_data

gt_bdc_tab.

* Delete the Transactional data created manually by submitting to the

* SAP standard program /SAPAPO/RLCDEL via selection screen variant.

PERFORM f_delete_manual_created_data USING gt_core_prod

gt_prod_var

gt_loc_data

CHANGING gt_variant_table.

* Delete the PPDS orders for selection screen Product and Location

* Done by submitting to SAP Standard program /SAPAPO/DELETE_PP_ORDER

* Via screen table.

PERFORM f_delete_ppds_orders USING gt_core_prod

gt_prod_var

gt_loc_data

CHANGING gt_variant_table.

ENDIF.

* Delete Products from the Transportation Lanes for the Products and

* locations entered at the selection screen.

PERFORM f_delete_product_from_tlane USING gt_core_prod

gt_prod_var

CHANGING gt_loc_data

gt_matid_all

gt_tlane.

* Run the Transportation Lane consistency check program

* PERFORM f_run_consistency_check.

* Set the Deletion flag for the Products selected for deletion.

IF p_test IS INITIAL.

PERFORM f_set_deletion_flag USING gt_core_prod

gt_prod_var

gt_loc_data

gt_matloc.

ENDIF.

* Display the ALV Report.

PERFORM f_display_alv USING gt_prod_data

gt_matloc

CHANGING gt_fcat

gt_matid_all.

ENDIF.

* If the user chooses to update the transportation lane

**MOD-1771404

IF p_tlan IS NOT INITIAL.

*MOD-1771404

* Retrieve the master data from teh SIGN portfolio meeting the user

* selection

PERFORM f_retrieve_masterdata CHANGING gt_masterdata

gt_tship

gt_whse.

* Collect all possible transportation lanes

PERFORM f_collect_tlanes USING gt_masterdata

gt_tship

gt_location

gt_new_product

CHANGING gt_new_tlane.

IF gt_new_tlane IS INITIAL.

EXIT.

ENDIF.

* The Tlanes can be categorised into 3 categories:

* 1> To be created fresh

* 2> Exists, but new product need to be assigned

* 3> Only validity dates need to be changed

PERFORM f_categorise_tlanes USING gt_new_tlane

CHANGING lt_tlane_new

lt_tlane_dat.

*MOD-1771404 changed by Aveek

PERFORM f_update_tlane.

*MOD-1771404 changed by Aveek

* PERFORM f_update_tlane using gt_new_tlane.

*MOD-1771404

ENDIF.

** Include for subroutine declaration

include ZAXXPR_DELETE_MASTER_DATA_F02.

*&---------------------------------------------------------------------*

*& Include ZAXXPR_DELETE_MASTER_DATA_F02

*&---------------------------------------------------------------------*

*&---------------------------------------------------------------------*

*& Include ZAXXPR_DELETE_MASTER_DATA_F02

*&---------------------------------------------------------------------*

*&---------------------------------------------------------------------*

*& Include ZAXXPR_DELETE_MASTER_DATA_F01

*&---------------------------------------------------------------------*

************************************************************************

* PROGRAM--INITIAL CREATION

*

* Description :

*

* This is the Form include that contains the local subroutines of the

* main program ZAXXPR_DELETE_MASTER_DATA...

************************************************************************

************************************************************************

* PROGRAM--Modification MOD-1771404

************************************************************************

*

* Program name : ZAXXPR_DELETE_MASTER_DATA_F01

* Reference program (copied from) : na.

* Development specification ID :

* Date created : 15.02.2006

* Author : Aveek Ghose..

* Description :

*

* This is the Form include that contains the local subroutines of the

* main program ZAXXPR_DELETE_MASTER_DATA

************************************************************************

************************************************************************

* MOD-1887120

* Program name : ZAXXPR_DELETE_MASTER_DATA_F01

* Reference program (copied from) : na.

* Development specification ID :

* Date created : 10.03.2006

* Author : Aveek Ghose

* Description :

*

* This is the Form include that contains the local subroutines of the

* main program ZAXXPR_DELETE_MASTER_DATA

************************************************************************

*&---------------------------------------------------------------------*

*& Form f_validate_product

*&---------------------------------------------------------------------*

* Validates the product

*----------------------------------------------------------------------*

FORM f_validate_product.

* Local Date Declaration

DATA: lv_prd TYPE matnr,

lv_matnr TYPE /sapapo/matnr.

* Field symbols:

FIELD-SYMBOLS:

<lfs_prd> TYPE s_range_product.

IF p_mdel IS INITIAL.

EXIT.

ENDIF.

* Both Product and Location can not be a range at the selection screen

IF s_prd-low IS NOT INITIAL AND

s_prd-high IS NOT INITIAL AND

s_mkt-low IS NOT INITIAL AND

s_mkt-high IS NOT INITIAL.

* Error Message: Both Product and Location can not be multiple

MESSAGE e056.

ENDIF.

* Check if both Product and location dont have multiple entries

READ TABLE s_prd INDEX 2 TRANSPORTING NO FIELDS.

IF sy-subrc = 0.

READ TABLE s_mkt INDEX 2 TRANSPORTING NO FIELDS.

IF sy-subrc = 0.

* Error Message: Both Product and Location can not be multiple

MESSAGE e056.

ENDIF.

ENDIF.

* Check if user has entered * in the select option for location.

READ TABLE s_prd ASSIGNING <lfs_prd> WITH KEY low = gc_star.

IF sy-subrc = 0.

* Product value as * not allowed at the selection screen

MESSAGE e059.

ELSE.

READ TABLE s_prd ASSIGNING <lfs_prd> WITH KEY high = gc_star.

IF sy-subrc = 0.

* Product value as * not allowed at the selection screen

MESSAGE e059.

ENDIF.

ENDIF.

SELECT pcode UP TO 1 ROWS

INTO lv_prd

FROM zap_sign

WHERE pcode IN s_prd.

ENDSELECT.

IF sy-subrc <> 0 OR

lv_prd IS INITIAL.

* Product does not exist in APO

MESSAGE e016.

ENDIF.

ENDFORM. " f_validate_product

*&---------------------------------------------------------------------*

*& Form f_validate_market

*&---------------------------------------------------------------------*

* Validates the market

*----------------------------------------------------------------------*

FORM f_validate_market .

* Local Date Declaration

DATA: lv_mkt TYPE char4, " Market

lv_pdctr TYPE char2, " Production center

lv_whse1 TYPE char3, " Warehouse1

lv_whse2 TYPE char3. " Warehouse2

* Field Symbols:

FIELD-SYMBOLS:

<lfs_mkt> TYPE s_range_location.

IF p_mdel IS INITIAL.

EXIT.

ENDIF.

* Both Product and Location can not be multiple at the selection screen

IF s_prd-low IS NOT INITIAL AND

s_prd-high IS NOT INITIAL AND

s_mkt-low IS NOT INITIAL AND

s_mkt-high IS NOT INITIAL.

* Error Message: Both Product and Location can not be multiple

MESSAGE e056.

ENDIF.

* Check if both Product and location dont have multiple entries

READ TABLE s_prd INDEX 2 TRANSPORTING NO FIELDS.

IF sy-subrc = 0.

READ TABLE s_mkt INDEX 2 TRANSPORTING NO FIELDS.

IF sy-subrc = 0.

* Error Message: Both Product and Location can not be multiple

MESSAGE e056.

ENDIF.

ENDIF.

* Check if user has entered * in the select option for location.

READ TABLE s_mkt ASSIGNING <lfs_mkt> WITH KEY low = gc_star.

IF sy-subrc = 0.

* Product value as * not allowed at the selection screen

MESSAGE e060.

ELSE.

READ TABLE s_mkt ASSIGNING <lfs_mkt> WITH KEY high = gc_star.

IF sy-subrc = 0.

* Product value as * not allowed at the selection screen

MESSAGE e060.

ENDIF.

ENDIF.

* Check if the Location is a market

SELECT markt UP TO 1 ROWS

INTO lv_mkt

FROM zap_sign

WHERE markt IN s_mkt.

ENDSELECT.

IF sy-subrc = 0 OR

lv_mkt IS NOT INITIAL.

EXIT.

ENDIF.

* Check if the Location is a Production center

SELECT pdctr UP TO 1 ROWS

INTO lv_pdctr

FROM zap_sign

WHERE pdctr IN s_mkt.

ENDSELECT.

IF sy-subrc = 0 OR

lv_pdctr IS NOT INITIAL.

EXIT.

ENDIF.

* Check if the Location is a Warehouse 1

SELECT whse1 UP TO 1 ROWS

INTO lv_whse1

FROM zap_sign

WHERE whse1 IN s_mkt.

ENDSELECT.

IF sy-subrc = 0 OR

lv_whse1 IS NOT INITIAL.

EXIT.

ENDIF.

* Check if the Location is a Warehouse 2

SELECT whse2 UP TO 1 ROWS

INTO lv_whse2

FROM zap_sign

WHERE whse2 IN s_mkt.

ENDSELECT.

IF sy-subrc <> 0 OR

lv_whse2 IS NOT INITIAL.

* Location does not exist in APO

MESSAGE e017.

ENDIF.

ENDFORM. " f_validate_market

*&---------------------------------------------------------------------*

*& Form F_GET_F4_DATA

*&---------------------------------------------------------------------*

* Get all the data required for custom F4 helps

*----------------------------------------------------------------------*

* <--ct_f4_data_matnr Itab with products

* <--ct_f4_data_loc Itab with F4 data for location

* <--ct_view_data Itab wiht data selected from view table

*----------------------------------------------------------------------*

FORM f_get_f4_data CHANGING ct_f4_data_matnr TYPE t_f4_data_matnr

ct_f4_data_loc TYPE t_f4_data_loc

ct_view_data TYPE t_view_data.

* Local Data Declaration

DATA: ls_f4_data_matnr TYPE s_f4_data_matnr,

ls_f4_data_loc TYPE s_f4_data_loc,

lts_warehouse TYPE SORTED TABLE OF s_whse

WITH NON-UNIQUE KEY whse,

lt_whse TYPE STANDARD TABLE OF s_whse,

ls_whse TYPE s_whse.

* Local Field-symbols

FIELD-SYMBOLS: <lfs_view> TYPE s_view_data,

<lfs_whse> TYPE s_whse.

IF ( ct_f4_data_matnr IS INITIAL AND

ct_f4_data_loc IS INITIAL ).

SELECT pcode "Material Number

maktx "Product Desc

markt "Market

pdctr "Production center

pctxt "Prod center desc

whse1 "Warehouse 1

whse2 "Warehouse 2

prvar "Prod Variant

vartx "Variant Description

INTO TABLE ct_view_data

FROM ZAP_SIGN.

IF sy-subrc <> 0.

* no sourcing info is maintained in the sign portfolio

MESSAGE i005.

LEAVE LIST-PROCESSING.

ENDIF.

LOOP AT ct_view_data ASSIGNING <lfs_view>.

ls_whse-whse = <lfs_view>-whse1.

APPEND ls_whse TO lt_whse.

ls_whse-whse = <lfs_view>-whse2.

APPEND ls_whse TO lt_whse.

ENDLOOP.

SORT lt_whse BY whse.

DELETE ADJACENT DUPLICATES FROM lt_whse COMPARING whse.

IF NOT lt_whse IS INITIAL.

* Get the Warehouse Descriptions

SELECT whse "Warehouse Name

whdesc "Warehouse Description

FROM zap_whse

INTO TABLE lts_warehouse

FOR ALL ENTRIES IN lt_whse

WHERE whse = lt_whse-whse.

ENDIF.

* Populate the Internal Table with Product,Product Variant

* and Location. The location can be the Market,Production center,

* Warehouse 1,Warehouse 2. All the four locations will be clubbed

* under the field Location in the internal table

LOOP AT ct_view_data ASSIGNING <lfs_view>.

ls_f4_data_matnr-pcode = <lfs_view>-pcode.

ls_f4_data_matnr-maktx = <lfs_view>-maktx.

APPEND ls_f4_data_matnr TO ct_f4_data_matnr.

CLEAR ls_f4_data_matnr.

ls_f4_data_loc-pcode = <lfs_view>-pcode.

ls_f4_data_loc-desc = <lfs_view>-martx.

ls_f4_data_loc-locno = <lfs_view>-markt.

ls_f4_data_loc-prvar = <lfs_view>-prvar.

ls_f4_data_loc-pdctr = <lfs_view>-pdctr.

ls_f4_data_loc-vartx = <lfs_view>-vartx.

ls_f4_data_loc-maktx = <lfs_view>-maktx.

ls_f4_data_loc-status = <lfs_view>-status.

APPEND ls_f4_data_loc TO ct_f4_data_loc.

CLEAR ls_f4_data_loc.

ls_f4_data_loc-pcode = <lfs_view>-pcode.

ls_f4_data_loc-desc = <lfs_view>-pctxt.

ls_f4_data_loc-locno = <lfs_view>-pdctr.

ls_f4_data_loc-prvar = <lfs_view>-prvar.

ls_f4_data_loc-pdctr = <lfs_view>-pdctr.

ls_f4_data_loc-vartx = <lfs_view>-vartx.

ls_f4_data_loc-maktx = <lfs_view>-maktx.

ls_f4_data_loc-status = <lfs_view>-status.

APPEND ls_f4_data_loc TO ct_f4_data_loc.

CLEAR ls_f4_data_loc.

* Read the description for Warehouse 1

READ TABLE lts_warehouse ASSIGNING <lfs_whse> WITH KEY

whse = <lfs_view>-whse1.

IF sy-subrc = 0.

ls_f4_data_loc-pcode = <lfs_view>-pcode.

ls_f4_data_loc-desc = <lfs_whse>-whdesc.

ls_f4_data_loc-locno = <lfs_view>-whse1.

ls_f4_data_loc-prvar = <lfs_view>-prvar.

ls_f4_data_loc-pdctr = <lfs_view>-pdctr.

ls_f4_data_loc-vartx = <lfs_view>-vartx.

ls_f4_data_loc-maktx = <lfs_view>-maktx.

ls_f4_data_loc-status = <lfs_view>-status.

APPEND ls_f4_data_loc TO ct_f4_data_loc.

CLEAR ls_f4_data_loc.

ENDIF.

* Read the description for Warehouse 2

READ TABLE lts_warehouse ASSIGNING <lfs_whse> WITH KEY

whse = <lfs_view>-whse2.

IF sy-subrc = 0.

ls_f4_data_loc-pcode = <lfs_view>-pcode.

ls_f4_data_loc-desc = <lfs_whse>-whdesc.

ls_f4_data_loc-locno = <lfs_view>-whse2.

ls_f4_data_loc-prvar = <lfs_view>-prvar.

ls_f4_data_loc-pdctr = <lfs_view>-pdctr.

ls_f4_data_loc-vartx = <lfs_view>-vartx.

ls_f4_data_loc-maktx = <lfs_view>-maktx.

ls_f4_data_loc-status = <lfs_view>-status.

APPEND ls_f4_data_loc TO ct_f4_data_loc.

CLEAR ls_f4_data_loc.

ENDIF.

ENDLOOP.

SORT ct_f4_data_matnr BY pcode.

DELETE ADJACENT DUPLICATES FROM ct_f4_data_matnr COMPARING pcode.

ENDIF.

ENDFORM. " F_GET_F4_DATA

*&---------------------------------------------------------------------*

*& Form f_f4_for_prodcentre

*&---------------------------------------------------------------------*

* Display F4 Help for Product

*----------------------------------------------------------------------*

* -->IV_PRD Field Name for Product

* -->IT_F4_DATA Itab with F4 data

*----------------------------------------------------------------------*

FORM f_f4_for_prodcentre USING iv_prd TYPE dynfnam

it_f4_data_matnr TYPE t_f4_data_matnr.

* Local Constants Declaration

CONSTANTS: lc_pcode TYPE fieldname VALUE 'PCODE'.

PERFORM f_launch_f4_window USING lc_pcode

iv_prd

text-016

it_f4_data_matnr.

ENDFORM. " f4_for_prodcentre

*&---------------------------------------------------------------------*

*& Form f_f4_for_market

*&---------------------------------------------------------------------*

* Display F4 Help for locations

*----------------------------------------------------------------------*

* -->IV_LOC Field Name for Location

* -->IT_F4_DATA Itab with the F4 Data

*----------------------------------------------------------------------*

FORM f_f4_for_market USING iv_loc TYPE dynfnam

it_f4_data_loc TYPE t_f4_data_loc.

* Local Data Declaratino

DATA: lt_loc_for_f4 TYPE STANDARD TABLE OF s_f4_loc.

* Local Constants Declaration

CONSTANTS:

lc_pdctr TYPE fieldname VALUE 'LOCNO'.

lt_loc_for_f4 = it_f4_data_loc .

SORT lt_loc_for_f4 BY locno.

DELETE ADJACENT DUPLICATES FROM lt_loc_for_f4 COMPARING locno.

DELETE lt_loc_for_f4 WHERE locno IS INITIAL.

PERFORM f_launch_f4_window USING lc_pdctr

iv_loc

text-017

lt_loc_for_f4.

ENDFORM. " f_f4_for_market

*&---------------------------------------------------------------------*

*& Form f_launch_f4_window

*&---------------------------------------------------------------------*

* Displays the Custom F4 Help for the field name passed

*----------------------------------------------------------------------*

* -->IV_RETFLD Return field

* -->IV_DYNFLD Screen field

* -->IV_WINTITLE Window title

* -->IT_VALUETAB Value table

*----------------------------------------------------------------------*

FORM f_launch_f4_window USING iv_retfld TYPE fieldname

iv_dynfld TYPE dynfnam

iv_wintitle TYPE c

it_valuetab TYPE STANDARD TABLE.

DATA:

lv_dynprog TYPE syrepid,

lv_dynpnr TYPE sydynnr.

lv_dynprog = sy-repid.

lv_dynpnr = sy-dynnr.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = iv_retfld

dynpprog = lv_dynprog

dynpnr = lv_dynpnr

dynprofield = iv_dynfld

window_title = iv_wintitle

value_org = gc_s

TABLES

value_tab = it_valuetab

EXCEPTIONS

parameter_error = 1

no_values_found = 2

OTHERS = 3.

IF sy-subrc <> 0.

* Error while displaying search help

MESSAGE i058.

EXIT.

ENDIF.

ENDFORM. " f_launch_f4_window

*&---------------------------------------------------------------------*

*& Form f_check_product_status

*&---------------------------------------------------------------------*

* Get all the Products with status Inactive selected for deletion

*----------------------------------------------------------------------*

* -->IT_F4_LOC_DATA Itab wiht the products to be deleted

* <--CT_PROD_DATA Itab with the Product and Locs to be deleted

* <--CT_CORE_PROD Itab with the core products to be deleted

* <--CT_PROD_VAR Itab with the product varients to be deleted

* <--CT_LOC_DATA Itab with the locations to be deleted

*----------------------------------------------------------------------*

FORM f_check_product_status USING it_f4_data_loc TYPE t_f4_data_loc

CHANGING ct_prod_data TYPE t_f4_data_loc

ct_core_prod TYPE t_f4_data_loc

ct_prod_var TYPE t_f4_data_loc

ct_loc_data TYPE t_f4_data_loc

ct_matloc TYPE t_matloc.

*MOD-1771404

** Local Date Declaration

* DATA: lv_mkt TYPE char4, " Market

* lv_pdctr TYPE char2, " Production center

* lv_whse1 TYPE char3, " Warehouse1

* lv_whse2 TYPE char3. " Warehouse2

* Local Date Declaration

DATA: lv_mkt TYPE char4, " Market

lv_pdctr TYPE char2, " Production center

lv_whse1 TYPE char3, " Warehouse1

lv_whse2 TYPE char3. " Warehouse2

DATA: ls_sign type zap_sign.

DATA: LV_PDCTR1 TYPE char2,

LV_LTEXT1 TYPE char40.

*MOD-1771404

DATA: lv_locid type /sapapo/locid,

lv_ware_desc type /SAPAPO/LOC_DESCR40.

*MOD-1771404

DATA:

lv_matnr TYPE /sapapo/matnr,

lt_matloc TYPE STANDARD TABLE OF /sapapo/v_matloc,

lv_prod_data TYPE s_f4_data_loc,

LV_TABIX TYPE SY-TABIX,

lv_line type i,

lv_count type i,

lv_count1 type i.

*MOD-011

RANGES: LV_MKT1 FOR S_MKT.

DATA: int TYPE i,

rspar TYPE TABLE OF rsparams,

wa_rspar LIKE LINE OF rspar,

lv_indicator type i.

DATA: lv_indicator1 type i value 0.

DATA: L_WA_PROD TYPE s_f4_data_loc.

DATA: IT_ITAB_PROD TYPE standard table of s_f4_data_loc.

*MOD-011

FIELD-SYMBOLS:

<lfs_core_prod> TYPE s_f4_data_loc,

<lfs_prod_data> TYPE s_f4_data_loc,

<lfs_tsign> TYPE zap_sign.

* <lfs_zdm0705> TYPE ZDM0705.

FIELD-SYMBOLS:

<lfs_view> TYPE s_view_data,

*MOD-1771404

<lfs_loc_data> TYPE s_f4_data_loc.

*MOD-1771404

ct_prod_data = it_f4_data_loc.

***MOD-1771404

* Check if the Location is a market

SELECT *

into table t_sign

FROM zap_sign

WHERE pcode in s_prd AND

( markt in s_mkt or

pdctr in s_mkt OR

whse1 in s_mkt or

whse2 in s_mkt ).

IF sy-subrc <> 0.

MESSAGE I004 with s_prd.

LEAVE LIST-PROCESSING.

ENDIF.

* DELETE t_sign WHERE status <> gc_inactive.

*MOD-1771404

DELETE: ct_prod_data WHERE status <> gc_inactive,

ct_prod_data WHERE NOT ( pcode IN s_prd ).

**MOD-1771404: This was commneted out for WHH.

* ct_prod_data WHERE NOT ( locno IN s_mkt ).

**MOD-1771404: This was commneted out for WHH.

***MOD-1771404: This was commneted out for WHH.

IF not ct_prod_data[] IS INITIAL.

LOOP AT ct_prod_data ASSIGNING <lfs_prod_data>.

*MOD-1887120

LOOP AT S_MKT.

*MOD-1887120

READ TABLE t_sign ASSIGNING <lfs_tsign>

WITH KEY pcode = <lfs_prod_data>-pcode

prvar = <lfs_prod_data>-prvar

* whse2 = <lfs_prod_data>-locno BINARY SEARCH.*

whse2 = s_mkt-low BINARY SEARCH.

* whse1 = <lfs_prod_data>-locno BINARY SEARCH.

IF sy-subrc <> 0.

*MOD-1771404

*MOD-1887120

READ TABLE t_sign ASSIGNING <lfs_tsign>

WITH KEY pcode = <lfs_prod_data>-pcode

prvar = <lfs_prod_data>-prvar

* whse1 = <lfs_prod_data>-locno BINARY SEARCH.

whse1 = s_mkt-low BINARY SEARCH.

IF sy-subrc <> 0.

*MOD-1771404

READ TABLE t_sign ASSIGNING <lfs_tsign>

WITH KEY pcode = <lfs_prod_data>-pcode

prvar = <lfs_prod_data>-prvar

markt = s_mkt-low binary search.

*MOD-1887120

* markt = <lfs_prod_data>-locno binary search.

*

*MOD-1887120

IF sy-subrc <> 0.

READ TABLE t_sign ASSIGNING <lfs_tsign>

WITH KEY pcode = <lfs_prod_data>-pcode

prvar = <lfs_prod_data>-prvar

pdctr = s_mkt-low BINARY SEARCH.

* pdctr IN s_mkt BINARY SEARCH.

* pdctr = <lfs_prod_data>-locno BINARY SEARCH.

IF sy-subrc = 0.

IF s_mkt-low = <lfs_prod_data>-locno and

s_mkt-low = <lfs_tsign>-pdctr.

<lfs_prod_data>-lv_exist = 0.

Continue.

*MOD-1887120

* ELSE.

* <lfs_prod_data>-lv_exist = 1.

* Continue.

*MOD-1887120

ENDIF.

*MOD-1887120

IF s_mkt-low = <lfs_prod_data>-locno.

<lfs_prod_data>-lv_exist = 0.

Continue.

*MOD-1887120

* ELSE.

* <lfs_prod_data>-lv_exist = 1.

* Continue.

*MOD-1887120

ENDIF.

*MOD-1887120

ELSE.

<lfs_prod_data>-lv_exist = 1.

continue.

ENDIF.

ELSE.

READ TABLE t_sign ASSIGNING <lfs_tsign>

WITH KEY pcode = <lfs_prod_data>-pcode

prvar = <lfs_prod_data>-prvar

* markt = <lfs_prod_data>-locno BINARY SEARCH.

markt = s_mkt-low BINARY SEARCH.

* pdctr = <lfs_prod_data>-locno BINARY SEARCH.

IF SY-SUBRC = 0.

<lfs_prod_data>-lv_exist = 0.

CONTINUE.

ELSE.

<lfs_prod_data>-lv_exist = 1.

Continue.

ENDIF.

ENDIF.

ELSE.

<lfs_prod_data>-lv_exist = 0.

<lfs_prod_data>-whse1 = <lfs_tsign>-whse1.

EXIT.

ENDIF.

ELSE.

<lfs_prod_data>-lv_exist = 0.

*MOD-1771404

<lfs_prod_data>-whse1 = <lfs_tsign>-whse1.

<lfs_prod_data>-whse2 = <lfs_tsign>-whse2.

*MOD-1771404

EXIT.

ENDIF.

ENDLOOP.

ENDLOOP.

ENDIF.

*MOD-1887120

* DELETE: ct_prod_data WHERE lv_exist eq 1.

* DELETE ADJACENT DUPLICATES FROM CT_PROD_DATA COMPARING

* LOCNO

* PCODE

* PRVAR

* WHSE1

* WHSE2.

*

*MOD-1887120

*MOD-1887120

* To Handle Multiple production centres

IF not ct_prod_data[] IS INITIAL.

SELECT *

into table t_sign

FROM zap_sign

WHERE pcode in s_prd AND

pdctr in s_mkt.

IF sy-subrc <> 0.

* MESSAGE I004 with s_prd.

ELSE.

* DELETE t_sign WHERE status <> gc_inactive.

LV_TABIX = 0.

IF not T_SIGN IS INITIAL.

LOOP AT t_sign assigning <lfs_tsign>.

LV_TABIX = LV_TABIX + 1.

LOOP AT S_MKT.

* Get the Warehouse Descriptions

* SELECT pdctr ltext up to 1 rows

* INTO (LV_PDCTR1, LV_LTEXT1)

* FROM ZDU1000

* WHERE PDCTR = S_MKT-LOW.

* ENDSELECT.

*MOD-1887120

if sy-subrc = 0.

*MOD-1887120

l_wa_prod-locno = <lfs_tsign>-pdctr.

l_wa_prod-desc = lv_ltext1.

l_wa_prod-pcode = <lfs_tsign>-pcode.

l_wa_prod-prvar = <lfs_tsign>-prvar.

l_wa_prod-vartx = <lfs_tsign>-vartx.

l_wa_prod-pdctr = s_mkt-low.

l_wa_prod-maktx = <lfs_tsign>-maktx.

l_wa_prod-whse1 = <lfs_tsign>-whse1.

l_wa_prod-whse2 = <lfs_tsign>-whse2.

* l_wa_prod-status = <lfs_tsign>-status.

* l_wa_prod-loctyp = <lfs_tsign>-loctyp.

APPEND l_wa_prod TO it_itab_prod.

APPEND LINES OF it_itab_prod TO ct_prod_data.

*MOD-1887120

endif.

*MOD-1887120

ENDLOOP.

ENDLOOP.

ENDIF.

ENDIF.

ENDIF.

*MOD-099

* DELETE: ct_prod_data WHERE lv_exist eq 1.

*MOD-099

SORT CT_PROD_DATA BY LOCNO

PCODE

PRVAR

PDCTR

STATUS

WHSE1

WHSE2.

DELETE ADJACENT DUPLICATES FROM CT_PROD_DATA COMPARING

LOCNO

PCODE

PRVAR

PDCTR

STATUS

WHSE1

WHSE2.

*MOD-1887120

IF ct_prod_data IS INITIAL.

* No Inactive products are present in the view table.

MESSAGE i063.

LEAVE LIST-PROCESSING.

ENDIF.

SELECT matnr locno INTO TABLE ct_matloc

FROM /sapapo/v_matloc

FOR ALL ENTRIES IN ct_prod_data

WHERE ( matnr = ct_prod_data-pcode OR

matnr = ct_prod_data-prvar ) AND

locno = ct_prod_data-locno.

*MOD-1887120

* LOCNO IN S_MKT.

*MOD-1887120

IF sy-subrc <> 0.

MESSAGE i066.

IF gv_flgstart IS NOT INITIAL.

LEAVE LIST-PROCESSING.

ELSE.

LEAVE TO SCREEN 1000.

ENDIF.

ENDIF.

* Delete the entries that are not in data base.

* LOOP AT ct_prod_data ASSIGNING <lfs_prod_data>.

* READ TABLE lt_matloc TRANSPORTING NO FIELDS

* WITH KEY matnr = <lfs_prod_data>-prvar

* locno = <lfs_prod_data>-locno.

* IF sy-subrc <> 0.

* CLEAR <lfs_prod_data>-prvar.

* ENDIF.

* ENDLOOP.

* DELETE ct_prod_data WHERE prvar IS INITIAL.

ct_core_prod = ct_prod_data.

ct_prod_var = ct_prod_data.

ct_loc_data = ct_prod_data.

SORT ct_core_prod BY pcode.

*MOD-1887120

* DELETE ADJACENT DUPLICATES FROM ct_core_prod COMPARING pcode.

*MOD-1887120

* DELETE ADJACENT DUPLICATES FROM CT_CORE_PROD COMPARING

* locno

* pcode

* prvar

* whse1

* whse2.

SORT CT_PROD_DATA BY LOCNO

PCODE

PRVAR

PDCTR

STATUS

WHSE1

WHSE2.

DELETE ADJACENT DUPLICATES FROM CT_PROD_DATA COMPARING

LOCNO

PCODE

PRVAR

PDCTR

STATUS

WHSE1

WHSE2.

*MOD-1887120

*MOD-1887120

DELETE ct_core_prod WHERE pcode IS INITIAL.

LOOP AT ct_core_prod ASSIGNING <lfs_core_prod>.

LOOP AT gt_view_data TRANSPORTING NO FIELDS

WHERE pcode = <lfs_core_prod>-pcode AND

status <> 'I'.

CLEAR <lfs_core_prod>-pcode.

EXIT.

ENDLOOP.

ENDLOOP.

DELETE ct_core_prod WHERE pcode IS INITIAL.

**MOD-1887120

* LV_TABIX = 0.

* IF not S_MKT IS INITIAL.

* LOOP AT S_MKT.

* LV_TABIX = LV_TABIX + 1.

* IF LV_TABIX > 1.

* delete: ct_core_prod WHERE NOT ( locno IN s_mkt ).

* ENDIF.

* ENDLOOP.

* ENDIF.

**MOD-1887120

*MOD-1771404

* SORT ct_prod_var BY prvar.

* DELETE ADJACENT DUPLICATES FROM ct_prod_var COMPARING prvar.

*MOD-1771404

LOOP AT ct_prod_var ASSIGNING <lfs_core_prod>.

SELECT SINGLE matnr INTO lv_matnr

FROM /sapapo/matkey

WHERE matnr = <lfs_core_prod>-prvar.

IF sy-subrc <> 0.

CLEAR <lfs_core_prod>-prvar.

ENDIF.

ENDLOOP.

DELETE ct_prod_var WHERE prvar IS INITIAL.

*MOD-1771404

* SORT ct_loc_data BY locno.

* DELETE ADJACENT DUPLICATES FROM ct_loc_data COMPARING locno.

*MOD-1771404

SORT ct_loc_data BY locno pcode prvar.

DELETE ADJACENT DUPLICATES FROM ct_loc_data COMPARING locno

pcode

prvar.

*MOD-1771404

DELETE ct_loc_data WHERE locno IS INITIAL.

*MOD-1771404

*MOD-1887120 for multiple locations

LV_INDICATOR = 0.

LOOP AT ct_prod_data ASSIGNING <lfs_prod_data>.

* READ TABLE CT_MATLOC TRANSPORTING NO FIELDS

* WITH KEY MATNR = <lfs_core_prod>-PCODE

* locno = <lfs_core_prod>-locno binary search.

* if sy-subrc <> 0.

clear: lv_whse1.

SELECT whse1 UP TO 1 ROWS

INTO lv_whse1

FROM zap_sign

WHERE whse1 = <lfs_prod_data>-locno or

whse2 = <lfs_prod_data>-locno and

pcode in s_prd.

ENDSELECT.

IF SY-SUBRC = 0.

PERFORM GET_DESC_LOC USING <lfs_prod_data>

changing lv_ware_desc.

if sy-subrc = 0.

<lfs_prod_data>-desc = lv_ware_desc.

lv_indicator = 1.

endif.

else.

<lfs_prod_data>-LV_EXIST = 1.

ENDIF.

* ENDIF.

ENDLOOP.

* DELETE CT_PROD_DATA WHERE LV_EXIST = 1.

*MOD-1887120

**MOD-1887120 for multiple locations

* LOOP AT ct_prod_data ASSIGNING <lfs_prod_data>.

* clear: lv_whse1.

* SELECT whse1 UP TO 1 ROWS

* INTO lv_whse1

* FROM zm_zap_sign

* WHERE pdctr = <lfs_prod_data>-locno and

* pcode in s_prd.

* ENDSELECT.

* IF SY-SUBRC = 0.

* lv_indicator = 1.

* else.

* <lfs_prod_data>-LV_EXIST = 1.

* ENDIF.

* ENDLOOP.

**MOD-1887120

**MOD-1887120 for multiple locations

* LOOP AT ct_core_prod ASSIGNING <lfs_core_prod>.

* clear: lv_whse1.

* SELECT whse1 UP TO 1 ROWS

* INTO lv_whse1

* FROM zm_zap_sign

* WHERE pdctr = <lfs_core_prod>-locno and

* pcode in s_prd.

* ENDSELECT.

* IF SY-SUBRC = 0.

* lv_indicator = 1.

* else.

* <lfs_core_prod>-LV_EXIST = 1.

* ENDIF.

* ENDLOOP.

**MOD-1887120

*MOD-1771404: 1 warehouse case

IF LV_INDICATOR NE 1.

clear: lv_whse1.

SELECT whse1 UP TO 1 ROWS

INTO lv_whse1

FROM zap_sign

WHERE whse1 IN s_mkt or

whse2 in s_mkt and

pcode in s_prd.

ENDSELECT.

LOOP AT ct_prod_data ASSIGNING <lfs_prod_data>.

* LOOP AT S_MKT.

READ TABLE t_sign ASSIGNING <lfs_tsign>

WITH KEY pcode = <lfs_prod_data>-pcode

prvar = <lfs_prod_data>-prvar

whse1 = s_mkt-low BINARY SEARCH.

**MOD-1887120

* whse1 = lv_whse1.

**MOD-1887120

if sy-subrc = 0.

<lfs_prod_data>-locno = s_mkt-low.

*MOD-1887120

* <lfs_prod_data>-whse1 = s_mkt-low.

<lfs_prod_data>-whse1 = lv_whse1.

*MOD-1887120

* PERFORM GET_DESC_LOC USING lv_prod_data

PERFORM GET_DESC_LOC USING <lfs_prod_data>

changing lv_ware_desc.

if sy-subrc = 0.

<lfs_prod_data>-desc = lv_ware_desc.

endif.

endif.

ENDLOOP.

*MOD-1887120

ENDIF.

*MOD-1887120

**MOD-1887120 Multiple Location Case.

* clear: lv_whse1.

* SELECT whse1 UP TO 1 ROWS

* INTO lv_whse1

* FROM zm_zap_sign

* WHERE whse1 IN s_mkt or

* whse2 in s_mkt and

* pcode in s_prd.

* ENDSELECT.

* LOOP AT ct_prod_data ASSIGNING <lfs_prod_data>.

* LOOP AT S_MKT.

* READ TABLE t_sign ASSIGNING <lfs_tsign>

* WITH KEY pcode = <lfs_prod_data>-pcode

* prvar = <lfs_prod_data>-prvar

* markt = s_mkt-low BINARY SEARCH.

* if sy-subrc = 0.

* <lfs_prod_data>-locno = s_mkt-low.

* <lfs_prod_data>-whse1 = lv_whse1.

* PERFORM GET_DESC_LOC USING lv_prod_data

* changing lv_ware_desc.

* if sy-subrc = 0.

* <lfs_prod_data>-desc = lv_ware_desc.

* endif.

* endif.

* ENDLOOP.

* ENDLOOP.

**MOD-1887120

REFRESH: ct_loc_data, ct_prod_var.

CLEAR: ct_loc_data, ct_prod_var.

ct_loc_data = ct_prod_data.

ct_prod_var = ct_prod_data.

SELECT matnr locno INTO TABLE ct_matloc

FROM /sapapo/v_matloc

FOR ALL ENTRIES IN ct_prod_data

WHERE ( matnr = ct_prod_data-pcode OR

matnr = ct_prod_data-prvar ) AND

*MOD-1887120

locno IN S_MKT.

* locno = ct_prod_data-locno.

*MOD-1887120

IF sy-subrc <> 0.

MESSAGE i066.

IF gv_flgstart IS NOT INITIAL.

LEAVE LIST-PROCESSING.

ELSE.

LEAVE TO SCREEN 1000.

ENDIF.

ENDIF.

*MOD-1771404

*MOD-1771404: 2 warehouse case.

*MOD-1771404

* Check if the Location is a Warehouse 1

*MOD-1887120

IF LV_INDICATOR NE 1.

*MOD-1887120

CLEAR: LV_WHSE1, LV_WHSE2.

SELECT whse1 UP TO 1 ROWS

INTO lv_whse1

FROM zap_sign

WHERE whse1 IN s_mkt or

whse2 in s_mkt and

pcode in s_prd.

ENDSELECT.

* IF sy-subrc = 0 OR

* lv_whse1 IS NOT INITIAL.

* EXIT.

* ENDIF.

* Check if the Location is a Warehouse 2

SELECT whse2 UP TO 1 ROWS

INTO lv_whse2

FROM zap_sign

WHERE whse1 IN s_mkt or

whse2 in s_mkt and

pcode in s_prd.

ENDSELECT.

* IF sy-subrc <> 0 OR

* lv_whse2 IS INITIAL.

** Location does not exist in APO

* MESSAGE e017.

* ENDIF.

*MOD-1887120

* LOOP AT ct_prod_data ASSIGNING <lfs_prod_data>.

**MOD-011

* LOOP AT S_MKT.

**MOD-011

* READ TABLE t_sign ASSIGNING <lfs_tsign>

* WITH KEY pcode = <lfs_prod_data>-pcode

* prvar = <lfs_prod_data>-prvar

* whse2 = lv_whse2 BINARY SEARCH.

* if sy-subrc = 0.

* <lfs_prod_data>-locno = s_mkt-low.

* <lfs_prod_data>-whse1 = lv_whse1.

* ENDIF.

**MOD-011

* ENDLOOP.

**MOD-011

* ENDLOOP.

**MOD-1771404

*MOD-1887120

*MOD-1887120

LOOP AT ct_prod_data ASSIGNING <lfs_prod_data>.

*MOD-1887120

LOOP AT S_MKT.

*MOD-1887120

READ TABLE t_sign ASSIGNING <lfs_tsign>

WITH KEY pcode = <lfs_prod_data>-pcode

prvar = <lfs_prod_data>-prvar

* WHSE2 = lv_whse2 binary search.

whse2 = S_MKT-LOW BINARY SEARCH.

if sy-subrc = 0.

<lfs_prod_data>-locno = s_mkt-low.

<lfs_prod_data>-whse1 = lv_whse1.

ENDIF.

*MOD-1887120

ENDLOOP.

*MOD-1887120

ENDLOOP.

*MOD-1887120

LOOP AT ct_prod_data ASSIGNING <lfs_prod_data>.

*MOD-1887120

LOOP AT S_MKT.

*MOD-1887120

READ TABLE t_sign ASSIGNING <lfs_tsign>

WITH KEY pcode = <lfs_prod_data>-pcode

prvar = <lfs_prod_data>-prvar

whse2 = s_mkt-low BINARY SEARCH.

if sy-subrc = 0.

<lfs_prod_data>-locno = s_mkt-low.

*MOD-1771404

<lfs_prod_data>-whse1 = <lfs_prod_data>-whse1.

<lfs_prod_data>-whse2 = s_mkt-low.

*MOD-1771404

PERFORM GET_DESC_WHSE2 USING lv_prod_data

changing lv_ware_desc.

if sy-subrc = 0.

<lfs_prod_data>-desc = lv_ware_desc.

endif.

endif.

*MOD-1887120

ENDLOOP.

*MOD-1887120

ENDLOOP.

LOOP AT ct_prod_data ASSIGNING <lfs_prod_data>.

*MOD-1887120

LOOP AT S_MKT.

*MOD-1887120

READ TABLE t_sign ASSIGNING <lfs_tsign>

WITH KEY pcode = <lfs_prod_data>-pcode

prvar = <lfs_prod_data>-prvar

whse2 = s_mkt-low BINARY SEARCH.

* whse2 = lv_whse2 BINARY SEARCH.

if sy-subrc = 0.

<lfs_prod_data>-locno = s_mkt-low.

*MOD-1771404

<lfs_prod_data>-whse1 = <lfs_prod_data>-whse1.

<lfs_prod_data>-whse2 = s_mkt-low.

* <lfs_prod_data>-whse2 = lv_whse2.

*MOD-1887120

*MOD-1771404

PERFORM GET_DESC_WHSE2 USING lv_prod_data

changing lv_ware_desc.

if sy-subrc = 0.

<lfs_prod_data>-desc = lv_ware_desc.

endif.

endif.

*MOD-1887120

ENDLOOP.

*MOD-1887120

ENDLOOP.

*MOD-1887120

ELSE.

DELETE: ct_prod_data WHERE NOT ( locno IN s_mkt ).

ENDIF.

*MOD-1887120

REFRESH: ct_loc_data, ct_prod_var.

CLEAR: ct_loc_data, ct_prod_var.

ct_loc_data = ct_prod_data.

ct_prod_var = ct_prod_data.

*MOD-1887120

**MOD-1887120

LOOP AT ct_prod_data ASSIGNING <lfs_prod_data>.

<lfs_prod_data>-lv_exist = 0.

ENDLOOP.

FIELD-SYMBOLs:<lfs_matloc> TYPE s_matloc.

LOOP AT ct_prod_data ASSIGNING <lfs_prod_data>.

READ TABLE CT_MATLOC ASSIGNING <lfs_matloc> with key

matnr = <lfs_prod_data>-pcode

locno = <lfs_prod_data>-locno.

if sy-subrc ne 0.

READ TABLE CT_MATLOC ASSIGNING <lfs_matloc> with key

matnr = <lfs_prod_data>-prvar

locno = <lfs_prod_data>-locno.

if sy-subrc ne 0.

<lfs_prod_data>-lv_exist = 1.

endif.

endif.

ENDLOOP.

DELETE CT_PROD_DATA WHERE LV_EXIST = 1.

REFRESH: ct_loc_data, ct_prod_var, ct_core_prod.

CLEAR: ct_loc_data, ct_prod_var, ct_core_prod.

ct_core_prod = ct_prod_data.

ct_prod_var = ct_prod_data.

ct_loc_data = ct_prod_data.

*MOD-1887120

**MOD-1887120 Changes made after release of transport on 28.03

DATA: L_WA_zdm0705 type zdm0705.

DATA: L_WA_ZDU1002 type zdu1002.

DATA: lv_prvar type CHAR18.

REFRESH: it_zdm0705.

REFRESH: it_zdu1002.

LOOP AT ct_prod_data ASSIGNING <lfs_prod_data>.

SELECT * APPENDING TABLE it_zdm0705

FROM zdm0705

WHERE parpr = <lfs_prod_data>-pcode.

ENDLOOP.

SELECT * into table it_zdu1002

FROM zdu1002

FOR ALL ENTRIES IN it_zdm0705

WHERE prvar = it_zdm0705-prvar.

SORT it_zdu1002 BY MARKT prvar.

DATA: lv_product type CHAR18.

clear: l_wa_zdu1002.

clear: l_wa_zdm0705.

SORT it_zdm0705 BY prvar parpr.

DELETE ADJACENT DUPLICATES FROM it_zdm0705 COMPARING ALL FIELDS.

LOOP AT IT_ZDM0705 INTO L_WA_ZDM0705.

READ TABLE IT_ZDU1002 INTO L_WA_ZDU1002

WITH KEY PRVAR = L_WA_ZDM0705-PRVAR BINARY SEARCH.

IF SY-SUBRC = 0.

lv_count = lv_count + 1.

IF L_WA_ZDU1002-STATUS NE 'I'.

lv_indicator1 = 1.

ENDIF.

ENDIF.

ENDLOOP.

**MOD-1887120 Changes made after release of transport on 28.03

* SORT it_zdm0705 BY prvar parpr.

* DELETE ADJACENT DUPLICATES FROM it_zdm0705 COMPARING ALL FIELDS.

* if lv_indicator1 = 1.

* LOOP AT it_zdu1002 into l_wa_zdu1002 WHERE STATUS NE 'I'.

* LOOP AT IT_ZDM0705 into l_wa_zdm0705

* WHERE prvar = l_wa_zdu1002-prvar.

** READ TABLE IT_ZDM0705 into l_wa_zdm0705 with key

** prvar = l_wa_zdu1002-prvar binary search.

** where dmoap NE 'Z'.

** IF L_WA_ZDU1002-PRVAR NE L_WA_ZDM0705-PRVAR.

* l_wa_zdm0705-dmoap = 'X'.

* modify it_zdm0705 from l_wa_zdm0705 transporting dmoap.

*

** else.

** l_wa_zdm0705-dmoap = 'Z'.

** modify it_zdm0705 from l_wa_zdm0705 transporting dmoap.

** exit.

* ENDLOOP.

* endif.

**MOD-1887120 Changes made after release of transport on 28.03

**MOD-1887120 Changes made after release of transport on 28.03

* SORT it_zdm0705 BY prvar parpr.

* DELETE ADJACENT DUPLICATES FROM it_zdm0705 COMPARING ALL FIELDS.

* if lv_indicator1 = 1.

* LOOP AT it_zdu1002 into l_wa_zdu1002 WHERE STATUS NE 'I'.

* READ TABLE IT_ZDM0705 ASSIGNING <LFS_ZDM0705>

* WITH KEY PRVAR = L_WA_ZDU1002-PRVAR BINARY SEARCH.

** LOOP AT IT_ZDM0705 into l_wa_zdm0705

** WHERE prvar = l_wa_zdu1002-prvar.

* IF SY-SUBRC = 0.

* <lfs_zdm0705>-dmoap = 'X'.

** l_wa_zdm0705-dmoap = 'X'.

** modify it_zdm0705 from l_wa_zdm0705 transporting dmoap.

* ENDIF.

* ENDLOOP.

** ENDLOOP.

* endif.

*MOD-1887120 Changes made after release of transport on 28.03

* LOOP AT it_zdu1002 into l_wa_zdu1002.

* READ TABLE IT_ZDM0705 into l_wa_zdm0705 with key

* prvar = l_wa_zdu1002-prvar binary search.

* if sy-subrc ne 0.

* l_wa_zdm0705-dmoap = 'X'.

* modify it_zdm0705 from l_wa_zdm0705 transporting dmoap.

* endif.

* ENDLOOP.

*mod-099

* SORT it_zdm0705 BY prvar parpr.

* DELETE ADJACENT DUPLICATES FROM it_zdm0705 COMPARING ALL FIELDS.

* LOOP AT ct_prod_data ASSIGNING <lfs_prod_data>.

** READ TABLE IT_ZDM0705 into l_wa_zdm0705 with key

** parpr = <lfs_prod_data>-pcode binary

*search.

** if sy-subrc ne 0.

* READ TABLE IT_ZDM0705 into l_wa_zdm0705 with key

* prvar = <lfs_prod_data>-prvar binary search.

* if sy-subrc ne 0.

* l_wa_zdm0705-dmoap = 'X'.

* modify it_zdm0705 from l_wa_zdm0705 transporting dmoap.

* endif.

** endif.

* ENDLOOP.

**mod-099

*MOD-1887120 Changes made after release of transport on 28.03

if lv_indicator1 = 1.

LOOP AT ct_prod_data ASSIGNING <lfs_prod_data>.

* READ TABLE IT_ZDM0705 into l_wa_zdm0705 with key

* parpr = <lfs_prod_data>-pcode

* dmoap = 'X'.

IF SY-SUBRC = 0.

delete ct_core_prod where pcode = <lfs_prod_data>-pcode.

* Indicates that the core product should not be included in

* transportation lane and /sapapo/bp2 transaction.

READ TABLE CT_MATLOC ASSIGNING <lfs_matloc> with key

matnr = <lfs_prod_data>-pcode

locno = <lfs_prod_data>-locno.

if sy-subrc ne 0.

READ TABLE CT_MATLOC ASSIGNING <lfs_matloc> with key

matnr = <lfs_prod_data>-prvar

locno = <lfs_prod_data>-locno.

if sy-subrc ne 0.

<lfs_prod_data>-lv_exist = 1.

endif.

endif.

endif.

ENDLOOP.

endif.

DELETE CT_PROD_DATA WHERE LV_EXIST = 1.

*mod-099 changed on 04042006

*MOD-099 changed on 04042006

REFRESH: ct_loc_data, ct_prod_var. " ct_core_prod.

CLEAR: ct_loc_data, ct_prod_var. " ct_core_prod.

*MOD-1887120

* ct_core_prod = ct_prod_data.

*MOD-1887120

ct_prod_var = ct_prod_data.

ct_loc_data = ct_prod_data.

lv_indicator1 = 0.

*MOD-1887120 Changes made after release of transport on 28.03

*MOD-1771404

* SELECT matnr locno INTO TABLE ct_matloc

* FROM /sapapo/v_matloc

* FOR ALL ENTRIES IN ct_prod_data

* WHERE ( matnr = ct_prod_data-pcode OR

* matnr = ct_prod_data-prvar ) AND

**

* locno = ct_prod_data-locno.

**

* IF sy-subrc <> 0.

* MESSAGE i066.

* IF gv_flgstart IS NOT INITIAL.

* LEAVE LIST-PROCESSING.

* ELSE.

* LEAVE TO SCREEN 1000.

* ENDIF.

* ENDIF.

*MOD-1771404

ENDFORM. " f_check_product_status

*&---------------------------------------------------------------------*

*& Form f_delete_transactional_data

*&---------------------------------------------------------------------*

* Delete the transactional data for the Product and Location

*----------------------------------------------------------------------*

* -->IT_CORE_PROD Itab with the core products to be deleted

* -->IT_PROD_VAR Itab with the product varients to be deleted

* -->IT_LOC_DATA Itab with the locations to be deleted

* <--CT_PROD_DATA Itab wiht Product and Locations selected

* <--CT_BDC_DATA BDC TABLE

*----------------------------------------------------------------------*

FORM f_delete_transactional_data USING it_core_prod TYPE t_f4_data_loc

it_prod_var TYPE t_f4_data_loc

it_loc_data TYPE t_f4_data_loc

CHANGING ct_prod_data TYPE t_f4_data_loc

ct_bdc_data TYPE STANDARD TABLE.

"#EC *

* CT_BDC_DATA is populated in the Perform populate_bdc_tab

* Local Data Declaration

DATA: lv_ctu_params TYPE ctu_params,

lv_fname TYPE dynfnam,

lv_count(2) TYPE n,

lt_msg_tab TYPE STANDARD TABLE OF bdcmsgcoll.

DATA: lv_prev_pcode type matnr.

DATA: percentage_text TYPE c LENGTH 5.

DATA: LV_TABIX(20).

DATA: lv_line type i.

DATA: lv_line1 type i.

DATA: LV_LINE2 TYPE I.

DATA: lv_pcode type /SAPAPO/MATNR.

DATA: s_product TYPE RANGE OF BAPI10001APXPRODLOCKEY-product,

s_product_wa LIKE LINE OF s_product.

* Field-symbols

FIELD-SYMBOLS: <lfs_msg_ret> TYPE bdcmsgcoll,

<lfs_data> TYPE s_f4_data_loc,

<lfs_data1> TYPE s_f4_data_loc.

REFRESH ct_bdc_data.

*MOD-1887120

sort it_core_prod by pcode.

delete adjacent duplicates from it_core_prod

comparing pcode.

describe table it_core_prod lines lv_line.

sort it_prod_var by pcode prvar.

delete adjacent duplicates from it_prod_var

comparing pcode prvar.

describe table it_prod_var lines lv_line1.

lv_line2 = lv_line + lv_line1.

if lv_line2 <= 7.

*Version 0002

*MOD-1887120: Code that is fixed till TESTAVEEK27.

*Populate the general selection criteria on first screen

PERFORM f_populate_bdc_tab USING:

'X' 'APO_BAPI_DEL_TRANS_OBJECTS' '1000',

' ' 'BDC_OKCODE' '=DUMMY',

' ' 'PLVERS' '000',

' ' 'MD_SYS' p_log,

' ' 'EXTRB' 'X',

' ' 'MO_DEL' 'X',

' ' 'SIM' space,

' ' 'P_LOGDEL' '5'.

*Populate the select options for Product

PERFORM f_populate_bdc_tab USING:

'X' 'APO_BAPI_DEL_TRANS_OBJECTS' '1000',

' ' 'BDC_OKCODE' '=%011'.

*Populate the select options screen for product

PERFORM f_populate_bdc_tab USING:

'X' 'SAPLALDB' '3000',

* ' ' 'BDC_SUBSCR' 'SAPLALDB 3010SCREEN_HEADER',

' ' 'BDC_OKCODE' '=ACPT'.

CLEAR lv_count.

LOOP AT it_core_prod ASSIGNING <lfs_data>.

lv_count = lv_count + 1.

CONCATENATE gc_rscsel gc_l_brac lv_count gc_r_brac INTO lv_fname.

PERFORM f_populate_bdc_tab USING:

' ' lv_fname <lfs_data>-pcode.

CLEAR lv_fname.

ENDLOOP.

LOOP AT it_prod_var ASSIGNING <lfs_data>.

lv_count = lv_count + 1.

CONCATENATE gc_rscsel gc_l_brac lv_count gc_r_brac INTO lv_fname.

PERFORM f_populate_bdc_tab USING:

' ' lv_fname <lfs_data>-prvar.

CLEAR lv_fname.

ENDLOOP.

*Populate the select options for the Locations

PERFORM f_populate_bdc_tab USING:

'X' 'APO_BAPI_DEL_TRANS_OBJECTS' '1000',

' ' 'BDC_OKCODE' '=%012'.

*Populate the select options screen for product

PERFORM f_populate_bdc_tab USING:

'X' 'SAPLALDB' '3000',

* ' ' 'BDC_SUBSCR' 'SAPLALDB 3010SCREEN_HEADER',

' ' 'BDC_OKCODE' '=ACPT'.

CLEAR lv_count.

LOOP AT it_loc_data ASSIGNING <lfs_data>.

lv_count = lv_count + 1.

CONCATENATE gc_rscsel gc_l_brac lv_count gc_r_brac INTO lv_fname.

PERFORM f_populate_bdc_tab USING:

' ' lv_fname <lfs_data>-locno.

CLEAR lv_fname.

ENDLOOP.

*Populate the objects to be deleted on first screen

PERFORM f_populate_bdc_tab USING:

'X' 'APO_BAPI_DEL_TRANS_OBJECTS' '1000',

' ' 'BDC_OKCODE' '=ONLI',

' ' 'PLVERS' '000',

' ' 'MD_SYS' p_log,

' ' 'EXTRB' 'X',

' ' 'MO_DEL' 'X',

' ' 'MO_STAT' 'X',

' ' 'PO_DEL' 'X',

' ' 'SL_DEL' 'X',

' ' 'ST_DEL' 'X',

' ' 'PIR_DEL' 'X',

' ' 'SIM' space,

' ' ' ' ' '.

PERFORM f_populate_bdc_tab USING:

'X' 'SAPLSPO1' '0500',

' ' 'BDC_OKCODE' '=OPT1'.

CLEAR gv_msg_error.

lv_ctu_params-nobinpt = space.

lv_ctu_params-dismode = gc_mode_e.

lv_ctu_params-updmode = 'S'.

lv_ctu_params-racommit = 'X'.

* Call Transaction /SAPAPO/BP2 for deleting the Transactional data

CALL TRANSACTION gc_bp2 USING ct_bdc_data OPTIONS FROM lv_ctu_params

MESSAGES INTO lt_msg_tab.

*MOD-1887120: Code that is fixed till TESTAVEEK27.

*Version 0002

else.

**Version 0005

*CTS D7AK900899 New Version code fixed for testaveek28 case.

*MOD-1887120: Code that is changed after the release of transport.

* Populate the general selection criteria on first screen

PERFORM f_populate_bdc_tab USING:

'X' 'APO_BAPI_DEL_TRANS_OBJECTS' '1000',

* ' ' 'BDC_CURSOR' 'EXT_PROD-LOW',

' ' 'BDC_OKCODE' '=%011',

* ' ' 'BDC_OKCODE' '=DUMMY',

' ' 'PLVERS' '000',

' ' 'MD_SYS' p_log,

' ' 'EXTRB' 'X',

' ' 'MO_DEL' 'X',

' ' 'SIM' space,

' ' 'P_LOGDEL' '5'.

sort it_core_prod by pcode.

delete adjacent duplicates from it_core_prod

comparing pcode.

describe table it_core_prod lines lv_line.

CLEAR lv_count.

* LOOP AT it_core_prod ASSIGNING <lfs_data>.

* lv_count = 1.

* CONCATENATE gc_rscsel gc_l_brac lv_count gc_r_brac INTO lv_fname.

*** if lv_line > 1.

* PERFORM f_populate_bdc_tab USING:

* 'X' 'SAPLALDB' '3000',

* ' ' lv_fname <lfs_data>-pcode,

* ' ' 'BDC_OKCODE' '=LINS'.

* CLEAR lv_fname.

* ENDLOOP.

*Populate the select options screen for product

* PERFORM f_populate_bdc_tab USING:

* 'X' 'SAPLALDB' '3000',

** ' ' 'BDC_SUBSCR' 'SAPLALDB 3010SCREEN_HEADER',

* ' ' 'BDC_OKCODE' '=ACPT'.

sort it_prod_var by pcode prvar.

delete adjacent duplicates from it_prod_var

comparing pcode prvar.

* PERFORM f_populate_bdc_tab USING:

* 'X' 'SAPLALDB' '3000'.

*MOD-1887120:

IF NOT IT_CORE_PROD[] IS INITIAL.

*MOD-1887120:

LOOP AT it_core_prod ASSIGNING <lfs_data>.

lv_pcode = <lfs_data>-pcode.

*lv_count = lv_count + 1.

lv_count = 1.

CONCATENATE gc_rscsel gc_l_brac lv_count gc_r_brac INTO lv_fname.

** if lv_line > 1.

PERFORM f_populate_bdc_tab USING:

'X' 'SAPLALDB' '3000',

' ' lv_fname <lfs_data>-pcode,

' ' 'BDC_OKCODE' '=LINS'.

CLEAR lv_fname.

describe table it_prod_var lines lv_line.

* sort <lfs_data> by locno pcode prvar.

LOOP AT it_prod_var ASSIGNING <lfs_data1> where pcode = lv_pcode.

lv_count = 1.

CONCATENATE gc_rscsel gc_l_brac lv_count gc_r_brac INTO lv_fname.

* if lv_line > 1.

PERFORM f_populate_bdc_tab USING:

'X' 'SAPLALDB' '3000',

' ' lv_fname <lfs_data1>-prvar,

' ' 'BDC_OKCODE' '=LINS'.

* else.

* PERFORM f_populate_bdc_tab USING:

* ' ' lv_fname <lfs_data>-prvar,

* ' ' 'BDC_OKCODE' '=LINS'.

* endif.

CLEAR lv_fname.

ENDLOOP.

*MOD-1887120: Changed after 04.04.2006

LOOP AT it_prod_var ASSIGNING <lfs_data1>.

lv_count = 1.

CONCATENATE gc_rscsel gc_l_brac lv_count

gc_r_brac INTO lv_fname.

PERFORM f_populate_bdc_tab USING:

'X' 'SAPLALDB' '3000',

' ' lv_fname <lfs_data1>-prvar,

' ' 'BDC_OKCODE' '=LINS'.

CLEAR lv_fname.

ENDLOOP.

ENDLOOP.

*MOD-1887120:

*MOD-1887120:

ELSE.

*MOD-1887120:

describe table it_prod_var lines lv_line.

* sort <lfs_data> by locno pcode prvar.

LOOP AT it_prod_var ASSIGNING <lfs_data1>. "where pcode=lv_pcode.

* lv_count = lv_count + 1.

lv_count = 1.

CONCATENATE gc_rscsel gc_l_brac lv_count gc_r_brac INTO lv_fname

.

* if lv_line > 1.

PERFORM f_populate_bdc_tab USING:

'X' 'SAPLALDB' '3000',

' ' lv_fname <lfs_data1>-prvar,

' ' 'BDC_OKCODE' '=LINS'.

* else.

* PERFORM f_populate_bdc_tab USING:

* ' ' lv_fname <lfs_data>-prvar,

* ' ' 'BDC_OKCODE' '=LINS'.

* endif.

CLEAR lv_fname.

ENDLOOP.

*MOD-1887120:

ENDIF.

*MOD-1887120:

* Populate the select options screen for product

PERFORM f_populate_bdc_tab USING:

* 'X' 'SAPLALDB' '3000',

* ' ' 'BDC_SUBSCR' 'SAPLALDB 3010SCREEN_HEADER',

' ' 'BDC_OKCODE' '=ACPT'.

* Populate the select options for the Locations

PERFORM f_populate_bdc_tab USING:

'X' 'APO_BAPI_DEL_TRANS_OBJECTS' '1000',

* ' ' 'BDC_CURSOR' 'EXT_PRD-LOW',

' ' 'BDC_OKCODE' '=%012',

' ' 'PLVERS' '000',

' ' 'MD_SYS' p_log,

' ' 'EXTRB' 'X',

' ' 'MO_DEL' 'X',

' ' 'SIM' space,

' ' 'P_LOGDEL' '5'.

* Populate the select options screen for product

PERFORM f_populate_bdc_tab USING:

'X' 'SAPLALDB' '3000',

* ' ' 'BDC_SUBSCR' 'SAPLALDB 3010SCREEN_HEADER',

' ' 'BDC_OKCODE' '=ACPT'.

CLEAR lv_count.

LOOP AT it_loc_data ASSIGNING <lfs_data>.

lv_count = lv_count + 1.

* lv_count = 1.

CONCATENATE gc_rscsel gc_l_brac lv_count gc_r_brac INTO lv_fname.

PERFORM f_populate_bdc_tab USING:

' ' lv_fname <lfs_data>-locno.

* ' ' 'BDC_OKCODE' '=LINS'.

CLEAR lv_fname.

* PERFORM f_populate_bdc_tab USING:

* 'X' 'SAPLALDB' '3000',

* ' ' lv_fname <lfs_data>-locno,

* ' ' 'BDC_OKCODE' '=LINS'.

* CLEAR lv_fname.

ENDLOOP.

* CLEAR lv_count.

* LOOP AT it_loc_data ASSIGNING <lfs_data>.

* lv_count = 1.

* CONCATENATE gc_rscsel gc_l_brac lv_count gc_r_brac INTO lv_fname.

* PERFORM f_populate_bdc_tab USING:

* 'X' 'SAPLALDB' '3000',

* ' ' lv_fname <lfs_data>-locno,

* ' ' 'BDC_OKCODE' '=LINS'.

* CLEAR lv_fname.

* ENDLOOP.

*

* Populate the objects to be deleted on first screen

PERFORM f_populate_bdc_tab USING:

'X' 'APO_BAPI_DEL_TRANS_OBJECTS' '1000',

' ' 'BDC_OKCODE' '=DUMMY',

' ' 'PLVERS' '000',

' ' 'MD_SYS' p_log,

' ' 'EXTRB' 'X',

' ' 'MO_DEL' 'X',

' ' 'MO_STAT' 'X',

' ' 'PO_DEL' 'X',

' ' 'SL_DEL' 'X',

' ' 'ST_DEL' 'X',

' ' 'PIR_DEL' 'X',

' ' 'SIM' space,

' ' ' ' ' '.

PERFORM f_populate_bdc_tab USING:

'X' 'SAPLSPO1' '0500',

' ' 'BDC_OKCODE' '=OPT1'.

CLEAR gv_msg_error.

lv_ctu_params-nobinpt = space.

* lv_ctu_params-dismode = gc_mode_e.

lv_ctu_params-dismode = 'A'.

lv_ctu_params-updmode = 'S'.

lv_ctu_params-racommit = 'X'.

* Call Transaction /SAPAPO/BP2 for deleting the Transactional data

CALL TRANSACTION gc_bp2 USING ct_bdc_data OPTIONS FROM lv_ctu_params

MESSAGES INTO lt_msg_tab.

***MOD-1887120: Code that is changed after the release of transport.

*CTS D7AK900899 New Version

*Code fixed for testaveek28 case.

**Version 0005

endif.

*MOD-1887120

**Version 0002

**MOD-1887120: Code that is fixed till TESTAVEEK27.

**Populate the general selection criteria on first screen

* PERFORM f_populate_bdc_tab USING:

* 'X' 'APO_BAPI_DEL_TRANS_OBJECTS' '1000',

* ' ' 'BDC_OKCODE' '=DUMMY',

* ' ' 'PLVERS' '000',

* ' ' 'MD_SYS' p_log,

* ' ' 'EXTRB' 'X',

* ' ' 'MO_DEL' 'X',

* ' ' 'SIM' space,

* ' ' 'P_LOGDEL' '5'.

*

**Populate the select options for Product

* PERFORM f_populate_bdc_tab USING:

* 'X' 'APO_BAPI_DEL_TRANS_OBJECTS' '1000',

* ' ' 'BDC_OKCODE' '=%011'.

*

**Populate the select options screen for product

* PERFORM f_populate_bdc_tab USING:

* 'X' 'SAPLALDB' '3000',

** ' ' 'BDC_SUBSCR' 'SAPLALDB 3010SCREEN_HEADER',

* ' ' 'BDC_OKCODE' '=ACPT'.

*

* CLEAR lv_count.

* LOOP AT it_core_prod ASSIGNING <lfs_data>.

* lv_count = lv_count + 1.

* CONCATENATE gc_rscsel gc_l_brac lv_count gc_r_brac INTO lv_fname.

* PERFORM f_populate_bdc_tab USING:

* ' ' lv_fname <lfs_data>-pcode.

* CLEAR lv_fname.

*

* ENDLOOP.

*

* LOOP AT it_prod_var ASSIGNING <lfs_data>.

* lv_count = lv_count + 1.

* CONCATENATE gc_rscsel gc_l_brac lv_count gc_r_brac INTO lv_fname.

* PERFORM f_populate_bdc_tab USING:

* ' ' lv_fname <lfs_data>-prvar.

* CLEAR lv_fname.

* ENDLOOP.

*

**Populate the select options for the Locations

* PERFORM f_populate_bdc_tab USING:

* 'X' 'APO_BAPI_DEL_TRANS_OBJECTS' '1000',

* ' ' 'BDC_OKCODE' '=%012'.

*

**Populate the select options screen for product

* PERFORM f_populate_bdc_tab USING:

* 'X' 'SAPLALDB' '3000',

** ' ' 'BDC_SUBSCR' 'SAPLALDB 3010SCREEN_HEADER',

* ' ' 'BDC_OKCODE' '=ACPT'.

*

* CLEAR lv_count.

*

* LOOP AT it_loc_data ASSIGNING <lfs_data>.

*

* lv_count = lv_count + 1.

* CONCATENATE gc_rscsel gc_l_brac lv_count gc_r_brac INTO lv_fname.

* PERFORM f_populate_bdc_tab USING:

* ' ' lv_fname <lfs_data>-locno.

*

* CLEAR lv_fname.

*

* ENDLOOP.

*

**Populate the objects to be deleted on first screen

* PERFORM f_populate_bdc_tab USING:

* 'X' 'APO_BAPI_DEL_TRANS_OBJECTS' '1000',

* ' ' 'BDC_OKCODE' '=ONLI',

* ' ' 'PLVERS' '000',

* ' ' 'MD_SYS' p_log,

* ' ' 'EXTRB' 'X',

* ' ' 'MO_DEL' 'X',

* ' ' 'MO_STAT' 'X',

* ' ' 'PO_DEL' 'X',

* ' ' 'SL_DEL' 'X',

* ' ' 'ST_DEL' 'X',

* ' ' 'PIR_DEL' 'X',

* ' ' 'SIM' space,

* ' ' ' ' ' '.

*

* PERFORM f_populate_bdc_tab USING:

* 'X' 'SAPLSPO1' '0500',

* ' ' 'BDC_OKCODE' '=OPT1'.

*

*

**MOD-1887120: Code that is fixed till TESTAVEEK27.

**Version 0002

***Version 0005

**CTS D7AK900899 New Version code fixed for testaveek28 case.

**MOD-1887120: Code that is changed after the release of transport.

** Populate the general selection criteria on first screen

*

* PERFORM f_populate_bdc_tab USING:

* 'X' 'APO_BAPI_DEL_TRANS_OBJECTS' '1000',

** ' ' 'BDC_CURSOR' 'EXT_PROD-LOW',

* ' ' 'BDC_OKCODE' '=%011',

** ' ' 'BDC_OKCODE' '=DUMMY',

* ' ' 'PLVERS' '000',

* ' ' 'MD_SYS' p_log,

* ' ' 'EXTRB' 'X',

* ' ' 'MO_DEL' 'X',

* ' ' 'SIM' space,

* ' ' 'P_LOGDEL' '5'.

*

* sort it_core_prod by pcode.

* delete adjacent duplicates from it_core_prod

* comparing pcode.

* describe table it_core_prod lines lv_line.

*

* CLEAR lv_count.

** LOOP AT it_core_prod ASSIGNING <lfs_data>.

** lv_count = 1.

** CONCATENATE gc_rscsel gc_l_brac lv_count gc_r_brac INTO lv_fname.

**** if lv_line > 1.

** PERFORM f_populate_bdc_tab USING:

** 'X' 'SAPLALDB' '3000',

** ' ' lv_fname <lfs_data>-pcode,

** ' ' 'BDC_OKCODE' '=LINS'.

** CLEAR lv_fname.

** ENDLOOP.

*

**Populate the select options screen for product

** PERFORM f_populate_bdc_tab USING:

** 'X' 'SAPLALDB' '3000',

*** ' ' 'BDC_SUBSCR' 'SAPLALDB 3010SCREEN_HEADER',

** ' ' 'BDC_OKCODE' '=ACPT'.

*

* sort it_prod_var by pcode prvar.

* delete adjacent duplicates from it_prod_var

* comparing pcode prvar.

** PERFORM f_populate_bdc_tab USING:

** 'X' 'SAPLALDB' '3000'.

* LOOP AT it_core_prod ASSIGNING <lfs_data>.

* lv_pcode = <lfs_data>-pcode.

**lv_count = lv_count + 1.

* lv_count = 1.

* CONCATENATE gc_rscsel gc_l_brac lv_count gc_r_brac INTO lv_fname.

*** if lv_line > 1.

* PERFORM f_populate_bdc_tab USING:

* 'X' 'SAPLALDB' '3000',

* ' ' lv_fname <lfs_data>-pcode,

* ' ' 'BDC_OKCODE' '=LINS'.

* CLEAR lv_fname.

*

* describe table it_prod_var lines lv_line.

*

** sort <lfs_data> by locno pcode prvar.

* LOOP AT it_prod_var ASSIGNING <lfs_data1> where pcode = lv_pcode.

** lv_count = lv_count + 1.

* lv_count = 1.

* CONCATENATE gc_rscsel gc_l_brac lv_count gc_r_brac INTO lv_fname.

** if lv_line > 1.

* PERFORM f_populate_bdc_tab USING:

* 'X' 'SAPLALDB' '3000',

* ' ' lv_fname <lfs_data1>-prvar,

* ' ' 'BDC_OKCODE' '=LINS'.

** else.

** PERFORM f_populate_bdc_tab USING:

** ' ' lv_fname <lfs_data>-prvar,

** ' ' 'BDC_OKCODE' '=LINS'.

** endif.

* CLEAR lv_fname.

* ENDLOOP.

* ENDLOOP.

*

** Populate the select options screen for product

* PERFORM f_populate_bdc_tab USING:

** 'X' 'SAPLALDB' '3000',

** ' ' 'BDC_SUBSCR' 'SAPLALDB 3010SCREEN_HEADER',

* ' ' 'BDC_OKCODE' '=ACPT'.

*

*

** Populate the select options for the Locations

* PERFORM f_populate_bdc_tab USING:

* 'X' 'APO_BAPI_DEL_TRANS_OBJECTS' '1000',

** ' ' 'BDC_CURSOR' 'EXT_PRD-LOW',

* ' ' 'BDC_OKCODE' '=%012',

* ' ' 'PLVERS' '000',

* ' ' 'MD_SYS' p_log,

* ' ' 'EXTRB' 'X',

* ' ' 'MO_DEL' 'X',

* ' ' 'SIM' space,

* ' ' 'P_LOGDEL' '5'.

*

*

** Populate the select options screen for product

* PERFORM f_populate_bdc_tab USING:

* 'X' 'SAPLALDB' '3000',

** ' ' 'BDC_SUBSCR' 'SAPLALDB 3010SCREEN_HEADER',

* ' ' 'BDC_OKCODE' '=ACPT'.

*

*

* CLEAR lv_count.

* LOOP AT it_loc_data ASSIGNING <lfs_data>.

* lv_count = lv_count + 1.

** lv_count = 1.

* CONCATENATE gc_rscsel gc_l_brac lv_count gc_r_brac INTO lv_fname.

* PERFORM f_populate_bdc_tab USING:

* ' ' lv_fname <lfs_data>-locno.

** ' ' 'BDC_OKCODE' '=LINS'.

* CLEAR lv_fname.

** PERFORM f_populate_bdc_tab USING:

** 'X' 'SAPLALDB' '3000',

** ' ' lv_fname <lfs_data>-locno,

** ' ' 'BDC_OKCODE' '=LINS'.

** CLEAR lv_fname.

* ENDLOOP.

*

*

** CLEAR lv_count.

** LOOP AT it_loc_data ASSIGNING <lfs_data>.

** lv_count = 1.

** CONCATENATE gc_rscsel gc_l_brac lv_count gc_r_brac INTO lv_fname.

** PERFORM f_populate_bdc_tab USING:

** 'X' 'SAPLALDB' '3000',

** ' ' lv_fname <lfs_data>-locno,

** ' ' 'BDC_OKCODE' '=LINS'.

** CLEAR lv_fname.

** ENDLOOP.

*

**

** Populate the objects to be deleted on first screen

* PERFORM f_populate_bdc_tab USING:

* 'X' 'APO_BAPI_DEL_TRANS_OBJECTS' '1000',

* ' ' 'BDC_OKCODE' '=DUMMY',

* ' ' 'PLVERS' '000',

* ' ' 'MD_SYS' p_log,

* ' ' 'EXTRB' 'X',

* ' ' 'MO_DEL' 'X',

* ' ' 'MO_STAT' 'X',

* ' ' 'PO_DEL' 'X',

* ' ' 'SL_DEL' 'X',

* ' ' 'ST_DEL' 'X',

* ' ' 'PIR_DEL' 'X',

* ' ' 'SIM' space,

* ' ' ' ' ' '.

*

* PERFORM f_populate_bdc_tab USING:

* 'X' 'SAPLSPO1' '0500',

* ' ' 'BDC_OKCODE' '=OPT1'.

*

****MOD-1887120: Code that is changed after the release of transport.

**CTS D7AK900899 New Version

**Code fixed for testaveek28 case.

***Version 0005

**Version 0006 latest version.

**Code for looping at it_prod_var and doing the call transaction for

**each record

**CTS D7AK900899 New Version

*

* sort it_prod_var by pcode prvar.

* delete adjacent duplicates from it_prod_var

* comparing pcode prvar.

*

* clear: lv_prev_pcode.

*

* LOOP AT it_prod_var ASSIGNING <lfs_data>.

*

** Populate the general selection criteria on first screen

* PERFORM f_populate_bdc_tab USING:

* 'X' 'APO_BAPI_DEL_TRANS_OBJECTS' '1000',

** ' ' 'BDC_CURSOR' 'EXT_PROD-LOW',

* ' ' 'BDC_OKCODE' '=%011',

** ' ' 'BDC_OKCODE' '=DUMMY',

* ' ' 'PLVERS' '000',

* ' ' 'MD_SYS' p_log,

* ' ' 'EXTRB' 'X',

* ' ' 'MO_DEL' 'X',

* ' ' 'SIM' space,

* ' ' 'P_LOGDEL' '5'.

*

*

**Populate the select options screen for product

* PERFORM f_populate_bdc_tab USING:

* 'X' 'SAPLALDB' '3000',

** ' ' 'BDC_SUBSCR' 'SAPLALDB 3010SCREEN_HEADER',

* ' ' 'BDC_OKCODE' '=ACPT'.

*

* lv_count = lv_count + 1.

* CONCATENATE gc_rscsel gc_l_brac lv_count gc_r_brac INTO lv_fname.

** if lv_prev_pcode ne <lfs_data>-pcode.

* PERFORM f_populate_bdc_tab USING:

* ' ' lv_fname <lfs_data>-pcode.

* CLEAR lv_fname.

*

* lv_count = lv_count + 1.

* CONCATENATE gc_rscsel gc_l_brac lv_count gc_r_brac INTO lv_fname.

* PERFORM f_populate_bdc_tab USING:

* ' ' lv_fname <lfs_data>-prvar.

* CLEAR lv_fname.

* clear: lv_count.

*

*

**Populate the select options for the Locations

* PERFORM f_populate_bdc_tab USING:

* 'X' 'APO_BAPI_DEL_TRANS_OBJECTS' '1000',

* ' ' 'BDC_OKCODE' '=%012'.

*

**Populate the select options screen for product

* PERFORM f_populate_bdc_tab USING:

* 'X' 'SAPLALDB' '3000',

** ' ' 'BDC_SUBSCR' 'SAPLALDB 3010SCREEN_HEADER',

* ' ' 'BDC_OKCODE' '=ACPT'.

*

* CLEAR lv_count.

* lv_count = lv_count + 1.

* CONCATENATE gc_rscsel gc_l_brac lv_count gc_r_brac INTO lv_fname.

* PERFORM f_populate_bdc_tab USING:

* ' ' lv_fname <lfs_data>-locno.

* CLEAR lv_fname.

* clear: lv_count.

*

** Populate the objects to be deleted on first screen

* PERFORM f_populate_bdc_tab USING:

* 'X' 'APO_BAPI_DEL_TRANS_OBJECTS' '1000',

* ' ' 'BDC_OKCODE' '=DUMMY',

* ' ' 'PLVERS' '000',

* ' ' 'MD_SYS' p_log,

* ' ' 'EXTRB' 'X',

* ' ' 'MO_DEL' 'X',

* ' ' 'MO_STAT' 'X',

* ' ' 'PO_DEL' 'X',

* ' ' 'SL_DEL' 'X',

* ' ' 'ST_DEL' 'X',

* ' ' 'PIR_DEL' 'X',

* ' ' 'SIM' space,

* ' ' ' ' ' '.

*

* PERFORM f_populate_bdc_tab USING:

* 'X' 'SAPLSPO1' '0500',

* ' ' 'BDC_OKCODE' '=OPT1'.

*

* CLEAR gv_msg_error.

* lv_ctu_params-nobinpt = space.

** lv_ctu_params-dismode = gc_mode_e.

* lv_ctu_params-dismode = 'A'.

* lv_ctu_params-updmode = 'S'.

* lv_ctu_params-racommit = 'X'.

*

** Call Transaction /SAPAPO/BP2 for deleting the Transactional data

* CALL TRANSACTION gc_bp2 USING ct_bdc_data OPTIONS

* FROM lv_ctu_params

* MESSAGES INTO lt_msg_tab.

*

* clear: ct_bdc_data.

*

* ENDLOOP.

***

******MOD-1887120: Code that is changed after the release of transport.

****CTS D7AK900899 New Version

****Version 0006

**MOD-1887120:

* CLEAR gv_msg_error.

* lv_ctu_params-nobinpt = space.

** lv_ctu_params-dismode = gc_mode_e.

* lv_ctu_params-dismode = 'A'.

* lv_ctu_params-updmode = 'S'.

* lv_ctu_params-racommit = 'X'.

*

** Call Transaction /SAPAPO/BP2 for deleting the Transactional data

* CALL TRANSACTION gc_bp2 USING ct_bdc_data OPTIONS FROM lv_ctu_params

* MESSAGES INTO lt_msg_tab.

**MOD-1887120:

** commit work and wait.

*MOD-1771404

DO 10 TIMES.

WAIT UP TO '0.1' SECONDS.

percentage_text(3) = sy-index.

percentage_text+3 = '%'.

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

EXPORTING

percentage = sy-index

text = percentage_text.

ENDDO.

*MOD-1771404

LOOP AT lt_msg_tab ASSIGNING <lfs_msg_ret>

WHERE msgtyp = gc_error OR

msgtyp = gc_abend.

gv_msg_error = gc_set.

EXIT.

ENDLOOP.

ENDFORM. " f_delete_transactional_data

*&---------------------------------------------------------------------*

*& Form F_POPULATE_BDC_TAB

*&---------------------------------------------------------------------*

* Pupulates BDC Table with the parameters passed to the perform

*----------------------------------------------------------------------*

* -->IV_FLG Flag for New Screem

* -->IV_VAR1 Program Name / Field Name

* -->IV_VAR2 Screen Number / Field Value

*----------------------------------------------------------------------*

FORM f_populate_bdc_tab USING iv_flg TYPE any

iv_var1 TYPE any

iv_var2 TYPE any.

* Local Data Declaration

DATA: ls_bdc_data TYPE bdcdata.

* Populate the BDC Table with the variables passed in it.

CLEAR ls_bdc_data.

IF iv_flg = gc_set. " = 'X'

ls_bdc_data-program = iv_var1.

ls_bdc_data-dynpro = iv_var2.

ls_bdc_data-dynbegin = gc_set.

ELSE.

ls_bdc_data-fnam = iv_var1.

ls_bdc_data-fval = iv_var2.

ENDIF.

APPEND ls_bdc_data TO gt_bdc_tab.

ENDFORM. " F_POPULATE_BDC_TAB

*&---------------------------------------------------------------------*

*& Form f_delete_manual_created_data

*&---------------------------------------------------------------------*

* Delete the Manually entered transactional data for prod and loc

*----------------------------------------------------------------------*

* -->IT_CORE_PROD Itab with the core products to be deleted

* -->IT_PROD_VAR Itab with the product varients to be deleted

* -->IT_LOC_DATA Itab with the locations to be deleted

* <--CT_VARIANT_TABLE Screen Varient Table.

*----------------------------------------------------------------------*

FORM f_delete_manual_created_data USING it_core_prod TYPE t_f4_data_loc

it_prod_var TYPE t_f4_data_loc

it_loc_data TYPE t_f4_data_loc

CHANGING ct_variant_table TYPE t_rsparams.

* Field-symbols

FIELD-SYMBOLS: <lfs_data> TYPE s_f4_data_loc.

* Populate the selection screen table

PERFORM f_populate_screen_table USING:

* Field Name Type Sign Option Low Value

* Populate the Additional selection options

* Select the Manual selection button

gc_manual_sel gc_radio_btn gc_sign_i gc_option_eq gc_set_val space,

* Populate the Planning Version

gc_plan_vrsn gc_parameter gc_sign_i gc_option_eq gc_pvrsn_000 space.

* Populate the Core Products to be deleted

LOOP AT it_core_prod ASSIGNING <lfs_data>.

PERFORM f_populate_screen_table USING:

gc_product gc_sel_optn gc_sign_i gc_option_eq <lfs_data>-pcode space.

ENDLOOP.

* Populate the Product Variants to be deleted

LOOP AT it_prod_var ASSIGNING <lfs_data>.

PERFORM f_populate_screen_table USING:

gc_product gc_sel_optn gc_sign_i gc_option_eq <lfs_data>-prvar space.

ENDLOOP.

* Populate the Locations to be deleted.

LOOP AT it_loc_data ASSIGNING <lfs_data>.

PERFORM f_populate_screen_table USING:

gc_location gc_sel_optn gc_sign_i gc_option_eq <lfs_data>-locno space.

ENDLOOP.

* Populate the Fixed Orders Checkbox

PERFORM f_populate_screen_table USING:

gc_fixed_ord gc_parameter gc_sign_i gc_option_eq gc_set_val space,

* Populate the Selection Objects

* Unselect the Key Figure Radio Button

gc_key_fig gc_radio_btn gc_sign_i gc_option_eq space space,

* By Category Radio Button

gc_category gc_radio_btn gc_sign_i gc_option_eq gc_set_val space,

* Populate the Settings

* Select Delete Transactional data only in APO Radio Button

gc_only_apo gc_radio_btn gc_sign_i gc_option_eq gc_set_val space,

* Uncheck the Test Run check box.

gc_test_run gc_parameter gc_sign_i gc_option_eq space space.

* Submit to SAP Standard report /SAPAPO/RLCDELETE

* For deleting manually entered data for the product and location

SUBMIT /sapapo/rlcdelete WITH SELECTION-TABLE ct_variant_table

AND RETURN.

ENDFORM. " f_delete_manual_created_data

*&---------------------------------------------------------------------*

*& Form F_POPULATE_SCREEN_TABLE

*&---------------------------------------------------------------------*

* Populate the screen table with the parameters passed

*----------------------------------------------------------------------*

* -->IV_NAME Screen field Name

* -->IV_TYPE Screen field type

* -->IV_SIGN Sign I / E

* -->IV_OPTION Option BT/EQ

* -->IV_LOW Lower value

* -->IV_HIGH Higher value

*----------------------------------------------------------------------*

FORM f_populate_screen_table USING iv_name TYPE rsscr_name

iv_type TYPE rsscr_kind

iv_sign TYPE tvarv_sign

iv_option TYPE tvarv_opti

iv_low TYPE any

iv_high TYPE tvarv_val.

* Local Data Declaration

DATA: ls_variant TYPE rsparams.

* Populate the Screen Table

ls_variant-selname = iv_name.

ls_variant-kind = iv_type.

ls_variant-sign = iv_sign.

ls_variant-option = iv_option.

ls_variant-low = iv_low.

ls_variant-high = iv_high.

APPEND ls_variant TO gt_variant_table.

CLEAR ls_variant.

ENDFORM. " F_POPULATE_SCREEN_TABLE

*&---------------------------------------------------------------------*

*& Form f_delete_ppds_orders

*&---------------------------------------------------------------------*

* Delete the PPDS orders

*----------------------------------------------------------------------*

* -->IT_CORE_PROD Itab with the core products to be deleted

* -->IT_PROD_VAR Itab with the product varients to be deleted

* -->IT_LOC_DATA Itab with the locations to be deleted

* <--CT_VARIANT_TABLE Screen Varient Table.

*----------------------------------------------------------------------*

FORM f_delete_ppds_orders USING it_core_prod TYPE t_f4_data_loc

it_prod_var TYPE t_f4_data_loc

it_loc_data TYPE t_f4_data_loc

CHANGING ct_variant_table TYPE t_rsparams.

* Field-symbols

FIELD-SYMBOLS: <lfs_data> TYPE s_f4_data_loc.

REFRESH ct_variant_table.

* Populate the selection screen variant

PERFORM f_populate_screen_table USING:

* Field Name Type Sign Option Low Value

* Populate the Location Product details

gc_pl_vrsn gc_parameter gc_sign_i gc_option_eq gc_pvrsn_000 space.

* Populate the Core Products to be deleted

LOOP AT it_core_prod ASSIGNING <lfs_data>.

PERFORM f_populate_screen_table USING:

gc_prod gc_sel_optn gc_sign_i gc_option_eq <lfs_data>-pcode space.

ENDLOOP.

* Populate the Product Variants to be deleted

LOOP AT it_prod_var ASSIGNING <lfs_data>.

PERFORM f_populate_screen_table USING:

gc_prod gc_sel_optn gc_sign_i gc_option_eq <lfs_data>-prvar space.

ENDLOOP.

* Populate the Locations to be deleted.

LOOP AT it_loc_data ASSIGNING <lfs_data>.

PERFORM f_populate_screen_table USING:

gc_loc gc_sel_optn gc_sign_i gc_option_eq <lfs_data>-locno space.

ENDLOOP.

* Populate Product planned externally checkbox

PERFORM f_populate_screen_table USING:

gc_plan_prod gc_parameter gc_sign_i gc_option_eq gc_set_val space,

* Populate Subcontracting Planned Orders

gc_contract gc_parameter gc_sign_i gc_option_eq gc_set_val space,

* Uncheck the Display order check box

gc_display_ord gc_parameter gc_sign_i gc_option_eq space space,

* Check the Delete Order check box

gc_delete_ord gc_parameter gc_sign_i gc_option_eq gc_set_val space,

* Uncheck the Send Deleted orders checkbox

gc_send_delete gc_parameter gc_sign_i gc_option_eq space space.

* Submit standard program /SAPAPO/DELETE_PP_ORDER

* For deleting PPDS orders created for the product and location

SUBMIT /sapapo/delete_pp_order WITH SELECTION-TABLE ct_variant_table

AND RETURN.

ENDFORM. " f_delete_ppds_orders

*&---------------------------------------------------------------------*

*& Form f_delete_product_from_tlane

*&---------------------------------------------------------------------*

* Delete Products from the Transportation Lane

*&---------------------------------------------------------------------*

* -->IT_CORE_PROD Itab with the core products to be deleted

* -->IT_PROD_VAR Itab with the product varients to be deleted

* <--CT_LOC_DATA Itab with the locations to be deleted

* <--CT_MATID_ALL Itab with Matid for all the Products

* <--CT_TLANE Itab with transportation lane data

*----------------------------------------------------------------------*

FORM f_delete_product_from_tlane USING it_core_prod TYPE t_f4_data_loc

it_prod_var TYPE t_f4_data_loc

CHANGING ct_loc_data TYPE t_f4_data_loc

ct_matid_all TYPE t_matid

ct_tlane TYPE t_tlane_data.

CONSTANTS:

lc_stime TYPE t VALUE '000000',

lc_etime TYPE t VALUE '235959',

lc_utc TYPE timezone VALUE 'UTC'.

DATA:

lv_dummy TYPE /sapapo/c_loctype,

lv_valfr TYPE timestamp,

lv_valto TYPE timestamp,

lv_matid TYPE /sapapo/matid,

lv_srcid TYPE /sapapo/locid,

lv_desid TYPE /sapapo/locid.

DATA:

lt_trprod TYPE STANDARD TABLE OF /sapapo/trprod,

lt_matid TYPE t_matid,

ls_matid TYPE s_matid,

lt_tlaneupd TYPE t_tlaneupd,

ls_tlaneupd TYPE s_tlaneupd.

FIELD-SYMBOLS:

<lfs_trprod> TYPE /sapapo/trprod.

* Local Data Declaration

DATA: lv_matid_low TYPE /sapapo/matid,

lv_locid_low TYPE /sapapo/locid,

lv_loctyp TYPE /sapapo/c_loctype,

lr_matid TYPE RANGE OF /sapapo/matid,

ls_trprod TYPE s_tlane_data,

lr_locid TYPE RANGE OF /sapapo/locid,

ls_locid TYPE s_locid,

ls_loc_new TYPE /sapapo/loc,

lt_locid_all TYPE STANDARD TABLE OF s_locid,

lv_locid TYPE /SAPAPO/LOCID,

lv_locno TYPE /SAPAPO/LOCNO.

* Field-symbols

FIELD-SYMBOLS: <lfs_data> TYPE s_f4_data_loc,

<lfs_locid> TYPE s_locid,

<lfs_matid> TYPE s_matid.

*MOD-1771404

FIELD-SYMBOLS:

* <lfs_zdm0705> TYPE zdm0705,

<lfs_prod_data> TYPE s_f4_data_loc,

<lfs_matloc> TYPE s_matloc.

*MOD-1771404

TYPES: BEGIN OF s_view_data,

pcode TYPE matnr, " Product

maktx TYPE char40, " Prod Desc

markt TYPE char4, " Market

martx TYPE char20, " Market Desc

pdctr TYPE char2, " Product Center

pctxt TYPE char20, " Description

whse1 TYPE CHAR3, " Warehouse1

whse2 TYPE CHAR3, " Warehouse2

prvar TYPE CHAR18, " Product Variant

vartx TYPE CHAR30, " Variant Description

status TYPE CHAR1, " Status

END OF s_view_data,

lv_view_data TYPE STANDARD TABLE OF s_view_data.

* For Core Products

LOOP AT it_core_prod ASSIGNING <lfs_data>.

* Get the MATID for the Core Products

PERFORM f_get_matid_for_prod USING <lfs_data>-pcode

CHANGING lv_matid_low.

ls_matid-matid = lv_matid_low.

ls_matid-matnr = <lfs_data>-pcode.

APPEND ls_matid TO ct_matid_all.

CLEAR ls_matid.

* Populate the Range Table with the Core Products

PERFORM f_populate_range_table_matid USING lv_matid_low

CHANGING lr_matid.

CLEAR lv_matid_low.

ENDLOOP.

* For Product Variants

LOOP AT it_prod_var ASSIGNING <lfs_data>.

* Get the MATID for the Core Products

PERFORM f_get_matid_for_prod USING <lfs_data>-prvar

CHANGING lv_matid_low.

ls_matid-matnr = <lfs_data>-prvar.

ls_matid-matid = lv_matid_low.

APPEND ls_matid TO ct_matid_all.

CLEAR ls_matid.

* Populate the Range Table with the Core Products

PERFORM f_populate_range_table_matid USING lv_matid_low

CHANGING lr_matid.

CLEAR lv_matid_low.

ENDLOOP.

*MOD-1771404

DELETE ADJACENT DUPLICATES FROM LR_matid COMPARING SIGN OPTION

LOW HIGH.

*MOD-1771404

* For Locations

LOOP AT ct_loc_data ASSIGNING <lfs_data>.

* Get the Locid for the Location

PERFORM f_get_locid_for_loc USING <lfs_data>-locno

CHANGING lv_locid_low

lv_loctyp.

<lfs_data>-loctyp = lv_loctyp.

ls_locid-locno = <lfs_data>-locno.

ls_locid-locid = lv_locid_low.

APPEND ls_locid TO lt_locid_all.

CLEAR ls_locid.

* Populate the Range Table with the Location

PERFORM f_populate_range_table_locid USING lv_locid_low

CHANGING lr_locid.

CLEAR: lv_locid_low, lv_loctyp.

ENDLOOP.

*MOD-1771404

DELETE ADJACENT DUPLICATES FROM LR_LOCID COMPARING SIGN OPTION

LOW HIGH.

*MOD-1771404

*MOD-1771404

** Get all the transportation lanes for the above Product and Locations

* SELECT *

* FROM /sapapo/trprod

* INTO TABLE lt_trprod

* WHERE matid IN lr_matid AND

* ( locfr IN lr_locid OR

* locto IN lr_locid ).

* IF sy-subrc <> 0.

** No Transportation lane selected for deletion

* MESSAGE i047.

** EXIT.

* ENDIF.

*MOD-1771404

* Get all the transportation lanes for the above Product and Locations

SELECT *

FROM /sapapo/trprod

INTO TABLE lt_trprod

WHERE matid IN lr_matid AND

( locfr IN lr_locid OR

locto IN lr_locid ).

IF sy-subrc <> 0.

* No Transportation lane selected for deletion

MESSAGE i047.

* EXIT.

ENDIF.

*MOD-1771404

DELETE ADJACENT DUPLICATES FROM lt_locid_all COMPARING locid locno.

*MOD-1771404

LOOP AT lt_trprod ASSIGNING <lfs_trprod>.

READ TABLE lt_locid_all ASSIGNING <lfs_locid> WITH KEY

locid = <lfs_trprod>-locto.

IF sy-subrc = 0.

ls_trprod-locto = <lfs_locid>-locno.

ENDIF.

CLEAR ls_loc_new.

CALL FUNCTION '/SAPAPO/CMDS_LOC_SINGLE'

EXPORTING

iv_locid = <lfs_trprod>-locfr

IMPORTING

es_loc = ls_loc_new

EXCEPTIONS

empty_locid = 1

no_location_found = 2

OTHERS = 3.

IF sy-subrc = 0.

ls_trprod-locfr = ls_loc_new-locno.

ENDIF.

*MOD-1771404

clear: lv_locid, lv_locno.

SELECT single locid locno

FROM /sapapo/loc

INTO (lv_locid, lv_locno)

WHERE locid = <lfs_trprod>-locto.

IF SY-SUBRC = 0.

IF ls_trprod-locto is initial.

ls_trprod-locto = lv_locno.

ENDIF.

ENDIF.

*MOD-1771404

READ TABLE ct_matid_all ASSIGNING <lfs_matid> WITH KEY

matid = <lfs_trprod>-matid.

IF sy-subrc = 0.

ls_trprod-matid = <lfs_matid>-matnr.

ENDIF.

APPEND ls_trprod TO ct_tlane.

CLEAR ls_trprod.

ENDLOOP.

**MOD-1887120 Changes made after release of transport on 28.03

DATA: L_WA_zdm0705 type zdm0705.

DATA: L_WA_ZDU1002 type zdu1002.

DATA: lv_prvar type CHAR18.

DATA: lv_indicator1 type i.

* SORT it_zdm0705 BY prvar parpr.

* DELETE ADJACENT DUPLICATES FROM it_zdm0705 COMPARING ALL FIELDS.

**MOD-1887120

DATA: lv_product type CHAR18.

* clear: l_wa_zdu1002.

* clear: l_wa_zdm0705.

* SORT it_zdm0705 BY prvar parpr.

** DELETE ADJACENT DUPLICATES FROM it_zdm0705 COMPARING ALL FIELDS.

* LOOP AT IT_ZDM0705 INTO L_WA_ZDM0705.

* READ TABLE IT_ZDU1002 INTO L_WA_ZDU1002

* WITH KEY PRVAR = L_WA_ZDM0705-PRVAR BINARY SEARCH.

* IF SY-SUBRC = 0.

* IF L_WA_ZDU1002-STATUS NE 'I'.

* lv_indicator1 = 1.

* ENDIF.

* ENDIF.

* ENDLOOP.

***MOD-1887120 Changes made after release of transport on 28.03

* SORT it_zdm0705 BY prvar parpr.

* DELETE ADJACENT DUPLICATES FROM it_zdm0705 COMPARING ALL FIELDS.

* if lv_indicator1 = 1.

* LOOP AT it_zdu1002 into l_wa_zdu1002 WHERE STATUS NE 'I'.

* READ TABLE IT_ZDM0705 ASSIGNING <LFS_ZDM0705>

* WITH KEY PRVAR = L_WA_ZDU1002-PRVAR BINARY SEARCH.

** LOOP AT IT_ZDM0705 into l_wa_zdm0705

** WHERE prvar = l_wa_zdu1002-prvar.

* IF SY-SUBRC = 0.

* <lfs_zdm0705>-dmoap = 'X'.

** l_wa_zdm0705-dmoap = 'X'.

** modify it_zdm0705 from l_wa_zdm0705 transporting dmoap.

* ENDIF.

* ENDLOOP.

** ENDLOOP.

* endif.

*

**MOD-1887120 Changes made after release of transport on 28.03

if lv_indicator1 = 1.

LOOP AT it_prod_var ASSIGNING <lfs_prod_data>.

READ TABLE IT_ZDM0705 into l_wa_zdm0705 with key

parpr = <lfs_prod_data>-pcode

dmoap = 'X'.

IF SY-SUBRC = 0.

delete it_core_prod where pcode = <lfs_prod_data>-pcode.

* Indicates that the core product should not be included in

* transportation lane and /sapapo/bp2 transaction.

READ TABLE GT_MATLOC ASSIGNING <lfs_matloc> with key

matnr = <lfs_prod_data>-pcode

locno = <lfs_prod_data>-locno.

if sy-subrc ne 0.

READ TABLE GT_MATLOC ASSIGNING <lfs_matloc> with key

matnr = <lfs_prod_data>-prvar

locno = <lfs_prod_data>-locno.

if sy-subrc ne 0.

<lfs_prod_data>-lv_exist = 1.

endif.

endif.

endif.

ENDLOOP.

endif.

DELETE it_prod_var WHERE LV_EXIST = 1.

*MOD-1887120 Changes made after release of transport on 28.03

LOOP AT CT_TLANE INTO LS_TRPROD.

READ TABLE IT_ZDM0705 into l_wa_zdm0705 with key

prvar = ls_trprod-matid

dmoap = 'X'.

if sy-subrc = 0.

LS_TRPROD-MATID = 'X'.

MODIFY CT_TLANE FROM LS_TRPROD TRANSPORTING MATID.

COMMIT WORK AND WAIT.

else.

READ TABLE IT_ZDM0705 into l_wa_zdm0705 with key

parpr = ls_trprod-matid

dmoap = 'X'.

if sy-subrc = 0.

LS_TRPROD-MATID = 'X'.

MODIFY CT_TLANE FROM LS_TRPROD TRANSPORTING MATID.

COMMIT WORK AND WAIT.

endif.

endif.

ENDLOOP.

DELETE CT_TLANE WHERE MATID = 'X'.

**MOD-1887120 Changes made after release of transport on 28.03

IF p_test IS NOT INITIAL.

EXIT.

ENDIF.

*MOD-1771404

* Delete SAP Table /SAPAPO/TRPROD

DELETE /sapapo/trprod FROM TABLE lt_trprod.

IF sy-subrc = 0.

COMMIT WORK.

ELSE.

ROLLBACK WORK.

ENDIF.

*MOD-1771404

ENDFORM. " f_delete_product_from_tlane

*&---------------------------------------------------------------------*

*& Form f_get_matid_for_prod

*&---------------------------------------------------------------------*

* Get the MATID for the material passed

*----------------------------------------------------------------------*

* -->IV_PRD Product (Material Number)

* <--CV_MATID MATID for the above material no

*----------------------------------------------------------------------*

FORM f_get_matid_for_prod USING iv_prd TYPE any

CHANGING cv_matid TYPE /sapapo/matid.

* Local Data Declaration

DATA: lv_matnr TYPE /sapapo/matnr.

CHECK NOT iv_prd IS INITIAL.

CLEAR lv_matnr.

lv_matnr = iv_prd.

CALL FUNCTION '/SAPAPO/DM_MATERIAL_GET_MATID'

EXPORTING

iv_matnr = lv_matnr

IMPORTING

ev_matid = cv_matid

EXCEPTIONS

matid_not_found = 1

OTHERS = 2.

IF sy-subrc <> 0.

CLEAR cv_matid.

ENDIF.

ENDFORM. " f_get_matid_for_prod

*&---------------------------------------------------------------------*

*& Form f_get_locid_for_loc

*&---------------------------------------------------------------------*

* Get the LOCID for the Location passed

*----------------------------------------------------------------------*

* -->IV_MKT Location Number

* <--CV_LOCID LOCID for the above Location

* <--CV_LOCTYP Location Type

*----------------------------------------------------------------------*

FORM f_get_locid_for_loc USING iv_mkt TYPE /sapapo/locno

CHANGING cv_locid_low TYPE /sapapo/locid

cv_loctyp TYPE /sapapo/c_loctype.

* Local Data Declaration

DATA: ls_loc TYPE /sapapo/loc.

CHECK NOT iv_mkt IS INITIAL.

CLEAR ls_loc.

CALL FUNCTION '/SAPAPO/LOC_LOCNO_GET_LOCID'

EXPORTING

iv_locno = iv_mkt

IMPORTING

* ev_locid = cv_locid_low

es_location = ls_loc

EXCEPTIONS

location_not_found = 1

not_qualified = 2

OTHERS = 3.

IF sy-subrc <> 0.

CLEAR cv_locid_low.

ELSE.

cv_loctyp = ls_loc-loctype.

cv_locid_low = ls_loc-locid.

ENDIF.

ENDFORM. " f_get_locid_for_loc

*&---------------------------------------------------------------------*

*& Form f_populate_range_table_matid

*&---------------------------------------------------------------------*

* Populate the Range thable wiht the values passed

*----------------------------------------------------------------------*

* -->IV_VALUE_LOW Lower Value of the Range

* <--ES_RANGE Structure of type Range

* <--CT_RANGE_TAB Table of type Range

*----------------------------------------------------------------------*

FORM f_populate_range_table_matid USING iv_value_low TYPE any

CHANGING ct_range_tab TYPE t_matid_range.

* Local Data Declaration

DATA: ls_locid TYPE s_range_locid.

ls_locid-sign = gc_sign_i.

ls_locid-option = gc_option_eq.

ls_locid-low = iv_value_low.

APPEND ls_locid TO ct_range_tab.

CLEAR ls_locid.

ENDFORM. " f_populate_range_table_matid

*&---------------------------------------------------------------------*

*& Form f_set_deletion_flag

*&---------------------------------------------------------------------*

* Set the deletion flag for the Products to be deleted

*----------------------------------------------------------------------*

* -->IT_CORE_PROD Itab with the core products to be deleted

* -->IT_PROD_VAR Itab with the product varients to be deleted

* -->IT_LOC_DATA Itab with the location details

*----------------------------------------------------------------------*

FORM f_set_deletion_flag USING it_core_prod TYPE t_f4_data_loc

it_prod_var TYPE t_f4_data_loc

it_loc_data TYPE t_f4_data_loc

ct_matloc TYPE t_matloc.

* Local Data Declaration

DATA: lv_own_sys TYPE bapiapologsys,

lv_matnr TYPE /sapapo/matnr,

lt_product TYPE STANDARD TABLE OF bapi10001key,

ls_product TYPE bapi10001key,

ls_prod_key TYPE bapi_prodloc_key,

lt_prod_key TYPE STANDARD TABLE OF bapi_prodloc_key,

lt_matloc TYPE t_matloc,

lt_return TYPE STANDARD TABLE OF bapiret2.

* Field Symbols

FIELD-SYMBOLS: <lfs_mat> TYPE s_f4_data_loc,

<lfs_product> TYPE bapi10001key,

<lfs_loc> TYPE s_f4_data_loc,

<lfs_return> TYPE bapiret2.

*MOD-1771404

*MOD-1887120

SORT IT_PROD_VAR BY locno

pcode

prvar.

delete adjacent duplicates from it_prod_var comparing locno

pcode

prvar.

SORT it_loc_data by locno

pcode

prvar

loctyp

whse1.

delete adjacent duplicates from it_loc_data comparing locno

pcode

prvar

loctyp

whse1.

*MOD-1771404

* Populate the Core Product

LOOP AT it_core_prod ASSIGNING <lfs_mat>.

LOOP AT it_loc_data ASSIGNING <lfs_loc>.

READ TABLE ct_matloc TRANSPORTING NO FIELDS

WITH KEY matnr = <lfs_mat>-pcode

locno = <lfs_loc>-locno.

IF sy-subrc = 0.

ls_prod_key-loctype = <lfs_loc>-loctyp.

ls_prod_key-product = <lfs_mat>-pcode.

ls_prod_key-location = <lfs_loc>-locno.

APPEND ls_prod_key TO lt_prod_key.

CLEAR ls_prod_key.

ENDIF.

ENDLOOP.

ENDLOOP.

*MOD-1887120

sort lt_prod_key by product location loctype.

delete adjacent duplicates from lt_prod_key

comparing product

location

loctype.

*MOD-1887120

* Populate the Product Variant

LOOP AT it_prod_var ASSIGNING <lfs_mat>.

LOOP AT it_loc_data ASSIGNING <lfs_loc>.

READ TABLE ct_matloc TRANSPORTING NO FIELDS

WITH KEY matnr = <lfs_mat>-prvar

locno = <lfs_loc>-locno.

IF sy-subrc = 0.

ls_prod_key-loctype = <lfs_loc>-loctyp.

ls_prod_key-product = <lfs_mat>-prvar.

ls_prod_key-location = <lfs_loc>-locno.

APPEND ls_prod_key TO lt_prod_key.

CLEAR ls_prod_key.

ENDIF.

ENDLOOP.

ENDLOOP.

*MOD-1771404

*MOD-1887120

sort lt_prod_key by product location loctype.

*MOD-1887120

delete adjacent duplicates from lt_prod_key comparing product

location

loctype.

*MOD-1771404

* Get the Own Logical system name

CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'

IMPORTING

own_logical_system = lv_own_sys

EXCEPTIONS

own_logical_system_not_defined = 1

OTHERS = 2.

IF sy-subrc <> 0.

CLEAR lv_own_sys.

ENDIF.

* This BAPI will set the deletion flag for the materials selected

* for deletion in the SAP table /SAPAPO/MATLOC

CALL FUNCTION 'BAPI_PRDSRVAPS_REMOVEITEMS'

EXPORTING

logical_system = lv_own_sys

business_system_group = gc_bs_group

commit_control = space

TABLES

product_location_keys = lt_prod_key

return = lt_return.

CLEAR gv_flg_error.

LOOP AT lt_return ASSIGNING <lfs_return>

WHERE type = gc_error OR

type = gc_abend .

gv_flg_error = gc_set.

EXIT.

ENDLOOP.

IF gv_flg_error = gc_set.

* Product deletion failed for all the selected products

MESSAGE i048.

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

* Delete the Products using the SAP report /SAPAPO/DELETE_PRODUCTS

SUBMIT /sapapo/delete_products AND RETURN.

SORT lt_prod_key BY product.

DELETE ADJACENT DUPLICATES FROM lt_prod_key

COMPARING product.

* Look for products which dont have a location

SELECT matnr locno

INTO TABLE lt_matloc

FROM /sapapo/v_matloc

FOR ALL ENTRIES IN gt_prod_data

WHERE matnr = gt_prod_data-pcode OR

matnr = gt_prod_data-prvar.

SORT lt_matloc BY matnr.

DELETE ADJACENT DUPLICATES FROM lt_matloc

COMPARING matnr.

LOOP AT gt_prod_data ASSIGNING <lfs_mat>.

READ TABLE lt_matloc TRANSPORTING NO FIELDS

WITH KEY matnr = <lfs_mat>-pcode

BINARY SEARCH.

IF sy-subrc <> 0.

ls_product-product = <lfs_mat>-pcode.

APPEND ls_product TO lt_product.

ENDIF.

READ TABLE lt_matloc TRANSPORTING NO FIELDS

WITH KEY matnr = <lfs_mat>-prvar

BINARY SEARCH.

IF sy-subrc <> 0.

ls_product-product = <lfs_mat>-prvar.

APPEND ls_product TO lt_product.

ENDIF.

ENDLOOP.

SORT lt_product.

DELETE ADJACENT DUPLICATES FROM lt_product COMPARING ALL FIELDS.

* In case of copre products check if they have any active variants

* before deleting them

LOOP AT lt_product ASSIGNING <lfs_product>.

SELECT SINGLE matnr INTO lv_matnr

FROM /sapapo/matkey

WHERE matnr = <lfs_product>-product.

IF sy-subrc <> 0.

CLEAR <lfs_product>-product.

CONTINUE.

ENDIF.

FIND gc_dot IN <lfs_product>-product.

IF sy-subrc <> 0.

LOOP AT gt_view_data TRANSPORTING NO FIELDS

WHERE pcode = <lfs_product>-product AND

status <> 'I'.

CLEAR <lfs_product>-product.

EXIT.

ENDLOOP.

ENDIF.

ENDLOOP.

DELETE lt_product WHERE product IS INITIAL.

REFRESH gt_product.

gt_product = lt_product.

IF lt_product IS NOT INITIAL.

* Delete the products which dont have any locations

CALL FUNCTION 'BAPI_PRDSRVAPS_DELMULTI'

EXPORTING

logical_system = lv_own_sys

business_system_group = gc_bs_group

commit_control = space

TABLES

product_keys = lt_product

return = lt_return.

CLEAR gv_flg_error.

LOOP AT lt_return ASSIGNING <lfs_return>

WHERE type = gc_error OR

type = gc_abend .

gv_flg_error = gc_set.

EXIT.

ENDLOOP.

IF gv_flg_error = gc_set.

* Product deletion failed for all the selected products

MESSAGE i048.

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

* Delete the Products using the SAP report /SAPAPO/DELETE_PRODUCTS

SUBMIT /sapapo/delete_products AND RETURN.

ENDIF.

ENDIF.

ENDIF.

ENDFORM. " f_set_deletion_flag

*&---------------------------------------------------------------------*

*& Form f_display_alv

*&---------------------------------------------------------------------*

* Display ALV report with selected Product and Locations

*----------------------------------------------------------------------*

* -->IT_PROD_DATA Itab with the Product and Location combs

* <--CT_FCAT Itab for Field Catelogue

* <--CT_MATID_ALL Itab with Matid for all the Products

*----------------------------------------------------------------------*

FORM f_display_alv USING it_prod_data TYPE t_f4_data_loc

ct_matloc TYPE t_matloc

CHANGING ct_fcat TYPE slis_t_fieldcat_alv

ct_matid_all TYPE t_matid.

*Local constants:

CONSTANTS:

lc_tabprd TYPE tabname VALUE 'LT_DISPLAYPRD'.

* Local Data Declaration

DATA: ls_display TYPE s_display,

ls_product TYPE bapi10001key,

ls_layout TYPE slis_layout_alv,

ls_displayprd TYPE s_displayprd,

lt_displayprd TYPE t_displayprd,

lv_flg_del TYPE char1,

lv_flg_prd TYPE flag,

lv_repid TYPE syrepid,

lt_events TYPE STANDARD TABLE OF slis_alv_event,

lt_eventsprd TYPE STANDARD TABLE OF slis_alv_event,

lt_display TYPE STANDARD TABLE OF s_display,

lt_prod_1 TYPE STANDARD TABLE OF s_f4_data_loc,

lt_prod_2 TYPE STANDARD TABLE OF s_f4_data_loc,

lt_matloc TYPE STANDARD TABLE OF /sapapo/v_matloc,

lt_matlocdel TYPE STANDARD TABLE OF /sapapo/matloc,

ls_matloc TYPE /sapapo/matloc,

ls_matid TYPE s_matid.

*MOD-1771404

DATA: lv_locid type /sapapo/locid,

lv_ware_desc type /SAPAPO/LOC_DESCR40.

*MOD-1771404

* Local Date Declaration

DATA: lv_mkt TYPE char4, " Market

lv_pdctr TYPE char2, " Production center

lv_whse1 TYPE char3, " Warehouse1

lv_whse2 TYPE char3, " Warehouse2

l_wa_matloc type s_matloc.

DATA: l_wa_display type s_display.

lv_repid = sy-repid.

* Field-Symbols

FIELD-SYMBOLS: <lfs_prod> TYPE s_f4_data_loc,

<lfs_prod_data> TYPE s_f4_data_loc,

<lfs_display> TYPE s_display,

<lfs_displayprd> TYPE s_displayprd,

<lfs_matloc> TYPE /sapapo/v_matloc,

<lfs_matid> TYPE s_matid.

**MOD-1887120

* LOOP AT IT_PROD_DATA ASSIGNING <lfs_prod_data>.

* READ TABLE ct_matloc into l_wa_matloc

* WITH KEY matnr = <lfs_prod_data>-prvar

* locno = <lfs_prod_data>-locno.

* IF sy-subrc = 0.

* CLEAR: ls_display, ls_displayprd.

* ls_display-prod = <lfs_prod_data>-prvar.

* ls_display-p_des = <lfs_prod_data>-vartx.

**MOD-1771404

** ls_display-loc = <lfs_prod>-locno.

** ls_display-l_des = <lfs_prod>-desc.

**MOD-1771404

* ls_display-loc = l_wa_matloc-LOCNO.

* ls_display-l_des = lv_ware_desc.

* APPEND ls_display TO lt_display.

* <lfs_prod_data>-locno = l_wa_matloc-LOCNO.

* ENDIF.

* READ TABLE gt_product TRANSPORTING NO FIELDS

* WITH KEY product = <lfs_prod_data>-prvar.

* IF sy-subrc = 0.

* ls_displayprd-prod = <lfs_prod_data>-prvar.

* ls_displayprd-p_des = <lfs_prod_data>-vartx.

* APPEND ls_displayprd TO lt_displayprd.

* ENDIF.

* ENDLOOP.

**MOD-1887120

lt_prod_1 = it_prod_data.

lt_prod_2 = it_prod_data.

CLEAR lv_flg_del.

*MOD-1887120

* SORT lt_prod_1 BY prvar locno.

SORT lt_prod_1 BY locno pcode prvar pdctr status whse1 whse2.

* DELETE ADJACENT DUPLICATES FROM lt_prod_1 COMPARING prvar locno.

DELETE ADJACENT DUPLICATES FROM lt_prod_1 COMPARING locno

pcode

prvar

pdctr

status

whse1

whse2.

*MOD-1887120

*MOD-1887120

* SORT lt_prod_2 BY pcode locno.

SORT lt_prod_2 BY locno pcode prvar pdctr status whse1 whse2.

* DELETE ADJACENT DUPLICATES FROM lt_prod_2 COMPARING pcode locno.

DELETE ADJACENT DUPLICATES FROM lt_prod_2 COMPARING locno

pcode

prvar

pdctr

status

whse1

whse2.

*MOD-1887120

**MOD-1771404

* PERFORM F_GET_LOC_DESC USING IT_PROD_DATA

* CHANGING lv_ware_desc.

**MOD-1771404

LOOP AT lt_prod_1 ASSIGNING <lfs_prod>.

*MOD-1887120

LOOP AT S_MKT.

*MOD-1887120

READ TABLE ct_matloc TRANSPORTING NO FIELDS

WITH KEY matnr = <lfs_prod>-prvar

locno = s_mkt-low.

*MOD-1887120

* locno = <lfs_prod>-locno.

*MOD-1887120

IF sy-subrc = 0.

CLEAR: ls_display, ls_displayprd.

ls_display-prod = <lfs_prod>-prvar.

ls_display-p_des = <lfs_prod>-vartx.

*MOD-1771404

* ls_display-loc = <lfs_prod>-locno.

* ls_display-l_des = <lfs_prod>-desc.

*MOD-1771404

*MOD-1887120

ls_display-loc = S_MKT-LOW.

*MOD-1887120

*MOD-1887120

* ls_display-loc = <lfs_prod>-locno.

*MOD-1887120

**MOD-1887120

PERFORM F_GET_LOC_DESC CHANGING lv_ware_desc.

**MOD-1887120

ls_display-l_des = lv_ware_desc.

APPEND ls_display TO lt_display.

ENDIF.

READ TABLE gt_product TRANSPORTING NO FIELDS

WITH KEY product = <lfs_prod>-prvar.

IF sy-subrc = 0.

ls_displayprd-prod = <lfs_prod>-prvar.

ls_displayprd-p_des = <lfs_prod>-vartx.

APPEND ls_displayprd TO lt_displayprd.

ENDIF.

ENDLOOP.

ENDLOOP.

LOOP AT lt_prod_2 ASSIGNING <lfs_prod>.

*MOD-1887120

LOOP AT S_MKT.

*MOD-1887120

READ TABLE ct_matloc TRANSPORTING NO FIELDS

WITH KEY matnr = <lfs_prod>-pcode

locno = s_mkt-low.

*MOD-1887120

* locno = <lfs_prod>-locno.

*MOD-1887120

IF sy-subrc = 0.

CLEAR: ls_display, lv_flg_prd.

LOOP AT gt_view_data TRANSPORTING NO FIELDS

WHERE pcode = <lfs_prod>-pcode AND

status <> 'I'.

lv_flg_prd = 'X'.

ENDLOOP.

IF lv_flg_prd IS INITIAL.

ls_display-prod = <lfs_prod>-pcode.

ls_display-p_des = <lfs_prod>-maktx.

* ls_display-loc = <lfs_prod>-locno.

* ls_display-l_des = <lfs_prod>-desc.

*MOD-1887120

ls_display-loc = S_MKT-LOW.

*MOD-1887120

* ls_display-loc = <lfs_prod>-locno.

*MOD-1887120

**MOD-1887120

* PERFORM F_GET_LOC_DESC USING lt_prod_2

PERFORM F_GET_LOC_DESC CHANGING lv_ware_desc.

**MOD-1887120

ls_display-l_des = lv_ware_desc.

APPEND ls_display TO lt_display.

READ TABLE gt_product TRANSPORTING NO FIELDS

WITH KEY product = <lfs_prod>-pcode.

IF sy-subrc = 0.

ls_displayprd-prod = <lfs_prod>-pcode.

ls_displayprd-p_des = <lfs_prod>-maktx.

APPEND ls_displayprd TO lt_displayprd.

ENDIF.

ENDIF.

ENDIF.

ENDLOOP.

ENDLOOP.

LOOP AT gt_product INTO ls_product.

ls_displayprd-prod = ls_product.

FIND gc_dot IN ls_product.

IF sy-subrc = 0.

READ TABLE gt_prod_data ASSIGNING <lfs_prod>

WITH KEY prvar = ls_product-product.

IF sy-subrc = 0.

ls_displayprd-p_des = <lfs_prod>-vartx.

ENDIF.

ELSE.

READ TABLE it_prod_data ASSIGNING <lfs_prod>

WITH KEY pcode = ls_product-product.

IF sy-subrc = 0.

ls_displayprd-p_des = <lfs_prod>-maktx.

ENDIF.

ENDIF.

ENDLOOP.

SORT lt_display BY prod loc.

*MOD-1887120

DELETE ADJACENT DUPLICATES FROM lt_display

COMPARING prod loc.

*MOD-1887120

**MOD-1887120

*LOOP AT lt_display into l_wa_display.

* READ TABLE CT_MATLOC INTO L_WA_MATLOC

* WITH KEY matnr = l_wa_display-prod

* locno = l_wa_display-loc.

* IF sy-subrc ne 0.

* l_wa_display-status = 'X'.

* modify lt_display from l_wa_display transporting status.

* ENDIF.

*ENDLOOP.

*DELETE lt_display WHERE status = 'X'.

**MOD-1887120

SORT lt_displayprd BY prod.

DELETE ADJACENT DUPLICATES FROM lt_displayprd

COMPARING prod.

IF lt_display IS INITIAL.

EXIT.

ENDIF.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

EXPORTING

i_callback_program = lv_repid

i_callback_user_command = gc_show_log

i_callback_pf_status_set = gc_set_pf.

* Populate the top of page event.

PERFORM f_get_events CHANGING lt_events.

REFRESH gt_fcat.

* Populate the Field Catelog

PERFORM f_populate_fieldcat USING :

* Position Field TABLE TITLE OUTPUT_LEN JUSTIFY

gc_pos_3 gc_prodct gc_tabname text-003 gc_len_prod gc_left,

gc_pos_4 gc_prod_des gc_tabname text-004 gc_len_p_des gc_left,

gc_pos_5 gc_loctn gc_tabname text-005 gc_len_loc gc_left,

gc_pos_6 gc_loc_des gc_tabname text-006 gc_len_l_des gc_left.

* If not test mode then display status of deletion

IF p_test <> gc_set.

PERFORM f_populate_fieldcat USING :

* Position Field TABLE TITLE OUTPUT_LEN JUSTIFY

gc_pos_2 gc_status gc_tabname text-019 gc_len_stat gc_left,

gc_pos_1 gc_light gc_tabname space gc_len_lt gc_center.

SELECT *

FROM /sapapo/v_matloc

INTO TABLE lt_matloc

FOR ALL ENTRIES IN lt_display

WHERE matnr = lt_display-prod AND

locno = lt_display-loc.

*Check if the product is deleted.

LOOP AT lt_display ASSIGNING <lfs_display>.

READ TABLE lt_matloc ASSIGNING <lfs_matloc>

WITH KEY matnr = <lfs_display>-prod

locno = <lfs_display>-loc.

IF sy-subrc = 0.

<lfs_display>-status = text-020.

<lfs_display>-light = gc_red.

CLEAR <lfs_matloc>-lvorm.

MOVE-CORRESPONDING <lfs_matloc> TO ls_matloc.

APPEND ls_matloc TO lt_matlocdel.

lv_flg_del = gc_set.

ELSE.

<lfs_display>-status = text-021.

<lfs_display>-light = gc_green.

ENDIF.

ENDLOOP.

IF lv_flg_del = gc_set. " Deletion failed for atleast one prod

* Deletion failed for some products.

MODIFY /sapapo/matloc FROM TABLE lt_matlocdel.

MESSAGE s064.

ELSE.

* Deletion successful for all the products

MESSAGE s065.

ENDIF.

ENDIF. " For IF p_test <> gc_set.

* Display the ALV List Display

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

is_layout = ls_layout

it_fieldcat = gt_fcat

i_tabname = gc_tabname

it_events = lt_events

TABLES

t_outtab = lt_display

EXCEPTIONS

program_error = 1

maximum_of_appends_reached = 2

OTHERS = 3.

IF sy-subrc <> 0.

* Error in displaying end report

MESSAGE e062.

LEAVE LIST-PROCESSING.

ENDIF.

IF p_test IS INITIAL.

PERFORM f_get_events_prd CHANGING lt_eventsprd.

REFRESH gt_fcat.

* Populate the Field Catelog

PERFORM f_populate_fieldcat USING :

* Position Field TABLE TITLE OUTPUT_LEN JUSTIFY

gc_pos_3 gc_prodct lc_tabprd text-003 gc_len_prod gc_left,

gc_pos_4 gc_prod_des lc_tabprd text-004 gc_len_p_des gc_left.

IF p_test <> gc_set.

PERFORM f_populate_fieldcat USING :

* Position Field TABLE TITLE OUTPUT_LEN JUSTIFY

gc_pos_2 gc_status lc_tabprd text-019 gc_len_stat gc_left,

gc_pos_1 gc_light lc_tabprd space gc_len_lt gc_center.

* Check the Products from the /SAPAPO/MATKEY to check for deletion

SELECT matid matnr INTO TABLE ct_matid_all

FROM /sapapo/matkey

FOR ALL ENTRIES IN lt_displayprd

WHERE matnr = lt_displayprd-prod.

LOOP AT lt_displayprd ASSIGNING <lfs_displayprd>.

READ TABLE ct_matid_all INTO ls_matid

WITH KEY matnr = <lfs_displayprd>-prod.

IF sy-subrc = 0.

<lfs_displayprd>-status = text-020.

<lfs_displayprd>-light = gc_red.

lv_flg_del = gc_set.

ELSE.

<lfs_displayprd>-status = text-021.

<lfs_displayprd>-light = gc_green.

ENDIF.

ENDLOOP.

IF lv_flg_del = gc_set. " Deletion failed for atleast one prod

* Deletion failed for some products.

MESSAGE s064.

ELSE.

* Deletion successful for all the products

MESSAGE s065.

ENDIF.

ENDIF.

* Display the ALV List Display

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

is_layout = ls_layout

it_fieldcat = gt_fcat

i_tabname = lc_tabprd

it_events = lt_eventsprd

TABLES

t_outtab = lt_displayprd

EXCEPTIONS

program_error = 1

maximum_of_appends_reached = 2

OTHERS = 3.

IF sy-subrc <> 0.

* Error in displaying end report

MESSAGE e062.

LEAVE LIST-PROCESSING.

ENDIF.

ENDIF.

* Displays the ALV list

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'

EXCEPTIONS

program_error = 1

OTHERS = 2.

ENDFORM. " f_display_alv

*&---------------------------------------------------------------------*

*& Form f_get_events

*&---------------------------------------------------------------------*

* Get the TOP OF PAGE event

*----------------------------------------------------------------------*

* <--CT_EVENTS Itab with the events to be triggred

*----------------------------------------------------------------------*

FORM f_get_events CHANGING ct_events TYPE slis_t_event.

* Field Symbols

FIELD-SYMBOLS: <lfs_events> TYPE slis_alv_event.

* Collect all the events triggered

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

IMPORTING

et_events = ct_events

EXCEPTIONS

list_type_wrong = 1

OTHERS = 2.

IF sy-subrc <> 0.

EXIT.

ENDIF.

SORT ct_events BY name.

READ TABLE ct_events ASSIGNING <lfs_events>

WITH KEY name = slis_ev_top_of_page

BINARY SEARCH.

IF sy-subrc = 0.

<lfs_events>-form = slis_ev_top_of_page.

ENDIF.

ENDFORM. " f_get_events

*&---------------------------------------------------------------------*

*& Form vpopulate_fieldcat

*&---------------------------------------------------------------------*

* Populate the fieldcatelog for ALV report

*----------------------------------------------------------------------*

* -->IV_CPOS Column Position

* -->IV_FNAM Field Name

* -->IV_TABNAM Internal Table Name

* -->IV_TITLE Column Title

* -->IV_OPT_LEN Output Length

* -->IV_JUSTIFY Justify left / right

*----------------------------------------------------------------------*

FORM f_populate_fieldcat USING iv_cpos TYPE lvc_colpos

iv_fnam TYPE lvc_fname

iv_tabnam TYPE lvc_tname

iv_title TYPE reptext

iv_opt_len TYPE lvc_outlen

iv_justify TYPE lvc_just.

* Local Data Declaration

DATA: ls_fcat TYPE slis_fieldcat_alv.

CLEAR ls_fcat.

ls_fcat-col_pos = iv_cpos.

ls_fcat-fieldname = iv_fnam.

ls_fcat-tabname = iv_tabnam.

ls_fcat-reptext_ddic = iv_title.

ls_fcat-outputlen = iv_opt_len.

ls_fcat-just = iv_justify.

IF iv_fnam = gc_light.

ls_fcat-icon = gc_set.

ENDIF.

APPEND ls_fcat TO gt_fcat.

ENDFORM. " f_populate_fieldcat

*&---------------------------------------------------------------------*

*& Form F_SET_PF

*&---------------------------------------------------------------------*

* Set the PF Status for the display and log screen

*----------------------------------------------------------------------*

* -->CT_EXTAB

*----------------------------------------------------------------------*

FORM f_set_pf USING ct_extab TYPE slis_t_extab. "#EC CALLED

* Dynamic perform required to set custom PF status for ALV report

"#EC *

* CT_EXTAB is required as per the standard exit perform of ALVgrid fm

* Local Data Declation.

DATA: ls_extab TYPE slis_extab,

lt_extab TYPE STANDARD TABLE OF slis_extab.

* If the Test Run check box is selected then disable the Log Icons

IF p_test = gc_set.

ls_extab-fcode = gc_td_log.

APPEND ls_extab TO lt_extab.

CLEAR ls_extab.

SET PF-STATUS 'PF_DISPLAY_LOG' EXCLUDING lt_extab.

ENDIF.

IF gt_tlane IS INITIAL.

ls_extab-fcode = gc_tlane.

APPEND ls_extab TO lt_extab.

CLEAR ls_extab.

ENDIF.

SET PF-STATUS 'PF_DISPLAY_LOG' EXCLUDING lt_extab.

ENDFORM. " F_SET_PF

*&---------------------------------------------------------------------*

*& Form f_show_log

*&---------------------------------------------------------------------*

* Display Log report using

*----------------------------------------------------------------------*

* --> iv_ucomm OK Code for the user command

* --> is_selfield Selected field information

*----------------------------------------------------------------------*

FORM f_show_log USING iv_ucomm TYPE sy-ucomm

is_selfield TYPE slis_selfield. "#EC CALLED

* Dynamic perform for displaying log based on user action

"#EC *

* IS_SELFIELD is passed as per the standard exit perform for ALVgrid

IF iv_ucomm = gc_td_log.

* Local Data Delaration.

DATA: lt_msg_dtl TYPE STANDARD TABLE OF bdcmsgcoll,

lv_mode TYPE char1,

lv_error TYPE char1,

lv_date TYPE char10,

lv_time TYPE char8,

lv_date_to TYPE char10,

lv_time_to TYPE char8.

* Field-Symbols

FIELD-SYMBOLS: <lfs_msg_dtl> TYPE bdcmsgcoll.

REFRESH gt_bdc_tab.

CLEAR: lv_date, lv_time.

CONCATENATE gv_date_before+6(2) gv_date_before+4(2)

gv_date_before+0(4) INTO lv_date SEPARATED BY gc_dot.

CONCATENATE gv_time_before+0(2) gv_time_before+2(2)

gv_time_before+4(2) INTO lv_time SEPARATED BY gc_colon.

CONCATENATE sy-datum+6(2) sy-datum+4(2)

sy-datum+0(4) INTO lv_date_to SEPARATED BY gc_dot.

CONCATENATE sy-uzeit+0(2) sy-uzeit+2(2)

sy-uzeit+4(2) INTO lv_time_to SEPARATED BY gc_colon.

* Populate the BDC Table for SLG1 Transaction

PERFORM f_populate_bdc_tab USING:

'X' 'SAPLSLG3' '0100',

' ' 'BDC_CURSOR' 'BALHDR-ALPROG',

* ' ' 'BDC_OKCODE' '=SELE',

' ' 'BALHDR-OBJECT' '*',

' ' 'BALHDR-SUBOBJECT' '*',

' ' 'BALHDR-EXTNUMBER' '*',

' ' 'BALHDR-ALDATE' lv_date,

' ' 'BALHDR-ALTIME' lv_time,

' ' '*BALHDR-ALDATE' lv_date_to,

' ' '*BALHDR-ALTIME' lv_time_to,

' ' 'BALHDR-ALUSER' sy-uname,

' ' 'BALHDR-ALTCODE' '*',

' ' 'BALHDR-ALPROG' '*',

' ' 'MODE_ALL' 'X',

' ' 'PROBCLASS_4' 'X'.

CLEAR lv_error.

lv_mode = gc_foreground.

* Call Transaction SLG1 for displaying the LOG for the action.

CALL TRANSACTION gc_slg1 USING gt_bdc_tab MODE lv_mode

MESSAGES INTO lt_msg_dtl.

LOOP AT lt_msg_dtl ASSIGNING <lfs_msg_dtl> WHERE

msgtyp = gc_error OR

msgtyp = gc_abend.

lv_error = gc_set.

EXIT.

ENDLOOP.

IF lv_error = gc_set.

* Error while displaying Log.

MESSAGE i049.

ENDIF.

ELSEIF iv_ucomm = gc_tlane.

* Display Tlane deletion data.

PERFORM f_display_tlane USING gt_tlane.

ENDIF.

ENDFORM. " f_show_log

*&---------------------------------------------------------------------*

*& Form top_of_page

*&---------------------------------------------------------------------*

* Write Header details in the TOP OF PAGE for ALV report

*----------------------------------------------------------------------*

FORM top_of_page. "#EC CALLED

* Dynamic perform for displaying the Top of Page heading in ALV report

* Local Data Declaration

DATA: lv_time TYPE char8,

lv_date TYPE char10.

REFRESH gt_top_page.

CLEAR: lv_time,lv_date.

CONCATENATE sy-datum+6(2) sy-datum+4(2) sy-datum+0(4) INTO lv_date

SEPARATED BY gc_dot.

CONCATENATE sy-uzeit+0(2) sy-datum+2(2) sy-datum+4(2) INTO lv_time

SEPARATED BY gc_dot.

* Populate the Header

PERFORM f_populate_top_page USING:

gs_type_h gc_space text-015,

gs_type_s text-007 sy-uname,

gs_type_s text-008 lv_date,

gs_type_s text-009 lv_time,

gs_type_s gc_space gc_space.

* If Test Run then select

IF p_test = gc_set. " IF test run

PERFORM f_populate_top_page USING:

gs_type_a text-010 text-013,

gs_type_a space text-014.

ELSEIF gv_msg_error = gc_set. "IF error in call trns

PERFORM f_populate_top_page USING:

gs_type_a text-010 text-018.

ELSEIF gv_flg_error = gc_set. " IF error in deletion

PERFORM f_populate_top_page USING:

gs_type_a text-010 text-012.

ELSEIF gv_flg_error <> gc_set. " IF no error

PERFORM f_populate_top_page USING:

gs_type_a text-010 text-011.

ENDIF.

* Write the Header in the TOP OF PAGE of ALV

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = gt_top_page.

ENDFORM. " top_of_page

*&---------------------------------------------------------------------*

*& Form f_populate_top_page

*&---------------------------------------------------------------------*

* Populate the Header for ALV top of page with parameters passed

*----------------------------------------------------------------------*

* -->IV_TYPE Line Type

* -->IV_KEY Key

* -->IV_INFO Info to be printed

*----------------------------------------------------------------------*

FORM f_populate_top_page USING iv_type TYPE char1

iv_key TYPE any

iv_info TYPE any.

* Local Data Declaration

DATA: ls_top_page TYPE slis_listheader.

CLEAR ls_top_page.

ls_top_page-typ = iv_type.

ls_top_page-key = iv_key.

ls_top_page-info = iv_info.

APPEND ls_top_page TO gt_top_page.

ENDFORM. " f_populate_top_page

*&---------------------------------------------------------------------*

*& Form f_populate_range_table_LOCID

*&---------------------------------------------------------------------*

* Populate the Range thable wiht the values passed

*----------------------------------------------------------------------*

* -->IV_VALUE_LOW Lower Value of the Range

* <--CT_RANGE_TAB Table of type Range

*----------------------------------------------------------------------*

FORM f_populate_range_table_locid USING iv_value_low TYPE any

CHANGING ct_range_tab TYPE t_locid_range.

* Local Data Declaration

DATA: ls_locid TYPE s_range_locid.

ls_locid-sign = gc_sign_i.

ls_locid-option = gc_option_eq.

ls_locid-low = iv_value_low.

APPEND ls_locid TO ct_range_tab.

CLEAR ls_locid.

ENDFORM. " f_populate_range_table_LOCID

*&---------------------------------------------------------------------*

*& Form f_display_tlane

*&---------------------------------------------------------------------*

* Display Transportation lane deletion data

*----------------------------------------------------------------------*

* -->CT_TLANE Itab with details of Tlane deleted

*----------------------------------------------------------------------*

FORM f_display_tlane USING ct_tlane TYPE t_tlane_data.

* Local Data Declaration

DATA: lt_tl_events TYPE STANDARD TABLE OF slis_alv_event.

* Populate the top of page event.

PERFORM f_get_events_tl CHANGING lt_tl_events.

REFRESH gt_fcat.

*MOD-1887120

SORT CT_TLANE BY LOCFR LOCTO MATID.

*MOD-1887120

* Populate the Field Catelog

PERFORM f_populate_fieldcat USING :

* Position Field TABLE TITLE OUTPUT_LEN JUSTIFY

gc_pos_1 gc_locfr gc_tl_tab text-023 gc_len_l_des gc_left,

gc_pos_2 gc_locto gc_tl_tab text-024 gc_len_l_des gc_left,

gc_pos_3 gc_prod_tl gc_tl_tab text-022 gc_len_l_des gc_left.

* Display the ALV Grid Display

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

it_fieldcat = gt_fcat

i_save = gc_save

it_events = lt_tl_events

TABLES

t_outtab = ct_tlane

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

* Error in displaying end report

MESSAGE e062.

LEAVE LIST-PROCESSING.

ENDIF.

ENDFORM. " f_display_tlane

*&---------------------------------------------------------------------*

*& Form f_get_events_tl

*&---------------------------------------------------------------------*

* Get event top of page for Tlane report

*----------------------------------------------------------------------*

* <--CT_EVENTS Itab for top of page

*----------------------------------------------------------------------*

FORM f_get_events_tl CHANGING ct_events TYPE slis_t_event.

* Field Symbols

FIELD-SYMBOLS: <lfs_events> TYPE slis_alv_event.

* Collect all the events triggered

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

IMPORTING

et_events = ct_events

EXCEPTIONS

list_type_wrong = 1

OTHERS = 2.

IF sy-subrc <> 0.

EXIT.

ENDIF.

SORT ct_events BY name.

READ TABLE ct_events ASSIGNING <lfs_events>

WITH KEY name = slis_ev_top_of_page

BINARY SEARCH.

IF sy-subrc = 0.

<lfs_events>-form = gc_lt_top.

ENDIF.

ENDFORM. " f_get_events_tl

*&---------------------------------------------------------------------*

*& Form F_TOP_TL

*&---------------------------------------------------------------------*

* Write Header details in the TOP OF PAGE for TLANE report

*----------------------------------------------------------------------*

FORM f_top_tl. "#EC CALLED

* Dynamic perform for displaying the Top of Page heading in ALV report

* Local Data Declaration

DATA: lv_time TYPE char8,

lv_date TYPE char10.

REFRESH gt_top_page.

CLEAR: lv_time,lv_date.

CONCATENATE sy-datum+6(2) sy-datum+4(2) sy-datum+0(4) INTO lv_date

SEPARATED BY gc_dot.

CONCATENATE sy-uzeit+0(2) sy-datum+2(2) sy-datum+4(2) INTO lv_time

SEPARATED BY gc_dot.

* Populate the Header

PERFORM f_populate_top_page USING:

gs_type_h gc_space text-025,

gs_type_s text-007 sy-uname,

gs_type_s text-008 lv_date,

gs_type_s text-009 lv_time,

gs_type_s gc_space gc_space.

IF p_test IS INITIAL.

PERFORM f_populate_top_page USING:

gs_type_a text-010 text-026.

ELSE.

PERFORM f_populate_top_page USING:

gs_type_a text-010 text-041.

ENDIF.

* Write the Header in the TOP OF PAGE of ALV

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = gt_top_page.

ENDFORM. " F_TOP_TL

*&---------------------------------------------------------------------*

*& Form f_adj_screen_flds

*&---------------------------------------------------------------------*

* Adjusts the screen fields

*----------------------------------------------------------------------*

FORM f_adj_screen_flds .

*MOD-1771404 by Aveek

* IF p_mdel IS INITIAL.

* LOOP AT SCREEN.

* IF screen-name = 'P_LOG' OR

* screen-name = 'S_PRD-LOW' OR

* screen-name = 'S_PRD-HIGH' OR

* screen-name = 'S_MKT-LOW' OR

* screen-name = 'S_MKT-HIGH' OR

* screen-name = 'P_TEST'.

* screen-input = 0.

* REFRESH: s_prd, s_mkt.

* MODIFY SCREEN.

* ENDIF.

* ENDLOOP.

* ENDIF.

* IF p_tlan IS INITIAL.

* LOOP AT SCREEN.

* IF screen-name = 'P_SRC' OR

* screen-name = 'P_DES' OR

* screen-name = 'P_PRD' OR

* screen-name = 'P_TDAT' OR

* screen-name = 'P_TPRD' OR

* screen-name = 'P_FRD' OR

* screen-name = 'P_TOD'.

* screen-input = 0.

* CLEAR: p_src, p_des, p_prd.

* MODIFY SCREEN.

* ENDIF.

* ENDLOOP.

* ENDIF.

*

* IF p_tdat IS INITIAL.

* LOOP AT SCREEN.

* IF screen-name = 'P_FRD' OR

* screen-name = 'P_TOD'.

* screen-input = 0.

* CLEAR: p_frd, p_tod.

* MODIFY SCREEN.

* ENDIF.

* ENDLOOP.

* ENDIF.

***MOD-1771404 by Aveek

ENDFORM. " f_adj_screen_flds

*&---------------------------------------------------------------------*

*& Form f_update_tlane

*&---------------------------------------------------------------------*

* Updates transportation lane

*----------------------------------------------------------------------*

**MOD-1771404 by Aveek

FORM f_update_tlane .

CONSTANTS:

lc_stime TYPE t VALUE '000000',

lc_etime TYPE t VALUE '235959',

lc_utc TYPE timezone VALUE 'UTC'.

DATA:

lv_dummy TYPE /sapapo/c_loctype,

lv_valfr TYPE timestamp,

lv_valto TYPE timestamp,

lv_matid TYPE /sapapo/matid,

lv_srcid TYPE /sapapo/locid,

lv_desid TYPE /sapapo/locid.

DATA:

lt_trprod TYPE STANDARD TABLE OF /sapapo/trprod,

lt_matid TYPE t_matid,

ls_matid TYPE s_matid,

lt_tlaneupd TYPE t_tlaneupd,

ls_tlaneupd TYPE s_tlaneupd.

FIELD-SYMBOLS:

<lfs_trprod> TYPE /sapapo/trprod.

PERFORM f_get_locid_for_loc USING p_src

CHANGING lv_srcid

lv_dummy.

PERFORM f_get_locid_for_loc USING p_des

CHANGING lv_desid

lv_dummy.

PERFORM f_get_matid_for_prod USING p_prd

CHANGING lv_matid.

ls_matid-matid = lv_matid.

ls_matid-matnr = p_prd.

APPEND ls_matid TO lt_matid.

SELECT b~matid a~prvar

APPENDING TABLE lt_matid

FROM zap_sign AS a JOIN

/sapapo/matkey AS b

ON a~prvar = b~matnr

WHERE pcode = p_prd AND

( pdctr = p_src OR

whse1 = p_src OR

whse2 = p_src ) AND

( whse1 = p_des OR

whse2 = p_des OR

markt = p_des ).

**MOD-1771404 Changed code

* SELECT b~matid a~prvar

* APPENDING TABLE lt_matid

* FROM zm_zap_sign AS a JOIN

* /sapapo/matkey AS b

* ON a~prvar = b~matnr

* WHERE pcode = p_prd AND

* ( markt = p_src or

* pdctr = p_src OR

* whse1 = p_src OR

* whse2 = p_src ) OR

* ( pdctr = p_des OR

* whse1 = p_des OR

* whse2 = p_des OR

* markt = p_des ).

*MOD-1771404

IF sy-subrc <> 0.

MESSAGE i072 WITH p_prd p_src p_des.

LEAVE LIST-PROCESSING.

ENDIF.

SELECT * INTO TABLE lt_trprod

FROM /sapapo/trprod

FOR ALL ENTRIES IN lt_matid

WHERE locfr = lv_srcid AND

locto = lv_desid AND

matid = lt_matid-matid.

*MOD-1771404

* SELECT * INTO TABLE lt_trprod

* FROM /sapapo/trprod

* FOR ALL ENTRIES IN lt_matid

* WHERE ( locfr = lv_srcid OR

* locfr = lv_desid ) AND

* matid = lt_matid-matid OR

* ( locto = lv_srcid OR

* locto = lv_desid ) AND

* matid = lt_matid-matid.

*MOD-1771404

IF sy-subrc <> 0.

MESSAGE i067 WITH p_src p_des p_prd.

LEAVE LIST-PROCESSING.

ENDIF.

* Change of validity dates

IF p_tdat IS NOT INITIAL.

IF p_frd IS INITIAL OR p_tod IS INITIAL.

MESSAGE i070.

LEAVE LIST-PROCESSING.

ELSE.

IF p_frd > p_tod.

MESSAGE i071.

LEAVE LIST-PROCESSING.

ENDIF.

ENDIF.

CONVERT: DATE p_frd TIME lc_stime

INTO TIME STAMP lv_valfr TIME ZONE lc_utc,

DATE p_tod TIME lc_etime

INTO TIME STAMP lv_valto TIME ZONE lc_utc.

LOOP AT lt_trprod ASSIGNING <lfs_trprod>.

<lfs_trprod>-valfr = lv_valfr.

<lfs_trprod>-valto = lv_valto.

ENDLOOP.

*MOD-1771404

MODIFY /sapapo/trprod FROM TABLE lt_trprod.

*MOD-1771404

IF sy-subrc = 0.

COMMIT WORK AND WAIT.

MESSAGE s068 WITH p_src p_des p_prd.

ENDIF.

ENDIF.

* Removal of product assignment

IF p_tprd IS NOT INITIAL.

*MOD-1771404

DELETE /sapapo/trprod FROM TABLE lt_trprod.

*MOD-1771404

IF sy-subrc = 0.

COMMIT WORK AND WAIT.

MESSAGE s069 WITH p_prd p_src p_des.

ENDIF.

ENDIF.

* Display the lanes updated in an ALV

CLEAR ls_tlaneupd.

ls_tlaneupd-locfr = p_src.

ls_tlaneupd-locto = p_des.

IF p_tdat IS NOT INITIAL.

ls_tlaneupd-msg = text-034.

ELSE.

ls_tlaneupd-msg = text-035.

ENDIF.

LOOP AT lt_matid INTO ls_matid.

ls_tlaneupd-matnr = ls_matid-matnr.

APPEND ls_tlaneupd TO lt_tlaneupd.

ENDLOOP.

*MOD-1771404

* LOOP AT lt_trprod INTO ls_trprod.

* CALL FUNCTION '/SAPAPO/DM_MATID_GET_MATERIAL'

* EXPORTING

* iv_matid = ls_trprod-matid

* iv_langu = sy-langu

* IMPORTING

* ev_matnr = lv_matnr.

*

* ls_tlaneupd-matnr = lv_matnr.

* ls_tlaneupd-locfr

* ls_tlaneupd-locto

* ls_tlaneupd-matnr

* ls_tlaneupd-matid

*

*

* APPEND ls_tlaneupd TO lt_tlaneupd.

* ENDLOOP.

*

* ls_tlaneupd-matnr = ls_matid-matnr.

* APPEND ls_tlaneupd TO lt_tlaneupd.

* ENDLOOP.

*MOD-1771404

PERFORM display_alv_tlaneupd USING lt_tlaneupd.

ENDFORM. " f_update_tlane

***MOD-1771404 by Aveek

*&---------------------------------------------------------------------*

*& Form display_alv_tlaneupd

*&---------------------------------------------------------------------*

* Displays the ALV for updated Tlane

*----------------------------------------------------------------------*

* -->IT_TLANEUPD Tlane table

*----------------------------------------------------------------------*

FORM display_alv_tlaneupd USING it_tlaneupd TYPE t_tlaneupd.

* Local Data Declaration

DATA: lt_tl_events TYPE STANDARD TABLE OF slis_alv_event.

* Populate the top of page event.

PERFORM f_get_events_tlupd CHANGING lt_tl_events.

REFRESH gt_fcat.

* Populate the Field Catelog

PERFORM f_populate_fieldcat USING :

* Position Field TABLE TITLE OUTPUT_LEN JUSTIFY

gc_pos_1 gc_locfr gc_tl_tabu text-023 gc_len_l_des gc_left,

gc_pos_2 gc_locto gc_tl_tabu text-024 gc_len_l_des gc_left,

gc_pos_3 gc_matnr gc_tl_tabu text-022 gc_len_l_des gc_left,

gc_pos_4 gc_msg gc_tl_tabu text-036 gc_len_l_des gc_left.

* Display the ALV Grid Display

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

it_fieldcat = gt_fcat

i_save = gc_save

it_events = lt_tl_events

TABLES

t_outtab = it_tlaneupd

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

* Error in displaying end report

MESSAGE e062.

LEAVE LIST-PROCESSING.

ENDIF.

ENDFORM. " display_alv_tlaneupd

*&---------------------------------------------------------------------*

*& Form f_get_events_tlupd

*&---------------------------------------------------------------------*

* Gets the events tab

*----------------------------------------------------------------------*

* <--CT_EVENTS Event table

*----------------------------------------------------------------------*

FORM f_get_events_tlupd CHANGING ct_events TYPE slis_t_event.

* Field Symbols

FIELD-SYMBOLS: <lfs_events> TYPE slis_alv_event.

* Collect all the events triggered

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

IMPORTING

et_events = ct_events

EXCEPTIONS

list_type_wrong = 1

OTHERS = 2.

IF sy-subrc <> 0.

EXIT.

ENDIF.

SORT ct_events BY name.

READ TABLE ct_events ASSIGNING <lfs_events>

WITH KEY name = slis_ev_top_of_page

BINARY SEARCH.

IF sy-subrc = 0.

<lfs_events>-form = gc_tlupd_top.

ENDIF.

ENDFORM. " f_get_events_tlupd

*&---------------------------------------------------------------------*

*& Form F_TOP_TLUPD

*&---------------------------------------------------------------------*

* Write Header details in the TOP OF PAGE for TLANE report

*----------------------------------------------------------------------*

FORM f_top_tlupd. "#EC CALLED

* Dynamic perform for displaying the Top of Page heading in ALV report

* Local Data Declaration

DATA: lv_time TYPE char8,

lv_date TYPE char10.

REFRESH gt_top_page.

CLEAR: lv_time,lv_date.

CONCATENATE sy-datum+6(2) sy-datum+4(2) sy-datum+0(4) INTO lv_date

SEPARATED BY gc_dot.

CONCATENATE sy-uzeit+0(2) sy-datum+2(2) sy-datum+4(2) INTO lv_time

SEPARATED BY gc_dot.

* Populate the Header

PERFORM f_populate_top_page USING:

gs_type_h gc_space text-037,

gs_type_s text-007 sy-uname,

gs_type_s text-008 lv_date,

gs_type_s text-009 lv_time,

gs_type_s gc_space gc_space,

gs_type_a text-010 text-038.

* Write the Header in the TOP OF PAGE of ALV

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = gt_top_page.

ENDFORM. " F_TOP_TLUPD

*&---------------------------------------------------------------------*

*& Form f_get_events_prd

*&---------------------------------------------------------------------*

* Gets the events for product

*----------------------------------------------------------------------*

* <--CT_EVENTS Events table

*----------------------------------------------------------------------*

FORM f_get_events_prd CHANGING ct_events TYPE slis_t_event.

* Field Symbols

FIELD-SYMBOLS: <lfs_events> TYPE slis_alv_event.

* Collect all the events triggered

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

IMPORTING

et_events = ct_events

EXCEPTIONS

list_type_wrong = 1

OTHERS = 2.

IF sy-subrc <> 0.

EXIT.

ENDIF.

SORT ct_events BY name.

READ TABLE ct_events ASSIGNING <lfs_events>

WITH KEY name = slis_ev_top_of_page

BINARY SEARCH.

IF sy-subrc = 0.

<lfs_events>-form = gc_prd_top.

ENDIF.

ENDFORM. " f_get_events_prd

*&---------------------------------------------------------------------*

*& Form F_TOP_PRD

*&---------------------------------------------------------------------*

* Write Header details in the TOP OF PAGE for TLANE report

*----------------------------------------------------------------------*

FORM f_top_prd. "#EC CALLED

* Dynamic perform for displaying the Top of Page heading in ALV report

* Local Data Declaration

DATA: lv_time TYPE char8,

lv_date TYPE char10.

REFRESH gt_top_page.

CLEAR: lv_time,lv_date.

CONCATENATE sy-datum+6(2) sy-datum+4(2) sy-datum+0(4) INTO lv_date

SEPARATED BY gc_dot.

CONCATENATE sy-uzeit+0(2) sy-datum+2(2) sy-datum+4(2) INTO lv_time

SEPARATED BY gc_dot.

* Populate the Header

PERFORM f_populate_top_page USING:

gs_type_s gc_space gc_space.

IF p_test IS NOT INITIAL.

PERFORM f_populate_top_page USING

gs_type_a text-010 text-039.

ELSE.

PERFORM f_populate_top_page USING

gs_type_a text-010 text-040.

ENDIF.

* Write the Header in the TOP OF PAGE of ALV

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = gt_top_page.

ENDFORM. " F_TOP_TLUPD

*&---------------------------------------------------------------------*

*& Form launch_WUF

*&---------------------------------------------------------------------*

* Launches the WUF

*----------------------------------------------------------------------*

* -->IT_CORE_PROD Core product

* -->IT_PROD_VAR Product variant

*----------------------------------------------------------------------*

FORM launch_wuf USING it_core_prod TYPE t_f4_data_loc

it_prod_var TYPE t_f4_data_loc.

CONSTANTS:

lc_rscsel TYPE fieldname VALUE 'RSCSEL-SLOW_I'.

DATA: lv_ctu_params TYPE ctu_params,

lv_fname TYPE dynfnam,

lv_count(2) TYPE n,

lt_msg_tab TYPE STANDARD TABLE OF bdcmsgcoll.

* Field-symbols

FIELD-SYMBOLS: <lfs_msg_ret> TYPE bdcmsgcoll,

<lfs_data> TYPE s_f4_data_loc.

PERFORM f_populate_bdc_tab USING:

'X' 'SAPLWUF_SELECTION' '0100',

space 'BDC_OKCODE' '=OBSEL',

space 'WUF_OBJ_NAME_STRUC-NAME' 'Location Product',

'X' 'SAPLWUF_SELECTION' '0100',

space 'BDC_OKCODE' '=MORE__1',

space 'WUF_OPT_FIELDS-DISPLAY_DEPS' 'X',

space 'BDC_CURSOR' 'WUF_SEL_FIELDS-LOW__1',

space 'WUF_SEL_FIELDS-FIELDNAMETXT__1' 'Product',

'X' 'SAPLALDB' '3000',

space 'BDC_OKCODE' '=ACPT'.

CLEAR lv_count.

LOOP AT it_core_prod ASSIGNING <lfs_data>.

lv_count = lv_count + 1.

CONCATENATE lc_rscsel gc_l_brac lv_count gc_r_brac INTO lv_fname.

PERFORM f_populate_bdc_tab USING:

' ' lv_fname <lfs_data>-pcode.

CLEAR lv_fname.

ENDLOOP.

LOOP AT it_prod_var ASSIGNING <lfs_data>.

lv_count = lv_count + 1.

CONCATENATE lc_rscsel gc_l_brac lv_count gc_r_brac INTO lv_fname.

PERFORM f_populate_bdc_tab USING:

' ' lv_fname <lfs_data>-prvar.

CLEAR lv_fname.

ENDLOOP.

PERFORM f_populate_bdc_tab USING:

'X' 'SAPLWUF_SELECTION' '0100',

space 'BDC_OKCODE' '=EXEC_DIR',

'X' 'SAPMSSY0' '0120',

space 'BDC_OKCODE' '=&F15',

'X' 'SAPLWUF_SELECTION' '0100',

space 'BDC_OKCODE' '=EXIT'.

lv_ctu_params-nobinpt = space.

lv_ctu_params-dismode = 'E'.

lv_ctu_params-updmode = 'S'.

lv_ctu_params-racommit = 'X'.

CALL TRANSACTION 'WUF' USING gt_bdc_tab OPTIONS FROM lv_ctu_params

MESSAGES INTO lt_msg_tab.

ENDFORM. " launch_WUF

*&---------------------------------------------------------------------*

*& Form f_retrieve_masterdata

*&---------------------------------------------------------------------*

* Gets the master data from the SIGN portfolio meeting the

* user selection

*----------------------------------------------------------------------*

* <--ET_MASTERDATA Master data table

*----------------------------------------------------------------------*

FORM f_retrieve_masterdata CHANGING et_masterdata TYPE t_masterdata

et_tship TYPE t_tship

et_whse TYPE t_whse.

DATA:

lt_masterdata TYPE t_masterdata,

lt_tship TYPE t_tship,

ls_tship TYPE s_tship,

ls_whse TYPE s_whse.

SELECT * INTO TABLE et_masterdata

FROM zap_scmpf

WHERE ( pcode = p_prd ) AND

( markt = p_src or

pdctr = p_src ) OR

( pdctr = p_des OR

markt = p_des ) AND

delfl = space.

IF sy-subrc <> 0.

* No sourcing info is maintained for the user selection

MESSAGE i018.

LEAVE LIST-PROCESSING.

ENDIF.

* Obtaining all the possible transhipments in the sourcing

lt_masterdata = et_masterdata.

DELETE lt_masterdata WHERE whind IS INITIAL.

IF lt_masterdata IS INITIAL.

EXIT.

ENDIF.

** MOD-1771404

SELECT * INTO TABLE et_tship

FROM zap_tshpt

FOR ALL ENTRIES IN lt_masterdata

WHERE markt = lt_masterdata-markt AND

( pcode = lt_masterdata-pcode OR

pcode = lt_masterdata-prvar ). " AND

* pcode = lt_masterdata-pcode AND

* pdctr = lt_masterdata-pdctr.

** MOD-1771404

IF sy-subrc = 0.

SORT et_tship BY markt pcode pdctr altscn sloc dloc.

DELETE ADJACENT DUPLICATES FROM et_tship

COMPARING markt pcode pdctr altscn sloc dloc.

lt_tship = et_tship.

SORT lt_tship BY sloc dloc.

DELETE ADJACENT DUPLICATES FROM lt_tship

COMPARING sloc dloc.

LOOP AT lt_tship INTO ls_tship.

CLEAR ls_whse.

ls_whse-whse = ls_tship-sloc.

APPEND ls_whse TO et_whse.

IF ls_tship-dloc IS INITIAL.

CONTINUE.

ENDIF.

CLEAR ls_whse.

ls_whse-whse = ls_tship-dloc.

APPEND ls_whse TO et_whse.

ENDLOOP.

SORT et_whse BY whse.

DELETE ADJACENT DUPLICATES FROM et_whse

COMPARING whse.

ENDIF.

ENDFORM. " f_retrieve_masterdata

*&---------------------------------------------------------------------*

*& Form f_collect_tlanes

*&---------------------------------------------------------------------*

* Collects all possible transportation lanes

*----------------------------------------------------------------------*

* -->IT_MASTERDATA Master data table

* -->IT_LOCATION Location table

* -->IT_PRODUCT Product table

* <--ET_TLANE Transportation lane table

*----------------------------------------------------------------------*

FORM f_collect_tlanes USING it_masterdata TYPE t_masterdata

it_tship TYPE t_tship

it_location TYPE t_location

it_product TYPE t_product

CHANGING et_tlane TYPE t_tlane.

CONSTANTS:

lc_stime TYPE t VALUE '000000',

lc_etime TYPE t VALUE '235959',

lc_utc TYPE timezone VALUE 'UTC'.

DATA:

lv_dummy TYPE /sapapo/c_loctype,

lv_valfr TYPE timestamp,

lv_valto TYPE timestamp,

lv_matid TYPE /sapapo/matid,

lv_srcid TYPE /sapapo/locid,

lv_desid TYPE /sapapo/locid.

DATA:

lt_trprod TYPE STANDARD TABLE OF /sapapo/trprod,

lt_matid TYPE t_matid,

ls_matid TYPE s_matid,

lt_tlaneupd TYPE t_tlaneupd,

ls_tlaneupd TYPE s_tlaneupd.

FIELD-SYMBOLS:

<lfs_trprod> TYPE /sapapo/trprod.

DATA:

ls_tlane TYPE s_tlane.

DATA: LV_EXIST type i.

DATA:

lv_dtfrmin TYPE timestamp,

lv_dttomax TYPE timestamp,

lv_tabix TYPE sytabix,

lv_locfr TYPE /sapapo/locno,

lv_locto TYPE /sapapo/locno,

lv_matnr TYPE /sapapo/matnr.

DATA:

ls_masterdata TYPE zap_scmpf.

FIELD-SYMBOLS:

<lfs_tlanetmp> TYPE s_tlane,

<lfs_tlane> TYPE s_tlane.

LOOP AT it_masterdata INTO ls_masterdata

WHERE status = 'P' OR

status = 'A'.

* Check if the core product exists in the data base

READ TABLE it_product TRANSPORTING NO FIELDS

WITH KEY matnr = ls_masterdata-pcode

BINARY SEARCH.

IF sy-subrc <> 0.

* Core product exists, find the tlanes involving it

PERFORM f_find_tlane_comb USING ls_masterdata

it_tship

gc_core

it_location

CHANGING et_tlane.

ELSE.

*MOD-1771404

* Product doesnt exist in database, update log

lv_locfr = ls_masterdata-pdctr.

lv_locto = ls_masterdata-markt.

lv_matnr = ls_masterdata-pcode.

PERFORM f_update_log_table USING gc_msgid

gc_err

gc_msgno_028

lv_locfr lv_locto lv_matnr

space space

CHANGING gt_log_tlane.

*MOD-1771404

ENDIF.

* Check if the variant exists in the data base

READ TABLE it_product TRANSPORTING NO FIELDS

WITH KEY matnr = ls_masterdata-prvar

BINARY SEARCH.

IF sy-subrc <> 0.

* Variant exists, find the tlanes involving it

PERFORM f_find_tlane_comb USING ls_masterdata

it_tship

gc_var

it_location

CHANGING et_tlane.

ELSE.

*MOD-1771404

* Product doesnt exist in database, update log

lv_locfr = ls_masterdata-pdctr.

lv_locto = ls_masterdata-markt.

lv_matnr = ls_masterdata-prvar.

PERFORM f_update_log_table USING gc_msgid

gc_err

gc_msgno_029

lv_locfr lv_locto lv_matnr

space space

CHANGING gt_log_tlane.

ENDIF.

*MOD-1771404

ENDLOOP.

*MOD-1771404

IF et_tlane IS INITIAL.

* The location(s)/product(s) not available in the db for tlane creation

MESSAGE i023.

PERFORM f_update_log_table USING gc_msgid

gc_err

gc_msgno_023

space space space

space space

CHANGING gt_log_tlane.

EXIT.

ENDIF.

*MOD-1771404

SORT et_tlane BY locfr locto matnr datfr datto.

DELETE ADJACENT DUPLICATES FROM et_tlane

COMPARING locfr locto matnr datfr datto.

READ TABLE et_tlane ASSIGNING <lfs_tlane> INDEX 1.

lv_dtfrmin = <lfs_tlane>-datfr.

lv_dttomax = <lfs_tlane>-datto.

LOOP AT et_tlane ASSIGNING <lfs_tlane>.

IF <lfs_tlane>-datfr < lv_dtfrmin.

lv_dtfrmin = <lfs_tlane>-datfr.

ENDIF.

IF <lfs_tlane>-datto > lv_dttomax.

lv_dttomax = <lfs_tlane>-datto.

ENDIF.

AT END OF matnr.

<lfs_tlane>-datfr = lv_dtfrmin.

<lfs_tlane>-datto = lv_dttomax.

lv_tabix = sy-tabix + 1.

READ TABLE et_tlane ASSIGNING <lfs_tlanetmp> INDEX lv_tabix.

IF sy-subrc = 0.

lv_dtfrmin = <lfs_tlanetmp>-datfr.

lv_dttomax = <lfs_tlanetmp>-datto.

ENDIF.

ENDAT.

ENDLOOP.

SORT et_tlane BY locfr locto matnr datfr ASCENDING datto DESCENDING.

DELETE ADJACENT DUPLICATES FROM et_tlane

COMPARING locfr locto matnr.

** Get the internal guids for material and locations

LOOP AT et_tlane ASSIGNING <lfs_tlane>.

PERFORM f_get_locid_from_locno USING <lfs_tlane>-locfr

CHANGING <lfs_tlane>-lidfr.

PERFORM f_get_locid_from_locno USING <lfs_tlane>-locto

CHANGING <lfs_tlane>-lidto.

PERFORM f_get_matid_from_matnr USING <lfs_tlane>-matnr

CHANGING <lfs_tlane>-matid.

ENDLOOP.

PERFORM f_get_locid_for_loc USING p_src

CHANGING lv_srcid

lv_dummy.

PERFORM f_get_locid_for_loc USING p_des

CHANGING lv_desid

lv_dummy.

PERFORM f_get_matid_for_prod USING p_prd

CHANGING lv_matid.

ls_matid-matid = lv_matid.

ls_matid-matnr = p_prd.

APPEND ls_matid TO lt_matid.

loop at et_tlane into ls_tlane.

READ TABLE lt_matid TRANSPORTING NO FIELDS

WITH KEY matnr = ls_tlane-matnr

BINARY SEARCH.

IF sy-subrc <> 0.

lv_exist = 1.

modify et_tlane from ls_tlane transporting lv_exist.

endif.

endloop.

delete et_tlane where lv_exist = 1.

ENDFORM. " f_collect_tlanes

*&---------------------------------------------------------------------*

*& Form f_find_tlane_comb

*&---------------------------------------------------------------------*

* Finds tlanes involving a product

*----------------------------------------------------------------------*

* -->IS_MASTERDATA Masterdata table

* -->IV_PRDTP Prioduct type

* -->IT_LOCATION Location table

* <--ET_TLANE Tlane table

*----------------------------------------------------------------------*

FORM f_find_tlane_comb USING is_masterdata TYPE zap_scmpf

it_tship TYPE t_tship

iv_prdtp TYPE c

it_location TYPE t_location

CHANGING et_tlane TYPE t_tlane.

DATA:

lv_matnr TYPE /sapapo/matnr,

ls_tship TYPE s_tship,

ls_tship_tmp TYPE s_tship,

lv_locfr TYPE /sapapo/locno,

lv_locwh TYPE /sapapo/locno,

lv_locto TYPE /sapapo/locno.

CASE iv_prdtp.

WHEN gc_core.

lv_matnr = is_masterdata-pcode.

WHEN gc_var.

lv_matnr = is_masterdata-prvar.

ENDCASE.

* First see if the Source and Market exist in the database.

* Check the presence of transhipments in the sourcing. We assume that

* the destination can only be blank for the last entry of a given

* sourcing alternative

READ TABLE it_location TRANSPORTING NO FIELDS

WITH KEY locno = is_masterdata-markt

BINARY SEARCH.

IF sy-subrc <> 0.

* Market exists in the data base

READ TABLE it_location TRANSPORTING NO FIELDS

WITH KEY locno = is_masterdata-pdctr

BINARY SEARCH.

IF sy-subrc <> 0.

* Source exists in the data base

IF is_masterdata-whind IS INITIAL.

lv_locfr = is_masterdata-pdctr.

lv_locto = is_masterdata-markt.

PERFORM f_build_tlane USING lv_locfr lv_locto lv_matnr

gc_ltp_1001 gc_ltp_1002

is_masterdata-datab

is_masterdata-datbi

CHANGING et_tlane.

ELSE.

LOOP AT it_tship INTO ls_tship

WHERE markt = is_masterdata-markt AND

pcode = is_masterdata-pcode AND

* pcode = is_masterdata-prvar AND

pdctr = is_masterdata-pdctr.

ls_tship_tmp = ls_tship.

* For every alternative sourcing

AT NEW altscn.

* Define lane between the source and the first transhipment

READ TABLE it_location TRANSPORTING NO FIELDS

WITH KEY locno = ls_tship-sloc

BINARY SEARCH.

IF sy-subrc <> 0.

lv_locfr = is_masterdata-pdctr.

lv_locto = ls_tship_tmp-sloc.

PERFORM f_build_tlane USING lv_locfr

lv_locto

lv_matnr

gc_ltp_1001

gc_ltp_1002

ls_tship_tmp-datab

ls_tship_tmp-datbi

CHANGING et_tlane.

ELSE.

lv_locfr = is_masterdata-pdctr.

lv_locto = is_masterdata-markt.

lv_locwh = ls_tship-sloc.

PERFORM f_update_log_table USING gc_msgid

gc_err

gc_msgno_087

lv_locfr lv_locto

lv_locwh space

space

CHANGING gt_log_tlane.

ENDIF.

ENDAT.

* Define lanes between the successive transhipments in the srcing

IF ls_tship-dloc IS NOT INITIAL.

READ TABLE it_location TRANSPORTING NO FIELDS

WITH KEY locno = ls_tship-dloc

BINARY SEARCH.

IF sy-subrc <> 0.

lv_locfr = ls_tship_tmp-sloc.

lv_locto = ls_tship_tmp-dloc.

PERFORM f_build_tlane USING lv_locfr lv_locto lv_matnr

gc_ltp_1002 gc_ltp_1002

ls_tship_tmp-datab

ls_tship_tmp-datbi

CHANGING et_tlane.

ELSE.

lv_locfr = is_masterdata-pdctr.

lv_locto = is_masterdata-markt.

lv_locwh = ls_tship-dloc.

PERFORM f_update_log_table USING gc_msgid

gc_err

gc_msgno_087

lv_locfr lv_locto

lv_locwh space

space

CHANGING gt_log_tlane.

ENDIF.

ENDIF.

AT END OF altscn.

* Define lane between the final transhipment and the market

IF ls_tship_tmp-dloc IS NOT INITIAL.

lv_locfr = ls_tship_tmp-dloc.

lv_locto = is_masterdata-markt.

PERFORM f_build_tlane USING lv_locfr lv_locto lv_matnr

gc_ltp_1002 gc_ltp_1002

ls_tship_tmp-datab

ls_tship_tmp-datbi

CHANGING et_tlane.

ELSE.

lv_locfr = ls_tship_tmp-sloc.

lv_locto = is_masterdata-markt.

PERFORM f_build_tlane USING lv_locfr lv_locto lv_matnr

gc_ltp_1002 gc_ltp_1002

ls_tship_tmp-datab

ls_tship_tmp-datbi

CHANGING et_tlane.

ENDIF.

ENDAT.

CLEAR ls_tship_tmp.

ENDLOOP.

ENDIF.

ELSE.

* Source is yet to be created in the database, update log

lv_locfr = is_masterdata-pdctr.

lv_locto = is_masterdata-markt.

PERFORM f_update_log_table USING gc_msgid

gc_err

gc_msgno_031

lv_locfr lv_locto

lv_matnr space

space

CHANGING gt_log_tlane.

ENDIF.

ELSE.

* Market is yet to be created in the database, update log

lv_locfr = is_masterdata-pdctr.

lv_locto = is_masterdata-markt.

PERFORM f_update_log_table USING gc_msgid

gc_err

gc_msgno_030

lv_locfr lv_locto

lv_matnr space

space

CHANGING gt_log_tlane.

ENDIF.

ENDFORM. " f_find_tlane_comb

*&---------------------------------------------------------------------*

*& Form f_build_tlane

*&---------------------------------------------------------------------*

* Builds a Tlane

*----------------------------------------------------------------------*

* -->IV_LOCFR Location from

* -->IV_LOCTO Location to

* -->IV_MATNR Product

* -->IV_LTPFR Loctype from

* -->IV_LTPTO Loctype to

* -->IS_MASTERDATA Master data

* <--ET_TLANE Tlane table

*----------------------------------------------------------------------*

FORM f_build_tlane USING iv_locfr TYPE /sapapo/locno

iv_locto TYPE /sapapo/locno

iv_matnr TYPE /sapapo/matnr

iv_ltpfr TYPE /sapapo/c_loctype

iv_ltpto TYPE /sapapo/c_loctype

iv_datfr TYPE Dats

iv_datto TYPE dats

CHANGING et_tlane TYPE t_tlane.

DATA:

ls_tlane TYPE s_tlane.

ls_tlane-locfr = iv_locfr.

ls_tlane-locto = iv_locto.

ls_tlane-matnr = iv_matnr.

ls_tlane-ltpfr = iv_ltpfr.

ls_tlane-ltpto = iv_ltpto.

PERFORM f_get_tstamps USING iv_datfr iv_datto

CHANGING ls_tlane-datfr ls_tlane-datto.

APPEND ls_tlane TO et_tlane.

ENDFORM. " f_build_tlane

*&---------------------------------------------------------------------*

*& Form f_get_tstamps

*&---------------------------------------------------------------------*

* Gets the timestamps for the Tlane validity dates

*----------------------------------------------------------------------*

* -->IS_MASTERDATA Master data table

* <--EV_DATFR Valid from tstamp

* <--EV_DATTO Valid to tstamp

*----------------------------------------------------------------------*

FORM f_get_tstamps USING iv_datfr TYPE d

iv_datto TYPE d

CHANGING ev_datfr TYPE timestamp

ev_datto TYPE timestamp.

CONVERT DATE iv_datfr TIME gc_startti

INTO TIME STAMP ev_datfr TIME ZONE gc_utc.

CONVERT DATE iv_datto TIME gc_endti

INTO TIME STAMP ev_datto TIME ZONE gc_utc.

ENDFORM. " f_get_tstamps

*&---------------------------------------------------------------------*

*& Form f_update_log_table

*&---------------------------------------------------------------------*

* Update logs

*----------------------------------------------------------------------*

* -->IV_MSGID Message class

* -->IV_MSGTY Message type

* -->IV_MSGNO Message no

* -->IV_MSGV1 Variable1

* -->IV_MSGV2 Variable2

* -->IV_MSGV3 Variable3

* -->IV_MSGV4 Variable4

* -->IV_MSG Message

* <--ET_LOG_TABLE Log table

*----------------------------------------------------------------------*

FORM f_update_log_table USING iv_msgid TYPE symsgid

iv_msgty TYPE symsgty

iv_msgno TYPE symsgno

iv_msgv1 TYPE any

iv_msgv2 TYPE any

iv_msgv3 TYPE any

iv_msgv4 TYPE any

iv_msg TYPE bapi_msg

CHANGING et_log_table TYPE t_log_table.

DATA:

ls_log_table TYPE bal_s_msg.

DATA: lv_datto type timestamp.

ls_log_table-msgty = iv_msgty.

ls_log_table-msgid = iv_msgid.

ls_log_table-msgno = iv_msgno.

ls_log_table-msgv1 = iv_msgv1.

ls_log_table-msgv2 = iv_msgv2.

ls_log_table-msgv3 = iv_msgv3.

ls_log_table-msgv4 = iv_msgv4.

ls_log_table-context-value = iv_msg.

APPEND ls_log_table TO et_log_table.

ENDFORM. " f_update_log_table

*&---------------------------------------------------------------------*

*& Form f_get_locid_from_locno

*&---------------------------------------------------------------------*

* Gets the guid for locations

*----------------------------------------------------------------------*

* -->IV_LOCNO Location no

* <--EV_LOCID Location id

*----------------------------------------------------------------------*

FORM f_get_locid_from_locno USING iv_locno TYPE /sapapo/locno

CHANGING ev_locid TYPE /sapapo/locid.

CALL FUNCTION '/SAPAPO/DM_LOCNO_GET_LOCID'

EXPORTING

iv_locno = iv_locno

IMPORTING

ev_locid = ev_locid

EXCEPTIONS

location_not_found = 1

OTHERS = 2.

IF sy-subrc <> 0.

* Do nothing

ENDIF.

ENDFORM. " f_get_locid_from_locno

**&---------------------------------------------------------------------

**

**& Form f_get_locid_from_locno

**&---------------------------------------------------------------------

**

** Gets the guid for locations

**----------------------------------------------------------------------

**

** -->IV_LOCNO Location no

** <--EV_LOCID Location id

**----------------------------------------------------------------------

*MOD-1771404

*FORM f_get_locid_from_locno USING iv_locno TYPE /sapapo/locno

* CHANGING ev_locid TYPE /sapapo/locid.

*

* CALL FUNCTION '/SAPAPO/DM_LOCNO_GET_LOCID'

* EXPORTING

* iv_locno = iv_locno

* IMPORTING

* ev_locid = ev_locid

* EXCEPTIONS

* location_not_found = 1

* OTHERS = 2.

*

* IF sy-subrc <> 0.

** Do nothing

* ENDIF.

*

*

*ENDFORM. " f_get_locid_from_locno

*MOD-1771404

*&---------------------------------------------------------------------*

*& Form f_get_matid_from_matnr

*&---------------------------------------------------------------------*

* Gets the guid for material

*----------------------------------------------------------------------*

* -->IV_MATNR Material no

* <--EV_MATID Material id

*----------------------------------------------------------------------*

FORM f_get_matid_from_matnr USING iv_matnr TYPE /sapapo/matnr

CHANGING ev_matid TYPE /sapapo/matid.

CALL FUNCTION '/SAPAPO/DM_MATERIAL_GET_MATID'

EXPORTING

iv_matnr = iv_matnr

IMPORTING

ev_matid = ev_matid

EXCEPTIONS

matid_not_found = 1

OTHERS = 2.

IF sy-subrc <> 0.

* Do nothing

ENDIF.

ENDFORM. " f_get_matid_from_matnr

*&---------------------------------------------------------------------*

*& Form f_categorise_tlanes

*&---------------------------------------------------------------------*

* Categorises Transp lanes

*----------------------------------------------------------------------*

* -->IT_TLANE Tlane table

* <--ET_TLANE_NEW Tlane table with new entries

* <--ET_TLANE_DAT Tlane table with date changes

*----------------------------------------------------------------------*

FORM f_categorise_tlanes USING it_tlane TYPE t_tlane

CHANGING et_tlane_new TYPE t_tlane

et_tlane_dat TYPE t_tlane.

DATA:

lt_tlane_cr TYPE STANDARD TABLE OF /sapapo/trprod,

ls_tlane_cr TYPE /sapapo/trprod, "#EC NEEDED

ls_tlane_tmp TYPE s_tlane,

ls_tlane TYPE s_tlane,

ls_tlane_new TYPE s_tlane.

DATA: lv_exist type i.

DATA: lv_exist1 type i.

DATA:

lv_dtfrmin TYPE timestamp,

lv_dttomax TYPE timestamp,

lv_tabix TYPE sytabix,

lv_locfr TYPE /sapapo/locno,

lv_locto TYPE /sapapo/locno,

lv_matnr TYPE /sapapo/matnr.

DATA:

ls_masterdata TYPE zap_scmpf.

FIELD-SYMBOLS:

<lfs_tlanetmp> TYPE s_tlane,

<lfs_tlane> TYPE s_tlane.

*MOD-1771404

SORT it_tlane BY locfr locto matnr datfr datto.

DELETE ADJACENT DUPLICATES FROM it_tlane

COMPARING locfr locto matnr datfr datto.

READ TABLE it_tlane ASSIGNING <lfs_tlane> INDEX 1.

lv_dtfrmin = <lfs_tlane>-datfr.

lv_dttomax = <lfs_tlane>-datto.

LOOP AT it_tlane ASSIGNING <lfs_tlane>.

IF <lfs_tlane>-datfr < lv_dtfrmin.

lv_dtfrmin = <lfs_tlane>-datfr.

ENDIF.

IF <lfs_tlane>-datto > lv_dttomax.

lv_dttomax = <lfs_tlane>-datto.

ENDIF.

AT END OF matnr.

<lfs_tlane>-datfr = lv_dtfrmin.

<lfs_tlane>-datto = lv_dttomax.

lv_tabix = sy-tabix + 1.

READ TABLE it_tlane ASSIGNING <lfs_tlanetmp> INDEX lv_tabix.

IF sy-subrc = 0.

lv_dtfrmin = <lfs_tlanetmp>-datfr.

lv_dttomax = <lfs_tlanetmp>-datto.

ENDIF.

ENDAT.

ENDLOOP.

SORT it_tlane BY locfr locto matnr datfr ASCENDING datto DESCENDING.

DELETE ADJACENT DUPLICATES FROM it_tlane

COMPARING locfr locto matnr.

*MOD-1771404

* The table /SAPAPO/TRPROD the key field is /SAPAPO/TRPID.

* But over here we are retrieving data from it with respect to

* the source and destination which anyway is unique for a given

* product involved in the lane.

SELECT locfr locto matid valfr valto

INTO CORRESPONDING FIELDS OF TABLE lt_tlane_cr

FROM /sapapo/trprod

FOR ALL ENTRIES IN it_tlane

WHERE locfr = it_tlane-lidfr AND

locto = it_tlane-lidto.

* valfr = it_tlane-datfr and

* valto = it_tlane-datto.

*MOD-1771404

IF sy-subrc = 0.

SORT lt_tlane_cr BY locfr locto matid valfr valto.

endif.

LOOP AT it_tlane INTO ls_tlane.

READ TABLE lt_tlane_cr INTO ls_tlane_cr

WITH KEY locfr = ls_tlane-lidfr

locto = ls_tlane-lidto

matid = ls_tlane-matid.

*MOD-1771404

* BINARY SEARCH.

*MOD-1771404

IF sy-subrc = 0.

APPEND ls_tlane TO et_tlane_dat.

ELSE.

* Check whether a product needs to be assigned to an existing

* Tlane

READ TABLE lt_tlane_cr INTO ls_tlane_cr

WITH KEY locfr = ls_tlane-lidfr

locto = ls_tlane-lidto

BINARY SEARCH.

IF sy-subrc = 0.

* Mark the record to denote assignment of prod to existing

* Tlane

ls_tlane-crtyp = 'X'.

ENDIF.

IF ls_tlane-locfr = ls_tlane_tmp-locfr AND

ls_tlane-locto = ls_tlane_tmp-locto.

ls_tlane-crtyp = 'X'.

ENDIF.

APPEND ls_tlane TO et_tlane_new.

ENDIF.

ls_tlane_tmp = ls_tlane.

CLEAR ls_tlane.

ENDLOOP.

*MOD-1771404

SORT et_tlane_new BY locfr locto matnr.

SORT et_tlane_dat BY locfr locto matnr.

if not et_tlane_new[] is initial.

delete adjacent duplicates from et_tlane_new

comparing locfr locto matnr.

endif.

if not et_tlane_dat[] is initial.

delete adjacent duplicates from et_tlane_dat

comparing locfr locto matnr.

endif.

*MOD-1771404

ENDFORM. " f_categorise_tlanes

*&---------------------------------------------------------------------*

*& Form F_GET_LOC_DESC

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* -->P_IT_PROD_DATA text

* <--P_LV_WARE_DESC text

*----------------------------------------------------------------------*

FORM F_GET_LOC_DESC CHANGING LV_WARE_DESC TYPE /SAPAPO/LOC_DESCR40.

*MOD-1771404

FIELD-SYMBOLS:

<lfs_prod_data> TYPE s_f4_data_loc.

*MOD-1771404

DATA: lv_locid type /sapapo/locid.

* Local Date Declaration

DATA: lv_mkt TYPE char4, " Market

lv_pdctr TYPE char2, " Production center

lv_whse1 TYPE char3, " Warehouse1

lv_whse2 TYPE char3. " Warehouse2

* LOOP AT it_prod_data ASSIGNING <lfs_prod_data>.

* Check if the Location is a market

SELECT markt UP TO 1 ROWS

INTO lv_mkt

FROM zap_sign

* where markt = <lfs_prod_data>-locno.

WHERE markt = s_mkt-low.

ENDSELECT.

IF sy-subrc = 0 OR

lv_mkt IS NOT INITIAL.

SELECT locid up to 1 rows

into lv_locid

from /sapapo/loc

where locno = lv_mkt.

ENDSELECT.

if sy-subrc = 0.

SELECT DESCR40 UP TO 1 ROWS

INTO lv_ware_desc

FROM /SAPAPO/LOCT

WHERE locid = lv_locid.

ENDSELECT.

if sy-subrc = 0.

*MOD-1887120

* <LFS_PROD_DATA>-LOCNO = s_mkt-low.

* <LFS_PROD_DATA>-DESC = lv_ware_desc.

* endif.

*MOD-1887120

exit.

endif.

ENDIF.

endif.

* Check if the Location is a Production center

SELECT pdctr UP TO 1 ROWS

INTO lv_pdctr

FROM zap_sign

* WHERE pdctr IN s_mkt.

WHERE pdctr = s_mkt-low.

ENDSELECT.

IF sy-subrc = 0 OR

lv_pdctr IS NOT INITIAL.

SELECT locid up to 1 rows

into lv_locid

from /sapapo/loc

where locno = lv_pdctr.

ENDSELECT.

if sy-subrc = 0.

SELECT DESCR40 UP TO 1 ROWS

INTO lv_ware_desc

FROM /SAPAPO/LOCT

WHERE locid = lv_locid.

ENDSELECT.

if sy-subrc = 0.

*MOD-1887120

* <LFS_PROD_DATA>-LOCNO = s_mkt-low.

* <LFS_PROD_DATA>-DESC = lv_ware_desc.

*MOD-1887120

exit.

endif.

endif.

ENDIF.

* Check if the Location is a Warehouse 1

SELECT whse1 UP TO 1 ROWS

INTO lv_whse1

FROM zap_sign

* WHERE whse1 IN s_mkt.

WHERE whse1 = s_mkt-low.

ENDSELECT.

IF sy-subrc = 0 OR

lv_whse1 IS NOT INITIAL.

SELECT locid up to 1 rows

into lv_locid

from /sapapo/loc

where locno = lv_whse1.

ENDSELECT.

if sy-subrc = 0.

SELECT DESCR40 UP TO 1 ROWS

INTO lv_ware_desc

FROM /SAPAPO/LOCT

WHERE locid = lv_locid.

ENDSELECT.

if sy-subrc = 0.

*MOD-1887120

* <LFS_PROD_DATA>-LOCNO = lv_whse1.

* <LFS_PROD_DATA>-DESC = lv_ware_desc.

*MOD-1887120

exit.

endif.

endif.

ENDIF.

* Check if the Location is a Warehouse 2

SELECT whse2 UP TO 1 ROWS

INTO lv_whse2

FROM zap_sign

* WHERE whse2 IN s_mkt.

WHERE whse2 = s_mkt-low.

ENDSELECT.

IF sy-subrc <> 0 OR

lv_whse2 IS NOT INITIAL.

SELECT locid up to 1 rows

into lv_locid

from /sapapo/loc

where locno = lv_whse2.

ENDSELECT.

if sy-subrc = 0.

SELECT DESCR40 UP TO 1 ROWS

INTO lv_ware_desc

FROM /SAPAPO/LOCT

WHERE locid = lv_locid.

ENDSELECT.

if sy-subrc = 0.

*MOD-1887120

* <LFS_PROD_DATA>-LOCNO = LV_WHSE2.

* <LFS_PROD_DATA>-DESC = lv_ware_desc.

*MOD-1887120

exit.

endif.

* Location does not exist in APO

MESSAGE e017.

ENDIF.

endif.

* ENDLOOP.

ENDFORM. " F_GET_LOC_DESC

*&---------------------------------------------------------------------*

*& Form GET_DESC_LOC

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* -->P_<LFS_PROD_DATA> text

* <--P_LV_WARE_DESC text

*----------------------------------------------------------------------*

FORM GET_DESC_LOC USING p_lv_prod_data type s_f4_data_loc

CHANGING p_LV_WARE_DESC type /SAPAPO/LOC_DESCR40.

*MOD-1771404

FIELD-SYMBOLS:

<lfs_prod_data> TYPE s_f4_data_loc.

*MOD-1771404

DATA: lv_locid type /sapapo/locid.

data: lv_ware_desc type /sapapo/loc_descr40.

** Local Date Declaration

* DATA: lv_mkt TYPE zdmarkt, " Market

* lv_pdctr TYPE zdpdctr, " Production center

* lv_whse1 TYPE zawhse1, " Warehouse1

* lv_whse2 TYPE zawhse2. " Warehouse2

* Local Date Declaration

DATA: lv_mkt TYPE char4, " Market

lv_pdctr TYPE char2, " Production center

lv_whse1 TYPE char3, " Warehouse1

lv_whse2 TYPE char3. " Warehouse2

* Check if the Location is a market

SELECT whse1 UP TO 1 ROWS

INTO lv_whse1

FROM zap_sign

* WHERE whse1 eq s_mkt-low.

WHERE whse1 = p_lv_prod_data-locno.

ENDSELECT.

IF sy-subrc = 0 OR

lv_mkt IS NOT INITIAL.

SELECT locid up to 1 rows

into lv_locid

from /sapapo/loc

where locno = lv_whse1.

ENDSELECT.

if sy-subrc = 0.

SELECT DESCR40 UP TO 1 ROWS

INTO p_lv_ware_desc

FROM /SAPAPO/LOCT

WHERE locid = lv_locid.

ENDSELECT.

if sy-subrc = 0.

lv_ware_desc = p_lv_ware_desc.

endif.

exit.

endif.

ENDIF.

ENDFORM. " GET_DESC_LOC

*&---------------------------------------------------------------------*

*& Form GET_DESC_WHSE2

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* -->P_LV_PROD_DATA text

* <--P_LV_WARE_DESC text

*----------------------------------------------------------------------*

FORM GET_DESC_WHSE2 USING p_lv_prod_data type s_f4_data_loc

CHANGING p_LV_WARE_DESC type /SAPAPO/LOC_DESCR40.

*MOD-1771404

FIELD-SYMBOLS:

<lfs_prod_data> TYPE s_f4_data_loc.

*MOD-1771404

DATA: lv_locid type /sapapo/locid.

data: lv_ware_desc type /sapapo/loc_descr40.

* Local Date Declaration

DATA: lv_mkt TYPE char4, " Market

lv_pdctr TYPE char2, " Production center

lv_whse1 TYPE char3, " Warehouse1

lv_whse2 TYPE char3. " Warehouse2

*MOD-1771404

* Check if the Location is a market

* SELECT whse2 UP TO 1 ROWS

* INTO lv_whse2

* FROM zm_zap_sign

* WHERE whse1 IN s_mkt.

* ENDSELECT.

*MOD-1771404

SELECT whse2 UP TO 1 ROWS

INTO lv_whse2

FROM zap_sign

WHERE whse1 IN s_mkt or

whse2 in s_mkt and

pcode in s_prd.

ENDSELECT.

IF sy-subrc = 0 OR

lv_mkt IS NOT INITIAL.

SELECT locid up to 1 rows

into lv_locid

from /sapapo/loc

where locno = lv_whse2.

ENDSELECT.

if sy-subrc = 0.

SELECT DESCR40 UP TO 1 ROWS

INTO p_lv_ware_desc

FROM /SAPAPO/LOCT

WHERE locid = lv_locid.

ENDSELECT.

if sy-subrc = 0.

lv_ware_desc = p_lv_ware_desc.

endif.

exit.

endif.

ENDIF.

ENDFORM. " GET_DESC_WHSE2

*&---------------------------------------------------------------------*

*& Form f_clear_tables

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM f_clear_tables.

REFRESH: IT_ZDM0705, IT_ZDU1002, GT_PROD_DATA,

GT_CORE_PROD, GT_LOC_DATA.

CLEAR: IT_ZDM0705, IT_ZDU1002, GT_PROD_DATA,

GT_CORE_PROD, GT_LOC_DATA.

ENDFORM. " f_clear_tables

*Text elements

*----------------------------------------------------------

* 002 Test Delete

* 028 Validity Date Change

* 029 Product Removal

* 030 From date

* 031 To date

* 032 Transportation Lane

* 042 WUF

*Selection texts

*----------------------------------------------------------

* P_DES Destination

* P_FRD From Date

* P_LOG Logical system

* P_MDEL Model

* P_PRD Production

* P_SRC Source

* P_TDAT To Date

* P_TEST Test

* P_TLAN Transportation Lane

* P_TOD To Date

* P_TPRD Product Removal

* S_MKT Market

* S_PRD Product

*----------------------------------------------------------*

*Messages

*----------------------------------------------------------*

*Message class: ZAXXP_SIGN_FPV

*005 no sourcing info is maintained in the sign portfolio

*016 Product does not exist in APO

*017 Location does not exist in APO

*056 Both Product and Location can not be multiple

*059 Product value as * not allowed at the selection screen

*060 Product value as * not allowed at the selection screen

*085 Core Product is Initial.

*086 Product Variant is Initial

  • No labels