*& Date: 2005/03/16 *
*& Purpose: Download Planning data into an excel spreadsheet, allow *
*& the user to make modifications and then upload the file *
*& back into R/3 to make the modifications *
*&---------------------------------------------------------------------*
REPORT zpuplanning_downl_upl1 LINE-SIZE 255 MESSAGE-ID ZP.
************************************************************************
************************************************************************
* INCLUDES - PART 1
************************************************************************
include zpiplanning_downl_upl_top1.
************************************************************************
* SELECTION SCREEN
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLE text-000.
PARAMETERS: rb_downl RADIOBUTTON GROUP rbg1.
SELECTION-SCREEN ULINE.
SELECT-OPTIONS: s_matnr FOR mara-matnr, " Material
s_werks FOR marc-werks, " Plant
s_dispo FOR mdkp-dispo, " MRP Controller
* s_dsdat FOR mdkp-dsdat, " Date
s_beskz FOR marc-beskz
DEFAULT 'F', " Procurement Type
s_sobsl FOR marc-sobsl, " Spec. Proc Type.
* s_delkz FOR mdtb-delkz, " MRP Element
s_ekgrp FOR marc-ekgrp. " Purchasing Group
PARAMETERS : p_vkorg like mvke-vkorg, " sales organisation
p_vtweg like mvke-vtweg, " Distribution channel
p_lgnum like mlgn-lgnum. " Warehouse number
SELECT-OPTIONS: s_vmsta for mvke-vmsta. " sales status
SELECTION-SCREEN BEGIN OF BLOCK bl2 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_dsdat FOR mdkp-dsdat, " Date
s_delkz FOR mdtb-delkz. " MRP Element
SELECTION-SCREEN END OF BLOCK bl2.
SELECTION-SCREEN BEGIN OF BLOCK bl3 WITH FRAME TITLE text-015.
SELECT-OPTIONS: s_amatnr for mara-matnr. " active BOM
PARAMETERS : p_datuv like stko-datuv default sy-datum,
p_capid like tc04t-capid default 'PP01'.
SELECTION-SCREEN END OF BLOCK bl3.
SELECTION-SCREEN BEGIN OF BLOCK bl4 WITH FRAME TITLE text-016.
SELECT-OPTIONS: s_budat FOR mkpf-budat, " consumption date
s_bwart FOR mseg-bwart. " Mvt type for consumption
SELECTION-SCREEN END OF BLOCK bl4.
SELECTION-SCREEN SKIP 3.
PARAMETERS: rb_upld RADIOBUTTON GROUP rbg1.
SELECTION-SCREEN ULINE.
PARAMETERS: p_file LIKE rlgrap-filename,
chk_fir AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK bl1.
DATA: g_title TYPE string,
g_subrc TYPE sy-subrc.
DATA: wa_file TYPE file_table,
it_files TYPE filetable.
g_title = text-002.
AT SELECTION-SCREEN.
select single matnr from mara into mara-matnr where matnr in s_matnr.
if sy-subrc ne 0.
message e000.
endif.
select single werks from marc into marc-werks where werks in s_werks.
if sy-subrc ne 0.
message e001.
endif.
select single matnr from mast into mast-matnr where matnr in s_amatnr.
if sy-subrc ne 0.
message e002.
endif.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
g_title = text-010.
REFRESH: it_files.
CALL METHOD cl_gui_frontend_services=%GTfile_open_dialog
EXPORTING
window_title = g_title
default_extension = 'xls'
* DEFAULT_FILENAME =
file_filter =
cl_gui_frontend_services=%GTFILETYPE_EXCEL
initial_directory = 'C:\'
CHANGING
file_table = it_files
rc = g_subrc
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc %LT%GT 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
READ TABLE it_files INTO wa_file INDEX 1.
IF sy-subrc = 0.
p_file = wa_file-filename.
ENDIF.
************************************************************************
* INCLUDES - PART 2
************************************************************************
* INCLUDE z_alv_include_v2.
* INCLUDE zpiplanning_downl_upl_inc1.
*&---------------------------------------------------------------------*
*& Include Z_ALV_INCLUDE_V2
*&---------------------------------------------------------------------*
*----------------------------------------------------------------------*
* INCLUDE Z_ALV_INCLUDE *
*----------------------------------------------------------------------*
* Type Pools
TYPE-POOLS: rsds.
* Class definitions
*CLASS lcl_event_receiver DEFINITION DEFERRED.
****************************************************************
* LOCAL CLASSES: Definition
****************************************************************
* class c_event_receiver: local class to handle print events
* - PRINT_TOP_OF_PAGE (page header)
* - PRINT_END_OF_PAGE (page footer)
* - PRINT_TOP_OF_LIST (list header)
* - PRINT_END_OF_LIST (list footer)
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
* § 2. Define a method for each print event you need.
METHODS:
handle_top_of_page
FOR EVENT print_top_of_page OF cl_gui_alv_grid,
handle_end_of_page
FOR EVENT print_end_of_page OF cl_gui_alv_grid,
handle_top_of_list
FOR EVENT print_top_of_list OF cl_gui_alv_grid,
handle_end_of_list
FOR EVENT print_end_of_list OF cl_gui_alv_grid,
handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column,
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed,
handle_data_changed_finished
FOR EVENT data_changed_finished OF cl_gui_alv_grid
IMPORTING e_modified
et_good_cells.
PRIVATE SECTION.
DATA: e_row TYPE lvc_s_row,
e_column TYPE lvc_s_col.
DATA: error_in_data TYPE c.
* Methods to modularize event handler method HANDLE_DATA_CHANGED:
* METHODS: update_data_in_table
* IMPORTING
** ps_good_planetype TYPE lvc_s_modi
* pr_data_changed TYPE REF TO cl_alv_changed_data_protocol.
*
* METHODS: ch_new_plane_v_new_seatsocc
* IMPORTING
* psg_plane TYPE lvc_s_modi
* psg_socc TYPE lvc_s_modi
* ps_saplane TYPE saplane
* pr_data_changed TYPE REF TO cl_alv_changed_data_protocol.
*
* METHODS: ch_new_plane_v_old_seatsocc
* IMPORTING
* psg_plane TYPE lvc_s_modi
* ps_saplane TYPE saplane
* pr_data_changed TYPE REF TO cl_alv_changed_data_protocol.
*
* METHODS: check_seatsocc
* IMPORTING
* ps_good TYPE lvc_s_modi
* pr_data_changed TYPE REF TO cl_alv_changed_data_protocol.
ENDCLASS. "lcl_event_receiver DEFINITION
DATA:
* ok_code LIKE sy-ucomm,
g_repid LIKE sy-repid,
g_repid2 LIKE sy-repid,
gs_print TYPE lvc_s_prnt,
gs_print2 TYPE lvc_s_prnt,
gs_layout TYPE lvc_s_layo,
gs_layout2 TYPE lvc_s_layo,
gs_variant TYPE disvariant,
gs_variant2 TYPE disvariant,
g_report_name TYPE lvc_s_layo-grid_title,
g_report_name2 TYPE lvc_s_layo-grid_title,
g_container_name TYPE scrfname,
g_container_name2 TYPE scrfname,
g_structure_name TYPE dd02l-tabname,
g_structure_name2 TYPE dd02l-tabname,
gt_sort TYPE lvc_t_sort,
gt_sort2 TYPE lvc_t_sort,
gt_fieldcat TYPE lvc_t_fcat WITH HEADER LINE,
gt_fieldcat2 TYPE lvc_t_fcat WITH HEADER LINE.
*declaration of Objects
DATA:
custom_container TYPE REF TO cl_gui_custom_container,
custom_container2 TYPE REF TO cl_gui_custom_container,
top_container TYPE REF TO cl_gui_container,
top_container2 TYPE REF TO cl_gui_container,
main_container TYPE REF TO cl_gui_container,
main_container2 TYPE REF TO cl_gui_container,
bottom_container TYPE REF TO cl_gui_container,
bottom_container2 TYPE REF TO cl_gui_container,
ez_split_container TYPE REF TO cl_gui_easy_splitter_container,
ez_split_container2 TYPE REF TO cl_gui_easy_splitter_container,
splitter_container TYPE REF TO cl_gui_splitter_container,
splitter_container2 TYPE REF TO cl_gui_splitter_container,
grid1 TYPE REF TO cl_gui_alv_grid,
grid2 TYPE REF TO cl_gui_alv_grid,
text_box_top TYPE REF TO cl_dd_document,
text_box_top2 TYPE REF TO cl_dd_document,
text_box_bottom TYPE REF TO cl_dd_document,
text_box_bottom2 TYPE REF TO cl_dd_document,
event_receiver TYPE REF TO lcl_event_receiver,
event_receiver2 TYPE REF TO lcl_event_receiver.
FIELD-SYMBOLS:
* %LTfs_data%GT TYPE REF TO data,
* %LTfs_table%GT TYPE ANY TABLE,
%LTgt_output%GT TYPE STANDARD TABLE,
%LTgt_output2%GT TYPE ANY TABLE,
%LTgt_boms%GT type standard table.
*&---------------------------------------------------------------------*
*& Form CREATE_HEADER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --%GT p1 text
* %LT-- p2 text
*----------------------------------------------------------------------*
FORM create_screen_header.
DATA:
it_sel_crit LIKE rsparams OCCURS 20 WITH HEADER LINE,
it_program_texts LIKE textpool OCCURS 0 WITH HEADER LINE,
it_list_commentary TYPE slis_t_listheader,
ls_line TYPE slis_listheader,
data_type.
FIELD-SYMBOLS: %LTlfs1%GT.
TYPES: BEGIN OF type_param_table,
parnam(255) TYPE c,
lowval TYPE tvarv_val,
toval(4) TYPE c,
higval TYPE tvarv_val,
END OF type_param_table.
READ TEXTPOOL sy-cprog INTO it_program_texts.
CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
EXPORTING
curr_report = sy-cprog
TABLES
selection_table = it_sel_crit
EXCEPTIONS
not_found = 1
no_report = 2
OTHERS = 3.
IF NOT sy-subrc = 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error getting sel options - contact support'.
ENDIF.
LOOP AT it_sel_crit.
READ TABLE it_program_texts WITH KEY
key = it_sel_crit-selname.
ASSIGN (it_sel_crit-selname) TO %LTlfs1%GT.
DESCRIBE FIELD %LTlfs1%GT TYPE data_type.
IF data_type = 'D'.
IF NOT it_sel_crit-low IS INITIAL.
CONCATENATE it_sel_crit-low(4) '/' it_sel_crit-low+4(2) '/'
it_sel_crit-low+6(2) INTO it_sel_crit-low.
ENDIF.
IF NOT it_sel_crit-high IS INITIAL.
CONCATENATE it_sel_crit-high(4) '/' it_sel_crit-high+4(2) '/'
it_sel_crit-high+6(2) INTO it_sel_crit-high.
ENDIF.
ENDIF.
IF data_type = 'T'.
IF NOT it_sel_crit-low IS INITIAL.
CONCATENATE it_sel_crit-low(2) ':' it_sel_crit-low+2(2)
INTO it_sel_crit-low.
ENDIF.
IF NOT it_sel_crit-high IS INITIAL.
CONCATENATE it_sel_crit-high(2) ':' it_sel_crit-high+2(2)
INTO it_sel_crit-high.
ENDIF.
ENDIF.
CLEAR ls_line.
ls_line-typ = 'S'.
ls_line-key = it_program_texts-entry.
IF NOT it_sel_crit-high IS INITIAL.
CONCATENATE it_sel_crit-low 'to' it_sel_crit-high
INTO ls_line-info
SEPARATED BY space.
ELSE.
ls_line-info = it_sel_crit-low.
ENDIF.
APPEND ls_line TO it_list_commentary.
ENDLOOP.
EXPORT it_list_commentary FROM it_list_commentary
TO MEMORY ID 'DYNDOS_FOR_ALV'.
CALL FUNCTION 'REUSE_ALV_GRID_COMMENTARY_SET'
EXPORTING
document = text_box_top
bottom = space.
* get TOP-%GTHTML_TABLE ready
CALL METHOD text_box_top-%GTmerge_document.
ENDFORM. " CREATE_HEADER
*&---------------------------------------------------------------------*
*& Form create_screen_header_man
*&---------------------------------------------------------------------*
FORM create_screen_header_man.
TYPES: BEGIN OF ty_parm_table,
entry(150) TYPE c.
INCLUDE STRUCTURE rsparams.
TYPES: END OF ty_parm_table.
DATA:
it_sel_crit LIKE rsparams OCCURS 20 WITH HEADER LINE,
it_program_texts LIKE textpool OCCURS 0 WITH HEADER LINE,
it_parameters TYPE TABLE OF ty_parm_table WITH HEADER LINE,
ls_line TYPE slis_listheader,
data_type,
s_table TYPE REF TO cl_dd_table_element,
column1 TYPE REF TO cl_dd_area,
column2 TYPE REF TO cl_dd_area,
column3 TYPE REF TO cl_dd_area,
a_logo TYPE REF TO cl_dd_area,
line_text(255) TYPE c,
line_text2(255) TYPE c,
old_line_text(255) TYPE c,
line_concat(255) TYPE c,
ICON_NAME TYPE ICON_NAME.
FIELD-SYMBOLS: %LTlfs1%GT.
* read the selection texts from the selection screen
READ TEXTPOOL sy-cprog INTO it_program_texts.
CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
EXPORTING
curr_report = sy-cprog
TABLES
selection_table = it_sel_crit
EXCEPTIONS
not_found = 1
no_report = 2
OTHERS = 3.
IF NOT sy-subrc = 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error getting sel options - contact support'.
ENDIF.
* Split the top section of the screen with 99% to the left
* this will leave one little frame at the right for us
* to insert the companyt logo
CALL METHOD text_box_top-%GTvertical_split
EXPORTING
split_area = text_box_top
split_width = '99%'
IMPORTING
right_area = a_logo.
CALL METHOD a_logo-%GTadd_picture
EXPORTING
picture_id = 'CAMOPLAST_LOGO_COL_229_110'.
* add a table for the parameter display and add 2 columns
CALL METHOD text_box_top-%GTadd_table
EXPORTING
no_of_columns = 3
with_heading = ' '
cell_background_transparent = 'X'
width = ''
border = '1'
IMPORTING
table = s_table.
CALL METHOD s_table-%GTadd_column
IMPORTING
column = column1.
CALL METHOD s_table-%GTadd_column
IMPORTING
column = column2.
CALL METHOD s_table-%GTadd_column
IMPORTING
column = column3.
* add the table column names in the first row of the table
line_text = 'Parameter Name'.
CALL METHOD column1-%GTadd_text
EXPORTING
text = line_text
sap_emphasis = 'Strong'.
line_text = 'Type'.
CALL METHOD column2-%GTadd_text
EXPORTING
text = line_text
sap_emphasis = 'Strong'.
CALL METHOD column3-%GTadd_gap
EXPORTING
width = 3.
line_text = 'Value'.
CALL METHOD column3-%GTadd_text
EXPORTING
text = line_text
sap_emphasis = 'Strong'.
CALL METHOD s_table-%GTnew_row.
LOOP AT it_sel_crit.
READ TABLE it_program_texts WITH KEY
key = it_sel_crit-selname.
it_parameters-entry = it_program_texts-entry.
MOVE-CORRESPONDING it_sel_crit TO it_parameters.
APPEND it_parameters.
ENDLOOP.
SORT it_parameters BY entry.
LOOP AT it_parameters.
* if the text is set with the dictionary default text, remove
* the D character from the begining of the string
IF it_parameters(8) = 'D '.
it_parameters-entry = it_parameters-entry+8.
ENDIF.
ASSIGN (it_parameters-selname) TO %LTlfs1%GT.
DESCRIBE FIELD %LTlfs1%GT TYPE data_type.
IF data_type = 'D'.
IF NOT it_parameters-low IS INITIAL AND
NOT it_parameters-low = '00000000'.
CONCATENATE it_parameters-low(4) '/' it_parameters-low+4(2) '/'
it_parameters-low+6(2) INTO it_parameters-low.
ELSE.
CONTINUE.
ENDIF.
IF NOT it_parameters-high IS INITIAL AND
NOT it_parameters-HIGH = '00000000'.
CONCATENATE it_parameters-high(4) '/' it_parameters-high+4(2)
'/'
it_parameters-high+6(2) INTO
it_parameters-high.
ENDIF.
ENDIF.
IF data_type = 'T'.
IF NOT it_parameters-low IS INITIAL.
CONCATENATE it_parameters-low(2) ':' it_parameters-low+2(2)
INTO it_parameters-low.
ENDIF.
IF NOT it_parameters-high IS INITIAL.
CONCATENATE it_parameters-high(2) ':' it_parameters-high+2(2)
INTO it_parameters-high.
ENDIF.
ENDIF.
IF NOT it_parameters-high IS INITIAL AND
NOT it_parameters-high = ' 0.000'.
CONCATENATE it_parameters-low 'to' it_parameters-high
INTO line_concat
SEPARATED BY space.
ELSE.
line_concat = it_parameters-low.
ENDIF.
IF NOT it_parameters-low IS INITIAL.
CALL METHOD s_table-%GTnew_row.
IF old_line_text NE it_parameters-entry.
line_text = it_parameters-entry.
CALL METHOD column1-%GTadd_text
EXPORTING
text = line_text
sap_emphasis = 'Strong'.
**************************
* KEVIN NORRIS 2008/01/08 - ADD ICONS TO TABLE
ICON_NAME = 'ICON_EQUAL'.
IF it_parameters-SIGN = ''.
CASE it_parameters-OPTION.
WHEN 'EQ'.
ICON_NAME = 'ICON_EQUAL'.
WHEN 'NE'.
ICON_NAME = 'ICON_NOT_EQUAL'.
WHEN 'GT'.
ICON_NAME = 'ICON_GREATER'.
WHEN 'LT'.
ICON_NAME = 'ICON_LESS'.
WHEN 'GE'.
ICON_NAME = 'ICON_GREATER_EQUAL'.
WHEN 'LE'.
ICON_NAME = 'ICON_LESS_EQUAL'.
WHEN 'BT'.
ICON_NAME = 'ICON_INTERVAL_INCLUDE'.
WHEN 'NB'.
ICON_NAME = 'ICON_INTERVAL_EXCLUDE'.
ENDCASE.
elseIF it_parameters-SIGN = 'I'.
CASE it_parameters-OPTION.
WHEN 'EQ'.
ICON_NAME = 'ICON_EQUAL_GREEN'.
WHEN 'NE'.
ICON_NAME = 'ICON_NOT_EQUAL_GREEN'.
WHEN 'GT'.
ICON_NAME = 'ICON_GREATER_GREEN'.
WHEN 'LT'.
ICON_NAME = 'ICON_LESS_GREEN'.
WHEN 'GE'.
ICON_NAME = 'ICON_GREATER_EQUAL_GREEN'.
WHEN 'LE'.
ICON_NAME = 'ICON_LESS_EQUAL_GREEN'.
WHEN 'BT'.
ICON_NAME = 'ICON_INTERVAL_INCLUDE_GREEN'.
WHEN 'NB'.
ICON_NAME = 'ICON_INTERVAL_EXCLUDE_GREEN'.
ENDCASE.
ELSEIF it_parameters-SIGN = 'E'.
CASE it_parameters-OPTION.
WHEN 'EQ'.
ICON_NAME = 'ICON_EQUAL_RED'.
WHEN 'NE'.
ICON_NAME = 'ICON_NOT_EQUAL_RED'.
WHEN 'GT'.
ICON_NAME = 'ICON_GREATER_RED'.
WHEN 'LT'.
ICON_NAME = 'ICON_LESS_RED'.
WHEN 'GE'.
ICON_NAME = 'ICON_GREATER_EQUAL_RED'.
WHEN 'LE'.
ICON_NAME = 'ICON_LESS_EQUAL_RED'.
WHEN 'BT'.
ICON_NAME = 'ICON_INTERVAL_INCLUDE_RED'.
WHEN 'NB'.
ICON_NAME = 'ICON_INTERVAL_EXCLUDE_RED'.
ENDCASE.
ENDIF.
CALL METHOD column2-%GTadd_icon
EXPORTING
sap_icon = ICON_NAME.
**************************
old_line_text = line_text.
ENDIF.
CALL METHOD column1-%GTadd_gap
EXPORTING
width = 3.
CALL METHOD column3-%GTadd_gap
EXPORTING
width = 3.
* for checkboxes or radio-buttons, place a checked icon
* in the value box instead of the X character
IF line_concat = 'X'.
CALL METHOD column3-%GTadd_icon
EXPORTING
sap_icon = 'ICON_CHECKED'.
ELSE.
line_text = line_concat.
CALL METHOD column3-%GTadd_text
EXPORTING
text = line_text.
ENDIF.
CALL METHOD column3-%GTadd_gap
EXPORTING
width = 3.
CALL METHOD text_box_top-%GTnew_line.
ENDIF.
ENDLOOP.
* get TOP-%GTHTML_TABLE ready
CALL METHOD text_box_top-%GTmerge_document.
ENDFORM. " create_screen_header_man
*---------------------------------------------------------------------*
* FORM OUTPUT_REPORT_HEADER *
*---------------------------------------------------------------------*
* Output Report Header *
*---------------------------------------------------------------------*
* --%GT P_TITLE2 *
* --%GT P_TITLE3 *
*---------------------------------------------------------------------*
FORM output_page_header USING p_title2 p_title3.
***
* Variables to control Column Header and Page # Printing
DATA: print_pages(1) TYPE c VALUE 'X'.
* Control Page Description. Displays '** Supplemental Page ** if value
* is not populated in ABAP program
DATA: page_desc(23) TYPE c.
DATA: title1(80) VALUE ' *** Company Confidential - My Company ***'.
* Report Title Lengths
DATA: title1_length TYPE i,
title2_length TYPE i,
title3_length TYPE i.
* Misc Report System Field Lengths
DATA: cprog_length TYPE i,
tcode_length TYPE i,
sysid_length TYPE i.
* Report Field Starting Positions
DATA: title1_start TYPE i,
title2_start TYPE i,
title3_start TYPE i,
right_start TYPE i.
CONSTANTS: c_max_width TYPE i VALUE '255'.
DATA: report_width TYPE i VALUE 0.
* Misc Field Lengths
* Get Report Title Lengths
title1_length = STRLEN( title1 ).
title2_length = STRLEN( p_title2 ).
title3_length = STRLEN( p_title3 ).
* Determine Report Title Starting Positions
IF sy-linsz %GT '255'.
report_width = c_max_width.
ELSE.
report_width = sy-linsz.
ENDIF.
title1_start = report_width / 2 - ( title1_length / 2 ).
title2_start = report_width / 2 - ( title2_length / 2 ).
title3_start = report_width / 2 - ( title3_length / 2 ).
right_start = report_width - 23.
* Determine actual field lengths for output
cprog_length = STRLEN( sy-cprog ).
tcode_length = STRLEN( sy-tcode ).
sysid_length = STRLEN( sy-sysid ).
* Print page numbering (Note: batch mode cannot print page x of x!)
IF print_pages = 'X'.
WRITE: AT right_start 'Page:', sy-pagno.
ELSE.
IF page_desc = space.
WRITE: AT right_start '** Supplemental Page **'.
ELSE.
WRITE: AT right_start page_desc.
ENDIF.
ENDIF.
* Output 2nd Report Title Line
WRITE: /1 'User:', 9 sy-uname.
WRITE: AT title2_start p_title2.
WRITE: AT right_start 'Date:', sy-datum.
* Output 3rd Report Title Line
WRITE: /1 'Transaction:', sy-tcode.
WRITE: AT title3_start p_title3.
WRITE: AT right_start 'Time:', sy-uzeit.
SKIP.
***
ENDFORM. " OUTPUT_REPORT_HEADER
*&---------------------------------------------------------------------*
*& Form print_list_header
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --%GT p1 text
* %LT-- p2 text
*----------------------------------------------------------------------*
FORM print_list_header.
DATA: max_lines TYPE i VALUE 50,
counter TYPE i VALUE 0.
TYPES: BEGIN OF s_infotab,
flag(1) TYPE c,
olength(1) TYPE x,
line TYPE rsvar-infoline,
END OF s_infotab.
DATA: infotab TYPE TABLE OF s_infotab,
wa_infotab TYPE s_infotab.
CALL FUNCTION 'PRINT_SELECTIONS'
EXPORTING
mode = 1
rname = sy-cprog
rvariante = sy-slset
TABLES
infotab = infotab
EXCEPTIONS
OTHERS = 1.
IF NOT sy-subrc = 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error in FM PRINT_SELECTIONS - contact support'.
ENDIF.
* if the page header extends beyond 57 lines, the entire page header
* will not fit on one page and a page header overflow results. Limit
* the selection parameter section to 50 lines so that the combination
* of the pager header and the list header will not overflow and dump.
LOOP AT infotab INTO wa_infotab.
counter = counter + 1.
IF NOT counter %GT max_lines.
WRITE: / wa_infotab-line.
ELSE.
WRITE: / '.....'.
EXIT.
ENDIF.
ENDLOOP.
ENDFORM. " print_list_header
*&---------------------------------------------------------------------*
*& Form setup_splitter_container
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --%GT p1 text
* %LT-- p2 text
*----------------------------------------------------------------------*
FORM setup_splitter_container USING p_mode TYPE string.
CONSTANTS: c_top_height TYPE i VALUE 22,
c_main_height TYPE i VALUE 50.
* create a custom container control
CREATE OBJECT custom_container
EXPORTING
container_name = g_container_name
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF p_mode = 'MODE1'.
main_container = custom_container.
ELSEIF p_mode = 'MODE2'.
* MODE2 - In mode 2 the screen is devided into into two seperate
* sections that are relative to the screen size. The top part to be
* used for displaying parameters takes 20% of the screen and the
* second section takes the remaining section of screen.
* create the splitter container to divide the screen
CREATE OBJECT ez_split_container
EXPORTING
parent = custom_container
orientation = 0 " horizontal split
sash_position = 20. " percent of top container
* set the containers to the appropriate section of the screen
top_container = ez_split_container-%GTtop_left_container.
main_container = ez_split_container-%GTbottom_right_container.
ELSEIF p_mode = 'MODE3'.
* MODE3 - In mode 3 the screen is devided into into three seperate
* sections that are fixed sizes. The top part to be
* used for displaying parameters takes 22 lines, the second takes 30
* lines and the third takes the remaining space in the screen
CREATE OBJECT splitter_container
EXPORTING
parent = custom_container
rows = 3
columns = 1.
CALL METHOD splitter_container-%GTset_border
EXPORTING
border = cl_gui_cfw=%GTtrue.
CALL METHOD splitter_container-%GTset_column_mode
EXPORTING
mode = splitter_container-%GTmode_absolute.
CALL METHOD splitter_container-%GTset_row_height
EXPORTING
id = 1
height = c_top_height.
CALL METHOD splitter_container-%GTset_row_height
EXPORTING
id = 2
height = c_main_height.
top_container =
splitter_container-%GTget_container( row = 1 column = 1 ).
main_container =
splitter_container-%GTget_container( row = 2 column = 1 ).
bottom_container =
splitter_container-%GTget_container( row = 3 column = 1 ).
ELSEIF p_mode = 'MODE3B'.
* MODE3B - In this mode the screen is devided into three seperate
* sections that are relative to the screen size. The top part to be
* used for displaying parameters takes 20% of the screen and the two
* other parts take equal amounts of the remaining space.
CREATE OBJECT splitter_container
EXPORTING
parent = custom_container
rows = 3
columns = 1.
CALL METHOD splitter_container-%GTset_border
EXPORTING
border = cl_gui_cfw=%GTtrue.
CALL METHOD splitter_container-%GTset_column_mode
EXPORTING
mode = splitter_container-%GTmode_relative.
CALL METHOD splitter_container-%GTset_row_height
EXPORTING
id = 1
height = 20.
CALL METHOD splitter_container-%GTset_row_height
EXPORTING
id = 2
height = 38.
top_container =
splitter_container-%GTget_container( row = 1 column = 1 ).
main_container =
splitter_container-%GTget_container( row = 2 column = 1 ).
bottom_container =
splitter_container-%GTget_container( row = 3 column = 1 ).
ENDIF.
ENDFORM. " setup_splitter_container
*&---------------------------------------------------------------------*
*& Form setup_splitter_container
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --%GT p1 text
* %LT-- p2 text
*----------------------------------------------------------------------*
FORM setup_splitter_container2 USING p_mode TYPE string.
CONSTANTS: c_top_height TYPE i VALUE 22,
c_main_height TYPE i VALUE 50.
* create a custom container control
CREATE OBJECT custom_container2
EXPORTING
container_name = g_container_name2
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF p_mode = 'MODE1'.
main_container2 = custom_container2.
ELSEIF p_mode = 'MODE2'.
* MODE2 - In mode 2 the screen is devided into into two seperate
* sections that are relative to the screen size. The top part to be
* used for displaying parameters takes 20% of the screen and the
* second section takes the remaining section of screen.
* create the splitter container to divide the screen
CREATE OBJECT ez_split_container2
EXPORTING
parent = custom_container2
orientation = 0 " horizontal split
sash_position = 20. " percent of top container
* set the containers to the appropriate section of the screen
top_container2 = ez_split_container2-%GTtop_left_container.
main_container2 = ez_split_container2-%GTbottom_right_container.
ELSEIF p_mode = 'MODE3'.
* MODE3 - In mode 3 the screen is devided into into three seperate
* sections that are fixed sizes. The top part to be
* used for displaying parameters takes 22 lines, the second takes 30
* lines and the third takes the remaining space in the screen
CREATE OBJECT splitter_container2
EXPORTING
parent = custom_container2
rows = 3
columns = 1.
CALL METHOD splitter_container2-%GTset_border
EXPORTING
border = cl_gui_cfw=%GTtrue.
CALL METHOD splitter_container2-%GTset_column_mode
EXPORTING
mode = splitter_container2-%GTmode_absolute.
CALL METHOD splitter_container2-%GTset_row_height
EXPORTING
id = 1
height = c_top_height.
CALL METHOD splitter_container2-%GTset_row_height
EXPORTING
id = 2
height = c_main_height.
top_container =
splitter_container2-%GTget_container( row = 1 column = 1 ).
main_container =
splitter_container2-%GTget_container( row = 2 column = 1 ).
bottom_container =
splitter_container2-%GTget_container( row = 3 column = 1 ).
ELSEIF p_mode = 'MODE3B'.
* MODE3B - In this mode the screen is devided into three seperate
* sections that are relative to the screen size. The top part to be
* used for displaying parameters takes 20% of the screen and the two
* other parts take equal amounts of the remaining space.
CREATE OBJECT splitter_container2
EXPORTING
parent = custom_container2
rows = 3
columns = 1.
CALL METHOD splitter_container2-%GTset_border
EXPORTING
border = cl_gui_cfw=%GTtrue.
CALL METHOD splitter_container2-%GTset_column_mode
EXPORTING
mode = splitter_container2-%GTmode_relative.
CALL METHOD splitter_container2-%GTset_row_height
EXPORTING
id = 1
height = 20.
CALL METHOD splitter_container2-%GTset_row_height
EXPORTING
id = 2
height = 38.
top_container =
splitter_container2-%GTget_container( row = 1 column = 1 ).
main_container =
splitter_container2-%GTget_container( row = 2 column = 1 ).
bottom_container =
splitter_container2-%GTget_container( row = 3 column = 1 ).
ENDIF.
ENDFORM. " setup_splitter_container2
*&---------------------------------------------------------------------*
*& Form setup_alv_grid
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --%GT p1 text
* %LT-- p2 text
*----------------------------------------------------------------------*
FORM setup_alv_grid.
* create an instance of alv control
CREATE OBJECT grid1
EXPORTING i_parent = main_container.
IF NOT g_structure_name IS INITIAL.
IF %LTgt_output%GT IS ASSIGNED.
CALL METHOD grid1-%GTset_table_for_first_display
EXPORTING
i_structure_name = g_structure_name
is_variant = gs_variant
i_save = 'A'
i_default = 'X'
is_print = gs_print
is_layout = gs_layout
CHANGING
it_outtab = %LTgt_output%GT
it_sort = gt_sort.
ELSE.
CALL METHOD grid1-%GTset_table_for_first_display
EXPORTING
i_structure_name = g_structure_name
is_variant = gs_variant
i_save = 'A'
i_default = 'X'
is_print = gs_print
is_layout = gs_layout
CHANGING
it_outtab = gt_output[]
it_sort = gt_sort.
ENDIF.
ELSE.
IF %LTgt_output%GT IS ASSIGNED.
CALL METHOD grid1-%GTset_table_for_first_display
EXPORTING
is_variant = gs_variant
i_save = 'A'
i_default = 'X'
is_print = gs_print
is_layout = gs_layout
CHANGING
it_fieldcatalog = gt_fieldcat[]
it_outtab = %LTgt_output%GT
it_sort = gt_sort.
ELSE.
CALL METHOD grid1-%GTset_table_for_first_display
EXPORTING
is_variant = gs_variant
i_save = 'A'
i_default = 'X'
is_print = gs_print
is_layout = gs_layout
CHANGING
it_fieldcatalog = gt_fieldcat[]
it_outtab = gt_output[]
it_sort = gt_sort.
ENDIF.
ENDIF.
ENDFORM. " setup_alv_grid
*&---------------------------------------------------------------------*
*& Form setup_alv_grid
*&---------------------------------------------------------------------*
FORM setup_dynamic_alv_grid.
* create an instance of alv control
CREATE OBJECT grid1
EXPORTING i_parent = main_container.
IF NOT g_structure_name IS INITIAL.
CALL METHOD grid1-%GTset_table_for_first_display
EXPORTING
i_structure_name = g_structure_name
is_variant = gs_variant
i_save = 'A'
i_default = 'X'
is_print = gs_print
is_layout = gs_layout
CHANGING
it_outtab = gt_output[]
it_sort = gt_sort.
ELSE.
CALL METHOD grid1-%GTset_table_for_first_display
EXPORTING
is_variant = gs_variant
i_save = 'A'
i_default = 'X'
is_print = gs_print
is_layout = gs_layout
CHANGING
it_fieldcatalog = gt_fieldcat[]
it_outtab = gt_output[]
it_sort = gt_sort.
ENDIF.
ENDFORM. " setup_alv_grid
*&---------------------------------------------------------------------*
*& Form setup_screen_header
*&---------------------------------------------------------------------*
FORM setup_screen_header.
* create an instance of the document control
CREATE OBJECT text_box_top
EXPORTING
background_color = 240.
PERFORM create_screen_header_man.
* CALL METHOD text_box_top-%GTadd_picture
* EXPORTING
* picture_id = 'ALV_BACKGROUND'
** WIDTH =
** ALTERNATIVE_TEXT =
* TABINDEX = '2'
* .
CALL METHOD text_box_top-%GTset_document_background
EXPORTING
picture_id = 'ALV_BACKGROUND'.
* display the document in the upper container
CALL METHOD text_box_top-%GTdisplay_document
EXPORTING
parent = top_container
EXCEPTIONS
html_display_error = 1
OTHERS = 2.
*CAMO_COL_1594_735
ENDFORM. " setup_screen_header
*&---------------------------------------------------------------------*
*& Form set_event_handlers
*&---------------------------------------------------------------------*
FORM set_event_handlers.
* Create Object to receive events and link them to handler methods.
* When the ALV Control raises the event for the specified instance
* the corresponding method is automatically called.
CREATE OBJECT event_receiver.
SET HANDLER event_receiver-%GThandle_top_of_list FOR grid1.
SET HANDLER event_receiver-%GThandle_top_of_page FOR grid1.
SET HANDLER event_receiver-%GThandle_end_of_list FOR grid1.
SET HANDLER event_receiver-%GThandle_end_of_page FOR grid1.
SET HANDLER event_receiver-%GThandle_double_click FOR grid1.
SET HANDLER event_receiver-%GThandle_data_changed FOR grid1.
SET HANDLER event_receiver-%GThandle_data_changed_finished FOR grid1.
ENDFORM. " set_event_handlers
*&--------------------------------------------------------------------*
*& Form SET_MODIFIABLE_GRID
*&--------------------------------------------------------------------*
FORM set_modifiable_grid.
* this method will trigger the changed_data event as soon as the data
* is changed. Without this method the changed_data event is only
* triggered when a second field is modified
CALL METHOD grid1-%GTregister_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=%GTmc_evt_enter.
ENDFORM. "SET_MODIFIABLE_GRID
****************************************************************
* LOCAL CLASSES: Implementation
****************************************************************
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_top_of_page.
IF NOT sy-pagno = 1.
PERFORM output_page_header
USING g_report_name
''.
ENDIF.
ENDMETHOD. "handle_top_of_page
*-------------------------------------------
METHOD handle_end_of_page.
ENDMETHOD. "handle_end_of_page
*-------------------------------------------
METHOD handle_top_of_list.
PERFORM print_list_header.
ENDMETHOD. "handle_top_of_list
*-------------------------------------------
METHOD handle_end_of_list.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_list_commentary
i_logo = 'CAMO_COL_1594_735'
* I_END_OF_LIST_GRID =
.
ENDMETHOD. "handle_end_of_list
*-------------------------------------------
METHOD handle_double_click.
ENDMETHOD. "handle_double_click
*-------------------------------------------
METHOD handle_data_changed.
ENDMETHOD. "handle_data_changed
METHOD handle_data_changed_finished.
DATA: lt_good LIKE LINE OF et_good_cells,
wa_output LIKE LINE OF gt_output,
l_fieldname1(60) TYPE c,
l_fieldname2(30) TYPE c.
FIELD-SYMBOLS: %LTfs1%GT TYPE ANY,
%LTfs2%GT TYPE ANY.
IF NOT e_modified IS INITIAL.
LOOP AT et_good_cells INTO lt_good.
CONCATENATE 'wa_output-' lt_good-fieldname INTO l_fieldname1.
ASSIGN (l_fieldname1) TO %LTfs1%GT.
l_fieldname2 = lt_good-fieldname.
SHIFT lt_good-value LEFT DELETING LEADING space.
%LTfs1%GT = lt_good-value.
MODIFY gt_output INDEX lt_good-row_id FROM wa_output
TRANSPORTING (l_fieldname2).
ENDLOOP.
ENDIF.
ENDMETHOD. "HANDLE_DATA_CHANGED_FINISHED
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
************************************************************************
* INITIALIZATION
************************************************************************
INITIALIZATION.
g_report_name = text-002.
g_container_name = 'CONTAINER1'.
* g_structure_name = 'ZPPLAN_DOWNL_UPL_STRUCT1'.
g_repid = sy-repid.
gs_print-reservelns = '2'. "reserved lines for end of page
gs_layout-cwidth_opt = 'X'. "optimize column width flag
gs_layout-zebra = 'X'. "zebra color patern
* DI1K907032 Madhu 20/08/2008 - Begin - PP-0414 - for customized style
gs_layout-stylefname = 'XYZSTYLEZYX'.
* DI1K907032 Madhu 20/08/2008 - End
gs_variant-report = g_report_name.
s_bwart-low = '261'.
s_bwart-sign = 'I'.
s_bwart-option = 'EQ'.
append s_bwart.
s_bwart-low = '262'.
s_bwart-sign = 'I'.
s_bwart-option = 'EQ'.
append s_bwart.
s_bwart-low = '551'.
s_bwart-sign = 'I'.
s_bwart-option = 'EQ'.
append s_bwart.
s_bwart-low = '552'.
s_bwart-sign = 'I'.
s_bwart-option = 'EQ'.
append s_bwart.
s_bwart-low = '553'.
s_bwart-sign = 'I'.
s_bwart-option = 'EQ'.
append s_bwart.
s_bwart-low = '554'.
s_bwart-sign = 'I'.
s_bwart-option = 'EQ'.
append s_bwart.
s_bwart-low = '555'.
s_bwart-sign = 'I'.
s_bwart-option = 'EQ'.
append s_bwart.
s_bwart-low = '556'.
s_bwart-sign = 'I'.
s_bwart-option = 'EQ'.
append s_bwart.
s_bwart-low = '543'.
s_bwart-sign = 'I'.
s_bwart-option = 'EQ'.
append s_bwart.
s_bwart-low = '544'.
s_bwart-sign = 'I'.
s_bwart-option = 'EQ'.
append s_bwart.
* Pour restreindre aux administrateurs seulement (incluant BATCH)
* PERFORM superuser(zssecur1) USING 'X'.
* Verifie si l'utilisateur a acces au programme
* PERFORM transaction_check(zssecur1) USING sy-tcode.
*
************************************************************************
* START-OF-SELECTION
************************************************************************
START-OF-SELECTION.
IF NOT rb_downl IS INITIAL.
* DOWNLOAD
* Everybody will have access in DL mode
* AUTHORITY-CHECK OBJECT 'ZM_ZMM02_D'
* ID 'ACTVT' FIELD 'DL'.
* IF sy-subrc NE 0.
* MESSAGE text-102 TYPE 'I'.
* LEAVE LIST-PROCESSING.
* endif.
* DI1K907032 Madhu 20/08/2008 - Begin - PP-0414 - for exploding the bom
PERFORM explode_active_boms.
* DI1K907032 Madhu 20/08/2008 - End
PERFORM get_material_list.
PERFORM get_material_plant_data.
* DI1K907032 Madhu 20/08/2008 - Begin - PP-0414 - for creating & filling
* dynamic table
PERFORM create_dynamic_table.
PERFORM fill_dynamic_columns.
* DI1K907032 Madhu 20/08/2008 - End
IF sy-batch EQ 'X'.
PERFORM export_to_excel.
ELSE.
CALL SCREEN 100.
ENDIF.
ELSE.
* UPLOAD
AUTHORITY-CHECK OBJECT 'ZM_ZMM02_D'
ID 'ACTVT' FIELD 'UL'.
IF sy-subrc NE 0.
MESSAGE text-102 TYPE 'I'.
LEAVE LIST-PROCESSING.
ENDIF.
IF NOT s_beskz-low CO 'F'.
MESSAGE text-101 TYPE 'I'.
LEAVE LIST-PROCESSING.
ENDIF.
PERFORM upload_excel_file.
IF sy-batch EQ 'X'.
PERFORM upload_modifications.
ELSE.
* DI1K907032 Madhu 20/08/2008 - Begin - PP-0414 - for creating & filling
* dynamic table
perform create_dynamic_table.
* DI1K907032 Madhu 20/08/2008 - End
CALL SCREEN 100.
ENDIF.
ENDIF.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_100'.
SET TITLEBAR 'TITLE_100'.
IF custom_container IS INITIAL.
PERFORM setup_splitter_container USING 'MODE2'.
PERFORM setup_fieldcat.
PERFORM set_custom_editable_grid.
PERFORM setup_alv_grid.
PERFORM setup_screen_header.
PERFORM set_event_handlers.
PERFORM set_event_handlers_local.
PERFORM set_modifiable_grid.
ENDIF. "IF custom_container IS INITIAL
* Controls are not integrated into the TAB-Order
* Call "set_focus" if you want to make sure that 'the cursor'
* is active in your control.
CALL METHOD cl_gui_control=%GTset_focus
EXPORTING
control = grid1.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
DATA: ok_code LIKE sy-ucomm,
e_valid TYPE char01.
CALL METHOD grid1-%GTcheck_changed_data
IMPORTING
e_valid = e_valid.
IF e_valid = 'X'.
MOVE sy-ucomm TO ok_code.
CASE ok_code.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'CMD_UPLOAD'.
* AUTHORITY-CHECK OBJECT 'ZM_ZMM02_D'
* ID 'ACTVT' FIELD 'UL'.
* IF sy-subrc NE 0.
* MESSAGE text-102 TYPE 'I'.
* RETURN.
* ENDIF.
PERFORM upload_modifications.
WHEN 'DLEXCEL'.
PERFORM export_to_excel.
ENDCASE.
ENDIF.
CLEAR ok_code.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Form exit_program
*&---------------------------------------------------------------------*
FORM exit_program.
CALL METHOD custom_container-%GTfree.
CALL METHOD cl_gui_cfw=%GTflush.
IF sy-subrc NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error in Flush(009) - contact support'.
ENDIF.
LEAVE PROGRAM.
ENDFORM. "exit_program
*&---------------------------------------------------------------------*
*& Include ZPIPLANNING_DOWNL_UPL_INC1
*&---------------------------------------------------------------------*
*----------------------------------------------------------------------*
***INCLUDE ZPIPLANNING_DOWNL_UPL_INC1 .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form get_material_plant_data
*&---------------------------------------------------------------------*
FORM get_material_plant_data .
if not p_lgnum is initial.
select matnr from mlgn into table gt_mlgn
for all entries in it_matnr_list
where matnr = it_matnr_list-matnr
and lgnum = p_lgnum.
it_matnr_list[] = gt_mlgn[].
endif.
LOOP AT it_matnr_list ASSIGNING %LTfs_matnr_list%GT.
PERFORM get_material_data.
IF NOT s_werks IS INITIAL.
DELETE it_marc FROM 1
WHERE NOT werks IN s_werks.
ENDIF.
LOOP AT it_marc ASSIGNING %LTfs_marc%GT.
CLEAR wa_imp_exp.
* DI1K907032 Madhu 03/09/2008 - Begin - PP-0414 - Fetching DChain spec
* status.
PERFORM get_sales_status.
if wa_imp_exp-vmsta is initial.
continue.
endif.
* DI1K907032 Madhu 20/08/2008 - End
PERFORM get_info_record_data.
PERFORM get_mrp_data.
PERFORM get_price_data.
PERFORM get_classification_data.
PERFORM read_mat_master_data.
PERFORM read_material_texts.
PERFORM read_plant_material_data.
* DI1K907032 Madhu 20/08/2008 - Begin - PP-0414 - Fetching Warehouse,
* Classification,
* Consumption, SupplyArea details.
PERFORM get_warehouse_data.
PERFORM get_classification.
PERFORM get_consumption.
PERFORM get_supply_area.
* DI1K907032 Madhu 20/08/2008 - End
* DI1K907032 Madhu 20/08/2008 - Begin - PP-0414 - Commented as
* gt_imp_exp is already filling in get_supply_area
*
* APPEND wa_imp_exp TO gt_imp_exp.
* DI1K907032 Madhu 20/08/2008 - End of comment
ENDLOOP.
ENDLOOP.
IF gt_output[] IS INITIAL.
gt_output[] = gt_imp_exp.
ENDIF.
ENDFORM. " get_material_plant_data
*&---------------------------------------------------------------------*
*& Form get_info_record_data
*&---------------------------------------------------------------------*
FORM get_info_record_data .
DATA: l_esokz TYPE esokz,
l_konp TYPE konp.
DATA: l_text1(70) type c,
l_text2(70) type c,
l_lines type i.
DATA: l_plnnr type mapl-plnnr,
l_beskz type marc-beskz,
l_arbid type plpo-arbid.
g_inforec_found = 0.
g_inforec_cond_found = 0.
* DI1K907032 Madhu 20/08/2008 - Begin - PP-0414 - Fetching the
* SupplyArea for supplier for 'E' Procurement type.
select single beskz from marc into l_beskz where matnr =
%LTfs_marc%GT-matnr
and werks =
%LTfs_marc%GT-werks.
IF l_beskz = 'E'.
clear wa_bom_comp.
read table gt_bom_comp into wa_bom_comp with key mat_comp =
%LTfs_marc%GT-matnr.
if sy-subrc eq 0.
select single plnnr from mapl into l_plnnr where matnr =
wa_bom_comp-mat_bom
and werks in s_werks.
select plnal statu datuv from plko into table gt_plko
where plnnr = l_plnnr
and plnty = 'N'.
clear wa_plko.
loop at gt_plko into wa_plko where statu = '4'
and datuv %LT= sy-datum.
exit.
endloop.
select plnkn from plas into table gt_plas where plnty = 'N'
and plnnr = l_plnnr
and plnal =
wa_plko-plnal
and loekz ne 'X'.
describe table gt_plas lines l_lines.
clear wa_plas.
read table gt_plas into wa_plas index l_lines.
select single arbid from plpo into l_arbid
where plnty = 'N'
and plnnr = l_plnnr
and plnkn = wa_plas-plnkn.
select single arbpl from crhd
into wa_imp_exp-lifnr where objty = 'A'
and objid = l_arbid.
select single ktext from crtx into wa_imp_exp-name1 where objty =
'A'
and objid =
l_arbid
and spras =
sy-langu.
endif.
* DI1K907032 Madhu 20/08/2008 - End
ELSE.
REFRESH it_eord.
CALL FUNCTION 'MD_CHECK_SINGLE_SOURCE'
EXPORTING
matnr = %LTfs_marc%GT-matnr
werk = %LTfs_marc%GT-werks
datum = sy-datum
* ORDCK =
* IMPORTING
* SINGLE =
TABLES
eordx = it_eord.
* Kevin Norris 2008/04/29 - MM-0236
* we now want to manage autet 1 and 2 since
* GRBY is now using scheduling agreements
IF NOT it_eord IS INITIAL.
* DELETE it_eord
* FROM 1
* WHERE NOT flifn = 'X'
* or not ( autet = '1' or
* autet = '2' ).
DELETE it_eord
FROM 1
WHERE ( autet %LT 1 ) or
( autet = '1' and not flifn = 'X' ) or
( autet = '2' and not febel = 'X').
DESCRIBE TABLE it_eord LINES sy-tabix.
IF sy-tabix %GT 0.
READ TABLE it_eord ASSIGNING %LTfs_eord%GT INDEX 1.
CLEAR wa_lfa1.
CALL FUNCTION 'LFA1_READ_SINGLE'
EXPORTING
id_lifnr = %LTfs_eord%GT-lifnr
IMPORTING
es_lfa1 = wa_lfa1
EXCEPTIONS
not_found = 1
input_not_specified = 2
OTHERS = 3.
IF sy-subrc %LT%GT 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
wa_imp_exp-lifnr = %LTfs_eord%GT-lifnr.
wa_imp_exp-name1 = wa_lfa1-name1.
wa_imp_exp-land1 = wa_lfa1-land1.
wa_imp_exp-regio = wa_lfa1-regio.
* DI1K907032 Madhu 20/08/2008 - Begin - PP-0414 - Fetching Vendor
* details
wa_imp_exp-ort01 = wa_lfa1-ort01.
wa_imp_exp-stras = wa_lfa1-stras.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = %LTfs_eord%GT-lifnr
IMPORTING
OUTPUT = %LTfs_eord%GT-lifnr.
select tdspras from stxh into table gt_stxh
where tdobject = 'LFA1'
and tdname = %LTfs_eord%GT-lifnr
and tdid = '0003'.
if sy-subrc eq 0.
refresh gt_tline.
clear : wa_tline, wa_stxh, l_text1, l_text2.
read table gt_stxh into wa_stxh index 1.
move %LTfs_eord%GT-lifnr to l_text1.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = '0003'
LANGUAGE = wa_stxh-tdspras
NAME = l_text1
OBJECT = 'LFA1'
TABLES
LINES = gt_tline.
read table gt_tline into wa_tline index 1.
clear : l_text1 , l_text2.
split wa_tline-tdline at ' ' into l_text1 l_text2.
split l_text2 at ' ' into l_text1 l_text2.
select tdspras from stxh into table gt_stxh
where tdobject = 'TEXT'
and tdname = l_text1
and tdid = 'ST'.
if sy-subrc eq 0.
describe table gt_stxh lines l_lines.
refresh gt_tline.
clear : wa_stxh, wa_tline.
if l_lines eq 1.
read table gt_stxh into wa_stxh index 1.
else.
read table gt_stxh into wa_stxh with key tdspras =
sy-langu.
endif.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = 'ST'
LANGUAGE = wa_stxh-tdspras
NAME = l_text1
OBJECT = 'TEXT'
TABLES
LINES = gt_tline.
read table gt_tline into wa_tline index 1.
wa_imp_exp-carrier1 = wa_tline-tdline.
clear wa_tline.
read table gt_tline into wa_tline index 2.
wa_imp_exp-carrier2 = wa_tline-tdline.
endif.
endif.
* DI1K907032 Madhu 20/08/2008 - End
ENDIF.
CLEAR wa_eina.
CALL FUNCTION 'ME_EINA_SINGL_READ_MATNR_LIFNR'
EXPORTING
pi_matnr = %LTfs_marc%GT-matnr
pi_lifnr = %LTfs_eord%GT-lifnr
* RELIF_ONLY =
* REFRESH_BUFFER =
IMPORTING
po_eina = wa_eina
EXCEPTIONS
no_records_found = 1
OTHERS = 2.
IF sy-subrc %LT%GT 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
wa_imp_exp-mahn1 = wa_eina-mahn1.
wa_imp_exp-mahn2 = wa_eina-mahn2.
wa_imp_exp-mahn3 = wa_eina-mahn3.
g_inforec_found = 1.
ENDIF.
IF %LTfs_marc%GT-sobsl = 'SC'.
l_esokz = '3'.
ELSE.
l_esokz = '0'.
ENDIF.
REFRESH it_eine.
CALL FUNCTION 'SELECT_EINE_ALL_FIELDS_FOR'
EXPORTING
i_select_type = '1'
is_infnr = 'X'
i_infnr = wa_eina-infnr
is_ekorg = 'X'
i_ekorg = %LTfs_eord%GT-ekorg
is_esokz = 'X'
i_esokz = l_esokz
* IS_WERKS =
* I_WERKS =
* I_REALLY_EXIST =
i_bypass = 'X'
TABLES
* T_WHERE_CLAUSE_IN =
t_eine = it_eine
CHANGING
db_count = sy-tabix
EXCEPTIONS
not_found = 1
error_in_select = 2
OTHERS = 3.
IF sy-subrc %LT%GT 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
clear wa_eine.
READ TABLE it_eine INTO wa_eine INDEX 1.
wa_imp_exp-plifz = wa_eine-aplfz.
wa_imp_exp-ekgrp = wa_eine-ekgrp.
wa_imp_exp-ackno = wa_eine-kzabs.
ENDIF.
REFRESH it_a018.
SELECT datab datbi knumh
FROM a018
INTO (wa_a018-datab, wa_a018-datbi, wa_a018-knumh)
WHERE kappl = 'M'
AND kschl = 'PB00'
AND lifnr = %LTfs_eord%GT-lifnr
AND matnr = %LTfs_marc%GT-matnr.
APPEND wa_a018 TO it_a018.
ENDSELECT.
IF NOT it_a018[] IS INITIAL.
g_inforec_cond_found = 1.
ENDIF.
* if no conditions exist in validity dates, select the last valid
* condition
it_a018_tmp[] = it_a018.
DELETE it_a018_tmp FROM 1
WHERE NOT datab %LT= sy-datum
OR NOT datbi %GT= sy-datum.
DESCRIBE TABLE it_a018_tmp LINES sy-tabix.
IF sy-tabix = 0.
it_a018_tmp[] = it_a018.
ENDIF.
DESCRIBE TABLE it_a018_tmp LINES sy-tabix.
IF sy-tabix %GT 0.
REFRESH: it_condnum, it_konp, it_condscale.
CLEAR wa_condnum.
SORT it_a018_tmp BY datbi DESCENDING.
READ TABLE it_a018_tmp INTO wa_a018 INDEX 1.
IF sy-subrc = 0.
wa_condnum-sign = 'I'.
wa_condnum-option = 'EQ'.
wa_condnum-low = wa_a018-knumh.
APPEND wa_condnum TO it_condnum.
ENDIF.
CALL FUNCTION 'SD_KONP_SELECT'
EXPORTING
scale_read = 'X'
* LONG_TEXT_READ = 'X'
TABLES
condition_item = it_konp
condition_number = it_condnum
condition_scale = it_condscale.
DELETE it_konp FROM 1
WHERE NOT loevm_ko IS INITIAL.
* get setup price
LOOP AT it_konp ASSIGNING %LTfs_conp%GT WHERE kschl = 'ZAD2'.
wa_imp_exp-setup = %LTfs_conp%GT-kbetr.
IF NOT %LTfs_conp%GT-konws = 'CAD'.
PERFORM convert_currency USING %LTfs_conp%GT-kbetr
%LTfs_conp%GT-konwa
CHANGING wa_imp_exp-setup.
ENDIF.
EXIT.
ENDLOOP.
* get treatment costs
LOOP AT it_konp ASSIGNING %LTfs_conp%GT WHERE kschl = 'ZAD6'.
wa_imp_exp-traitm = %LTfs_conp%GT-kbetr.
IF NOT %LTfs_conp%GT-konws = 'CAD'.
PERFORM convert_currency USING %LTfs_conp%GT-kbetr
%LTfs_conp%GT-konwa
CHANGING wa_imp_exp-traitm.
ENDIF.
EXIT.
ENDLOOP.
* get condition price
LOOP AT it_konp ASSIGNING %LTfs_conp%GT WHERE kschl = 'PB00'.
wa_imp_exp-verpr = %LTfs_conp%GT-kbetr.
wa_imp_exp-peinh = %LTfs_conp%GT-kpein.
wa_imp_exp-bstme = %LTfs_conp%GT-meins.
IF NOT %LTfs_conp%GT-konws = 'CAD'.
PERFORM convert_currency USING %LTfs_conp%GT-kbetr
%LTfs_conp%GT-konwa
CHANGING wa_imp_exp-verpr.
ENDIF.
* PRICE IN BASE UNIT OF MEASURE
wa_imp_exp-verpr_uom = ( wa_imp_exp-verpr *
wa_eina-umren ) /
%LTfs_conp%GT-kpein /
wa_eina-umrez.
* validate if scales exist
READ TABLE it_condscale INTO wa_condscale WITH KEY
knumh = %LTfs_conp%GT-knumh
kopos = %LTfs_conp%GT-kopos.
IF sy-subrc = 0.
wa_imp_exp-kostkz = 'X'.
ELSE.
wa_imp_exp-kostkz = ' '.
ENDIF.
EXIT.
ENDLOOP.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " get_info_record_data
*&---------------------------------------------------------------------*
*& Form read_mat_master_data
*&---------------------------------------------------------------------*
FORM read_mat_master_data .
wa_imp_exp-meins = wa_mara-meins.
wa_imp_exp-bismt = wa_mara-bismt.
wa_imp_exp-labor = wa_mara-labor.
wa_imp_exp-brgew = wa_mara-brgew.
wa_imp_exp-gewei = wa_mara-gewei.
wa_imp_exp-ntgew = wa_mara-ntgew.
wa_imp_exp-groes = wa_mara-groes.
wa_imp_exp-volum = wa_mara-volum.
wa_imp_exp-voleh = wa_mara-voleh.
wa_imp_exp-ekwsl = wa_mara-ekwsl.
* DI1K907032 Madhu 20/08/2008 - Begin - PP-0414 - Filling additional
* Material details
wa_imp_exp-normt = wa_mara-normt.
wa_imp_exp-mfrpn = wa_mara-mfrpn.
wa_imp_exp-ferth = wa_mara-ferth.
* DI1K907032 Madhu 20/08/2008 - End
IF g_inforec_found = 0.
* Reminder 1
IF wa_imp_exp-mahn1 IS INITIAL.
wa_imp_exp-mahn1 = wa_t405-mahn1.
ENDIF.
* Reminder 2
IF wa_imp_exp-mahn2 IS INITIAL.
wa_imp_exp-mahn2 = wa_t405-mahn2.
ENDIF.
* Reminder 3
IF wa_imp_exp-mahn3 IS INITIAL.
wa_imp_exp-mahn3 = wa_t405-mahn3.
ENDIF.
* Ackno required
IF wa_imp_exp-ackno IS INITIAL.
wa_imp_exp-ackno = wa_t405-kzabs.
ENDIF.
IF wa_imp_exp-bstme IS INITIAL.
wa_imp_exp-bstme = wa_mara-bstme.
ENDIF.
ENDIF.
ENDFORM. " get_mat_master_data
*&---------------------------------------------------------------------*
*& Form read_plant_material_data
*&---------------------------------------------------------------------*
FORM read_plant_material_data .
IF g_inforec_found = 0.
IF wa_imp_exp-plifz IS INITIAL.
wa_imp_exp-plifz = %LTfs_marc%GT-plifz. " GR Lead Time
ENDIF.
IF wa_imp_exp-ekgrp IS INITIAL.
wa_imp_exp-ekgrp = %LTfs_marc%GT-ekgrp. " Buyer
ENDIF.
ENDIF.
wa_imp_exp-werks = %LTfs_marc%GT-werks. " Plant
wa_imp_exp-matnr = %LTfs_marc%GT-matnr. " Material
wa_imp_exp-dispo = %LTfs_marc%GT-dispo. " MRP Controller
wa_imp_exp-mmsta = %LTfs_marc%GT-mmsta. " Plant-Specific Material Status
wa_imp_exp-webaz = %LTfs_marc%GT-webaz. " GR Lead Time
wa_imp_exp-eisbe = %LTfs_marc%GT-eisbe. " Safty Stock
wa_imp_exp-eislo = %LTfs_marc%GT-eislo. " Min Safty stock
wa_imp_exp-dismm = %LTfs_marc%GT-dismm. " MRP Type
wa_imp_exp-shzet = %LTfs_marc%GT-shzet. " Safty Time
wa_imp_exp-shflg = %LTfs_marc%GT-shflg. " Safty Time indicator
wa_imp_exp-maabc = %LTfs_marc%GT-maabc. " ABC Code
wa_imp_exp-disgr = %LTfs_marc%GT-disgr. " MRP Group
wa_imp_exp-mrppp = %LTfs_marc%GT-mrppp. " Planning Calendar
wa_imp_exp-rwpro = %LTfs_marc%GT-rwpro. " Coverage Profile
wa_imp_exp-bstrf = %LTfs_marc%GT-bstrf. " Rounding Value
wa_imp_exp-disls = %LTfs_marc%GT-disls. " Lot Size
wa_imp_exp-bstmi = %LTfs_marc%GT-bstmi. " Min. Lot Size
wa_imp_exp-sobsl = %LTfs_marc%GT-sobsl. " Spec. Proc. Type
wa_imp_exp-beskz = %LTfs_marc%GT-beskz. " Procurement Type
wa_imp_exp-qmatv = %LTfs_marc%GT-qmatv. " Inspection Setup
wa_imp_exp-schgt = %LTfs_marc%GT-schgt. " Bulk Indicator
wa_imp_exp-ekgrp = %LTfs_marc%GT-ekgrp. " Purchasing Group
* DI1K907032 Madhu 20/08/2008 - Begin - PP-0414 - Filling additional
* plant details
wa_imp_exp-bstma = %LTfs_marc%GT-bstma. " Maximum lot size
wa_imp_exp-minbe = %LTfs_marc%GT-minbe. " Reorder Point
wa_imp_exp-mabst = %LTfs_marc%GT-mabst. " Maximum stock level
* DI1K907032 Madhu 20/08/2008 - End
ENDFORM. " get_plant_material_data
*&---------------------------------------------------------------------*
*& Form read_material_texts
*&---------------------------------------------------------------------*
FORM read_material_texts .
READ TABLE it_makt ASSIGNING %LTfs_makt%GT
WITH KEY matnr = %LTfs_matnr_list%GT-matnr
spras = sy-langu.
IF sy-subrc = 0.
wa_imp_exp-maktx = %LTfs_makt%GT-maktx..
ENDIF.
ENDFORM. " get_material_texts
*&---------------------------------------------------------------------*
*& Form get_material_list
*&---------------------------------------------------------------------*
FORM get_material_list .
DATA: lpad18(18) TYPE c VALUE '000000000000000000'.
REFRESH gt_imp_exp.
* DI1K907032 Madhu 20/08/2008 - Begin of Comment - PP-0414 - Need to
* pick bom components also
* IF NOT rb_downl IS INITIAL.
SELECT matnr
FROM mara
INTO TABLE it_matnr_list
WHERE matnr IN s_matnr.
* ELSE.
* LOOP AT gt_output ASSIGNING %LTfs_output%GT.
* wa_matnr_list-matnr = %LTfs_output%GT-matnr.
* wa_matnr_list-werks = %LTfs_output%GT-werks.
* IF wa_matnr_list-matnr CO '0123456789. '.
* SHIFT wa_matnr_list-matnr RIGHT DELETING TRAILING space.
* OVERLAY wa_matnr_list-matnr WITH lpad18.
* ENDIF.
* APPEND wa_matnr_list TO it_matnr_list.
* ENDLOOP.
* ENDIF.
*
* DI1K907032 Madhu 20/08/2008 - End
ENDFORM. " get_material_list
*&---------------------------------------------------------------------*
*& Form get_material_data
*&---------------------------------------------------------------------*
FORM get_material_data .
CLEAR wa_mara.
CALL FUNCTION 'MARA_SINGLE_READ'
EXPORTING
* KZRFB = ' '
* MAXTZ = 0
matnr = %LTfs_matnr_list%GT-matnr
* SPERRMODUS = ' '
* STD_SPERRMODUS = ' '
* OUTPUT_NO_MESSAGE =
IMPORTING
wmara = wa_mara
EXCEPTIONS
lock_on_material = 1
lock_system_error = 2
wrong_call = 3
not_found = 4
OTHERS = 5.
IF sy-subrc %LT%GT 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CLEAR: it_makt.
REFRESH: it_makt.
CALL FUNCTION 'MAKT_GENERIC_READ_WITH_MATNR'
EXPORTING
* KZRFB = ' '
matnr = %LTfs_matnr_list%GT-matnr
TABLES
* KTEXT =
makt_tab = it_makt
EXCEPTIONS
wrong_call = 1
not_found = 2
OTHERS = 3.
IF sy-subrc %LT%GT 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CLEAR: it_marc.
REFRESH: it_marc.
CALL FUNCTION 'MARC_READ_WITH_MATNR'
EXPORTING
matnr = %LTfs_matnr_list%GT-matnr
* KZRFB = ' '
* SPERRMODUS = ' '
* STD_SPERRMODUS = ' '
TABLES
marc_tab = it_marc
EXCEPTIONS
not_found = 1
lock_on_marc = 2
lock_system_error = 3
enqueue_mode_changed = 4
OTHERS = 5.
IF g_bom_components ne 'X'.
IF NOT rb_downl IS INITIAL.
DELETE it_marc FROM 1
WHERE NOT dispo IN s_dispo.
DELETE it_marc FROM 1
WHERE NOT werks IN s_werks.
DELETE it_marc FROM 1
WHERE NOT beskz IN s_beskz.
DELETE it_marc FROM 1
WHERE NOT sobsl IN s_sobsl.
DELETE it_marc FROM 1
WHERE NOT ekgrp IN s_ekgrp.
ENDIF.
ELSE.
IF NOT rb_downl IS INITIAL.
DELETE it_marc FROM 1
WHERE NOT dispo IN s_dispo.
DELETE it_marc FROM 1
WHERE NOT werks IN s_werks.
* DELETE it_marc FROM 1
* WHERE NOT beskz IN s_beskz.
* DELETE it_marc FROM 1
* WHERE NOT sobsl IN s_sobsl.
DELETE it_marc FROM 1
WHERE NOT ekgrp IN s_ekgrp.
ENDIF.
ENDIF.
clear wa_t405.
CALL FUNCTION 'T405_SINGLE_READ'
EXPORTING
* KZRFB = ' '
t405_ekwsl = wa_mara-ekwsl
IMPORTING
wt405 = wa_t405
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc %LT%GT 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " get_material_data
*&---------------------------------------------------------------------*
*& Form GET_MRP_DATA
*&---------------------------------------------------------------------*
FORM get_mrp_data .
DATA: mdtbx LIKE mdtb OCCURS 0.
DATA: BEGIN OF mdkpx OCCURS 0,
matnr LIKE mdkp-matnr,
meins LIKE mdkp-meins,
dtnum LIKE mdkp-dtnum,
cflag LIKE mdkp-cflag,
dsdat LIKE mdkp-dsdat,
END OF mdkpx.
g_error_flag = 0.
SELECT matnr meins dtnum cflag dsdat
INTO CORRESPONDING FIELDS OF TABLE mdkpx
FROM mdkp
WHERE plwrk EQ %LTfs_marc%GT-werks
AND dispo EQ %LTfs_marc%GT-dispo
AND matnr EQ %LTfs_marc%GT-matnr
AND dtart EQ 'MD'
AND sobsl IN s_sobsl.
LOOP AT mdkpx.
REFRESH mdtbx.
IF mdkpx-cflag EQ 'X'.
IMPORT mdtbx FROM DATABASE mdtc(ar) ID mdkpx-dtnum.
ELSE.
SELECT * FROM mdtb INTO TABLE mdtbx WHERE dtnum = mdkpx-dtnum .
ENDIF.
LOOP AT mdtbx INTO mdtb WHERE delkz IN s_delkz
AND dat00 IN s_dsdat
AND plaab %LT%GT '26'.
IF mdtb-plumi = '-'.
mdtb-mng01 = mdtb-mng01 * -1.
ENDIF.
wa_imp_exp-mng01 = wa_imp_exp-mng01 + mdtb-mng01.
ENDLOOP.
ENDLOOP.
ENDFORM. " GET_MRP_DATA
*&---------------------------------------------------------------------*
*& Form GET_PRICE_DATA
*&---------------------------------------------------------------------*
FORM get_price_data .
* IF wa_imp_exp-verpr IS INITIAL AND g_inforec_found = 0.
IF g_inforec_found = 0.
REFRESH it_mbew.
CALL FUNCTION 'MBEW_READ_WITH_MATNR'
EXPORTING
matnr = %LTfs_marc%GT-matnr
* KZRFB = ' '
* SPERRMODUS = ' '
* STD_SPERRMODUS = ' '
TABLES
mbew_tab = it_mbew
EXCEPTIONS
not_found = 1
lock_on_mbew = 2
lock_system_error = 3
enqueue_mode_changed = 4
OTHERS = 5.
IF sy-subrc %LT%GT 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
LOOP AT it_mbew ASSIGNING %LTfs_mbew%GT
WHERE bwkey = %LTfs_marc%GT-werks.
* kevin Norris 2008/01/10 - Begin - MM-0236
* always take mbew-stprs
* IF %LTfs_mbew%GT-vprsv = 'V'.
* wa_imp_exp-verpr = %LTfs_mbew%GT-verpr.
* wa_imp_exp-peinh = %LTfs_mbew%GT-peinh.
* ELSEIF %LTfs_mbew%GT-vprsv = 'S'.
wa_imp_exp-verpr = %LTfs_mbew%GT-stprs.
wa_imp_exp-peinh = %LTfs_mbew%GT-peinh.
* ENDIF.
* kevin Norris 2008/01/10 - End - MM-0236
*PRICE IN BASE UNIT OF MEASURE
* kevin Norris 2008/01/10 - Begin - MM-0236
* always take mbew-stprs
* wa_imp_exp-verpr_uom = %LTfs_mbew%GT-verpr /
* %LTfs_mbew%GT-peinh.
wa_imp_exp-verpr_uom = %LTfs_mbew%GT-stprs /
%LTfs_mbew%GT-peinh.
* kevin Norris 2008/01/10 - End - MM-0236
EXIT.
ENDLOOP.
ENDIF.
ENDIF.
ENDFORM. " GET_PRICE_DATA
*&---------------------------------------------------------------------*
*& Form get_classification_data
*&---------------------------------------------------------------------*
FORM get_classification_data.
DATA BEGIN OF allocvaluesnumnew OCCURS 0.
INCLUDE STRUCTURE bapi1003_alloc_values_num.
DATA END OF allocvaluesnumnew.
DATA BEGIN OF allocvaluescharnew OCCURS 0.
INCLUDE STRUCTURE bapi1003_alloc_values_char.
DATA END OF allocvaluescharnew.
DATA BEGIN OF allocvaluescurrnew OCCURS 0.
INCLUDE STRUCTURE bapi1003_alloc_values_curr.
DATA END OF allocvaluescurrnew.
DATA:
l_clint LIKE kssk-clint. "internal class number
DATA:
objectkey LIKE bapi1003_key-object,
objecttable LIKE bapi1003_key-objecttable VALUE 'EQUI',
classnum LIKE bapi1003_key-classnum,
classtype LIKE bapi1003_key-classtype VALUE '002',
status LIKE bapi1003_key-status,
standardclass LIKE bapi1003_key-stdclass,
keydate LIKE bapi1003_key-keydate.
DATA: class_range TYPE TABLE OF bapi1003_class_num_range,
alloclist TYPE TABLE OF bapi1003_alloc_list.
DATA BEGIN OF return OCCURS 0.
INCLUDE STRUCTURE bapiret2.
DATA END OF return.
REFRESH:
allocvaluesnumnew ,
allocvaluescharnew,
allocvaluescurrnew,
return.
CLEAR:
allocvaluesnumnew ,
allocvaluescharnew,
allocvaluescurrnew,
return.
** Get class name
SELECT SINGLE clint
FROM klah
INTO l_clint
WHERE klart EQ '001'
AND class EQ '94'.
* get internal class number
SELECT SINGLE clint FROM kssk
INTO l_clint
WHERE objek EQ %LTfs_marc%GT-matnr
AND mafid EQ 'O'
AND klart EQ '001'
AND clint EQ l_clint.
IF sy-subrc EQ 0.
* DETERMINER LA CLASSE A METTRE A JOUR
MOVE %LTfs_marc%GT-matnr TO objectkey.
WRITE '94' TO classnum.
MOVE '1' TO status.
MOVE sy-datum TO keydate.
MOVE 'MARA' TO objecttable.
MOVE '001' TO classtype.
CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'
EXPORTING
objectkey = objectkey
objecttable = objecttable
classnum = classnum
classtype = classtype
keydate = sy-datum
unvaluated_chars = ' '
IMPORTING
status = status
standardclass = standardclass
TABLES
allocvaluesnum = allocvaluesnumnew
allocvalueschar = allocvaluescharnew
allocvaluescurr = allocvaluescurrnew
return = return.
LOOP AT allocvaluescharnew WHERE charact = 'PIECE_PEINTURE'.
IF allocvaluescharnew-value_neutral = '1'.
wa_imp_exp-paint = 'X'.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. " get_classification_data
*&---------------------------------------------------------------------*
*& Form SETUP_FIELDCAT
*&---------------------------------------------------------------------*
FORM setup_fieldcat .
REFRESH r_fieldn.
PERFORM include_modif_field USING 'WEBAZ'.
PERFORM include_modif_field USING 'EISBE'.
PERFORM include_modif_field USING 'EISLO'.
* PERFORM include_modif_field USING 'DISMM'. " MM-0236
PERFORM include_modif_field USING 'SHZET'.
PERFORM include_modif_field USING 'SHFLG'.
PERFORM include_modif_field USING 'MAABC'.
* PERFORM include_modif_field USING 'DISGR'. " MM-0236
PERFORM include_modif_field USING 'MRPPP'.
* PERFORM include_modif_field USING 'RWPRO'. " MM-0236
PERFORM include_modif_field USING 'BSTRF'.
PERFORM include_modif_field USING 'DISLS'.
PERFORM include_modif_field USING 'BSTMI'.
PERFORM include_modif_field USING 'EKWSL'.
PERFORM include_modif_field USING 'DISPO'. " MM-0236
PERFORM include_modif_field USING 'EKGRP'. " MM-0236
* DI1K907032 Madhu 20/08/2008 - Begin - PP-0414 - Additional columns for
* update
PERFORM include_modif_field USING 'MINBE'.
PERFORM include_modif_field USING 'MABST'.
PERFORM include_modif_field USING 'DISGR'.
PERFORM include_modif_field USING 'BSTMA'.
PERFORM include_modif_field USING 'LTKZE'.
PERFORM include_modif_field USING 'LTKZA'.
PERFORM include_modif_field USING 'LGBKZ'.
PERFORM include_modif_field USING 'LGPLA'.
PERFORM include_modif_field USING 'BSSKZ'.
PERFORM include_modif_field USING 'SOBSL'.
PERFORM include_modif_field USING 'PFEP_CONS_SERVICE'.
PERFORM include_modif_field USING 'PFEP_ABC_CONSOMMATION'.
PERFORM include_modif_field USING 'PFEP_PIECE_KIT'.
PERFORM include_modif_field USING 'PFEP_RACK'.
PERFORM include_modif_field USING 'PFEP_FREQUENCY'.
PERFORM include_modif_field USING 'PFEP_ROUTE'.
PERFORM include_modif_field USING 'PFEP_QTE_MAX_CONTENANT'.
PERFORM include_modif_field USING 'PFEP_CONTENANT'.
PERFORM include_modif_field USING 'PFEP_CONT_FOURN_PROFONDEUR'.
PERFORM include_modif_field USING 'PFEP_CONT_FOURN_LARGEUR'.
PERFORM include_modif_field USING 'PFEP_CONT_FOURN_HAUTEUR'.
PERFORM include_modif_field USING 'PFEP_PIECE_PROFONDEUR'.
PERFORM include_modif_field USING 'PFEP_PIECE_LARGEUR'.
PERFORM include_modif_field USING 'PFEP_PIECE_HAUTEUR'.
PERFORM include_modif_field USING 'PFEP_CONT_INTERNE_PROFONDEUR'.
PERFORM include_modif_field USING 'PFEP_CONT_INTERNE_LARGEUR'.
PERFORM include_modif_field USING 'PFEP_CONT_INTERNE_HAUTEUR'.
PERFORM include_modif_field USING 'PFEP_OCCURENCE_MAX'.
PERFORM include_modif_field USING 'PFEP_METHODE_TRANSPORT'.
PERFORM include_modif_field USING 'PFEP_REVISION_DATE'.
* DI1K907032 Madhu 20/08/2008 - End
* CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
* EXPORTING
* i_structure_name = 'ZPPLAN_DOWNL_UPL_STRUCT1'
* CHANGING
* ct_fieldcat = gt_fieldcat[].
gt_fieldcat[] = ifc[].
LOOP AT gt_fieldcat.
IF gt_fieldcat-fieldname IN r_fieldn.
gt_fieldcat-edit = 'X'.
MODIFY gt_fieldcat.
ENDIF.
ENDLOOP.
ENDFORM. " SETUP_FIELDCAT
*&---------------------------------------------------------------------*
*& Form EXCLUDE_MODIF_FIELD
*&---------------------------------------------------------------------*
FORM include_modif_field USING value(p_1220) TYPE lvc_fname.
r_fieldn-sign = 'I'.
r_fieldn-option = 'EQ'.
r_fieldn-low = p_1220.
APPEND r_fieldn.
ENDFORM. " EXCLUDE_MODIF_FIELD
*&---------------------------------------------------------------------*
*& Form upload_excel_file
*&---------------------------------------------------------------------*
FORM upload_excel_file .
DATA : l_scol TYPE i VALUE '1',
l_srow TYPE i VALUE '1',
l_ecol TYPE i VALUE '114',
l_erow TYPE i VALUE '65536'.
DATA : ld_index TYPE i,
l_bom_count type i,
l_col_pos type i,
l_bom_flag type c value space,
l_bom type mara-matnr,
f_type,
l_field(50) TYPE c,
lpad18(18) TYPE c VALUE '000000000000000000'.
* DATA : lt_intern TYPE kcde_cells OCCURS 0 WITH HEADER LINE.
DATA : lt_intern TYPE alsmex_tabline OCCURS 0 WITH HEADER LINE.
FIELD-SYMBOLS: %LTfs%GT.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file
i_begin_col = l_scol
i_begin_row = l_srow
i_end_col = l_ecol
i_end_row = l_erow
TABLES
intern = lt_intern
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc %LT%GT 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF lt_intern[] IS INITIAL.
FORMAT COLOR COL_BACKGROUND INTENSIFIED.
MESSAGE w037(zz) WITH 'No Data Uploaded'.
EXIT.
ELSE.
* SORT lt_intern BY row col.
LOOP AT lt_intern.
MOVE : lt_intern-col TO ld_index.
* Picking the dynamic bom columns & creating dynamic bom table
if lt_intern-row = 1 and lt_intern-col = 35.
l_bom_count = 0.
refresh ifc_boms.
l_col_pos = 35.
loop at lt_intern from 35.
if lt_intern-value = 'Common'.
exit.
endif.
l_bom_count = l_bom_count + 1.
clear xfc_boms.
xfc_boms-fieldname = lt_intern-value.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'
EXPORTING
INPUT = lt_intern-value
IMPORTING
OUTPUT = l_bom.
xfc_boms-scrtext_l = l_bom.
xfc_boms-datatype = 'C'.
xfc_boms-inttype = 'C'.
xfc_boms-intlen = 3.
xfc_boms-decimals = 0.
xfc_boms-col_pos = l_col_pos.
append xfc_boms to ifc_boms.
l_col_pos = l_col_pos + 1.
endloop.
call method cl_alv_table_create=%GTcreate_dynamic_table
EXPORTING
it_fieldcatalog = ifc_boms
IMPORTING
ep_table = dy_boms_table.
assign dy_boms_table-%GT* to %LTgt_boms%GT.
create data dy_boms_line like line of %LTgt_boms%GT.
assign dy_boms_line-%GT* to %LTwa_boms%GT.
l_bom_count = l_bom_count + 35.
endif.
IF NOT chk_fir IS INITIAL AND lt_intern-row = 1.
CONTINUE.
ENDIF.
* assigning both static & dynamic content to work areas.
if lt_intern-col %LT 35 or lt_intern-col %GT= l_bom_count.
if lt_intern-col %GT= 35.
ld_index = ld_index - ( l_bom_count - 35 ).
endif.
ASSIGN COMPONENT ld_index OF STRUCTURE wa_imp_exp TO %LTfs%GT.
IF sy-subrc = 0.
DESCRIBE FIELD %LTfs%GT TYPE f_type.
IF NOT f_type = 'C'.
REPLACE ALL OCCURRENCES OF ',' IN lt_intern-value WITH ''.
CONDENSE lt_intern-value NO-GAPS.
ENDIF.
MOVE : lt_intern-value TO %LTfs%GT.
UNASSIGN %LTfs%GT.
ENDIF.
else.
ld_index = ld_index - 34.
assign component ld_index of structure %LTwa_boms%GT to %LTfs%GT.
if sy-subrc = 0.
move lt_intern-value to %LTfs%GT.
* l_bom_flag = 'X'.
unassign %LTfs%GT.
endif.
endif.
* filling the internal tables at end of each row
AT END OF row.
* CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'
* EXPORTING
* input = wa_imp_exp-meins
* language = sy-langu
* IMPORTING
* output = wa_imp_exp-meins
* EXCEPTIONS
* unit_not_found = 1
* OTHERS = 2.
* IF sy-subrc %LT%GT 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
* ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'
EXPORTING
input = wa_imp_exp-bstme
language = sy-langu
IMPORTING
output = wa_imp_exp-bstme
EXCEPTIONS
unit_not_found = 1
OTHERS = 2.
IF sy-subrc %LT%GT 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'
EXPORTING
input = wa_imp_exp-gewei
language = sy-langu
IMPORTING
output = wa_imp_exp-gewei
EXCEPTIONS
unit_not_found = 1
OTHERS = 2.
IF sy-subrc %LT%GT 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'
EXPORTING
input = wa_imp_exp-voleh
language = sy-langu
IMPORTING
output = wa_imp_exp-voleh
EXCEPTIONS
unit_not_found = 1
OTHERS = 2.
IF sy-subrc %LT%GT 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF wa_imp_exp-matnr CO '0123456789 '.
SHIFT wa_imp_exp-matnr RIGHT DELETING TRAILING space.
OVERLAY wa_imp_exp-matnr WITH lpad18.
ENDIF.
APPEND wa_imp_exp TO gt_output.
* if l_bom_flag = 'X'.
append %LTwa_boms%GT to %LTgt_boms%GT.
* endif.
CLEAR wa_imp_exp.
ENDAT.
ENDLOOP.
ENDIF.
ENDFORM. " upload_excel_file
*&---------------------------------------------------------------------*
*& Form UPLOAD_MODIFICATIONS
*&---------------------------------------------------------------------*
FORM upload_modifications .
PERFORM explode_active_boms.
* gt_bom_comp[] = gt_bom_comp_temp[].
PERFORM get_material_list.
PERFORM get_material_plant_data.
PERFORM determine_changes.
ENDFORM. " UPLOAD_MODIFICATIONS
*&---------------------------------------------------------------------*
*& Form DETERMINE_CHANGES
*&---------------------------------------------------------------------*
FORM determine_changes .
DATA: bapimathead LIKE bapimathead,
bapi_mara LIKE bapi_mara,
bapi_marax LIKE bapi_marax,
bapi_marc LIKE bapi_marc,
bapi_marcx LIKE bapi_marcx,
bapi_mpop LIKE bapi_mpop,
bapi_mpgd LIKE bapi_mpgd,
bapi_mard LIKE bapi_mard,
bapi_mbew LIKE bapi_mbew,
bapi_mlgn LIKE bapi_mlgn,
bapi_mlgnx LIKE bapi_mlgnx,
bapi_mvke LIKE bapi_mvke,
bapi_mlgt LIKE bapi_mlgt,
bapi_mlgtx LIKE bapi_mlgtx,
bapiret2 LIKE bapiret2.
DATA: bapi_makt LIKE bapi_makt OCCURS 0 WITH HEADER LINE,
bapi_marm LIKE bapi_marm OCCURS 0 WITH HEADER LINE,
bapi_mean LIKE bapi_mean OCCURS 0 WITH HEADER LINE,
bapi_mlan LIKE bapi_mlan OCCURS 0 WITH HEADER LINE,
bapi_matreturn2 LIKE bapi_matreturn2,
l_msgtxt LIKE bapiret2-message,
text_format LIKE bapitga-textformat.
DATA: change_flag TYPE i VALUE 0,
min_1_change TYPE i VALUE 0,
min_1_change1 TYPE i VALUE 0,
l_pad4(4) TYPE c VALUE '0000',
l_change_flag TYPE c,
l_error_flag TYPE c,
l_t_pfep TYPE c,
l_cl_pfep TYPE c.
DATA: it_return TYPE TABLE OF bapi_matreturn2.
FIELD-SYMBOLS: %LTfs_return%GT LIKE LINE OF it_return.
SORT gt_imp_exp.
DELETE ADJACENT DUPLICATES FROM gt_imp_exp.
CLEAR: g_total_good,
g_total_bad,
g_nochange.
LOOP AT gt_output ASSIGNING %LTfs_output%GT.
change_flag = 0.
clear: l_change_flag, l_error_flag.
CLEAR: bapimathead, bapi_mara, bapi_marax, bapi_marc, bapi_marcx.
READ TABLE gt_imp_exp ASSIGNING %LTfs_imp_exp%GT
WITH KEY matnr = %LTfs_output%GT-matnr
werks = %LTfs_output%GT-werks
prvbe = %LTfs_output%GT-prvbe.
IF %LTfs_output%GT-webaz NE %LTfs_imp_exp%GT-webaz.
bapi_marc-gr_pr_time = %LTfs_output%GT-webaz.
bapi_marcx-gr_pr_time = 'X'.
change_flag = 1.
PERFORM write_change
USING 'WEBAZ (GR Lead Time)'
%LTfs_imp_exp%GT-webaz %LTfs_output%GT-webaz.
ENDIF.
IF %LTfs_output%GT-eisbe NE %LTfs_imp_exp%GT-eisbe.
bapi_marc-safety_stk = %LTfs_output%GT-eisbe.
bapi_marcx-safety_stk = 'X'.
change_flag = 1.
PERFORM write_change
USING 'EISBE (Safety Stock)'
%LTfs_imp_exp%GT-eisbe %LTfs_output%GT-eisbe.
ENDIF.
IF %LTfs_output%GT-eislo NE %LTfs_imp_exp%GT-eislo.
bapi_marc-min_safety_stk = %LTfs_output%GT-eislo.
bapi_marcx-min_safety_stk = 'X'.
change_flag = 1.
PERFORM write_change
USING 'EISLO (Min. Safety Stock)'
%LTfs_imp_exp%GT-eislo %LTfs_output%GT-eislo.
ENDIF.
* Kevin Norris 2008/01/19 - Begin - MM-0236 - Block upload of this field
* IF %LTfs_output%GT-dismm NE %LTfs_imp_exp%GT-dismm.
* bapi_marc-mrp_type = %LTfs_output%GT-dismm.
* bapi_marcx-mrp_type = 'X'.
* change_flag = 1.
* PERFORM write_change
* USING 'DISMM (MRP Type)'
* %LTfs_imp_exp%GT-dismm %LTfs_output%GT-dismm.
* ENDIF.
* Kevin Norris 2008/01/19 - Begin - MM-0236 - Add new fields for update
IF %LTfs_output%GT-dispo NE %LTfs_imp_exp%GT-dispo.
bapi_marc-mrp_ctrler = %LTfs_output%GT-dispo.
bapi_marcx-mrp_ctrler = 'X'.
change_flag = 1.
PERFORM write_change
USING 'DISPO (MRP Controller)'
%LTfs_imp_exp%GT-dispo %LTfs_output%GT-dispo.
ENDIF.
IF %LTfs_output%GT-ekgrp NE %LTfs_imp_exp%GT-ekgrp.
bapi_marc-pur_group = %LTfs_output%GT-ekgrp.
bapi_marcx-pur_group = 'X'.
change_flag = 1.
PERFORM write_change
USING 'EKGRP (Purchasing Group)'
%LTfs_imp_exp%GT-ekgrp %LTfs_output%GT-ekgrp.
ENDIF.
IF %LTfs_output%GT-shzet NE %LTfs_imp_exp%GT-shzet.
bapi_marc-safetytime = %LTfs_output%GT-shzet.
bapi_marcx-safetytime = 'X'.
change_flag = 1.
PERFORM write_change
USING 'SHZET (Safty Time)'
%LTfs_imp_exp%GT-shzet %LTfs_output%GT-shzet.
ENDIF.
IF %LTfs_output%GT-shflg NE %LTfs_imp_exp%GT-shflg.
bapi_marc-safty_t_id = %LTfs_output%GT-shflg.
bapi_marcx-safty_t_id = 'X'.
change_flag = 1.
PERFORM write_change
USING 'SHFLG (Safty Time Indicator)'
%LTfs_imp_exp%GT-shflg %LTfs_output%GT-shflg.
ENDIF.
IF %LTfs_output%GT-maabc NE %LTfs_imp_exp%GT-maabc.
bapi_marc-abc_id = %LTfs_output%GT-maabc.
bapi_marcx-abc_id = 'X'.
change_flag = 1.
PERFORM write_change
USING 'MAABC (ABC Code)'
%LTfs_imp_exp%GT-maabc %LTfs_output%GT-maabc.
ENDIF.
* Kevin Norris 2008/01/19 - Begin - MM-0236 - Block upload of this field
* SHIFT %LTfs_imp_exp%GT-disgr RIGHT DELETING TRAILING space.
* SHIFT %LTfs_output%GT-disgr RIGHT DELETING TRAILING space.
* OVERLAY %LTfs_imp_exp%GT-disgr WITH l_pad4.
* OVERLAY %LTfs_output%GT-disgr WITH l_pad4.
* IF %LTfs_output%GT-disgr NE %LTfs_imp_exp%GT-disgr.
* bapi_marc-mrp_group = %LTfs_output%GT-disgr.
* bapi_marcx-mrp_group = 'X'.
* change_flag = 1.
* PERFORM write_change
* USING 'DISGR (MRP Group)'
* %LTfs_imp_exp%GT-disgr %LTfs_output%GT-disgr.
* ENDIF.
IF %LTfs_output%GT-mrppp NE %LTfs_imp_exp%GT-mrppp.
bapi_marc-ppc_pl_cal = %LTfs_output%GT-mrppp.
bapi_marcx-ppc_pl_cal = 'X'.
change_flag = 1.
PERFORM write_change
USING 'MRPPP (Plann. Calendar)'
%LTfs_imp_exp%GT-mrppp %LTfs_output%GT-mrppp.
ENDIF.
* Kevin Norris 2008/01/19 - Begin - MM-0236 - Block upload of this field
* IF %LTfs_output%GT-rwpro NE %LTfs_imp_exp%GT-rwpro.
* bapi_marc-covprofile = %LTfs_output%GT-rwpro.
* bapi_marcx-covprofile = 'X'.
* change_flag = 1.
* PERFORM write_change
* USING 'RWPRO (Coverage Profile)'
* %LTfs_imp_exp%GT-rwpro %LTfs_output%GT-rwpro.
* ENDIF.
IF %LTfs_output%GT-bstrf NE %LTfs_imp_exp%GT-bstrf.
bapi_marc-round_val = %LTfs_output%GT-bstrf.
bapi_marcx-round_val = 'X'.
change_flag = 1.
PERFORM write_change
USING 'BSTRF (Rounding Value)'
%LTfs_imp_exp%GT-bstrf %LTfs_output%GT-bstrf.
ENDIF.
IF %LTfs_output%GT-disls NE %LTfs_imp_exp%GT-disls.
bapi_marc-lotsizekey = %LTfs_output%GT-disls.
bapi_marcx-lotsizekey = 'X'.
change_flag = 1.
PERFORM write_change
USING 'DISLS (Lot Size)'
%LTfs_imp_exp%GT-disls %LTfs_output%GT-disls.
ENDIF.
IF %LTfs_output%GT-bstmi NE %LTfs_imp_exp%GT-bstmi.
bapi_marc-minlotsize = %LTfs_output%GT-bstmi.
bapi_marcx-minlotsize = 'X'.
change_flag = 1.
PERFORM write_change
USING 'BSTMI (Min. lot size)'
%LTfs_imp_exp%GT-bstmi %LTfs_output%GT-bstmi.
ENDIF.
IF %LTfs_output%GT-ekwsl NE %LTfs_imp_exp%GT-ekwsl.
bapi_mara-pur_valkey = %LTfs_output%GT-ekwsl.
bapi_marax-pur_valkey = 'X'.
change_flag = 1.
PERFORM write_change
USING 'EKWSL (Purch. Key Value)'
%LTfs_imp_exp%GT-ekwsl %LTfs_output%GT-ekwsl.
ENDIF.
* if %LTfs_output%GT- ne %LTfs_imp_exp%GT-.
* BAPI_MARC- = %LTfs_output%GT-.
* BAPI_MARCX- = 'X'.
* endif.
* DI1K907032 Madhu 20/08/2008 - Begin - PP-0414 - changes on additional
* columns
IF %LTfs_output%GT-minbe NE %LTfs_imp_exp%GT-minbe.
bapi_marc-reorder_pt = %LTfs_output%GT-minbe.
bapi_marcx-reorder_pt = 'X'.
change_flag = 1.
PERFORM write_change
USING 'MINBE (Reorder Point)'
%LTfs_imp_exp%GT-minbe %LTfs_output%GT-minbe.
ENDIF.
IF %LTfs_output%GT-mabst NE %LTfs_imp_exp%GT-mabst.
bapi_marc-max_stock = %LTfs_output%GT-mabst.
bapi_marcx-max_stock = 'X'.
change_flag = 1.
PERFORM write_change
USING 'MABST (Maximum stock level)'
%LTfs_imp_exp%GT-mabst %LTfs_output%GT-mabst.
ENDIF.
IF %LTfs_output%GT-disgr NE %LTfs_imp_exp%GT-disgr.
bapi_marc-mrp_group = %LTfs_output%GT-disgr.
bapi_marcx-mrp_group = 'X'.
change_flag = 1.
PERFORM write_change
USING 'DISGR (MRP Group)'
%LTfs_imp_exp%GT-disgr %LTfs_output%GT-disgr.
ENDIF.
IF %LTfs_output%GT-bstma NE %LTfs_imp_exp%GT-bstma.
bapi_marc-maxlotsize = %LTfs_output%GT-bstma.
bapi_marcx-maxlotsize = 'X'.
change_flag = 1.
PERFORM write_change
USING 'BSTMA (Maximum lot size)'
%LTfs_imp_exp%GT-bstma %LTfs_output%GT-bstma.
ENDIF.
IF %LTfs_output%GT-sobsl NE %LTfs_imp_exp%GT-sobsl.
bapi_marc-spproctype = %LTfs_output%GT-sobsl.
bapi_marcx-spproctype = 'X'.
change_flag = 1.
PERFORM write_change
USING 'SOBSL (Special procurement type)'
%LTfs_imp_exp%GT-sobsl %LTfs_output%GT-sobsl.
ENDIF.
IF %LTfs_output%GT-ltkza NE %LTfs_imp_exp%GT-ltkza.
bapi_mlgn-withdrawal = %LTfs_output%GT-ltkza.
bapi_mlgnx-withdrawal = 'X'.
change_flag = 1.
PERFORM write_change
USING 'LTKZA (St typ Ind - StockRemoval)'
%LTfs_imp_exp%GT-ltkza %LTfs_output%GT-ltkza.
ENDIF.
IF %LTfs_output%GT-ltkze NE %LTfs_imp_exp%GT-ltkze.
bapi_mlgn-placement = %LTfs_output%GT-ltkze.
bapi_mlgnx-placement = 'X'.
change_flag = 1.
PERFORM write_change
USING 'LTKZE (St typ Ind - StockPlacement)'
%LTfs_imp_exp%GT-ltkze %LTfs_output%GT-ltkze.
ENDIF.
IF %LTfs_output%GT-lgbkz NE %LTfs_imp_exp%GT-lgbkz.
bapi_mlgn-stgesector = %LTfs_output%GT-lgbkz.
bapi_mlgnx-stgesector = 'X'.
change_flag = 1.
PERFORM write_change
USING 'LGBKZ (Storage section indicator)'
%LTfs_imp_exp%GT-lgbkz %LTfs_output%GT-lgbkz.
ENDIF.
IF %LTfs_output%GT-bsskz NE %LTfs_imp_exp%GT-bsskz.
bapi_mlgn-spec_mvmt = %LTfs_output%GT-bsskz.
bapi_mlgnx-spec_mvmt = 'X'.
change_flag = 1.
PERFORM write_change
USING 'BSSKZ (Special Mvt Ind for WM)'
%LTfs_imp_exp%GT-bsskz %LTfs_output%GT-bsskz.
ENDIF.
IF %LTfs_output%GT-lgpla NE %LTfs_imp_exp%GT-lgpla.
bapi_mlgt-stge_bin = %LTfs_output%GT-lgpla.
bapi_mlgtx-stge_bin = 'X'.
change_flag = 1.
PERFORM write_change
USING 'LGPLA (Storage Bin)'
%LTfs_imp_exp%GT-lgpla %LTfs_output%GT-lgpla.
ENDIF.
IF %LTfs_output%GT-PFEP_ROUTE NE %LTfs_imp_exp%GT-PFEP_ROUTE.
l_change_flag = 'X'.
if l_t_pfep ne 'X'.
concatenate text-010 text-011 %LTfs_output%GT-matnr
into wa_txtline
separated by space.
append wa_txtline to it_txttable....
endif.
PERFORM write_change
USING 'PFEP_ROUTE (Route)'
%LTfs_imp_exp%GT-PFEP_ROUTE %LTfs_output%GT-PFEP_ROUTE.
clear g_error.
PERFORM modify_t_pfep using %LTfs_output%GT-PFEP_ROUTE
%LTfs_imp_exp%GT-PFEP_ROUTE
%LTfs_output%GT-matnr
%LTfs_output%GT-prvbe
'PFEP_ROUTE'.
if g_error ne 'X'.
concatenate text-014 'PFEP_ROUTE' into wa_txtline.
append wa_txtline to it_txttable.
else.
concatenate text-013 'PFEP_ROUTE' into wa_txtline.
append wa_txtline to it_txttable.
l_error_flag = 'X'.
endif.
l_t_pfep = 'X'.
ENDIF.
IF %LTfs_output%GT-PFEP_FREQUENCY NE %LTfs_imp_exp%GT-PFEP_FREQUENCY.
l_change_flag = 'X'.
if l_t_pfep ne 'X'.
concatenate text-010 text-011 %LTfs_output%GT-matnr
into wa_txtline
separated by space.
append wa_txtline to it_txttable.
endif.
PERFORM write_change
USING 'PFEP_FREQUENCY (Frequency)'
%LTfs_imp_exp%GT-PFEP_FREQUENCY
%LTfs_output%GT-PFEP_FREQUENCY.
clear g_error.
PERFORM modify_t_pfep using %LTfs_output%GT-PFEP_FREQUENCY
%LTfs_imp_exp%GT-PFEP_FREQUENCY
%LTfs_output%GT-matnr
%LTfs_output%GT-prvbe
'PFEP_FREQUENCY'.
if g_error ne 'X'.
concatenate text-014 'PFEP_FREQUENCY' into wa_txtline.
append wa_txtline to it_txttable.
else.
concatenate text-013 'PFEP_FREQUENCY' into wa_txtline.
append wa_txtline to it_txttable.
l_error_flag = 'X'.
endif.
l_t_pfep = 'X'.
ENDIF.
IF %LTfs_output%GT-PFEP_RACK NE %LTfs_imp_exp%GT-PFEP_RACK.
l_change_flag = 'X'.
if l_t_pfep ne 'X'.
concatenate text-010 text-011 %LTfs_output%GT-matnr
into wa_txtline
separated by space.
append wa_txtline to it_txttable.
endif.
PERFORM write_change
USING 'PFEP_RACK (Rack)'
%LTfs_imp_exp%GT-PFEP_RACK %LTfs_output%GT-PFEP_RACK.
clear g_error.
PERFORM modify_t_pfep using %LTfs_output%GT-PFEP_RACK
%LTfs_imp_exp%GT-PFEP_RACK
%LTfs_output%GT-matnr
%LTfs_output%GT-prvbe
'PFEP_RACK'.
if g_error ne 'X'.
concatenate text-014 'PFEP_RACK' into wa_txtline.
append wa_txtline to it_txttable.
else.
concatenate text-013 'PFEP_RACK' into wa_txtline.
append wa_txtline to it_txttable.
l_error_flag = 'X'.
endif.
l_t_pfep = 'X'.
ENDIF.
IF %LTfs_output%GT-PFEP_CONTENANT NE %LTfs_imp_exp%GT-PFEP_CONTENANT.
l_change_flag = 'X'.
if l_t_pfep ne 'X'.
concatenate text-010 text-011 %LTfs_output%GT-matnr
into wa_txtline
separated by space.
append wa_txtline to it_txttable.
endif.
PERFORM write_change
USING 'PFEP_CONTENANT (Contenant)'
%LTfs_imp_exp%GT-PFEP_CONTENANT
%LTfs_output%GT-PFEP_CONTENANT.
clear g_error.
PERFORM modify_t_pfep using %LTfs_output%GT-PFEP_CONTENANT
%LTfs_imp_exp%GT-PFEP_CONTENANT
%LTfs_output%GT-matnr
%LTfs_output%GT-prvbe
'PFEP_CONTENANT'.
if g_error ne 'X'.
concatenate text-014 'PFEP_CONTENANT' into wa_txtline.
append wa_txtline to it_txttable.
else.
concatenate text-013 'PFEP_CONTENANT' into wa_txtline.
append wa_txtline to it_txttable.
l_error_flag = 'X'.
endif.
l_t_pfep = 'X'.
ENDIF.
IF %LTfs_output%GT-PFEP_QTY_MAX_CONTENANT NE
%LTfs_imp_exp%GT-PFEP_QTY_MAX_CONTENANT.
l_change_flag = 'X'.
if l_t_pfep ne 'X'.
concatenate text-010 text-011 %LTfs_output%GT-matnr
into wa_txtline
separated by space.
append wa_txtline to it_txttable.
endif.
PERFORM write_change
USING 'PFEP_QTE_MAX_CONTENANT (Max qty by container)'
%LTfs_imp_exp%GT-PFEP_QTY_MAX_CONTENANT
%LTfs_output%GT-PFEP_QTY_MAX_CONTENANT.
clear g_error.
PERFORM modify_t_pfep using %LTfs_output%GT-PFEP_QTY_MAX_CONTENANT
%LTfs_imp_exp%GT-PFEP_QTY_MAX_CONTENANT
%LTfs_output%GT-matnr
%LTfs_output%GT-prvbe
'PFEP_QTE_MAX_CONTENANT'.
if g_error ne 'X'.
concatenate text-014 'PFEP_QTE_MAX_CONTENANT' into wa_txtline.
append wa_txtline to it_txttable.
else.
concatenate text-013 'PFEP_QTE_MAX_CONTENANT' into wa_txtline.
append wa_txtline to it_txttable.
l_error_flag = 'X'.
endif.
l_t_pfep = 'X'.
ENDIF.
IF %LTfs_output%GT-PFEP_PIECE_KIT NE %LTfs_imp_exp%GT-PFEP_PIECE_KIT.
l_change_flag = 'X'.
if l_t_pfep ne 'X'.
concatenate text-010 text-011 %LTfs_output%GT-matnr
into wa_txtline
separated by space.
append wa_txtline to it_txttable....
endif.
PERFORM write_change
USING 'PFEP_PIECE_KIT (Part include in a kit)'
%LTfs_imp_exp%GT-PFEP_PIECE_KIT
%LTfs_output%GT-PFEP_PIECE_KIT.
clear g_error.
PERFORM modify_t_pfep using %LTfs_output%GT-PFEP_PIECE_KIT
%LTfs_imp_exp%GT-PFEP_PIECE_KIT
%LTfs_output%GT-matnr
%LTfs_output%GT-prvbe
'PFEP_PIECE_KIT'.
if g_error ne 'X'.
concatenate text-014 'PFEP_PIECE_KIT' into wa_txtline.
append wa_txtline to it_txttable.
else.
concatenate text-013 'PFEP_PIECE_KIT' into wa_txtline.
append wa_txtline to it_txttable.
l_error_flag = 'X'.
endif.
l_t_pfep = 'X'.
ENDIF.
IF %LTfs_output%GT-PFEP_METHOD_TRANSPORT NE
%LTfs_imp_exp%GT-PFEP_METHOD_TRANSPORT.
l_change_flag = 'X'.
if l_cl_pfep ne 'X'.
concatenate text-012 text-011 %LTfs_output%GT-matnr
into wa_txtline
SEPARATED by space.
append wa_txtline to it_txttable....
endif.
PERFORM write_change
USING 'PFEP_METHODE_TRANSPORT (Transport Method)'
%LTfs_imp_exp%GT-PFEP_METHOD_TRANSPORT
%LTfs_output%GT-PFEP_METHOD_TRANSPORT.
clear g_error.
perform modify_classification using
%LTfs_output%GT-PFEP_METHOD_TRANSPORT
'PFEP_METHOD_TRANSPORT'
%LTfs_output%GT-matnr.
if g_error ne 'X'.
concatenate text-014 'PFEP_METHODE_TRANSPORT' into wa_txtline.
append wa_txtline to it_txttable.
else.
concatenate text-013 'PFEP_METHODE_TRANSPORT' into wa_txtline.
append wa_txtline to it_txttable.
l_error_flag = 'X'.
endif.
l_cl_pfep = 'X'.
ENDIF.
IF %LTfs_output%GT-PFEP_OCCURENCE_MAX NE %LTfs_imp_exp%GT-PFEP_OCCURENCE_MAX
.
l_change_flag = 'X'.
if l_cl_pfep ne 'X'.
concatenate text-012 text-011 %LTfs_output%GT-matnr
into wa_txtline
SEPARATED by space.
append wa_txtline to it_txttable....
endif.
PERFORM write_change
USING 'PFEP_OCCURENCE_MAX (Max instance)'
%LTfs_imp_exp%GT-PFEP_OCCURENCE_MAX
%LTfs_output%GT-PFEP_OCCURENCE_MAX.
clear g_error.
perform modify_classification using
%LTfs_output%GT-PFEP_OCCURENCE_MAX
'PFEP_OCCURENCE_MAX'
%LTfs_output%GT-matnr.
if g_error ne 'X'.
concatenate text-014 'PFEP_OCCURENCE_MAX' into wa_txtline.
append wa_txtline to it_txttable.
else.
concatenate text-013 'PFEP_OCCURENCE_MAX' into wa_txtline.
append wa_txtline to it_txttable.
l_error_flag = 'X'.
endif.
l_cl_pfep = 'X'.
ENDIF.
IF %LTfs_output%GT-PFEP_REVISON_DATE NE %LTfs_imp_exp%GT-PFEP_REVISON_DATE
.
l_change_flag = 'X'.
if l_cl_pfep ne 'X'.
concatenate text-012 text-011 %LTfs_output%GT-matnr
into wa_txtline
SEPARATED by space.
append wa_txtline to it_txttable....
endif.
PERFORM write_change
USING 'PFEP_REVISON_DATE (Last Revision)'
%LTfs_imp_exp%GT-PFEP_REVISON_DATE
%LTfs_output%GT-PFEP_REVISON_DATE.
clear g_error.
perform modify_classification using
%LTfs_output%GT-PFEP_REVISON_DATE
'PFEP_REVISON_DATE'
%LTfs_output%GT-matnr.
if g_error ne 'X'.
concatenate text-014 'PFEP_REVISON_DATE' into wa_txtline.
append wa_txtline to it_txttable.
else.
concatenate text-013 'PFEP_REVISON_DATE' into wa_txtline.
append wa_txtline to it_txttable.
l_error_flag = 'X'.
endif.
l_cl_pfep = 'X'.
ENDIF.
IF %LTfs_output%GT-PFEP_CONS_SERVICE NE %LTfs_imp_exp%GT-PFEP_CONS_SERVICE.
l_change_flag = 'X'.
if l_cl_pfep ne 'X'.
concatenate text-012 text-011 %LTfs_output%GT-matnr
into wa_txtline
SEPARATED by space.
append wa_txtline to it_txttable....
endif.
PERFORM write_change
USING 'PFEP_CONS_SERVICE (Service Consumption)'
%LTfs_imp_exp%GT-PFEP_CONS_SERVICE
%LTfs_output%GT-PFEP_CONS_SERVICE.
clear g_error.
perform modify_classification using %LTfs_output%GT-PFEP_CONS_SERVICE
'PFEP_CONS_SERVICE'
%LTfs_output%GT-matnr.
if g_error ne 'X'.
concatenate text-014 'PFEP_CONS_SERVICE' into wa_txtline.
append wa_txtline to it_txttable.
else.
concatenate text-013 'PFEP_CONS_SERVICE' into wa_txtline.
append wa_txtline to it_txttable.
l_error_flag = 'X'.
endif.
l_cl_pfep = 'X'.
ENDIF.
IF %LTfs_output%GT-PFEP_CONT_INTERNE_HAUTEUR NE
%LTfs_imp_exp%GT-PFEP_CONT_INTERNE_HAUTEUR.
l_change_flag = 'X'.
if l_cl_pfep ne 'X'.
concatenate text-012 text-011 %LTfs_output%GT-matnr
into wa_txtline
SEPARATED by space.
append wa_txtline to it_txttable.
endif.
PERFORM write_change
USING 'PFEP_CONT_INTERNE_HAUTEUR (Internal container Height)'
%LTfs_imp_exp%GT-PFEP_CONT_INTERNE_HAUTEUR
%LTfs_output%GT-PFEP_CONT_INTERNE_HAUTEUR.
clear g_error.
perform modify_classification using
%LTfs_output%GT-PFEP_CONT_INTERNE_HAUTEUR
'PFEP_CONT_INTERNE_HAUTEUR'
%LTfs_output%GT-matnr.
if g_error ne 'X'.
concatenate text-014 'PFEP_CONT_INTERNE_HAUTEUR' into
wa_txtline.
append wa_txtline to it_txttable.
else.
concatenate text-013 'PFEP_CONT_INTERNE_HAUTEUR' into
wa_txtline.
append wa_txtline to it_txttable.
l_error_flag = 'X'.
endif.
l_cl_pfep = 'X'.
ENDIF.
IF %LTfs_output%GT-PFEP_CONT_INTERNE_LARGUER NE
%LTfs_imp_exp%GT-PFEP_CONT_INTERNE_LARGUER.
l_change_flag = 'X'.
if l_cl_pfep ne 'X'.
concatenate text-012 text-011 %LTfs_output%GT-matnr
into wa_txtline
SEPARATED by space.
append wa_txtline to it_txttable.
endif.
PERFORM write_change
USING 'PFEP_CONT_INTERNE_LARGUER (Internal Container width)'
%LTfs_imp_exp%GT-PFEP_CONT_INTERNE_LARGUER
%LTfs_output%GT-PFEP_CONT_INTERNE_LARGUER.
clear g_error.
perform modify_classification using
%LTfs_output%GT-PFEP_CONT_INTERNE_LARGUER
'PFEP_CONT_INTERNE_LARGUER'
%LTfs_output%GT-matnr.
if g_error ne 'X'.
concatenate text-014 'PFEP_CONT_INTERNE_LARGEUR' into
wa_txtline.
append wa_txtline to it_txttable.
else.
concatenate text-013 'PFEP_CONT_INTERNE_LARGEUR' into
wa_txtline.
append wa_txtline to it_txttable.
l_error_flag = 'X'.
endif.
l_cl_pfep = 'X'.
ENDIF.
IF %LTfs_output%GT-PFEP_CONT_INTERNE_PROFONDUER NE
%LTfs_imp_exp%GT-PFEP_CONT_INTERNE_PROFONDUER.
l_change_flag = 'X'.
if l_cl_pfep ne 'X'.
concatenate text-012 text-011 %LTfs_output%GT-matnr
into wa_txtline
SEPARATED by space.
append wa_txtline to it_txttable.
endif.
PERFORM write_change
USING 'PFEP_CONT_INTERNE_PROFONDUER (Internal container depth)'
%LTfs_imp_exp%GT-PFEP_CONT_INTERNE_PROFONDUER
%LTfs_output%GT-PFEP_CONT_INTERNE_PROFONDUER.
clear g_error.
perform modify_classification using
%LTfs_output%GT-PFEP_CONT_INTERNE_PROFONDUER
'PFEP_CONT_INTERNE_PROFONDEUR'
%LTfs_output%GT-matnr.
if g_error ne 'X'.
concatenate text-014 'PFEP_CONT_INTERNE_PROFONDUER' into
wa_txtline.
append wa_txtline to it_txttable.
else.
concatenate text-013 'PFEP_CONT_INTERNE_PROFONDUER' into
wa_txtline.
append wa_txtline to it_txttable.
l_error_flag = 'X'.
endif.
l_cl_pfep = 'X'.
ENDIF.
IF %LTfs_output%GT-PFEP_PIECE_HAUTEUR NE %LTfs_imp_exp%GT-PFEP_PIECE_HAUTEUR
.
l_change_flag = 'X'.
if l_cl_pfep ne 'X'.
concatenate text-012 text-011 %LTfs_output%GT-matnr
into wa_txtline
SEPARATED by space.
append wa_txtline to it_txttable.
endif.
PERFORM write_change
USING 'PFEP_PIECE_HAUTEUR (Part Height)'
%LTfs_imp_exp%GT-PFEP_PIECE_HAUTEUR
%LTfs_output%GT-PFEP_PIECE_HAUTEUR.
clear g_error.
perform modify_classification using
%LTfs_output%GT-PFEP_PIECE_HAUTEUR
'PFEP_PIECE_HAUTEUR'
%LTfs_output%GT-matnr.
if g_error ne 'X'.
concatenate text-014 'PFEP_PIECE_HAUTEUR' into wa_txtline.
append wa_txtline to it_txttable.
else.
concatenate text-013 'PFEP_PIECE_HAUTEUR' into wa_txtline.
append wa_txtline to it_txttable.
l_error_flag = 'X'.
endif.
l_cl_pfep = 'X'.
ENDIF.
IF %LTfs_output%GT-PFEP_PIECE_LARGEUR NE %LTfs_imp_exp%GT-PFEP_PIECE_LARGEUR
.
l_change_flag = 'X'.
if l_cl_pfep ne 'X'.
concatenate text-012 text-011 %LTfs_output%GT-matnr
into wa_txtline
SEPARATED by space.
append wa_txtline to it_txttable.
endif.
PERFORM write_change
USING 'PFEP_PIECE_LARGEUR (Part width)'
%LTfs_imp_exp%GT-PFEP_PIECE_LARGEUR
%LTfs_output%GT-PFEP_PIECE_LARGEUR.
clear g_error.
perform modify_classification using
%LTfs_output%GT-PFEP_PIECE_LARGEUR
'PFEP_PIECE_LARGEUR'
%LTfs_output%GT-matnr.
if g_error ne 'X'.
concatenate text-014 'PFEP_PIECE_LARGEUR' into wa_txtline.
append wa_txtline to it_txttable.
else.
concatenate text-013 'PFEP_PIECE_LARGEUR' into wa_txtline.
append wa_txtline to it_txttable.
l_error_flag = 'X'.
endif.
l_cl_pfep = 'X'.
ENDIF.
IF %LTfs_output%GT-PFEP_PIECE_PROFONDEUR NE
%LTfs_imp_exp%GT-PFEP_PIECE_PROFONDEUR.
l_change_flag = 'X'.
if l_cl_pfep ne 'X'.
concatenate text-012 text-011 %LTfs_output%GT-matnr
into wa_txtline
SEPARATED by space.
append wa_txtline to it_txttable.
endif.
PERFORM write_change
USING 'PFEP_PIECE_PROFONDEUR (Part depth)'
%LTfs_imp_exp%GT-PFEP_PIECE_PROFONDEUR
%LTfs_output%GT-PFEP_PIECE_PROFONDEUR.
clear g_error.
perform modify_classification using
%LTfs_output%GT-PFEP_PIECE_PROFONDEUR
'PFEP_PIECE_PROFONDEUR'
%LTfs_output%GT-matnr.
if g_error ne 'X'.
concatenate text-014 'PFEP_PIECE_PROFONDEUR' into wa_txtline.
append wa_txtline to it_txttable.
else.
concatenate text-013 'PFEP_PIECE_PROFONDEUR' into wa_txtline.
append wa_txtline to it_txttable.
l_error_flag = 'X'.
endif.
l_cl_pfep = 'X'.
ENDIF.
IF %LTfs_output%GT-PFEP_CONT_FOURN_HAUTEUR NE
%LTfs_imp_exp%GT-PFEP_CONT_FOURN_HAUTEUR.
l_change_flag = 'X'.
if l_cl_pfep ne 'X'.
concatenate text-012 text-011 %LTfs_output%GT-matnr
into wa_txtline
SEPARATED by space.
append wa_txtline to it_txttable.
endif.
PERFORM write_change
USING 'PFEP_CONT_FOURN_HAUTEUR (Supplier container Height)'
%LTfs_imp_exp%GT-PFEP_CONT_FOURN_HAUTEUR
%LTfs_output%GT-PFEP_CONT_FOURN_HAUTEUR.
clear g_error.
perform modify_classification using
%LTfs_output%GT-PFEP_CONT_FOURN_HAUTEUR
'PFEP_CONT_FOURN_HAUTEUR'
%LTfs_output%GT-matnr.
if g_error ne 'X'.
concatenate text-014 'PFEP_CONT_FOURN_HAUTEUR' into wa_txtline
.
append wa_txtline to it_txttable.
else.
concatenate text-013 'PFEP_CONT_FOURN_HAUTEUR' into wa_txtline
.
append wa_txtline to it_txttable.
l_error_flag = 'X'.
endif.
l_cl_pfep = 'X'.
ENDIF.
IF %LTfs_output%GT-PFEP_CONT_FOURN_LARGEUR NE
%LTfs_imp_exp%GT-PFEP_CONT_FOURN_LARGEUR.
l_change_flag = 'X'.
if l_cl_pfep ne 'X'.
concatenate text-012 text-011 %LTfs_output%GT-matnr
into wa_txtline
SEPARATED by space.
append wa_txtline to it_txttable.
endif.
PERFORM write_change
USING 'PFEP_CONT_FOURN_LARGEUR (Supplier container width)'
%LTfs_imp_exp%GT-PFEP_CONT_FOURN_LARGEUR
%LTfs_output%GT-PFEP_CONT_FOURN_LARGEUR.
clear g_error.
perform modify_classification using
%LTfs_output%GT-PFEP_CONT_FOURN_LARGEUR
'PFEP_CONT_FOURN_LARGEUR'
%LTfs_output%GT-matnr.
if g_error ne 'X'.
concatenate text-014 'PFEP_CONT_FOURN_LARGEUR' into wa_txtline
.
append wa_txtline to it_txttable.
else.
concatenate text-013 'PFEP_CONT_FOURN_LARGEUR' into wa_txtline
.
append wa_txtline to it_txttable.
l_error_flag = 'X'.
endif.
l_cl_pfep = 'X'.
ENDIF.
IF %LTfs_output%GT-PFEP_CONT_FOURN_PROFONDEUR NE
%LTfs_imp_exp%GT-PFEP_CONT_FOURN_PROFONDEUR.
l_change_flag = 'X'.
if l_cl_pfep ne 'X'.
concatenate text-012 text-011 %LTfs_output%GT-matnr
into wa_txtline
SEPARATED by space.
append wa_txtline to it_txttable.
endif.
PERFORM write_change
USING 'PFEP_CONT_FOURN_PROFONDEUR (Supplier container depth)'
%LTfs_imp_exp%GT-PFEP_CONT_FOURN_PROFONDEUR
%LTfs_output%GT-PFEP_CONT_FOURN_PROFONDEUR.
clear g_error.
perform modify_classification using
%LTfs_output%GT-PFEP_CONT_FOURN_PROFONDEUR
'PFEP_CONT_FOURN_PROFONDEUR'
%LTfs_output%GT-matnr.
if g_error ne 'X'.
concatenate text-014 'PFEP_CONT_FOURN_PROFONDEUR' into
wa_txtline.
append wa_txtline to it_txttable.
else.
concatenate text-013 'PFEP_CONT_FOURN_PROFONDEUR' into
wa_txtline.
append wa_txtline to it_txttable.
l_error_flag = 'X'.
endif.
l_cl_pfep = 'X'.
ENDIF.
IF %LTfs_output%GT-PFEP_ABC_CONSOMMATION NE
%LTfs_imp_exp%GT-PFEP_ABC_CONSOMMATION.
l_change_flag = 'X'.
if l_cl_pfep ne 'X'.
concatenate text-012 text-011 %LTfs_output%GT-matnr
into wa_txtline
SEPARATED by space.
append wa_txtline to it_txttable.
endif.
PERFORM write_change
USING 'PFEP_ABC_CONSOMMATION (ABC CONSUMPTION)'
%LTfs_imp_exp%GT-PFEP_ABC_CONSOMMATION
%LTfs_output%GT-PFEP_ABC_CONSOMMATION.
clear g_error.
perform modify_classification using
%LTfs_output%GT-PFEP_ABC_CONSOMMATION
'PFEP_ABC_CONSOMMATION'
%LTfs_output%GT-matnr.
if g_error ne 'X'.
concatenate text-014 'PFEP_ABC_CONSOMMATION' into wa_txtline.
append wa_txtline to it_txttable.
else.
concatenate text-013 'PFEP_ABC_CONSOMMATION' into wa_txtline.
append wa_txtline to it_txttable.
l_error_flag = 'X'.
endif.
l_cl_pfep = 'X'.
ENDIF.
if change_flag ne 1 and l_change_flag eq 'X'.
if l_error_flag ne 'X'.
g_total_good = g_total_good + 1.
else.
g_total_bad = g_total_bad + 1.
endif.
endif.
bapimathead-material = %LTfs_output%GT-matnr.
bapi_marc-plant = %LTfs_output%GT-werks.
bapi_marcx-plant = %LTfs_output%GT-werks.
bapi_mlgn-whse_no = p_lgnum.
bapi_mlgnx-whse_no = p_lgnum.
bapi_mlgt-whse_no = p_lgnum.
bapi_mlgt-stge_type = %LTfs_output%GT-ltkze.
bapi_mlgtx-whse_no = p_lgnum.
bapi_mlgtx-stge_type = %LTfs_output%GT-ltkze.
* DI1K907032 Madhu 20/08/2008 - End.
IF change_flag = 1.
min_1_change = 1.
CLEAR bapi_matreturn2.
CONCATENATE text-009 %LTfs_output%GT-matnr
INTO wa_txtline
SEPARATED BY space.
APPEND wa_txtline TO it_txttable.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = bapimathead
clientdata = bapi_mara
clientdatax = bapi_marax
plantdata = bapi_marc
plantdatax = bapi_marcx
* FORECASTPARAMETERS =
* FORECASTPARAMETERSX =
* PLANNINGDATA =
* PLANNINGDATAX =
* STORAGELOCATIONDATA =
* STORAGELOCATIONDATAX =
* VALUATIONDATA =
* VALUATIONDATAX =
WAREHOUSENUMBERDATA = bapi_mlgn
WAREHOUSENUMBERDATAX = bapi_mlgnx
* SALESDATA =
* SALESDATAX =
STORAGETYPEDATA = bapi_mlgt
STORAGETYPEDATAX = bapi_mlgtx
* FLAG_ONLINE = 'X'
* flag_cad_call = 'X'
* no_dequeue = 'X'
IMPORTING
return = bapi_matreturn2
TABLES
* MATERIALDESCRIPTION =
* UNITSOFMEASURE =
* UNITSOFMEASUREX =
* INTERNATIONALARTNOS =
* MATERIALLONGTEXT =
* TAXCLASSIFICATIONS =
returnmessages = it_return
* PRTDATA =
* PRTDATAX =
* EXTENSIONIN =
* EXTENSIONINX =
.
text_format = 'ASC'.
CLEAR l_msgtxt.
* message M3801 is a confirmation that the material was sucessfully
* changed if this message is not found something wrong happened.
READ TABLE it_return ASSIGNING %LTfs_return%GT WITH KEY
type = 'S'
id = 'M3'
number = '801'.
IF sy-subrc = 0.
g_total_good = g_total_good + 1.
REFRESH it_txttable.
ELSE.
LOOP AT it_return ASSIGNING %LTfs_return%GT.
CALL FUNCTION 'BAPI_MESSAGE_GETDETAIL'
EXPORTING
id = %LTfs_return%GT-id
number = %LTfs_return%GT-number
* LANGUAGE = SY-LANGU
textformat = text_format
* LINKPATTERN =
message_v1 = %LTfs_return%GT-message_v1
message_v2 = %LTfs_return%GT-message_v2
message_v3 = %LTfs_return%GT-message_v3
message_v4 = %LTfs_return%GT-message_v4
IMPORTING
message = l_msgtxt.
LOOP AT it_txttable INTO wa_txtline.
WRITE: / wa_txtline.
ENDLOOP.
REFRESH it_txttable.
CONCATENATE 'Error:' wa_txtline INTO wa_txtline.
WRITE: / l_msgtxt.
ENDLOOP.
g_total_bad = g_total_bad + 1.
SKIP.
ENDIF.
ELSE.
if l_change_flag ne 'X'.
g_nochange = g_nochange + 1.
endif.
ENDIF.
if l_change_flag eq 'X'.
min_1_change1 = 1.
endif.
ENDLOOP.
IF min_1_change = 1.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
* IMPORTING
* RETURN =
.
ENDIF.
IF min_1_change = 1 or min_1_change1 = 1.
WRITE: / text-003, 50 g_total_bad,
/ text-004, 50 g_total_good,
/ text-005, 50 g_nochange.
LEAVE TO LIST-PROCESSING.
ELSE.
MESSAGE I037(zz) WITH 'No changes were made'.
ENDIF.
ENDFORM. " DETERMINE_CHANGES
*&---------------------------------------------------------------------*
*& Form write_change
*&---------------------------------------------------------------------*
* --%GTP_1866 text
* --%GTP_%LTFS_IMP_EXP%GT_BSTMI text
* --%GTP_%LTFS_OUTPUT%GT_BSTMI text
*----------------------------------------------------------------------*
FORM write_change USING value(p_1866)
p_oldval
p_newval.
DATA: c_oldval(75) TYPE c,
c_newval(75) TYPE c.
WRITE p_oldval TO c_oldval.
WRITE p_newval TO c_newval.
CLEAR wa_txtline.
CONCATENATE text-006 p_1866 text-007 c_oldval
text-008 c_newval INTO wa_txtline
SEPARATED BY space.
APPEND wa_txtline TO it_txttable.
ENDFORM. " write_change
*&---------------------------------------------------------------------*
*& Form convert_currency
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --%GTP_%LTFS_CONP%GT_KBETR text
* --%GTP_%LTFS_CONP%GT_KONWS text
* %LT--P_WA_IMP_EXP_SETUP text
* %LT--P_ENDIF text
*----------------------------------------------------------------------*
FORM convert_currency USING p_foreign_amnt
p_foreign_curr
CHANGING p_locl_amnt.
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
* CLIENT = SY-MANDT
date = sy-datum
foreign_amount = p_foreign_amnt
foreign_currency = p_foreign_curr
local_currency = 'CAD'
* RATE = 0
* TYPE_OF_RATE = 'M'
* READ_TCURR = 'X'
IMPORTING
* EXCHANGE_RATE =
* FOREIGN_FACTOR =
local_amount = p_locl_amnt
* LOCAL_FACTOR =
* EXCHANGE_RATEX =
* FIXED_RATE =
* DERIVED_RATE_TYPE =
EXCEPTIONS
no_rate_found = 1
overflow = 2
no_factors_found = 3
no_spread_found = 4
derived_2_times = 5
OTHERS = 6.
IF sy-subrc %LT%GT 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " convert_currency
*&---------------------------------------------------------------------*
*& Form export_to_excel
*&---------------------------------------------------------------------*
FORM export_to_excel .
data : l_index type i.
PERFORM define_xls_header USING:
* Titre Sorting Data Format Col no Currency
* Column Type in DATA Type
text-x01 'S' 'STR' 'DFT' 1 0,
text-x02 'C' 'STR' 'DFT' 2 0,
text-x03 'C' 'STR' 'DFT' 3 0,
text-x04 'C' 'STR' 'DFT' 4 0,
text-x05 'C' 'NUM' 'NOP' 5 0,
text-x06 'C' 'STR' 'DFT' 6 0,
text-x07 'C' 'NUM' 'NOP' 7 0,
text-x08 'C' 'STR' 'DFT' 8 0,
text-x09 'C' 'STR' 'DFT' 9 0,
text-x10 'C' 'STR' 'DFT' 10 0,
text-x11 'C' 'STR' 'DFT' 11 0,
text-x12 'C' 'STR' 'DFT' 12 0,
text-x13 'C' 'STR' 'DFT' 13 0,
text-x14 'C' 'STR' 'DFT' 14 0,
text-x15 'C' 'STR' 'DFT' 15 0,
text-x16 'C' 'STR' 'DFT' 16 0,
text-x17 'C' 'STR' 'DFT' 17 0,
text-x18 'C' 'STR' 'DFT' 18 0,
text-x19 'C' 'STR' 'DFT' 19 0,
text-x20 'C' 'STR' 'DFT' 20 0,
text-x21 'C' 'NUM' 'NOP' 21 0,
text-x22 'C' 'STR' 'DFT' 22 0,
text-x23 'C' 'NUM' 'NOP' 23 0,
text-x24 'C' 'STR' 'DFT' 24 0,
text-x25 'C' 'STR' 'DFT' 25 0,
text-x26 'C' 'STR' 'DFT' 26 0,
text-x27 'C' 'STR' 'DFT' 27 0,
text-x28 'C' 'STR' 'DFT' 28 0,
text-x29 'C' 'STR' 'DFT' 29 0,
text-x30 'C' 'STR' 'DFT' 30 0,
text-x31 'C' 'STR' 'DFT' 31 0,
text-x32 'C' 'STR' 'DFT' 32 0,
text-x33 'C' 'STR' 'DFT' 33 0,
text-x34 'C' 'STR' 'DFT' 34 0.
l_index = 35.
loop at gt_mast into wa_mast.
PERFORM define_xls_header USING
wa_mast-matnr 'C' 'STR' 'DFT' l_index 0.
l_index = l_index + 1.
endloop.
*"35
PERFORM define_xls_header USING
text-x35 'C' 'STR' 'DFT' l_index 0.
*"36
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x36 'C' 'STR' 'DFT' l_index 0.
*"37
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x37 'C' 'STR' 'DFT' l_index 0.
*"38
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x38 'C' 'STR' 'DFT' l_index 0.
*"39
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x39 'C' 'STR' 'DFT' l_index 0.
*"40
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x40 'C' 'STR' 'DFT' l_index 0.
*"41
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x41 'C' 'STR' 'DFT' l_index 0.
*”42
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x42 'C' 'NUM' 'NOP' l_index 0.
*”43
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x43 'C' 'NUM' 'NOP' l_index 0.
*“44
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x44 'C' 'NUM' 'NOP' l_index 0.
*“45
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x45 'C' 'NUM' 'NOP' l_index 0.
*“46
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x46 'C' 'STR' 'DFT' l_index 0.
*“47
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x47 'C' 'NUM' 'NOP' l_index 0.
*“48
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x48 'C' 'NUM' 'NOP' l_index 0.
*“49
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x49 'C' 'NUM' 'NOP' l_index 0.
*“50
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x50 'C' 'STR' 'DFT' l_index 0.
*“51
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x51 'C' 'STR' 'DFT' l_index 0.
*“52
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x52 'C' 'STR' 'DFT' l_index 0.
*“53
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x53 'C' 'STR' 'DFT' l_index 0.
*“54
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x54 'C' 'STR' 'DFT' l_index 0.
*“55
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x55 'C' 'STR' 'DFT' l_index 0.
*“56
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x56 'C' 'NUM' 'NOP' l_index 0.
*“57
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x57 'C' 'STR' 'DFT' l_index 0.
*“58
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x58 'C' 'NUM' 'NOP' l_index 0.
*“59
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x59 'C' 'NUM' 'NOP' l_index 0.
*“60
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x60 'C' 'STR' 'DFT' l_index 0.
*“61
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x61 'C' 'STR' 'DFT' l_index 0.
*“62
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x62 'C' 'STR' 'DFT' l_index 0.
*“63
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x63 'C' 'STR' 'DFT' l_index 0.
*“64
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x64 'C' 'STR' 'DFT' l_index 0.
*“65
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x65 'C' 'STR' 'DFT' l_index 0.
*“66
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x66 'C' 'STR' 'DFT' l_index 0.
*“67
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x67 'C' 'STR' 'DFT' l_index 0.
*“68
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x68 'C' 'STR' 'DFT' l_index 0.
*“69
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x69 'C' 'STR' 'DFT' l_index 0.
*“70
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x70 'C' 'STR' 'DFT' l_index 0.
*“71
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x71 'C' 'STR' 'DFT' l_index 0.
*“72
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x72 'C' 'STR' 'DFT' l_index 0.
*“73
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x73 'C' 'STR' 'DFT' l_index 0.
*“74
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x74 'C' 'STR' 'DFT' l_index 0.
*“75
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x75 'C' 'STR' 'DFT' l_index 0.
*“76
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x76 'C' 'STR' 'DFT' l_index 0.
*“77
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x77 'C' 'STR' 'DFT' l_index 0.
*“78
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x78 'C' 'NUM' 'NOP' l_index 0.
*“79
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x79 'C' 'NUM' 'NOP' l_index 0.
*“80
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x80 'C' 'STR' 'DFT' l_index 0.
*“81
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x81 'C' 'NUM' 'NOP' l_index 0.
*“82
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x82 'C' 'STR' 'DFT' l_index 0.
*“83
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x83 'C' 'NUM' 'NOP' l_index 0.
*“84
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x84 'C' 'NUM' 'NOP' l_index 0.
*“85
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x85 'C' 'NUM' 'NOP' l_index 0.
*“86
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x86 'C' 'NUM' 'NOP' l_index 0.
*“87
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x87 'C' 'STR' 'DFT' l_index 0.
*“88
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x88 'C' 'NUM' 'NOP' l_index 0.
*“89
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x89 'C' 'STR' 'DFT' l_index 0.
*“90
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x90 'C' 'NUM' 'NOP' l_index 0.
*“91
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x91 'C' 'NUM' 'NOP' l_index 0.
*“92
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x92 'C' 'NUM' 'NOP' l_index 0.
*“93
l_index = l_index + 1.
PERFORM define_xls_header USING
text-x93 'C' 'STR' 'DFT' l_index 0.
CONCATENATE sy-repid sy-datum sy-uzeit INTO xtitle
SEPARATED BY space.
PERFORM transfer_to_xls TABLES %LTgt_output%GT
USING 1 -1
sy-repid(8)
space
space
xtitle.
ENDFORM. " export_to_excel
*&---------------------------------------------------------------------*
*& Form TRANSFER_TO_XLS
*&---------------------------------------------------------------------*
* Transferer dans Excel
*----------------------------------------------------------------------*
* --%GTXMPLT_D Donnees (table)
* --%GTFROM A partir de ce no de rangee
* --%GTTO A ce numero de rangee
* --%GTFNAME Nom du fichier
* --%GTXMPL_HEADER1 Entete dans Propriete
* --%GTXMPL_HEADER2 Entete dans Propriete
* --%GTXTITLE Nom pour SAP Office
*----------------------------------------------------------------------*
FORM transfer_to_xls TABLES xmplt_d
USING value(from)
value(to)
value(fname)
value(xmpl_header1)
value(xmpl_header2)
value(xtitle).
CALL FUNCTION 'XXL_FULL_API'
EXPORTING
data_ending_at = to
data_starting_at = from
n_hrz_keys = 1
n_vrt_keys = scolno
n_att_cols = ccolno
filename = fname
header_1 = xmpl_header1
header_2 = xmpl_header2
no_dialog = ' '
no_start = ' '
so_title = xtitle
TABLES
vkey = xmplt_v
hkey = xmplt_h
data = xmplt_d
sema = xmplt_s
online_text = xmplt_o
print_text = xmplt_p
EXCEPTIONS
cancelled_by_user = 1
data_too_big = 2
dim_mismatch_data = 3
dim_mismatch_sema = 4
dim_mismatch_vkey = 5
error_in_hkey = 6
error_in_sema = 7
file_open_error = 8
file_write_error = 9
inv_data_range = 10
inv_winsys = 11
inv_xxl = 12
OTHERS = 13.
WRITE: / 'XXL_FULL_API:', sy-subrc .
ENDFORM. " TRANSFER_TO_XLS
*&---------------------------------------------------------------------*
*& Form DEFINE_XLS_HEADER
*&---------------------------------------------------------------------*
* Definir les colonnes pour Excel
*----------------------------------------------------------------------*
* --%GTTEXT Texte de l'entete
* --%GTXLSCT Type de colonne (Trier "S" ou non "C")
* --%GTXLSTP Type de donnees
* --%GTXLSOP Compression
* --%GTXLSSC No colonne dans Data
* --%GTXLSCR Type de monnaie
*----------------------------------------------------------------------*
FORM define_xls_header USING value(text)
value(xlsct)
value(xlstp)
value(xlsop)
value(xlssc)
value(xlscr).
CASE xlsct.
WHEN 'S'.
ADD 1 TO scolno.
xmplt_v-col_no = scolno.
xmplt_v-col_name = text.
APPEND xmplt_v.
WHEN 'C'.
ADD 1 TO ccolno.
xmplt_h-row_no = 1.
xmplt_h-col_no = ccolno.
xmplt_h-col_name = text.
APPEND xmplt_h.
ENDCASE.
ADD 1 TO xcolno.
xmplt_s-col_no = xcolno.
xmplt_s-col_typ = xlstp.
xmplt_s-col_ops = xlsop.
xmplt_s-col_src = xlssc.
xmplt_s-col_cur = xlscr.
APPEND xmplt_s.
ENDFORM. " DEFINE_XLS_HEADER
*&---------------------------------------------------------------------*
*& Form set_event_handlers_local
*&---------------------------------------------------------------------*
FORM set_event_handlers_local .
* set handler event_receiver-%GTon_user_command for grid1.
ENDFORM. " set_event_handlers_local
*&---------------------------------------------------------------------*
*& Form get_warehouse_data
*&---------------------------------------------------------------------*
FORM get_warehouse_data .
select single lgbkz ltkze ltkza bsskz from mlgn into
(wa_imp_exp-lgbkz, wa_imp_exp-ltkze,
wa_imp_exp-ltkza, wa_imp_exp-bsskz)
where matnr eq %LTfs_marc%GT-matnr
and lgnum eq p_lgnum.
select single lgpla from mlgt into wa_imp_exp-lgpla
where matnr eq %LTfs_marc%GT-matnr
and lgnum eq p_lgnum
and lgtyp eq wa_imp_exp-ltkze.
ENDFORM. " get_warehouse_data
*&---------------------------------------------------------------------*
*& Form create_dynamic_table
*&---------------------------------------------------------------------*
FORM create_dynamic_table .
field-symbols : %LTl_field%GT type any.
data : l_col_pos type i value 1,
l_spchar type c.
data : l_index_to type i,
l_index_from type i,
l_tabix type i.
field-symbols : %LTfs%GT, %LTfs1%GT.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 'ZPPLAN_DOWNL_UPL_STRUCT1'
CHANGING
CT_FIELDCAT = IDETAILS
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC %LT%GT 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*ref_table_des ?=
* cl_abap_typedescr=%GTdescribe_by_name( 'YPPLAN_DOWNL_UPL_STRUCT1' )
.
* idetails[] = ref_table_des-%GTcomponents[].
loop at idetails into xdetails from 1 to 34.
clear xfc.
* xfc-fieldname = xdetails-name .
* xfc-scrtext_l = xdetails-name.
* xfc-datatype = xdetails-type_kind.
* xfc-inttype = xdetails-type_kind.
* xfc-intlen = xdetails-length.
* xfc-decimals = xdetails-decimals.
MOVE XDETAILS TO XFC.
xfc-col_pos = l_col_pos.
append xfc to ifc.
l_col_pos = l_col_pos + 1.
endloop.
if not rb_downl is initial.
loop at gt_mast into wa_mast.
clear xfc.
do.
if wa_mast-matnr ca '.@!^&(),:;/|\=`~[]{}'.
l_spchar = wa_mast-matnr+sy-fdpos(1).
replace l_spchar with '-' into wa_mast-matnr.
else.
exit.
endif.
enddo.
xfc-fieldname = wa_mast-matnr.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'
EXPORTING
INPUT = wa_mast-matnr
IMPORTING
OUTPUT = wa_mast-matnr.
xfc-scrtext_l = wa_mast-matnr.
xfc-datatype = 'C'.
xfc-inttype = 'C'.
xfc-intlen = 3.
xfc-decimals = 0.
xfc-col_pos = l_col_pos.
append xfc to ifc.
l_col_pos = l_col_pos + 1.
endloop.
else.
clear xfc_boms.
loop at ifc_boms into xfc_boms.
clear xfc.
move xfc_boms to xfc.
append xfc to ifc.
l_col_pos = l_col_pos + 1.
clear xfc_boms.
endloop.
endif.
loop at idetails into xdetails from 35 to 93.
clear xfc.
* xfc-fieldname = xdetails-name .
* xfc-scrtext_l = xdetails-name.
* xfc-datatype = xdetails-type_kind.
* xfc-inttype = xdetails-type_kind.
* xfc-intlen = xdetails-length.
* xfc-decimals = xdetails-decimals.
MOVE XDETAILS TO XFC.
xfc-col_pos = l_col_pos.
append xfc to ifc.
l_col_pos = l_col_pos + 1.
endloop.
describe table ifc lines l_index_to.
l_index_from = l_index_to - 3.
loop at ifc into xfc from l_index_from to l_index_to.
xfc-no_out = ' '.
modify ifc from xfc.
endloop.
call method cl_alv_table_create=%GTcreate_dynamic_table
EXPORTING
i_style_table = 'X'
it_fieldcatalog = ifc
IMPORTING
ep_table = dy_table.
assign dy_table-%GT* to %LTgt_output%GT.
create data dy_line like line of %LTgt_output%GT.
assign dy_line-%GT* to %LTwa_output%GT.
*sort gt_output by matnr prvbe.
clear wa_output.
loop at gt_output into wa_output.
clear %LTwa_output%GT.
move-corresponding wa_output to %LTwa_output%GT.
append %LTwa_output%GT to %LTgt_output%GT.
clear wa_output.
endloop.
if rb_downl is initial.
loop at %LTgt_boms%GT assigning %LTwa_boms%GT.
l_tabix = sy-tabix.
read table %LTgt_output%GT assigning %LTwa_output%GT index l_tabix.
loop at ifc_boms into xfc_boms.
assign component xfc_boms-fieldname of structure %LTwa_boms%GT to
%LTfs%GT.
assign component xfc_boms-fieldname of structure %LTwa_output%GT
to %LTfs1%GT.
if %LTfs%GT is assigned and %LTfs1%GT is assigned.
%LTfs1%GT = %LTfs%GT.
endif.
endloop.
modify %LTgt_output%GT from %LTwa_output%GT index l_tabix.
endloop.
endif.
ENDFORM. " create_dynamic_table
*&---------------------------------------------------------------------*
*& Form explode_active_boms
*&---------------------------------------------------------------------*
FORM explode_active_boms .
data : l_base_stufe type stpox-stufe,
l_bom_usage type stzu-stlan value '1',
l_index type i,
l_tabix type i,
l_explode(1) type c value space,
l_valid(1) type c value space.
select matnr from mast into table gt_mast where matnr in s_amatnr.
sort gt_mast by matnr.
* delete gt_mast from 21.
delete adjacent duplicates from gt_mast. "from 21.
l_tabix = 1.
refresh gt_bom_comp.
loop at gt_mast into wa_mast.
refresh : gt_stpox, gt_procurement.
clear wa_stpox.
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
AUMNG = 0
CAPID = p_capid
DATUV = p_datuv
MKTLS = 'X'
MEHRS = 'X'
MKMAT = ' '
MTNRV = wa_mast-matnr
STLAN = l_bom_usage
WERKS = s_werks-low
TABLES
STB = gt_stpox
* MATCAT =
EXCEPTIONS
ALT_NOT_FOUND = 1
CALL_INVALID = 2
MATERIAL_NOT_FOUND = 3
MISSING_AUTHORIZATION = 4
NO_BOM_FOUND = 5
NO_PLANT_DATA = 6
NO_SUITABLE_BOM_FOUND = 7
CONVERSION_ERROR = 8
OTHERS = 9
.
loop at gt_stpox into wa_stpox.
wa_stpox-index = l_tabix.
modify gt_stpox from wa_stpox.
clear wa_bom_comp.
wa_bom_comp-mat_bom = wa_mast-matnr.
wa_bom_comp-mat_comp = wa_stpox-idnrk.
wa_bom_comp-prvbe = wa_stpox-prvbe.
wa_bom_comp-valid = ' '.
append wa_bom_comp to gt_bom_comp.
clear wa_stpox.
l_tabix = l_tabix + 1.
endloop.
*sort gt_stpox by index.
select matnr beskz sobsl from marc into table gt_procurement
for all entries in gt_stpox
where matnr = gt_stpox-idnrk
and werks = s_werks-low.
clear : wa_stpox.
loop at gt_stpox into wa_stpox.
if sy-tabix = 1 or wa_stpox-stufe = 1.
clear wa_bom_comp.
read table gt_bom_comp into wa_bom_comp index wa_stpox-index.
if wa_bom_comp-mat_bom = wa_mast-matnr and
wa_bom_comp-mat_comp = wa_stpox-idnrk.
wa_bom_comp-valid = 'X'.
modify gt_bom_comp from wa_bom_comp index wa_stpox-index.
endif.
endif.
l_base_stufe = wa_stpox-stufe + 1.
l_index = wa_stpox-index.
clear wa_procurement.
read table gt_procurement into wa_procurement with key
matnr = wa_stpox-idnrk.
if wa_procurement-beskz ne 'F' or ( wa_procurement-beskz eq 'F' and
( wa_procurement-sobsl eq 'SC' or
wa_procurement-sobsl eq 'S2' ) ).
l_explode = 'X'.
endif.
clear wa_bom_comp.
read table gt_bom_comp into wa_bom_comp index wa_stpox-index.
if wa_bom_comp-mat_bom = wa_mast-matnr and
wa_bom_comp-mat_comp = wa_stpox-idnrk and
wa_bom_comp-valid = 'X'.
l_valid = 'X'.
endif.
clear wa_stpox.
loop at gt_stpox into wa_stpox where index %GT l_index.
if wa_stpox-stufe = l_base_stufe.
if l_explode = 'X' and l_valid = 'X'.
clear wa_bom_comp.
read table gt_bom_comp into wa_bom_comp index
wa_stpox-index.
if wa_bom_comp-mat_bom = wa_mast-matnr and
wa_bom_comp-mat_comp = wa_stpox-idnrk.
wa_bom_comp-valid = 'X'.
modify gt_bom_comp from wa_bom_comp index
wa_stpox-index.
endif.
endif.
elseif wa_stpox-stufe %LT= l_base_stufe.
exit.
endif.
clear wa_stpox.
endloop.
clear : wa_stpox, l_explode, l_valid.
endloop.
endloop.
if not gt_bom_comp[] is initial.
delete gt_bom_comp from 1 where not valid eq 'X'.
endif.
ENDFORM. " explode_active_boms
*&---------------------------------------------------------------------*
*& Form fill_dynamic_columns
*&---------------------------------------------------------------------*
FORM fill_dynamic_columns .
field-symbols : %LTl_matnr%GT type any,
%LTl_prvbe%GT type any,
%LTl_field%GT type any,
%LTl_common%GT type any.
types : begin of ty_common,
matnr type mara-matnr,
end of ty_common.
data : gt_common type table of ty_common,
wa_common like line of gt_common.
data : l_matnr type mara-matnr,
l_common type i value 0,
l_spchar type c.
clear l_matnr.
loop at %LTgt_output%GT assigning %LTwa_output%GT.
assign component 'MATNR' of structure %LTwa_output%GT to %LTl_matnr%GT.
assign component 'PRVBE' of structure %LTwa_output%GT to %LTl_prvbe%GT.
if sy-tabix = 1.
l_matnr = %LTl_matnr%GT.
elseif l_matnr ne %LTl_matnr%GT.
if l_common gt 1.
clear wa_common.
wa_common-matnr = l_matnr.
append wa_common to gt_common.
endif.
l_matnr = %LTl_matnr%GT.
l_common = 0.
endif.
clear wa_mast.
loop at gt_mast into wa_mast.
clear wa_bom_comp.
read table gt_bom_comp into wa_bom_comp
with key mat_bom = wa_mast-matnr
mat_comp = %LTl_matnr%GT
prvbe = %LTl_prvbe%GT.
if sy-subrc eq 0.
* CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'
* EXPORTING
* INPUT = wa_bom_comp-mat_bom
* IMPORTING
* OUTPUT = wa_bom_comp-mat_bom
* .
do.
if wa_bom_comp-mat_bom ca '.@!^&(),:;/|\=`~[]{}'.
l_spchar = wa_bom_comp-mat_bom+sy-fdpos(1).
replace l_spchar with '-' into wa_bom_comp-mat_bom.
else.
exit.
endif.
enddo.
assign component wa_bom_comp-mat_bom of structure
%LTwa_output%GT to %LTl_field%GT.
if sy-subrc eq 0.
%LTl_field%GT = 'X'.
l_common = l_common + 1.
endif.
endif.
clear wa_mast.
endloop.
endloop.
loop at %LTgt_output%GT assigning %LTwa_output%GT.
assign component 'MATNR' of structure %LTwa_output%GT to %LTl_matnr%GT.
read table gt_common into wa_common with key matnr = %LTl_matnr%GT
transporting no fields.
if sy-subrc eq 0.
assign component 'COMMON' of structure
%LTwa_output%GT to %LTl_common%GT.
if sy-subrc eq 0.
%LTl_common%GT = 'X'.
endif.
endif.
endloop.
ENDFORM. " fill_dynamic_columns
*&---------------------------------------------------------------------*
*& Form get_supply_area
*&---------------------------------------------------------------------*
FORM get_supply_area .
refresh r_prvbe.
clear: wa_bom_comp, r_prvbe.
loop at gt_bom_comp into wa_bom_comp where mat_comp = %LTfs_marc%GT-matnr.
if sy-tabix = 1.
wa_imp_exp-prvbe = wa_bom_comp-prvbe.
PERFORM get_t_pfep.
PERFORM get_lpk3_data.
append wa_imp_exp to gt_imp_exp.
clear r_prvbe.
r_prvbe-sign = 'I'.
r_prvbe-option = 'EQ'.
r_prvbe-low = wa_bom_comp-prvbe.
append r_prvbe.
elseif ( not wa_bom_comp-prvbe in r_prvbe ) or r_prvbe is initial.
wa_imp_exp-prvbe = wa_bom_comp-prvbe.
PERFORM get_t_pfep.
PERFORM get_lpk3_data.
append wa_imp_exp to gt_imp_exp.
clear r_prvbe.
r_prvbe-sign = 'I'.
r_prvbe-option = 'EQ'.
r_prvbe-low = wa_bom_comp-prvbe.
append r_prvbe.
endif.
endloop.
if r_prvbe is initial.
append wa_imp_exp to gt_imp_exp.
endif.
*refresh gt_stpo1.
*select datuv prvbe from stpo into table gt_stpo1
* where idnrk = %LTfs_marc%GT-matnr.
*if sy-subrc eq 0.
* sort gt_stpo1 by datuv descending.
* clear wa_stpo1.
* read table gt_stpo1 into wa_stpo1 index 1.
* wa_imp_exp-prvbe = wa_stpo1-prvbe.
*endif.
*clear wa_stpo.
*wa_stpo-matnr = %LTfs_marc%GT-matnr.
*wa_stpo-prvbe = wa_stpo1-prvbe.
*append wa_stpo to gt_stpo.
ENDFORM. " get_supply_area
*&---------------------------------------------------------------------*
*& Form get_t_pfep
*&---------------------------------------------------------------------*
FORM get_t_pfep .
data : l_vtlin type vtentries-vtlinnoint,
l_matnr type mara-matnr.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'
EXPORTING
INPUT = %LTfs_marc%GT-matnr
IMPORTING
OUTPUT = l_matnr.
CALL FUNCTION 'CARD_TABLE_READ_ENTRIES'
EXPORTING
VAR_TABLE = 'T_PFEP'
* CHANGE_NO =
* DATE =
TABLES
VAR_TAB_ENTRIES = gt_vtentries
* EXCEPTIONS
* ERROR = 1
* OTHERS = 2
.
IF SY-SUBRC %LT%GT 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
clear wa_vtentries.
loop at gt_vtentries into wa_vtentries where vtvalue = l_matnr.
l_vtlin = wa_vtentries-vtlinnoint.
if not wa_imp_exp-prvbe is initial.
read table gt_vtentries into wa_vtentries with key vtlinnoint =
l_vtlin
vtvalue = wa_imp_exp-prvbe transporting no
fields.
if sy-subrc eq 0.
exit.
endif.
else.
exit.
endif.
clear wa_vtentries.
endloop.
clear : wa_imp_exp-pfep_frequency,
wa_imp_exp-pfep_rack,
wa_imp_exp-pfep_route,
wa_imp_exp-pfep_contenant,
wa_imp_exp-pfep_qte_max_contenant,
wa_imp_exp-pfep_piece_kit.
loop at gt_vtentries into wa_vtentries where vtlinnoint eq l_vtlin.
case wa_vtentries-vtcharact.
when 'PFEP_FREQUENCY'.
wa_imp_exp-pfep_frequency = wa_vtentries-vtvalue.
when 'PFEP_RACK'.
wa_imp_exp-pfep_rack = wa_vtentries-vtvalue.
when 'PFEP_ROUTE'.
wa_imp_exp-pfep_route = wa_vtentries-vtvalue.
when 'PFEP_CONTENANT'.
wa_imp_exp-pfep_contenant = wa_vtentries-vtvalue.
when 'PFEP_QTE_MAX_CONTENANT'.
wa_imp_exp-pfep_qte_max_contenant = wa_vtentries-vtvalue.
when 'PFEP_PIECE_KIT'.
wa_imp_exp-pfep_piece_kit = wa_vtentries-vtvalue.
endcase.
endloop.
ENDFORM. " get_t_pfep
*&---------------------------------------------------------------------*
*& Form get_supplier
*&---------------------------------------------------------------------*
FORM get_supplier .
*data : l_plnnr type mapl-plnnr,
* l_plnkn type plas-plnkn,
* l_lines type i.
*
*select single plnnr from mapl into l_plnnr where matnr =
* %LTfs_marc%GT-matnr and werks = s_werks-low.
*
*select plnal statu datuv from plko into table gt_plko
* where plnnr = l_plnnr
* and plnty = 'N'.
*
*clear wa_plko.
*loop at gt_plko into wa_plko where statu = '4'
* and datuv %LT= sy-datum.
*exit.
*endloop.
*
*select single plnkn from plas into l_plnkn where plnty = 'N'
* and plnnr = l_plnnr
* and plnal = wa_plko-plnal
* and loekz ne 'X'.
*
*select arbid from plpo into table gt_plpo where plnty = 'N'
* and plnnr = l_plnnr
* and plnkn = l_plnkn.
*
*describe table gt_plpo lines l_lines.
*read table gt_plpo into wa_plpo index l_lines.
*
*select single arbpl from crhd into wa_imp_exp-supplier where objty =
* 'A'
*and objid = wa_plpo-arbid.
*
ENDFORM. " get_supplier
*&---------------------------------------------------------------------*
*& Form get_classification
*&---------------------------------------------------------------------*
FORM get_classification .
data : gt_class type table of SCLASS,
gt_objectdata type table of CLOBJDAT,
wa_objectdata like line of gt_objectdata.
data : l_object type AUSP-OBJEK.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
INPUT = %LTfs_marc%GT-matnr
IMPORTING
OUTPUT = %LTfs_marc%GT-matnr
EXCEPTIONS
LENGTH_ERROR = 1
OTHERS = 2.
IF SY-SUBRC %LT%GT 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
move %LTfs_marc%GT-matnr to l_object.
CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
EXPORTING
CLASS = 'CL_PFEP'
CLASSTEXT = 'X'
CLASSTYPE = '001'
CLINT = 0
FEATURES = 'X'
LANGUAGE = SY-LANGU
OBJECT = l_object
KEY_DATE = SY-DATUM
INITIAL_CHARACT = 'X'
CHANGE_SERVICE_CLF = 'X'
TABLES
T_CLASS = gt_class
T_OBJECTDATA = gt_objectdata
* I_SEL_CHARACTERISTIC =
* T_NO_AUTH_CHARACT =
EXCEPTIONS
NO_CLASSIFICATION = 1
NO_CLASSTYPES = 2
INVALID_CLASS_TYPE = 3
OTHERS = 4
.
IF SY-SUBRC %LT%GT 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
* EXPORTING
* CLASS = 'CL_PFEP'
* CLASSTEXT = 'X'
* CLASSTYPE = '001'
* CLINT = 0
* FEATURES = 'X'
* LANGUAGE = sy-langu
* OBJECT = l_object
* KEY_DATE = sy-datum
* INITIAL_CHARACT = 'X'
* CHANGE_SERVICE_CLF = 'X'
* TABLES
* T_CLASS = gt_class
* T_OBJECTDATA = gt_objectdata
** I_SEL_CHARACTERISTIC =
** T_NO_AUTH_CHARACT =
* .
*IF SY-SUBRC %LT%GT 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
clear wa_objectdata.
loop at gt_objectdata into wa_objectdata.
case wa_objectdata-atnam.
when 'PFEP_METHOD_TRANSPORT'.
wa_imp_exp-pfep_method_transport = wa_objectdata-ausp1.
when 'PFEP_OCCURENCE_MAX'.
wa_imp_exp-pfep_occurence_max = wa_objectdata-ausp1.
when 'PFEP_REVISON_DATE'.
wa_imp_exp-pfep_revison_date = wa_objectdata-ausp1.
when 'PFEP_CONS_SERVICE'.
wa_imp_exp-pfep_cons_service = wa_objectdata-ausp1.
when 'PFEP_ABC_CONSOMMATION'.
wa_imp_exp-pfep_abc_consommation = wa_objectdata-ausp1.
when 'PFEP_CONT_INTERNE_HAUTEUR'.
wa_imp_exp-pfep_cont_interne_hauteur = wa_objectdata-ausp1.
when 'PFEP_CONT_INTERNE_LARGUER'.
wa_imp_exp-pfep_cont_interne_larguer = wa_objectdata-ausp1.
when 'PFEP_CONT_INTERNE_PROFONDUER'.
wa_imp_exp-pfep_cont_interne_profonduer = wa_objectdata-ausp1.
when 'PFEP_CONT_FOURN_HAUTEUR'.
wa_imp_exp-pfep_cont_fourn_hauteur = wa_objectdata-ausp1.
when 'PFEP_CONT_FOURN_LARGEUR'.
wa_imp_exp-pfep_cont_fourn_largeur = wa_objectdata-ausp1.
when 'PFEP_CONT_FOURN_PROFONDEUR'.
wa_imp_exp-pfep_cont_fourn_profondeur = wa_objectdata-ausp1.
when 'PFEP_PIECE_HAUTEUR'.
wa_imp_exp-pfep_piece_hauteur = wa_objectdata-ausp1.
when 'PFEP_PIECE_LARGEUR'.
wa_imp_exp-pfep_piece_largeur = wa_objectdata-ausp1.
when 'PFEP_PIECE_PROFONDEUR'.
wa_imp_exp-pfep_piece_profondeur = wa_objectdata-ausp1.
endcase.
clear wa_objectdata.
endloop.
ENDFORM. " get_classification
*&---------------------------------------------------------------------*
*& Form get_lpk3_data
*&---------------------------------------------------------------------*
FORM get_lpk3_data .
select single berkz lgnum lgtyp lgpla from pkhd
INTO CORRESPONDING FIELDS OF wa_imp_exp
* ( wa_imp_exp-berkz,
* wa_imp_exp-lgnum,
* wa_imp_exp-lgtyp,
* wa_imp_exp-ccr_lgpla )
where matnr = %LTfs_marc%GT-matnr
and werks = s_werks-low
and prvbe = wa_imp_exp-prvbe.
ENDFORM. " get_lpk3_data
*&---------------------------------------------------------------------*
*& Form get_consumption
*&---------------------------------------------------------------------*
FORM get_consumption .
data : l_menge type mseg-menge,
l_month type i,
l_lines type i.
ranges : r_budat for mkpf-budat.
select mblnr mjahr budat from mkpf into table gt_mkpf where budat in
s_budat.
select mblnr mjahr menge from mseg into table gt_mseg for all entries in
gt_mkpf
where mblnr = gt_mkpf-mblnr
and mjahr = gt_mkpf-mjahr
and bwart in s_bwart
and matnr = %LTfs_marc%GT-matnr.
clear l_menge.
refresh gt_budat.
loop at gt_mseg into wa_mseg.
l_menge = l_menge + wa_mseg-menge.
read table gt_mkpf into wa_mkpf with key mblnr = wa_mseg-mblnr
mjahr = wa_mseg-mjahr.
clear wa_budat.
wa_budat-budat = wa_mkpf-budat.
append wa_budat to gt_budat.
endloop.
sort gt_budat by budat.
refresh r_budat.
loop at gt_budat into wa_budat.
l_month = wa_budat-budat+4(2).
if sy-tabix eq 1.
clear r_budat.
r_budat-sign = 'I'.
r_budat-option = 'EQ'.
r_budat-low = l_month.
append r_budat.
elseif not l_month in r_budat.
clear r_budat.
r_budat-sign = 'I'.
r_budat-option = 'EQ'.
r_budat-low = l_month.
append r_budat.
endif.
endloop.
describe table r_budat lines l_lines.
wa_imp_exp-no_of_months = l_lines.
wa_imp_exp-consumption = l_menge.
ENDFORM. " get_consumption
*&---------------------------------------------------------------------*
*& Form get_sales_status
*&---------------------------------------------------------------------*
FORM get_sales_status .
select single vmsta from mvke into wa_imp_exp-vmsta where matnr =
%LTfs_marc%GT-matnr
and vkorg =
p_vkorg
and vtweg =
p_vtweg
and vmsta in
s_vmsta.
ENDFORM. " get_sales_status
*&---------------------------------------------------------------------*
*& Form set_custom_editable_grid
*&---------------------------------------------------------------------*
FORM set_custom_editable_grid .
field-symbols: %LTl_celltab%GT type any,
%LTl_matnr%GT type any.
DATA: l_matnr like mara-matnr,
l_matnr1 like mara-matnr,
l_tabix like sy-tabix,
l_flag type c,
l_enabled type c.
ranges : r_matnr for mara-matnr.
refresh r_matnr.
loop at %LTgt_output%GT assigning %LTwa_output%GT.
l_tabix = sy-tabix.
clear l_flag.
assign component 'MATNR' of structure %LTwa_output%GT to %LTl_matnr%GT.
l_matnr = %LTl_matnr%GT.
if sy-tabix eq 1. "and not l_matnr in r_matnr.
l_enabled = 'X'.
refresh gt_style.
assign component 'XYZSTYLEZYX' of structure %LTwa_output%GT to
%LTl_celltab%GT.
perform change_style using l_enabled changing %LTl_celltab%GT.
clear r_matnr.
r_matnr-sign = 'I'.
r_matnr-option = 'EQ'.
r_matnr-low = l_matnr.
append r_matnr.
l_flag = 'X'.
else.
if not l_matnr in r_matnr.
l_enabled = 'X'.
refresh gt_style.
assign component 'XYZSTYLEZYX' of structure %LTwa_output%GT to
%LTl_celltab%GT.
perform change_style using l_enabled changing %LTl_celltab%GT.
clear r_matnr.
r_matnr-sign = 'I'.
r_matnr-option = 'EQ'.
r_matnr-low = l_matnr.
append r_matnr.
l_flag = 'X'.
endif.
endif.
if l_flag eq 'X'.
loop at %LTgt_output%GT assigning %LTwa_output1%GT.
assign component 'MATNR' of structure %LTwa_output1%GT to %LTl_matnr%GT.
l_matnr1 = %LTl_matnr%GT.
if l_matnr ne l_matnr1 or sy-tabix %LT= l_tabix.
continue.
endif.
l_enabled = SPACE.
refresh gt_style.
assign component 'XYZSTYLEZYX' of structure %LTwa_output1%GT to
%LTl_celltab%GT.
perform change_style using l_enabled changing %LTl_celltab%GT.
endloop.
endif.
endloop.
*loop at %LTgt_output%GT assigning %LTwa_output%GT.
*assign component 'MATNR' of structure %LTwa_output%GT to %LTl_matnr%GT.
*if sy-tabix eq 1.
* l_enabled = 'X'.
* l_matnr = %LTl_matnr%GT.
* refresh gt_style.
* assign component 'XYZSTYLEZYX' of structure %LTwa_output%GT to
* %LTl_celltab%GT.
* perform change_style using l_enabled changing %LTl_celltab%GT.
*else.
* if l_matnr ne %LTl_matnr%GT.
* l_enabled = 'X'.
* l_matnr = %LTl_matnr%GT.
* refresh gt_style.
* assign component 'XYZSTYLEZYX' of structure %LTwa_output%GT to
* %LTl_celltab%GT.
* perform change_style using l_enabled changing %LTl_celltab%GT.
* else.
* l_enabled = SPACE.
* refresh gt_style.
* assign component 'XYZSTYLEZYX' of structure %LTwa_output%GT to
* %LTl_celltab%GT.
* perform change_style using l_enabled changing %LTl_celltab%GT.
* endif.
*endif.
*endloop.
ENDFORM. " set_custom_editable_grid
**&---------------------------------------------------------------------
*
**& Form change_style
**&---------------------------------------------------------------------
*
FORM change_style USING VALUE(P_ENABLED)
CHANGING L_CELLTAB.
**&---------------------------------------------------------------------
*
**& Form change_style
**&---------------------------------------------------------------------
*
** text
**----------------------------------------------------------------------
*
** --%GTP_%LTL_CELLTAB%GT text
** --%GTP_L_ENABLED text
**----------------------------------------------------------------------
*
*FORM change_style TABLES P_L_CELLTAB STRUCTURE LVC_S_STYL
* %LTL_CELLTAB%GT #LOCAL# %GT
* "Insert correct name for %LT...%GT
* USING P_ENABLED.
if p_enabled eq 'X'.
gs_style-fieldname = 'WEBAZ'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'EISBE'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'EISLO'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'SHZET'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'SHFLG'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'MAABC'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'MRPPP'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'BSTRF'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'DISLS'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'BSTMI'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'EKWSL'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'DISPO'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'EKGRP'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'MINBE'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'MABST'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'DISGR'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'BSTMA'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'LTKZE'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'LTKZA'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'LGBKZ'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'LGPLA'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'BSSKZ'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'SOBSL'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_REVISION_DATE'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_METHODE_TRANSPORT'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_OCCURENCE_MAX'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_CONT_INTERNE_HAUTEUR'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_CONT_INTERNE_LARGEUR'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_CONT_INTERNE_PROFONDEUR'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_PIECE_HAUTEUR'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_PIECE_LARGEUR'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_PIECE_PROFONDEUR'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_CONT_FOURN_HAUTEUR'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_CONT_FOURN_LARGEUR'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_CONT_FOURN_PROFONDEUR'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_CONTENANT'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_QTE_MAX_CONTENANT'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_ROUTE'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_FREQUENCY'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_RACK'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_PIECE_KIT'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_ABC_CONSOMMATION'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_CONS_SERVICE'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_enabled.
insert gs_style into table gt_style.
L_CELLTAB = gt_style[].
else.
gs_style-fieldname = 'WEBAZ'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'EISBE'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'EISLO'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'SHZET'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'SHFLG'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'MAABC'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'MRPPP'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'BSTRF'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'DISLS'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'BSTMI'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'EKWSL'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'DISPO'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'EKGRP'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'MINBE'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'MABST'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'DISGR'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'BSTMA'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'LTKZE'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'LTKZA'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'LGBKZ'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'LGPLA'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'BSSKZ'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'SOBSL'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_REVISION_DATE'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_METHODE_TRANSPORT'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_OCCURENCE_MAX'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_CONT_INTERNE_HAUTEUR'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_CONT_INTERNE_LARGEUR'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_CONT_INTERNE_PROFONDEUR'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_PIECE_HAUTEUR'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_PIECE_LARGEUR'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_PIECE_PROFONDEUR'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_CONT_FOURN_HAUTEUR'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_CONT_FOURN_LARGEUR'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_CONT_FOURN_PROFONDEUR'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
* gs_style-fieldname = 'PFEP_CONTENANT'.
* gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
* insert gs_style into table gt_style.
*
* gs_style-fieldname = 'PFEP_QTE_MAX_CONTENANT'.
* gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
* insert gs_style into table gt_style.
* gs_style-fieldname = 'PFEP_ROUTE'.
* gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
* insert gs_style into table gt_style.
*
* gs_style-fieldname = 'PFEP_FREQUENCY'.
* gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
* insert gs_style into table gt_style.
*
* gs_style-fieldname = 'PFEP_RACK'.
* gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
* insert gs_style into table gt_style.
* gs_style-fieldname = 'PFEP_PIECE_KIT'.
* gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
* insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_ABC_CONSOMMATION'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
gs_style-fieldname = 'PFEP_CONS_SERVICE'.
gs_style-style = cl_gui_alv_grid=%GTmc_style_disabled.
insert gs_style into table gt_style.
L_CELLTAB = gt_style[].
endif.
ENDFORM. " change_style
*&---------------------------------------------------------------------*
*& Form modify_t_pfep
*&---------------------------------------------------------------------*
FORM modify_t_pfep USING NEW_VALUE
OLD_VALUE
MATNR
PRVBE
VALUE(CHARACTERISTIC).
DATA : l_vtlin type vtentries-vtlinnoint,
l_matnr type mara-matnr,
l_flag type c.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'
EXPORTING
INPUT = matnr
IMPORTING
OUTPUT = l_matnr.
refresh gt_vtentries.
CALL FUNCTION 'CARD_TABLE_READ_ENTRIES'
EXPORTING
VAR_TABLE = 'T_PFEP'
TABLES
VAR_TAB_ENTRIES = gt_vtentries
EXCEPTIONS
ERROR = 1
OTHERS = 2.
IF SY-SUBRC %LT%GT 0.
g_error = 'X'.
ENDIF.
clear: wa_vtentries, l_vtlin, l_flag.
loop at gt_vtentries into wa_vtentries where vtvalue = l_matnr.
l_vtlin = wa_vtentries-vtlinnoint.
if not prvbe is initial.
read table gt_vtentries into wa_vtentries with key vtlinnoint =
l_vtlin
vtvalue = prvbe transporting no fields.
if sy-subrc eq 0.
l_flag = 'X'.
exit.
endif.
else.
l_flag = 'X'.
exit.
endif.
clear: wa_vtentries.
endloop.
if l_flag = 'X'.
refresh gt_vtentries.
wa_vtentries-vtlinnoint = l_vtlin.
wa_vtentries-vtcharact = CHARACTERISTIC.
wa_vtentries-vtvalue = new_value.
append wa_vtentries to gt_vtentries.
CALL FUNCTION 'CAMA_TABLE_MAINTAIN_ENTRIES'
EXPORTING
VAR_TABLE = 'T_PFEP'
TABLES
VAR_TAB_ENTRIES = gt_vtentries
EXCEPTIONS
ERROR = 1
OTHERS = 2.
IF SY-SUBRC %LT%GT 0.
g_error = 'X'.
ENDIF.
if not old_value is initial.
refresh gt_vtentries.
wa_vtentries-vtlinnoint = l_vtlin.
wa_vtentries-vtcharact = CHARACTERISTIC.
wa_vtentries-vtvalue = old_value.
wa_vtentries-fldelete = 'X'.
append wa_vtentries to gt_vtentries.
CALL FUNCTION 'CAMA_TABLE_MAINTAIN_ENTRIES'
EXPORTING
VAR_TABLE = 'T_PFEP'
TABLES
VAR_TAB_ENTRIES = gt_vtentries
EXCEPTIONS
ERROR = 1
OTHERS = 2.
IF SY-SUBRC %LT%GT 0.
g_error = 'X'.
ENDIF.
endif.
else.
* sort gt_vtentries by vtlinnoint descending.
* read table gt_vtentries into wa_vtentries index 1.
* l_vtlin = wa_vtentries-vtlinnoint + 1.
refresh gt_vtentries.
* wa_vtentries-vtlinnoint = l_vtlin.
wa_vtentries-vtcharact = 'PFEP_COMPONENT'.
wa_vtentries-vtvalue = l_matnr.
append wa_vtentries to gt_vtentries.
* wa_vtentries-vtlinnoint = l_vtlin.
wa_vtentries-vtcharact = 'PFEP_SUPPLY_AREA'.
wa_vtentries-vtvalue = prvbe.
append wa_vtentries to gt_vtentries.
* wa_vtentries-vtlinnoint = l_vtlin.
wa_vtentries-vtcharact = CHARACTERISTIC.
wa_vtentries-vtvalue = new_value.
append wa_vtentries to gt_vtentries.
CALL FUNCTION 'CAMA_TABLE_MAINTAIN_ENTRIES'
EXPORTING
VAR_TABLE = 'T_PFEP'
TABLES
VAR_TAB_ENTRIES = gt_vtentries
EXCEPTIONS
ERROR = 1
OTHERS = 2.
IF SY-SUBRC %LT%GT 0.
g_error = 'X'.
ENDIF.
endif.
ENDFORM. " modify_t_pfep
*&---------------------------------------------------------------------*
*& Form modify_classification
*&---------------------------------------------------------------------*
FORM modify_classification USING new_value
characteristic
MATNR.
data : gt_class type table of SCLASS,
gt_objectdata type table of CLOBJDAT,
wa_objectdata like line of gt_objectdata.
data : l_object type BAPI1003_KEY-OBJECT,
l_new_value type ATWRT.
move matnr to l_object.
move new_value to l_new_value.
clear : wa_char_values, wa_num_values.
refresh : gt_char_values, gt_num_values.
CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
EXPORTING
CLASS = 'CL_PFEP'
CLASSTEXT = 'X'
CLASSTYPE = '001'
CLINT = 0
FEATURES = 'X'
LANGUAGE = SY-LANGU
OBJECT = l_object
KEY_DATE = SY-DATUM
INITIAL_CHARACT = 'X'
CHANGE_SERVICE_CLF = 'X'
TABLES
T_CLASS = gt_class
T_OBJECTDATA = gt_objectdata
EXCEPTIONS
NO_CLASSIFICATION = 1
NO_CLASSTYPES = 2
INVALID_CLASS_TYPE = 3
OTHERS = 4.
IF SY-SUBRC %LT%GT 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
clear wa_objectdata.
loop at gt_objectdata into wa_objectdata.
if wa_objectdata-ausp1 ne '?'.
clear wa_char_values.
wa_char_values-CHARACT = wa_objectdata-atnam.
wa_char_values-VALUE_CHAR = wa_objectdata-ausp1.
wa_char_values-VALUE_NEUTRAL = wa_objectdata-ausp1.
APPEND wa_char_values to gt_char_values.
clear wa_objectdata.
endif.
endloop.
clear wa_char_values.
wa_char_values-CHARACT = characteristic.
wa_char_values-VALUE_CHAR = l_new_value.
wa_char_values-VALUE_NEUTRAL = l_new_value.
APPEND wa_char_values to gt_char_values.
CALL FUNCTION 'BAPI_OBJCL_CHANGE'
EXPORTING
OBJECTKEY = l_object
OBJECTTABLE = 'MARA'
CLASSNUM = 'CL_PFEP'
CLASSTYPE = '001'
TABLES
ALLOCVALUESNUMNEW = gt_num_values
ALLOCVALUESCHARNEW = gt_char_values
ALLOCVALUESCURRNEW = gt_curr_values
RETURN = GT_RETURN.
read table gt_return into wa_return with key type = 'E'.
if sy-subrc eq 0.
g_error = 'X'.
endif.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = GT_RETURN1.
if gt_return1-type = 'E'.
g_error = 'X'.
endif.
ENDFORM. " modify_classification
*Selection texts
*----------------------------------------------------------
* CHK_FIR Check FIR
* P_CAPID Application
* P_DATUV Valid-From Date
* P_FILE File
* P_LGNUM Warehouse Number
* P_VKORG Sales Organization
* P_VTWEG Distribution Channel
* RB_DOWNL Download
* RB_UPLD Upload
* S_AMATNR Alternative Material
* S_BESKZ Procurement Type
* S_BUDAT Posting Date in the Document
* S_BWART Movement Type
* S_DELKZ MRP element
* S_DISPO MRP Controller (Materials Plan
* S_DSDAT MRP date
* S_EKGRP Purchasing Group
* S_MATNR Material
* S_SOBSL Special procurement type
* S_VMSTA Distribution-chain-specific
* S_WERKS Plant
*Messages
*----------------------------------------------------------
*
* Message class: ZP
*000 Do commit work every so often to avoid time out if run online
*001 No data exists for the selection criteria
*002
*YPE
*
* Message class: ZZ
*037
*Selection texts
*----------------------------------------------------------
* CHK_FIR Check FIR
* P_CAPID Application
* P_DATUV Valid-From Date
* P_FILE File
* P_LGNUM Warehouse Number
* P_VKORG Sales Organization
* P_VTWEG Distribution Channel
* RB_DOWNL Download
* RB_UPLD Upload
* S_AMATNR Alternative Material
* S_BESKZ Procurement Type
* S_BUDAT Posting Date in the Document
* S_BWART Movement Type
* S_DELKZ MRP element
* S_DISPO MRP Controller (Materials Plan
* S_DSDAT MRP date
* S_EKGRP Purchasing Group
* S_MATNR Material
* S_SOBSL Special procurement type
* S_VMSTA Distribution-chain-specific
* S_WERKS Plant
*Messages
*----------------------------------------------------------
*
* Message class: ZP
*000 hello
*001
*002
*YPE
*
* Message class: ZZ
*037