REPORT zupload_material MESSAGE-ID Zcn_d0311_01.
INCLUDE ZCN_D0311_UPLOAD_MARA_TOP.
INCLUDE ZCN_D0311_UPLOAD_MARA_SEL.
INCLUDE ZCN_D0311_UPLOAD_MARA_F01.
INCLUDE ZCN_D0311_UPLOAD_MARA_CLS.
INCLUDE ZCN_D0311_UPLOAD_MARA_O01.
INITIALIZATION.
CREATE OBJECT gr_data.
CALL METHOD gr_data->init.
*&---------------------------------------------------------------------*
*& AT SELECTION-SCREEN
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN.
* Download template
CASE sscrfields-ucomm.
WHEN gc_fc01.
PERFORM frm_download_template.
WHEN OTHERS.
ENDCASE.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL METHOD gr_data->f4_help.
START-OF-SELECTION.
IF gr_data IS NOT INITIAL.
CALL METHOD gr_data->get_data.
CALL METHOD gr_data->check_data.
CALL METHOD gr_data->process_data.
CALL SCREEN 200.
ENDIF.
ZCN_D0311_UPLOAD_MARA_TOP
*&---------------------------------------------------------------------*
*& Include ZCN_D0311_UPLOAD_MARA_TOP
*&---------------------------------------------------------------------*
TABLES:sscrfields.
CLASS:lcl_data DEFINITION DEFERRED.
CONSTANTS gc_fc01 TYPE syst_ucomm VALUE 'FC01'. "Function code1
DATA:gr_data TYPE REF TO lcl_data.
CLASS lcl_data DEFINITION FINAL.
PUBLIC SECTION.
CONSTANTS:
lc_a TYPE char1 VALUE 'A',
lc_pf TYPE char15 VALUE 'STATUS_0200',
lc_str_name TYPE dd02l-tabname VALUE 'ZCN_D0311_MARA_S',
lc_mtart TYPE char30 VALUE 'MTART',
lc_werks TYPE char30 VALUE 'WERKS',
lc_maktx TYPE char30 VALUE 'MAKTX',
lc_mbrsh TYPE char30 VALUE 'MBRSH',
lc_msg TYPE char30 VALUE 'MSG',
lc_matnr TYPE char30 VALUE 'MATNR',
lc_disls TYPE char30 VALUE 'DISLS',
lc_status TYPE char30 VALUE 'STATUS',
lc_disgr TYPE char30 VALUE 'DISGR',
lc_dismm TYPE char30 VALUE 'DISMM',
lc_meins TYPE char30 VALUE 'MEINS',
lc_mat TYPE char3 VALUE 'MAT',
lc_mm03 TYPE syst_tcode VALUE 'MM03',
lc_back TYPE char10 VALUE 'BACK',
lc_cancel TYPE char10 VALUE 'CANC',
lc_exit TYPE char10 VALUE 'EXIT'
.
DATA:
mt_upload TYPE STANDARD TABLE OF /Z/cn_d0311_mara_s,
mr_grid TYPE REF TO cl_gui_alv_grid.
METHODS init.
METHODS f4_help.
METHODS get_data.
METHODS free.
METHODS user_command_200."User command for screen 100
METHODS display_data.
METHODS check_data.
METHODS process_data.
* METHODS display_gui_data IMPORTING e_message TYPE char50.
PRIVATE SECTION.
METHODS set_layo EXPORTING VALUE(es_layo) TYPE lvc_s_layo.
METHODS set_fcat EXPORTING VALUE(et_fcat) TYPE lvc_t_fcat.
METHODS handle_hotspot_click
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id.
METHODS refresh_display.
ENDCLASS.
ZCN_D0311_UPLOAD_MARA_SEL
·
*&---------------------------------------------------------------------*
*& Include /Z/CN_D0311_UPLOAD_MARA_SEL
*&---------------------------------------------------------------------*
SELECTION-SCREEN FUNCTION KEY 1.
SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLE text-003.
PARAMETERS: p_file TYPE rlgrap-filename.
SELECTION-SCREEN END OF BLOCK bl1.
ZCN_D0311_UPLOAD_MARA_F01
*&---------------------------------------------------------------------*
*& Include /Z/CN_D0311_UPLOAD_MARA_F01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form CREATE_MATERIAL
*&---------------------------------------------------------------------*
* Main process
*----------------------------------------------------------------------*
* <--cs_upload Interim table of Upload data
*----------------------------------------------------------------------*
FORM create_material CHANGING cs_upload TYPE /Z/cn_d0311_mara_s.
CONSTANTS lc_x TYPE char1 VALUE 'X'.
DATA: ls_headdata TYPE bapimathead,
ls_clientdata TYPE bapi_mara,
ls_clientdatax TYPE bapi_marax,
lt_materialdescription TYPE t_bapi_makt,
ls_plantdata TYPE bapi_marc,
ls_plantdatax TYPE bapi_marcx,
ls_storagelocationdata TYPE bapi_mard,
ls_storagelocationdatax TYPE bapi_mardx,
ls_valuationdata TYPE bapi_mbew,
ls_valuationdatax TYPE bapi_mbewx.
* Enter header data
PERFORM fill_header_data_view USING cs_upload
CHANGING ls_headdata.
* Enter basic data
PERFORM fill_basic_data_view USING cs_upload
CHANGING lt_materialdescription
ls_clientdata
ls_clientdatax.
* Enter storage location data
PERFORM fill_storage_location_view USING cs_upload
CHANGING ls_storagelocationdata
ls_storagelocationdatax.
* Enter plant data
PERFORM fill_plant_views USING cs_upload
CHANGING ls_plantdata
ls_plantdatax.
PERFORM fill_accouning_view USING cs_upload
CHANGING ls_valuationdata
ls_valuationdatax.
* Create Material
PERFORM save_material USING ls_headdata "Head data
lt_materialdescription
ls_clientdata "Basic data
ls_clientdatax
ls_plantdata "MRP data
ls_plantdatax
ls_storagelocationdata
ls_storagelocationdatax
ls_valuationdata
ls_valuationdatax
CHANGING cs_upload.
"Create VALUATION_TYPE data
IF cs_upload-status = icon_led_green AND cs_upload-bwtar NE lc_x.
PERFORM create_valuation_type CHANGING cs_upload.
ENDIF.
"free
FREE: lt_materialdescription.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form save_material
*&---------------------------------------------------------------------*
* Save process
*----------------------------------------------------------------------*
* -->is_headdata Header Segment with Control Information
* -->it_materialdescription Material Descriptions
* -->is_clientdata Material Data at Client Level
* -->is_clientdatax Material Data at Client Level
* -->is_plantdata plant data
* -->is_pla