Complexity Management to extract the BOM and least level material inventory
Selection Screen:
1) Material number (MARD-MATNR) Mandatory
2) Storage location (MARD-LGORT) Mandatory
3)
Plant (MARD-WERKS)
Mandatory
4)
Valuation Area (MBEW-BWKEY)
5)
Valuation type
(MBEW-Valuation Type)
Processing Logic:
1) Read Table MARD fist based on above selection.
2) Either you can use JOIN OR FOR ALL ENTRIES when reading from other
tables . Other tables to read data are MBEW, MARA, MSLB, MSKA, MSKU, MAKT,
T001W
3)
Zero value inventory records are not required to be extracted.
Positive and Negative inventory value records to be extracted
4)
Snapshot Date is current system
date of the report extract which may be a custom field to be defined. Please
add this to selection screen and do not hard code it.
Output:
Source Name
|
SAP Description
|
SAP Table
|
SAP field
|
Src Material ID Code
|
Material number
|
MARA
|
MATNR
|
Src Material Name
|
Material name
description
|
MAKT
|
MAKTX
|
Src Plant/DC ID Cd
|
Plant code
|
MARD
|
WERKS
|
DC desc
|
Plant Name
|
T001W
|
NAME1
|
Src Standard Cost in
Local Currency
|
Standard price
|
MBEW
|
STPRS
|
Local
Currency
|
Local
Currency
|
T001
|
WAERS
|
Src Standard Cost Unit
of Measure
|
Price UOM
|
MBEW
|
PEINH
|
Src Current Cost in
USD
|
Planned price 1
|
MBEW
|
ZPLP1
|
Stock Location Code
|
Storage location code
|
MARD
|
LGORT
|
Stock Qty UOM
|
Base UOM
|
MARA
|
MEINS
|
Src Unrest Stock Qty
|
Unrestricted Stock Qty
|
MARD
|
LABST
|
Src Stock In Transit
Qty
|
In transit Qty
|
MARD
|
UMLME
|
Src Stock In QC
Inspection Qty
|
Quality
Inspection Qty
|
MARD
|
INSME
|
Src Blocked Stock Qty
|
Blocked Qty
|
MARD
|
SPEME
|
Snapshot Date
|
Current date of Inventory Extraction
|
Custom information
|
Provided
|
Src Vendor ID Code
|
Subcontracting
|
MSLB
|
LIFNR
|
Subcontracting -
Unrestricted Stock
|
MSLB
|
LBLAB
|
|
Vendor Consignment-
Unrestricted stock
|
MARD
|
KLABS
|
|
Vendor Consignment-
Quality Inspection
|
MARD
|
KINSM
|
|
Vendor Consignment-
Blocked – Vendor ID
|
MARD
|
KSPEM
|
|
Sales Order -
Unrestricted Stock
|
MSKA
|
KALAB
|
|
Sales Order - Quality
Stock
|
MSKA
|
KAINS
|
|
Sales Order - Blocked
Stock
|
MSKA
|
KASPE
|
|
Customer
|
MSKU
|
KUNNR
|
|
Customer Consignment-
Unrestricted stock
|
MSKU
|
KULAB
|
|
Customer Consignment-
Quality Inspection
|
MSKU
|
KUINS
|
***********************************************************************
* Program Title: Inventory Data Extract Creation : 05-AUG-2016 *
* SAP Name : /XXXXXX/MMM005 Application: MM *
* Author : XXXXXXX *
* Ticket No : XXXXXXXX *
* Transport : XXXXXXXX *
*_____________________________________________________________________*
* Description : This program extracts SAP Inventory details for all *
* the material stock across GTS production plants *
* ___________________________________________________________________ *
* Amendments: *
* CH.Request# Date Programmer TR.Request# *
* ================ | ============= | ============ | ================= *
* Action *
* ================ | ============= | ============ | ================= *
* XXXXXXX XXXXXXXX XXXXXX XXXXXXX *
* - Initial development.... *
***********************************************************************
REPORT /XXXXXX/mmm005 NO STANDARD PAGE HEADING.
INCLUDE /XXXXXX/mmm005_top. " Data Declarations
INCLUDE /XXXXXX/mmm005_scr. " Selection Screen Definition
INCLUDE /XXXXXX/mmm005_forms. " Form Routines
INCLUDE /XXXXXX/mmm005_cls_imp. " Class Implementations
*&---------------------------------------------------------------------*
*& AT SELECTION-SCREEN OUTPUT
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
PERFORM modify_sel_screen.
*&---------------------------------------------------------------------*
*& AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_pdir.
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_pdir.
PERFORM f4_filename.
*&---------------------------------------------------------------------*
*& Validations
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN ON s_matnr.
* Validate Material
PERFORM validate_material.
AT SELECTION-SCREEN ON s_werks.
* Validate Plant
PERFORM validate_plant.
AT SELECTION-SCREEN ON s_lgort.
* Validate Storage Location
PERFORM validate_stloc.
AT SELECTION-SCREEN ON s_bwkey.
* Validate Valuation Area
PERFORM validate_val_area.
AT SELECTION-SCREEN ON s_bwtar.
* Validate Valuation Type
PERFORM validate_val_type.
*&---------------------------------------------------------------------*
*& START-OF-SELECTION.
*&---------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM get_data.
PERFORM populate_final_data.
*&---------------------------------------------------------------------*
*& END-OF-SELECTION
*&---------------------------------------------------------------------*
END-OF-SELECTION.
IF g_it_final IS NOT INITIAL.
PERFORM file_extract.
PERFORM display_data.
ELSE.
MESSAGE i113(ei). " No data found
ENDIF.
* Program Title: Inventory Data Extract Creation : 05-AUG-2016 *
* SAP Name : /XXXXXX/MMM005 Application: MM *
* Author : XXXXXXX *
* Ticket No : XXXXXXXX *
* Transport : XXXXXXXX *
*_____________________________________________________________________*
* Description : This program extracts SAP Inventory details for all *
* the material stock across GTS production plants *
* ___________________________________________________________________ *
* Amendments: *
* CH.Request# Date Programmer TR.Request# *
* ================ | ============= | ============ | ================= *
* Action *
* ================ | ============= | ============ | ================= *
* XXXXXXX XXXXXXXX XXXXXX XXXXXXX *
* - Initial development.... *
***********************************************************************
REPORT /XXXXXX/mmm005 NO STANDARD PAGE HEADING.
INCLUDE /XXXXXX/mmm005_top. " Data Declarations
INCLUDE /XXXXXX/mmm005_scr. " Selection Screen Definition
INCLUDE /XXXXXX/mmm005_forms. " Form Routines
INCLUDE /XXXXXX/mmm005_cls_imp. " Class Implementations
*&---------------------------------------------------------------------*
*& AT SELECTION-SCREEN OUTPUT
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
PERFORM modify_sel_screen.
*&---------------------------------------------------------------------*
*& AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_pdir.
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_pdir.
PERFORM f4_filename.
*&---------------------------------------------------------------------*
*& Validations
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN ON s_matnr.
* Validate Material
PERFORM validate_material.
AT SELECTION-SCREEN ON s_werks.
* Validate Plant
PERFORM validate_plant.
AT SELECTION-SCREEN ON s_lgort.
* Validate Storage Location
PERFORM validate_stloc.
AT SELECTION-SCREEN ON s_bwkey.
* Validate Valuation Area
PERFORM validate_val_area.
AT SELECTION-SCREEN ON s_bwtar.
* Validate Valuation Type
PERFORM validate_val_type.
*&---------------------------------------------------------------------*
*& START-OF-SELECTION.
*&---------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM get_data.
PERFORM populate_final_data.
*&---------------------------------------------------------------------*
*& END-OF-SELECTION
*&---------------------------------------------------------------------*
END-OF-SELECTION.
IF g_it_final IS NOT INITIAL.
PERFORM file_extract.
PERFORM display_data.
ELSE.
MESSAGE i113(ei). " No data found
ENDIF.
****************************************************************
INCLUDE /XXXXXX/MMM005_TOP
****************************************************************
*&--------------------------------------------------------------------*
*& TYPE DECLARATIONS
*&--------------------------------------------------------------------*
TYPES:
* Strcture type to declare data for selection screen.
BEGIN OF t_wa_sel,
matnr TYPE mard-matnr,
lgort TYPE mard-lgort,
werks TYPE mard-werks,
bwkey TYPE mbew-bwkey,
bwtar TYPE t149d-bwtar,
erdat TYPE erdat,
END OF t_wa_sel,
BEGIN OF t_wa_mard_mska,
matnr TYPE matnr,
werks TYPE werks_d,
lgort TYPE lgort_d,
labst TYPE labst,
umlme TYPE umlmd,
insme TYPE insme,
speme TYPE speme,
klabs TYPE klabs,
kinsm TYPE kinsm,
kspem TYPE kspem,
charg TYPE charg_d,
sobkz TYPE sobkz,
kalab TYPE labst,
kains TYPE insme,
kaspe TYPE speme,
END OF t_wa_mard_mska,
BEGIN OF t_wa_mara,
matnr TYPE matnr,
meins TYPE meins,
END OF t_wa_mara,
BEGIN OF t_wa_makt,
matnr TYPE matnr,
maktx TYPE maktx,
END OF t_wa_makt,
BEGIN OF t_wa_mbew,
matnr TYPE matnr,
bwkey TYPE bwkey,
stprs TYPE stprs,
peinh TYPE peinh,
zplp1 TYPE dzplp1,
END OF t_wa_mbew,
BEGIN OF t_wa_mslb,
matnr TYPE matnr,
werks TYPE werks_d,
charg TYPE charg_d,
sobkz TYPE sobkz,
lifnr TYPE lifnr,
lblab TYPE labst,
END OF t_wa_mslb,
BEGIN OF t_wa_msku,
matnr TYPE matnr,
werks TYPE werks_d,
charg TYPE charg_d,
sobkz TYPE sobkz,
kunnr TYPE kunnr,
kulab TYPE msku-kulab,
kuins TYPE msku-kuins,
END OF t_wa_msku,
BEGIN OF t_wa_t001k,
bwkey TYPE bwkey,
bukrs TYPE bukrs,
END OF t_wa_t001k,
BEGIN OF t_wa_t001,
bukrs TYPE bukrs,
waers TYPE waers,
END OF t_wa_t001,
* Structure type to declare report output data
BEGIN OF t_wa_final,
matnr TYPE mara-matnr,
maktx TYPE makt-maktx,
werks TYPE mard-werks,
lgort TYPE mard-lgort,
meins TYPE mara-meins,
labst TYPE mard-labst,
insme TYPE mard-insme,
speme TYPE mard-speme,
umlme TYPE mard-umlme,
stprs TYPE mbew-stprs,
zplp1 TYPE mbew-zplp1,
peinh TYPE mbew-peinh,
waers TYPE t001-waers,
klabs TYPE mard-klabs,
kinsm TYPE mard-kinsm,
kspem TYPE mard-kspem,
kulab TYPE msku-kulab,
kuins TYPE msku-kuins,
kunnr TYPE msku-kunnr,
lblab TYPE mslb-lblab,
lifnr TYPE mslb-lifnr,
kalab TYPE mska-kalab,
kains TYPE mska-kains,
kaspe TYPE mska-kaspe,
* sdate TYPE erdat,
sdate TYPE c LENGTH 10,
END OF t_wa_final,
BEGIN OF t_wa_heading,
matnr TYPE char16,
maktx TYPE char20,
werks TYPE char5,
lgort TYPE char11,
meins TYPE char8,
labst TYPE char10,
insme TYPE char10,
speme TYPE char10,
umlme TYPE char14,
stprs TYPE char14,
zplp1 TYPE char13,
peinh TYPE char9,
waers TYPE char14,
klabs TYPE char20,
kinsm TYPE char25,
kspem TYPE char21,
kulab TYPE char19,
kuins TYPE char24,
kunnr TYPE char10,
lblab TYPE char17,
lifnr TYPE char13,
kalab TYPE char22,
kains TYPE char27,
kaspe TYPE char23,
sdate TYPE char13,
END OF t_wa_heading.
*&--------------------------------------------------------------------*
*& INTERNAL TABLES
*&--------------------------------------------------------------------*
DATA:
g_it_final TYPE STANDARD TABLE
OF t_wa_final,
g_it_mard_mska TYPE STANDARD TABLE
OF t_wa_mard_mska,
g_it_materials TYPE STANDARD TABLE
OF t_wa_mard_mska,
g_it_mara TYPE SORTED TABLE
OF t_wa_mara WITH UNIQUE KEY matnr,
g_it_makt TYPE SORTED TABLE
OF t_wa_makt WITH UNIQUE KEY matnr,
g_it_mbew TYPE SORTED TABLE
OF t_wa_mbew WITH NON-UNIQUE KEY matnr bwkey,
g_it_msku TYPE SORTED TABLE
OF t_wa_msku
WITH NON-UNIQUE KEY matnr werks charg sobkz,
g_it_mslb TYPE SORTED TABLE
OF t_wa_mslb
WITH NON-UNIQUE KEY matnr werks charg sobkz,
g_it_t001k TYPE SORTED TABLE
OF t_wa_t001k WITH UNIQUE KEY bwkey,
g_it_t001 TYPE SORTED TABLE
OF t_wa_t001 WITH UNIQUE KEY bukrs,
g_it_heading TYPE STANDARD TABLE OF t_wa_heading.
*&--------------------------------------------------------------------*
*& WORK VARIABLES
*&--------------------------------------------------------------------*
DATA:
* Workarea to declare selection screen data.
g_wa_sel TYPE t_wa_sel,
g_wa_mard_mska TYPE t_wa_mard_mska,
g_wa_mara TYPE t_wa_mara,
g_wa_makt TYPE t_wa_makt,
g_wa_mbew TYPE t_wa_mbew,
g_wa_msku TYPE t_wa_msku,
g_wa_mslb TYPE t_wa_mslb,
g_wa_t001k TYPE t_wa_t001k,
g_wa_t001 TYPE t_wa_t001,
g_wa_final TYPE t_wa_final,
g_wa_heading TYPE t_wa_heading.
DATA:
g_delimiter TYPE c.
*---------------------------------------------------------------------*
* CLASS LCL_REPORT DEFINITION
*---------------------------------------------------------------------*
CLASS lcl_report DEFINITION FINAL.
PUBLIC SECTION.
* Save file to presentation server or application server
CLASS-METHODS:
save_file IMPORTING
im_it_save_tab TYPE STANDARD TABLE
im_file TYPE fileintern
im_dir TYPE fileintern
im_it_heading TYPE STANDARD TABLE.
ENDCLASS. " CLASS lcl_report DEFINITIO
*&--------------------------------------------------------------------*
*& GLOBAL OBJECTS
*&--------------------------------------------------------------------*
DATA:
go_report TYPE REF TO lcl_report,
go_display TYPE REF TO cl_salv_display_settings,
go_columns TYPE REF TO cl_salv_columns_table,
go_column TYPE REF TO cl_salv_column_table,
go_alv TYPE REF TO cl_salv_table,
go_layout TYPE REF TO cl_salv_layout,
go_functions TYPE REF TO cl_salv_functions.
*& TYPE DECLARATIONS
*&--------------------------------------------------------------------*
TYPES:
* Strcture type to declare data for selection screen.
BEGIN OF t_wa_sel,
matnr TYPE mard-matnr,
lgort TYPE mard-lgort,
werks TYPE mard-werks,
bwkey TYPE mbew-bwkey,
bwtar TYPE t149d-bwtar,
erdat TYPE erdat,
END OF t_wa_sel,
BEGIN OF t_wa_mard_mska,
matnr TYPE matnr,
werks TYPE werks_d,
lgort TYPE lgort_d,
labst TYPE labst,
umlme TYPE umlmd,
insme TYPE insme,
speme TYPE speme,
klabs TYPE klabs,
kinsm TYPE kinsm,
kspem TYPE kspem,
charg TYPE charg_d,
sobkz TYPE sobkz,
kalab TYPE labst,
kains TYPE insme,
kaspe TYPE speme,
END OF t_wa_mard_mska,
BEGIN OF t_wa_mara,
matnr TYPE matnr,
meins TYPE meins,
END OF t_wa_mara,
BEGIN OF t_wa_makt,
matnr TYPE matnr,
maktx TYPE maktx,
END OF t_wa_makt,
BEGIN OF t_wa_mbew,
matnr TYPE matnr,
bwkey TYPE bwkey,
stprs TYPE stprs,
peinh TYPE peinh,
zplp1 TYPE dzplp1,
END OF t_wa_mbew,
BEGIN OF t_wa_mslb,
matnr TYPE matnr,
werks TYPE werks_d,
charg TYPE charg_d,
sobkz TYPE sobkz,
lifnr TYPE lifnr,
lblab TYPE labst,
END OF t_wa_mslb,
BEGIN OF t_wa_msku,
matnr TYPE matnr,
werks TYPE werks_d,
charg TYPE charg_d,
sobkz TYPE sobkz,
kunnr TYPE kunnr,
kulab TYPE msku-kulab,
kuins TYPE msku-kuins,
END OF t_wa_msku,
BEGIN OF t_wa_t001k,
bwkey TYPE bwkey,
bukrs TYPE bukrs,
END OF t_wa_t001k,
BEGIN OF t_wa_t001,
bukrs TYPE bukrs,
waers TYPE waers,
END OF t_wa_t001,
* Structure type to declare report output data
BEGIN OF t_wa_final,
matnr TYPE mara-matnr,
maktx TYPE makt-maktx,
werks TYPE mard-werks,
lgort TYPE mard-lgort,
meins TYPE mara-meins,
labst TYPE mard-labst,
insme TYPE mard-insme,
speme TYPE mard-speme,
umlme TYPE mard-umlme,
stprs TYPE mbew-stprs,
zplp1 TYPE mbew-zplp1,
peinh TYPE mbew-peinh,
waers TYPE t001-waers,
klabs TYPE mard-klabs,
kinsm TYPE mard-kinsm,
kspem TYPE mard-kspem,
kulab TYPE msku-kulab,
kuins TYPE msku-kuins,
kunnr TYPE msku-kunnr,
lblab TYPE mslb-lblab,
lifnr TYPE mslb-lifnr,
kalab TYPE mska-kalab,
kains TYPE mska-kains,
kaspe TYPE mska-kaspe,
* sdate TYPE erdat,
sdate TYPE c LENGTH 10,
END OF t_wa_final,
BEGIN OF t_wa_heading,
matnr TYPE char16,
maktx TYPE char20,
werks TYPE char5,
lgort TYPE char11,
meins TYPE char8,
labst TYPE char10,
insme TYPE char10,
speme TYPE char10,
umlme TYPE char14,
stprs TYPE char14,
zplp1 TYPE char13,
peinh TYPE char9,
waers TYPE char14,
klabs TYPE char20,
kinsm TYPE char25,
kspem TYPE char21,
kulab TYPE char19,
kuins TYPE char24,
kunnr TYPE char10,
lblab TYPE char17,
lifnr TYPE char13,
kalab TYPE char22,
kains TYPE char27,
kaspe TYPE char23,
sdate TYPE char13,
END OF t_wa_heading.
*&--------------------------------------------------------------------*
*& INTERNAL TABLES
*&--------------------------------------------------------------------*
DATA:
g_it_final TYPE STANDARD TABLE
OF t_wa_final,
g_it_mard_mska TYPE STANDARD TABLE
OF t_wa_mard_mska,
g_it_materials TYPE STANDARD TABLE
OF t_wa_mard_mska,
g_it_mara TYPE SORTED TABLE
OF t_wa_mara WITH UNIQUE KEY matnr,
g_it_makt TYPE SORTED TABLE
OF t_wa_makt WITH UNIQUE KEY matnr,
g_it_mbew TYPE SORTED TABLE
OF t_wa_mbew WITH NON-UNIQUE KEY matnr bwkey,
g_it_msku TYPE SORTED TABLE
OF t_wa_msku
WITH NON-UNIQUE KEY matnr werks charg sobkz,
g_it_mslb TYPE SORTED TABLE
OF t_wa_mslb
WITH NON-UNIQUE KEY matnr werks charg sobkz,
g_it_t001k TYPE SORTED TABLE
OF t_wa_t001k WITH UNIQUE KEY bwkey,
g_it_t001 TYPE SORTED TABLE
OF t_wa_t001 WITH UNIQUE KEY bukrs,
g_it_heading TYPE STANDARD TABLE OF t_wa_heading.
*&--------------------------------------------------------------------*
*& WORK VARIABLES
*&--------------------------------------------------------------------*
DATA:
* Workarea to declare selection screen data.
g_wa_sel TYPE t_wa_sel,
g_wa_mard_mska TYPE t_wa_mard_mska,
g_wa_mara TYPE t_wa_mara,
g_wa_makt TYPE t_wa_makt,
g_wa_mbew TYPE t_wa_mbew,
g_wa_msku TYPE t_wa_msku,
g_wa_mslb TYPE t_wa_mslb,
g_wa_t001k TYPE t_wa_t001k,
g_wa_t001 TYPE t_wa_t001,
g_wa_final TYPE t_wa_final,
g_wa_heading TYPE t_wa_heading.
DATA:
g_delimiter TYPE c.
*---------------------------------------------------------------------*
* CLASS LCL_REPORT DEFINITION
*---------------------------------------------------------------------*
CLASS lcl_report DEFINITION FINAL.
PUBLIC SECTION.
* Save file to presentation server or application server
CLASS-METHODS:
save_file IMPORTING
im_it_save_tab TYPE STANDARD TABLE
im_file TYPE fileintern
im_dir TYPE fileintern
im_it_heading TYPE STANDARD TABLE.
ENDCLASS. " CLASS lcl_report DEFINITIO
*&--------------------------------------------------------------------*
*& GLOBAL OBJECTS
*&--------------------------------------------------------------------*
DATA:
go_report TYPE REF TO lcl_report,
go_display TYPE REF TO cl_salv_display_settings,
go_columns TYPE REF TO cl_salv_columns_table,
go_column TYPE REF TO cl_salv_column_table,
go_alv TYPE REF TO cl_salv_table,
go_layout TYPE REF TO cl_salv_layout,
go_functions TYPE REF TO cl_salv_functions.
****************************************************************
INCLUDE /XXXXXX/MMM005_SCR
*****************************************************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t00.
SELECT-OPTIONS : s_matnr FOR g_wa_sel-matnr ,
s_lgort FOR g_wa_sel-lgort ,
s_werks FOR g_wa_sel-werks OBLIGATORY,
s_bwkey FOR g_wa_sel-bwkey,
s_bwtar FOR g_wa_sel-bwtar,
s_sdate FOR g_wa_sel-erdat.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-t01.
PARAMETERS : p_as TYPE c RADIOBUTTON GROUP rb1
DEFAULT 'X' USER-COMMAND comm,
p_ps TYPE c RADIOBUTTON GROUP rb1.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-t02.
PARAMETERS: p_ldir TYPE fileintern MODIF ID m1," Logical Directory
p_pdir(255) TYPE c MODIF ID m2, " Windows directory
p_file TYPE fileintern, " Filename
p_hline TYPE char1 AS CHECKBOX. " Header line
PARAMETER: p_tab TYPE char1 RADIOBUTTON GROUP rb2 " Tab delimited
DEFAULT 'X'.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(18) text-t03.
SELECTION-SCREEN POSITION 33.
PARAMETER p_delm TYPE char1 RADIOBUTTON GROUP rb2 . " Specify Delimiter
SELECTION-SCREEN POSITION 45.
PARAMETER p_delim TYPE char1 DEFAULT '|' . " Delimiter
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b3.
SELECT-OPTIONS : s_matnr FOR g_wa_sel-matnr ,
s_lgort FOR g_wa_sel-lgort ,
s_werks FOR g_wa_sel-werks OBLIGATORY,
s_bwkey FOR g_wa_sel-bwkey,
s_bwtar FOR g_wa_sel-bwtar,
s_sdate FOR g_wa_sel-erdat.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-t01.
PARAMETERS : p_as TYPE c RADIOBUTTON GROUP rb1
DEFAULT 'X' USER-COMMAND comm,
p_ps TYPE c RADIOBUTTON GROUP rb1.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-t02.
PARAMETERS: p_ldir TYPE fileintern MODIF ID m1," Logical Directory
p_pdir(255) TYPE c MODIF ID m2, " Windows directory
p_file TYPE fileintern, " Filename
p_hline TYPE char1 AS CHECKBOX. " Header line
PARAMETER: p_tab TYPE char1 RADIOBUTTON GROUP rb2 " Tab delimited
DEFAULT 'X'.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(18) text-t03.
SELECTION-SCREEN POSITION 33.
PARAMETER p_delm TYPE char1 RADIOBUTTON GROUP rb2 . " Specify Delimiter
SELECTION-SCREEN POSITION 45.
PARAMETER p_delim TYPE char1 DEFAULT '|' . " Delimiter
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b3.
*************************************************************************
INCLUDE /XXXXXX/MMM005_FORMS
*************************************************************************
*&--------------------------------------------------------------------*
*& FORM get_data.
*&--------------------------------------------------------------------*
* This suborutine is used to get data
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM get_data .
PERFORM get_mat_stock_data.
IF g_it_mard_mska IS NOT INITIAL.
g_it_materials = g_it_mard_mska.
SORT g_it_materials BY matnr.
DELETE ADJACENT DUPLICATES FROM g_it_materials
COMPARING matnr.
PERFORM get_mat_uom_data.
PERFORM get_mat_descriptions.
PERFORM get_mat_valuation_data.
PERFORM get_vendor_stock_data.
PERFORM get_customer_stock_data.
ENDIF.
PERFORM get_currency_data.
ENDFORM. " FORM get_data
*&--------------------------------------------------------------------*
*& FORM populate_final_data
*&--------------------------------------------------------------------*
* This suborutine is used to prepare final data
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM populate_final_data .
SORT g_it_mard_mska BY matnr werks lgort.
LOOP AT g_it_mard_mska INTO g_wa_mard_mska.
g_wa_final-matnr = g_wa_mard_mska-matnr.
g_wa_final-werks = g_wa_mard_mska-werks.
g_wa_final-lgort = g_wa_mard_mska-lgort.
g_wa_final-labst = g_wa_mard_mska-labst.
g_wa_final-umlme = g_wa_mard_mska-umlme.
g_wa_final-insme = g_wa_mard_mska-insme.
g_wa_final-speme = g_wa_mard_mska-speme.
g_wa_final-klabs = g_wa_mard_mska-klabs.
g_wa_final-kinsm = g_wa_mard_mska-kinsm.
g_wa_final-kspem = g_wa_mard_mska-kspem.
g_wa_final-kalab = g_wa_mard_mska-kalab.
g_wa_final-kains = g_wa_mard_mska-kains.
g_wa_final-kaspe = g_wa_mard_mska-kaspe.
CONCATENATE sy-datum+0(4) '.'
sy-datum+4(2) '.'
sy-datum+6(2) INTO g_wa_final-sdate.
* Unit of Measurement
CLEAR g_wa_mara.
READ TABLE g_it_mara INTO g_wa_mara
WITH KEY matnr = g_wa_mard_mska-matnr
BINARY SEARCH.
IF sy-subrc EQ 0.
g_wa_final-meins = g_wa_mara-meins.
ENDIF.
CLEAR g_wa_makt.
READ TABLE g_it_makt INTO g_wa_makt
WITH KEY matnr = g_wa_mard_mska-matnr
BINARY SEARCH.
IF sy-subrc EQ 0.
g_wa_final-maktx = g_wa_makt-maktx.
ENDIF.
CLEAR g_wa_mbew.
READ TABLE g_it_mbew INTO g_wa_mbew
WITH KEY matnr = g_wa_mard_mska-matnr
bwkey = g_wa_mard_mska-werks
BINARY SEARCH.
IF sy-subrc EQ 0.
g_wa_final-stprs = g_wa_mbew-stprs.
g_wa_final-peinh = g_wa_mbew-peinh.
g_wa_final-zplp1 = g_wa_mbew-zplp1.
CLEAR g_wa_t001k.
READ TABLE g_it_t001k INTO g_wa_t001k
WITH KEY bwkey = g_wa_mbew-bwkey
BINARY SEARCH.
IF sy-subrc EQ 0.
CLEAR g_wa_t001.
READ TABLE g_it_t001 INTO g_wa_t001
WITH KEY bukrs = g_wa_t001k-bukrs
BINARY SEARCH.
IF sy-subrc EQ 0.
g_wa_final-waers = g_wa_t001-waers.
ENDIF.
ENDIF.
ENDIF.
APPEND g_wa_final TO g_it_final.
CLEAR g_wa_final.
ENDLOOP.
*-Special Stocks with Vendor
LOOP AT g_it_mslb INTO g_wa_mslb.
CLEAR g_wa_mbew.
READ TABLE g_it_mbew INTO g_wa_mbew
WITH KEY matnr = g_wa_mslb-matnr
bwkey = g_wa_mslb-werks
BINARY SEARCH.
IF sy-subrc EQ 0.
g_wa_final-stprs = g_wa_mbew-stprs.
g_wa_final-peinh = g_wa_mbew-peinh.
g_wa_final-zplp1 = g_wa_mbew-zplp1.
CLEAR g_wa_t001k.
READ TABLE g_it_t001k INTO g_wa_t001k
WITH KEY bwkey = g_wa_mbew-bwkey
BINARY SEARCH.
IF sy-subrc EQ 0.
CLEAR g_wa_t001.
READ TABLE g_it_t001 INTO g_wa_t001
WITH KEY bukrs = g_wa_t001k-bukrs
BINARY SEARCH.
IF sy-subrc EQ 0.
g_wa_final-waers = g_wa_t001-waers.
ENDIF.
ENDIF.
ENDIF.
* Unit of Measurement
CLEAR g_wa_mara.
READ TABLE g_it_mara INTO g_wa_mara
WITH KEY matnr = g_wa_mslb-matnr
BINARY SEARCH.
IF sy-subrc EQ 0.
g_wa_final-meins = g_wa_mara-meins.
ENDIF.
CLEAR g_wa_makt.
READ TABLE g_it_makt INTO g_wa_makt
WITH KEY matnr = g_wa_mslb-matnr
BINARY SEARCH.
IF sy-subrc EQ 0.
g_wa_final-maktx = g_wa_makt-maktx.
ENDIF.
g_wa_final-lblab = g_wa_mslb-lblab.
g_wa_final-lifnr = g_wa_mslb-lifnr.
g_wa_final-matnr = g_wa_mslb-matnr.
g_wa_final-werks = g_wa_mslb-werks.
CONCATENATE sy-datum+0(4)
sy-datum+4(2)
sy-datum+6(2) INTO g_wa_final-sdate
SEPARATED BY '.'.
APPEND g_wa_final TO g_it_final.
CLEAR g_wa_final.
ENDLOOP.
*Special Stocks with Customer
LOOP AT g_it_msku INTO g_wa_msku.
CLEAR g_wa_mbew.
READ TABLE g_it_mbew INTO g_wa_mbew
WITH KEY matnr = g_wa_msku-matnr
bwkey = g_wa_msku-werks
BINARY SEARCH.
IF sy-subrc EQ 0.
g_wa_final-stprs = g_wa_mbew-stprs.
g_wa_final-peinh = g_wa_mbew-peinh.
g_wa_final-zplp1 = g_wa_mbew-zplp1.
CLEAR g_wa_t001k.
READ TABLE g_it_t001k INTO g_wa_t001k
WITH KEY bwkey = g_wa_mbew-bwkey
BINARY SEARCH.
IF sy-subrc EQ 0.
CLEAR g_wa_t001.
READ TABLE g_it_t001 INTO g_wa_t001
WITH KEY bukrs = g_wa_t001k-bukrs
BINARY SEARCH.
IF sy-subrc EQ 0.
g_wa_final-waers = g_wa_t001-waers.
ENDIF.
ENDIF.
ENDIF.
CLEAR g_wa_mara.
READ TABLE g_it_mara INTO g_wa_mara
WITH KEY matnr = g_wa_msku-matnr
BINARY SEARCH.
IF sy-subrc EQ 0.
g_wa_final-meins = g_wa_mara-meins.
ENDIF.
CLEAR g_wa_makt.
READ TABLE g_it_makt INTO g_wa_makt
WITH KEY matnr = g_wa_msku-matnr
BINARY SEARCH.
IF sy-subrc EQ 0.
g_wa_final-maktx = g_wa_makt-maktx.
ENDIF.
g_wa_final-kulab = g_wa_msku-kulab.
g_wa_final-kuins = g_wa_msku-kuins.
g_wa_final-kunnr = g_wa_msku-kunnr.
g_wa_final-matnr = g_wa_msku-matnr.
g_wa_final-werks = g_wa_msku-werks.
CONCATENATE sy-datum+0(4)
sy-datum+4(2)
sy-datum+6(2) INTO g_wa_final-sdate
SEPARATED BY '.'.
APPEND g_wa_final TO g_it_final.
CLEAR g_wa_final.
ENDLOOP.
SORT g_it_final BY matnr DESCENDING
lgort ASCENDING.
ENDFORM. " FORM populate_final_data
*&--------------------------------------------------------------------*
*& FORM modify_sel_screen.
*&--------------------------------------------------------------------*
* Modifying the selection Screen
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM modify_sel_screen.
* Make Logical file directory visible if application server is selected
LOOP AT SCREEN.
IF p_as IS INITIAL.
IF screen-group1 = 'M1'.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
ENDIF.
* Make Desktop Directory visible if presentation server is selected
IF p_ps IS INITIAL.
IF screen-group1 = 'M2'.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " MODIFY_SEL_SCREEN
*&--------------------------------------------------------------------*
*& Form F4_FILENAME
*&--------------------------------------------------------------------*
* Providing F4 Help for Desktop files
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM f4_filename .
DATA :
l_selected_folder TYPE string,
l_initial_folder TYPE string.
l_initial_folder = p_pdir.
CALL METHOD cl_gui_frontend_services=>directory_browse
EXPORTING
initial_folder = l_initial_folder
CHANGING
selected_folder = l_selected_folder
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
p_pdir = l_selected_folder.
ENDIF.
ENDFORM. " FORM f4_filename
*&--------------------------------------------------------------------*
*& FORM file_extract
*&--------------------------------------------------------------------*
* Uploading file to application server or Presentation Server
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM file_extract.
IF p_pdir IS NOT INITIAL OR
p_ldir IS NOT INITIAL.
REFRESH g_it_heading.
IF p_hline EQ 'X'.
PERFORM fill_heading.
ENDIF.
CREATE OBJECT go_report.
CALL METHOD lcl_report=>save_file
EXPORTING
im_it_save_tab = g_it_final
im_file = p_file
im_dir = p_ldir
im_it_heading = g_it_heading.
ENDIF.
ENDFORM. " FORM file_extract
*&--------------------------------------------------------------------*
*& FORM validate_material.
*&--------------------------------------------------------------------*
* This suborutine is used to validate material
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM validate_material.
IF s_matnr IS NOT INITIAL.
SELECT SINGLE matnr
INTO g_wa_sel-matnr
FROM mara
WHERE matnr IN s_matnr[].
IF sy-subrc NE 0.
MESSAGE text-t10 TYPE 'E'.
ENDIF.
ENDIF.
ENDFORM. " FORM validate_material.
*&--------------------------------------------------------------------*
*& FORM validate_plant.
*&--------------------------------------------------------------------*
* This subroutine is used to validate plant
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM validate_plant.
SELECT SINGLE werks
INTO g_wa_sel-werks
FROM t001w
WHERE werks IN s_werks.
IF sy-subrc NE 0.
MESSAGE text-t11 TYPE 'E'.
ENDIF.
ENDFORM. " FORM validate_plant.
*&--------------------------------------------------------------------*
*& FORM validate_stloc
*&--------------------------------------------------------------------*
* This subroutine is used to validate storage location
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM validate_stloc .
IF s_lgort IS NOT INITIAL.
SELECT lgort
INTO g_wa_sel-lgort
UP TO 1 ROWS
FROM t001l
WHERE lgort IN s_lgort.
ENDSELECT.
IF sy-subrc NE 0.
MESSAGE text-t12 TYPE 'E'.
ENDIF.
ENDIF.
ENDFORM. " FORM validate_stloc.
*&---------------------------------------------------------------------*
*& FORM validate_val_area
*&--------------------------------------------------------------------*
* This subroutine is used to validate valuation area
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM validate_val_area .
IF s_bwkey[] IS NOT INITIAL.
SELECT SINGLE bwkey
INTO g_wa_sel-bwkey
FROM t001k
WHERE bwkey IN s_bwkey[].
IF sy-subrc NE 0.
MESSAGE text-t13 TYPE 'E'.
ENDIF.
ENDIF.
ENDFORM. " FORM validate_val_area
*&---------------------------------------------------------------------*
*& FORM validate_val_type
*&--------------------------------------------------------------------*
* This subroutine is used to validate valuation type
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM validate_val_type .
IF s_bwtar[] IS NOT INITIAL.
SELECT SINGLE bwtar
INTO g_wa_sel-bwtar
FROM t149d
WHERE bwtar IN s_bwtar[].
IF sy-subrc NE 0.
MESSAGE text-t14 TYPE 'E'.
ENDIF.
ENDIF.
ENDFORM. " FORM validate_val_type
*&--------------------------------------------------------------------*
*& FORM display_data.
*&--------------------------------------------------------------------*
* This subroutine is used to display data
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM display_data.
DATA :
l_key TYPE salv_s_layout_key.
TRY .
* 1. Instantiate the ALV Global Class
* -----------------------------------------
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = go_alv
CHANGING
t_table = g_it_final.
* 2. This Function is for the Tool Bar
* -----------------------------------------
* Get Object Reference to the Tool Bar Functions
CALL METHOD go_alv->get_functions
RECEIVING
value = go_functions.
* Activate all ALV Tool Bar Functions
CALL METHOD go_functions->set_all
EXPORTING
value = if_salv_c_bool_sap=>true.
* 3. This is for the ALV Layout Functions
* -----------------------------------------
* Get the Object Reference for the ALV Layout
CALL METHOD go_alv->get_layout
RECEIVING
value = go_layout.
* Set the Key
l_key-report = sy-repid.
go_layout->set_key( l_key ).
* Set the Save Layout Option
go_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
* Activate Option of Saving Default Setting
go_layout->set_default( abap_true ).
* 4. Update Column Related Data
* -----------------------------------------
CALL METHOD go_alv->get_columns
RECEIVING
value = go_columns.
* Set the Key Fixation
go_columns->set_key_fixation( abap_true ).
TRY.
* Snapshot Date- Set Column Text
go_column ?= go_columns->get_column( columnname = 'SDATE' ).
go_column->set_long_text( text-t15 ).
go_column->set_medium_text( text-t15 ).
go_column->set_short_text( text-t16 ).
go_column->set_output_length( 13 ).
* Sales order Blocked Qty- Set Column Text
go_column ?= go_columns->get_column( columnname = 'KASPE' ).
go_column->set_long_text( text-t17 ).
go_column->set_medium_text( text-t18 ).
go_column->set_short_text( text-t19 ).
go_column->set_output_length( 25 ).
* Sales order Quality Ins Qty- Set Column Text
go_column ?= go_columns->get_column( columnname = 'KAINS' ).
go_column->set_long_text( text-t20 ).
go_column->set_medium_text( text-t21 ).
go_column->set_short_text( text-t22 ).
go_column->set_output_length( 29 ).
* Sales Order Unrestricted Qty- Set Column Text
go_column ?= go_columns->get_column( columnname = 'KALAB' ).
go_column->set_long_text( text-t23 ).
go_column->set_medium_text( text-t24 ).
go_column->set_short_text( text-t25 ).
go_column->set_output_length( 25 ).
* Subcon Vendor- Set Column Text
go_column ?= go_columns->get_column( columnname = 'LIFNR' ).
go_column->set_long_text( text-t26 ).
go_column->set_medium_text( text-t26 ).
go_column->set_short_text( text-t27 ).
go_column->set_output_length( 13 ).
* SubCon Unrest Qty- Set Column Text
go_column ?= go_columns->get_column( columnname = 'LBLAB' ).
go_column->set_long_text( text-t28 ).
go_column->set_medium_text( text-t29 ).
go_column->set_short_text( text-t30 ).
go_column->set_output_length( 17 ).
* Customer- Set Column Text
go_column ?= go_columns->get_column( columnname = 'KUNNR' ).
go_column->set_long_text( text-t31 ).
go_column->set_medium_text( text-t31 ).
go_column->set_short_text( text-t31 ).
go_column->set_output_length( 10 ).
* Customer Quality Ins Qty - Set Column Text
go_column ?= go_columns->get_column( columnname = 'KUINS' ).
go_column->set_long_text( text-t32 ).
go_column->set_medium_text( text-t33 ).
go_column->set_short_text( text-t34 ).
go_column->set_output_length( 25 ).
* Customer Unrest Qty- Set Column Text
go_column ?= go_columns->get_column( columnname = 'KULAB' ).
go_column->set_long_text( text-t35 ).
go_column->set_medium_text( text-t36 ).
go_column->set_short_text( text-t37 ).
go_column->set_output_length( 22 ).
* V-Consign Blocked Qty - Set Column Text
go_column ?= go_columns->get_column( columnname = 'KSPEM' ).
go_column->set_long_text( text-t38 ).
go_column->set_medium_text( text-t39 ).
go_column->set_short_text( text-t40 ).
go_column->set_output_length( 23 ).
* V-Consign Quality Ins Qty - Set Column Text
go_column ?= go_columns->get_column( columnname = 'KINSM' ).
go_column->set_long_text( text-t41 ).
go_column->set_medium_text( text-t42 ).
go_column->set_short_text( text-t43 ).
go_column->set_output_length( 25 ).
* V-Consign Unrest Qty - Set Column Text
go_column ?= go_columns->get_column( columnname = 'KLABS' ).
go_column->set_long_text( text-t44 ).
go_column->set_medium_text( text-t45 ).
go_column->set_short_text( text-t46 ).
go_column->set_output_length( 20 ).
* Local Currency- Set Column Text
go_column ?= go_columns->get_column( columnname = 'WAERS' ).
go_column->set_long_text( text-t47 ).
go_column->set_medium_text( text-t47 ).
go_column->set_short_text( text-t48 ).
go_column->set_output_length( 14 ).
* Price UOM- Set Column Text
go_column ?= go_columns->get_column( columnname = 'PEINH' ).
go_column->set_long_text( text-t49 ).
go_column->set_medium_text( text-t49 ).
go_column->set_short_text( text-t49 ).
go_column->set_output_length( 9 ).
* Current Price- Set Column Text
go_column ?= go_columns->get_column( columnname = 'ZPLP1' ).
go_column->set_long_text( text-t50 ).
go_column->set_medium_text( text-t50 ).
go_column->set_short_text( text-t51 ).
go_column->set_output_length( 13 ).
* Standard Price- Set Column Text
go_column ?= go_columns->get_column( columnname = 'STPRS' ).
go_column->set_long_text( text-t52 ).
go_column->set_medium_text( text-t52 ).
go_column->set_short_text( text-t53 ).
go_column->set_output_length( 14 ).
* In transit Qty- Set Column Text
go_column ?= go_columns->get_column( columnname = 'UMLME' ).
go_column->set_long_text( text-t54 ).
go_column->set_medium_text( text-t54 ).
go_column->set_short_text( text-t55 ).
go_column->set_output_length( 15 ).
* Block Qty - Set Column Text
go_column ?= go_columns->get_column( columnname = 'SPEME' ).
go_column->set_long_text( text-t56 ).
go_column->set_medium_text( text-t56 ).
go_column->set_short_text( text-t56 ).
go_column->set_output_length( 10 ).
* QI Qty - Set Column Text
go_column ?= go_columns->get_column( columnname = 'INSME' ).
go_column->set_long_text( text-t57 ).
go_column->set_medium_text( text-t57 ).
go_column->set_short_text( text-t57 ).
go_column->set_output_length( 5 ).
* Unrest Qty - Set Column Text
go_column ?= go_columns->get_column( columnname = 'LABST' ).
go_column->set_medium_text( text-t58 ).
go_column->set_long_text( text-t58 ).
go_column->set_short_text( text-t58 ).
go_column->set_output_length( 10 ).
* Base UOM - Set Column Text
go_column ?= go_columns->get_column( columnname = 'MEINS' ).
go_column->set_long_text( text-t59 ).
go_column->set_medium_text( text-t59 ).
go_column->set_short_text( text-t59 ).
go_column->set_output_length( 8 ).
* Storage loc - Set Column Text
go_column ?= go_columns->get_column( columnname = 'LGORT' ).
go_column->set_long_text( text-t60 ).
go_column->set_medium_text( text-t60 ).
go_column->set_short_text( text-t61 ).
go_column->set_output_length( 11 ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
* Do Nothing
ENDTRY.
* Modify Display Settings
* -----------------------------------------
CALL METHOD go_alv->get_display_settings
RECEIVING
value = go_display.
go_display->set_striped_pattern( abap_true ).
* 6. Display the ALV Data
* -----------------------------------------
go_alv->display( ).
CATCH cx_salv_msg .
MESSAGE i113(ei). " No data found
ENDTRY.
ENDFORM. " FORM display_data
*&--------------------------------------------------------------------*
*& FORM get_mat_valuation_data
*&--------------------------------------------------------------------*
* This subroutine fetches material valuation data from table MBEW
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM get_mat_valuation_data .
SELECT matnr
bwkey
stprs
peinh
zplp1
INTO TABLE g_it_mbew
FROM mbew
FOR ALL ENTRIES IN g_it_materials
WHERE matnr EQ g_it_materials-matnr
AND bwkey IN s_bwkey
AND bwtar IN s_bwtar.
ENDFORM. " FORM get_mat_valuation_data
*&--------------------------------------------------------------------*
*& FORM get_vendor_stock_data
*&--------------------------------------------------------------------*
* This subroutine fetches special stocks with vendor data from
* table MSLB
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM get_vendor_stock_data .
SELECT matnr
werks
charg
sobkz
lifnr
lblab
INTO TABLE g_it_mslb
FROM mslb
FOR ALL ENTRIES IN g_it_mard_mska
WHERE matnr EQ g_it_mard_mska-matnr
AND werks EQ g_it_mard_mska-werks.
ENDFORM. " FORM get_vendor_stock_data
*&--------------------------------------------------------------------*
*& FORM get_customer_stock_data
*&--------------------------------------------------------------------*
* This subroutine fetches special stocks with customer data from
* table MSKU
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM get_customer_stock_data .
SELECT matnr
werks
charg
sobkz
kunnr
kulab
kuins
INTO TABLE g_it_msku
FROM msku
FOR ALL ENTRIES IN g_it_mard_mska
WHERE matnr EQ g_it_mard_mska-matnr
AND werks EQ g_it_mard_mska-werks.
ENDFORM. " FORM get_customer_stock_data
*&--------------------------------------------------------------------*
*& FORM get_currency_data
*&--------------------------------------------------------------------*
* This subroutine fetches currency key data from T001 based on
* company code that is retrieved from table T001K
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM get_currency_data .
IF s_bwkey IS NOT INITIAL.
SELECT bwkey
bukrs
INTO TABLE g_it_t001k
FROM t001k
WHERE bwkey IN s_bwkey[].
ELSE.
IF g_it_mbew IS NOT INITIAL.
SELECT bwkey
bukrs
INTO TABLE g_it_t001k
FROM t001k
FOR ALL ENTRIES IN g_it_mbew
WHERE bwkey EQ g_it_mbew-bwkey.
ENDIF.
ENDIF.
IF g_it_t001k IS NOT INITIAL.
SELECT bukrs
waers
INTO TABLE g_it_t001
FROM t001
FOR ALL ENTRIES IN g_it_t001k
WHERE bukrs EQ g_it_t001k-bukrs.
ENDIF.
ENDFORM. " FORM get_currency_data
*&--------------------------------------------------------------------*
*& FORM get_mat_uom_data
*&--------------------------------------------------------------------*
* This subroutine fetches UOM data for the materials
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM get_mat_uom_data .
SELECT matnr
meins
INTO TABLE g_it_mara
FROM mara
FOR ALL ENTRIES IN g_it_materials
WHERE matnr EQ g_it_materials-matnr.
ENDFORM. " FORM get_mat_uom_data
*&--------------------------------------------------------------------*
*& FORM get_mat_descriptions
*&--------------------------------------------------------------------*
* This subroutine fetches all the material descriptions
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM get_mat_descriptions .
SELECT matnr
maktx
FROM makt
INTO TABLE g_it_makt
FOR ALL ENTRIES IN g_it_materials
WHERE matnr EQ g_it_materials-matnr
AND spras EQ sy-langu.
ENDFORM. " FORM get_mat_descriptions
*&--------------------------------------------------------------------*
*& Form GET_MAT_STOCK_DATA
*&--------------------------------------------------------------------*
* This subroutine retrieves storage location data and sales order
* stock data from tables MARD and MSKA
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM get_mat_stock_data .
SELECT mard~matnr
mard~werks
mard~lgort
mard~labst
mard~umlme
mard~insme
mard~speme
mard~klabs
mard~kinsm
mard~kspem
mska~charg
mska~sobkz
mska~kalab
mska~kains
mska~kaspe
INTO TABLE g_it_mard_mska
FROM mard
LEFT OUTER JOIN mska
ON mard~matnr EQ mska~matnr
AND mard~werks EQ mska~werks
AND mard~lgort EQ mska~lgort
WHERE mard~matnr IN s_matnr
AND mard~werks IN s_werks
AND mard~lgort IN s_lgort.
IF sy-subrc EQ 0.
LOOP AT g_it_mard_mska INTO g_wa_mard_mska.
DELETE g_it_mard_mska
WHERE umlme IS INITIAL
AND labst IS INITIAL
AND insme IS INITIAL
AND speme IS INITIAL
AND klabs IS INITIAL
AND kinsm IS INITIAL
AND kspem IS INITIAL
AND kains IS INITIAL
AND kaspe IS INITIAL
AND kalab IS INITIAL.
ENDLOOP.
ENDIF.
ENDFORM. " FORM get_mat_stock_data
*&--------------------------------------------------------------------*
*& FORM fill_heading
*&--------------------------------------------------------------------*
* Creating Header for Output file
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM fill_heading .
CLEAR g_wa_heading.
g_wa_heading-matnr = text-t04. " Material
g_wa_heading-maktx = text-t05. " Mat. Description
g_wa_heading-werks = text-t06. " Plant
g_wa_heading-lgort = text-t60. " Storage loc
g_wa_heading-meins = text-t59. " Base UOM
g_wa_heading-labst = text-t58. " Unrest Qty
g_wa_heading-insme = text-t57. " QI Qty
g_wa_heading-speme = text-t56. " Block Qty
g_wa_heading-umlme = text-t54. " In transit Qty
g_wa_heading-stprs = text-t52. " Standard Price
g_wa_heading-zplp1 = text-t50. " Current Price
g_wa_heading-peinh = text-t49. " Price UOM
g_wa_heading-waers = text-t47. " Local Currency
g_wa_heading-klabs = text-t44. " V-Consign Unrest Qty
g_wa_heading-kinsm = text-t41. " V-Consign Quality Ins Qty
g_wa_heading-kspem = text-t38. " V-Consign Blocked Qty
g_wa_heading-kulab = text-t35. " Customer Unrest Qty
g_wa_heading-kuins = text-t32. " Customer Quality Ins Qty
g_wa_heading-kunnr = text-t31. " Customer
g_wa_heading-lblab = text-t28. " SubCon Unrest Qty
g_wa_heading-lifnr = text-t26. " Subcon Vendor
g_wa_heading-kalab = text-t23. " Sales Order Unrest Qty
g_wa_heading-kains = text-t20. " Sales order Quality Ins Qty
g_wa_heading-kaspe = text-t17. " Sales order Blocked Qty
g_wa_heading-sdate = text-t15. " Snapshot Date
APPEND g_wa_heading TO g_it_heading.
ENDFORM. " FORM fill_heading
*& FORM get_data.
*&--------------------------------------------------------------------*
* This suborutine is used to get data
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM get_data .
PERFORM get_mat_stock_data.
IF g_it_mard_mska IS NOT INITIAL.
g_it_materials = g_it_mard_mska.
SORT g_it_materials BY matnr.
DELETE ADJACENT DUPLICATES FROM g_it_materials
COMPARING matnr.
PERFORM get_mat_uom_data.
PERFORM get_mat_descriptions.
PERFORM get_mat_valuation_data.
PERFORM get_vendor_stock_data.
PERFORM get_customer_stock_data.
ENDIF.
PERFORM get_currency_data.
ENDFORM. " FORM get_data
*&--------------------------------------------------------------------*
*& FORM populate_final_data
*&--------------------------------------------------------------------*
* This suborutine is used to prepare final data
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM populate_final_data .
SORT g_it_mard_mska BY matnr werks lgort.
LOOP AT g_it_mard_mska INTO g_wa_mard_mska.
g_wa_final-matnr = g_wa_mard_mska-matnr.
g_wa_final-werks = g_wa_mard_mska-werks.
g_wa_final-lgort = g_wa_mard_mska-lgort.
g_wa_final-labst = g_wa_mard_mska-labst.
g_wa_final-umlme = g_wa_mard_mska-umlme.
g_wa_final-insme = g_wa_mard_mska-insme.
g_wa_final-speme = g_wa_mard_mska-speme.
g_wa_final-klabs = g_wa_mard_mska-klabs.
g_wa_final-kinsm = g_wa_mard_mska-kinsm.
g_wa_final-kspem = g_wa_mard_mska-kspem.
g_wa_final-kalab = g_wa_mard_mska-kalab.
g_wa_final-kains = g_wa_mard_mska-kains.
g_wa_final-kaspe = g_wa_mard_mska-kaspe.
CONCATENATE sy-datum+0(4) '.'
sy-datum+4(2) '.'
sy-datum+6(2) INTO g_wa_final-sdate.
* Unit of Measurement
CLEAR g_wa_mara.
READ TABLE g_it_mara INTO g_wa_mara
WITH KEY matnr = g_wa_mard_mska-matnr
BINARY SEARCH.
IF sy-subrc EQ 0.
g_wa_final-meins = g_wa_mara-meins.
ENDIF.
CLEAR g_wa_makt.
READ TABLE g_it_makt INTO g_wa_makt
WITH KEY matnr = g_wa_mard_mska-matnr
BINARY SEARCH.
IF sy-subrc EQ 0.
g_wa_final-maktx = g_wa_makt-maktx.
ENDIF.
CLEAR g_wa_mbew.
READ TABLE g_it_mbew INTO g_wa_mbew
WITH KEY matnr = g_wa_mard_mska-matnr
bwkey = g_wa_mard_mska-werks
BINARY SEARCH.
IF sy-subrc EQ 0.
g_wa_final-stprs = g_wa_mbew-stprs.
g_wa_final-peinh = g_wa_mbew-peinh.
g_wa_final-zplp1 = g_wa_mbew-zplp1.
CLEAR g_wa_t001k.
READ TABLE g_it_t001k INTO g_wa_t001k
WITH KEY bwkey = g_wa_mbew-bwkey
BINARY SEARCH.
IF sy-subrc EQ 0.
CLEAR g_wa_t001.
READ TABLE g_it_t001 INTO g_wa_t001
WITH KEY bukrs = g_wa_t001k-bukrs
BINARY SEARCH.
IF sy-subrc EQ 0.
g_wa_final-waers = g_wa_t001-waers.
ENDIF.
ENDIF.
ENDIF.
APPEND g_wa_final TO g_it_final.
CLEAR g_wa_final.
ENDLOOP.
*-Special Stocks with Vendor
LOOP AT g_it_mslb INTO g_wa_mslb.
CLEAR g_wa_mbew.
READ TABLE g_it_mbew INTO g_wa_mbew
WITH KEY matnr = g_wa_mslb-matnr
bwkey = g_wa_mslb-werks
BINARY SEARCH.
IF sy-subrc EQ 0.
g_wa_final-stprs = g_wa_mbew-stprs.
g_wa_final-peinh = g_wa_mbew-peinh.
g_wa_final-zplp1 = g_wa_mbew-zplp1.
CLEAR g_wa_t001k.
READ TABLE g_it_t001k INTO g_wa_t001k
WITH KEY bwkey = g_wa_mbew-bwkey
BINARY SEARCH.
IF sy-subrc EQ 0.
CLEAR g_wa_t001.
READ TABLE g_it_t001 INTO g_wa_t001
WITH KEY bukrs = g_wa_t001k-bukrs
BINARY SEARCH.
IF sy-subrc EQ 0.
g_wa_final-waers = g_wa_t001-waers.
ENDIF.
ENDIF.
ENDIF.
* Unit of Measurement
CLEAR g_wa_mara.
READ TABLE g_it_mara INTO g_wa_mara
WITH KEY matnr = g_wa_mslb-matnr
BINARY SEARCH.
IF sy-subrc EQ 0.
g_wa_final-meins = g_wa_mara-meins.
ENDIF.
CLEAR g_wa_makt.
READ TABLE g_it_makt INTO g_wa_makt
WITH KEY matnr = g_wa_mslb-matnr
BINARY SEARCH.
IF sy-subrc EQ 0.
g_wa_final-maktx = g_wa_makt-maktx.
ENDIF.
g_wa_final-lblab = g_wa_mslb-lblab.
g_wa_final-lifnr = g_wa_mslb-lifnr.
g_wa_final-matnr = g_wa_mslb-matnr.
g_wa_final-werks = g_wa_mslb-werks.
CONCATENATE sy-datum+0(4)
sy-datum+4(2)
sy-datum+6(2) INTO g_wa_final-sdate
SEPARATED BY '.'.
APPEND g_wa_final TO g_it_final.
CLEAR g_wa_final.
ENDLOOP.
*Special Stocks with Customer
LOOP AT g_it_msku INTO g_wa_msku.
CLEAR g_wa_mbew.
READ TABLE g_it_mbew INTO g_wa_mbew
WITH KEY matnr = g_wa_msku-matnr
bwkey = g_wa_msku-werks
BINARY SEARCH.
IF sy-subrc EQ 0.
g_wa_final-stprs = g_wa_mbew-stprs.
g_wa_final-peinh = g_wa_mbew-peinh.
g_wa_final-zplp1 = g_wa_mbew-zplp1.
CLEAR g_wa_t001k.
READ TABLE g_it_t001k INTO g_wa_t001k
WITH KEY bwkey = g_wa_mbew-bwkey
BINARY SEARCH.
IF sy-subrc EQ 0.
CLEAR g_wa_t001.
READ TABLE g_it_t001 INTO g_wa_t001
WITH KEY bukrs = g_wa_t001k-bukrs
BINARY SEARCH.
IF sy-subrc EQ 0.
g_wa_final-waers = g_wa_t001-waers.
ENDIF.
ENDIF.
ENDIF.
CLEAR g_wa_mara.
READ TABLE g_it_mara INTO g_wa_mara
WITH KEY matnr = g_wa_msku-matnr
BINARY SEARCH.
IF sy-subrc EQ 0.
g_wa_final-meins = g_wa_mara-meins.
ENDIF.
CLEAR g_wa_makt.
READ TABLE g_it_makt INTO g_wa_makt
WITH KEY matnr = g_wa_msku-matnr
BINARY SEARCH.
IF sy-subrc EQ 0.
g_wa_final-maktx = g_wa_makt-maktx.
ENDIF.
g_wa_final-kulab = g_wa_msku-kulab.
g_wa_final-kuins = g_wa_msku-kuins.
g_wa_final-kunnr = g_wa_msku-kunnr.
g_wa_final-matnr = g_wa_msku-matnr.
g_wa_final-werks = g_wa_msku-werks.
CONCATENATE sy-datum+0(4)
sy-datum+4(2)
sy-datum+6(2) INTO g_wa_final-sdate
SEPARATED BY '.'.
APPEND g_wa_final TO g_it_final.
CLEAR g_wa_final.
ENDLOOP.
SORT g_it_final BY matnr DESCENDING
lgort ASCENDING.
ENDFORM. " FORM populate_final_data
*&--------------------------------------------------------------------*
*& FORM modify_sel_screen.
*&--------------------------------------------------------------------*
* Modifying the selection Screen
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM modify_sel_screen.
* Make Logical file directory visible if application server is selected
LOOP AT SCREEN.
IF p_as IS INITIAL.
IF screen-group1 = 'M1'.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
ENDIF.
* Make Desktop Directory visible if presentation server is selected
IF p_ps IS INITIAL.
IF screen-group1 = 'M2'.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " MODIFY_SEL_SCREEN
*&--------------------------------------------------------------------*
*& Form F4_FILENAME
*&--------------------------------------------------------------------*
* Providing F4 Help for Desktop files
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM f4_filename .
DATA :
l_selected_folder TYPE string,
l_initial_folder TYPE string.
l_initial_folder = p_pdir.
CALL METHOD cl_gui_frontend_services=>directory_browse
EXPORTING
initial_folder = l_initial_folder
CHANGING
selected_folder = l_selected_folder
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
p_pdir = l_selected_folder.
ENDIF.
ENDFORM. " FORM f4_filename
*&--------------------------------------------------------------------*
*& FORM file_extract
*&--------------------------------------------------------------------*
* Uploading file to application server or Presentation Server
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM file_extract.
IF p_pdir IS NOT INITIAL OR
p_ldir IS NOT INITIAL.
REFRESH g_it_heading.
IF p_hline EQ 'X'.
PERFORM fill_heading.
ENDIF.
CREATE OBJECT go_report.
CALL METHOD lcl_report=>save_file
EXPORTING
im_it_save_tab = g_it_final
im_file = p_file
im_dir = p_ldir
im_it_heading = g_it_heading.
ENDIF.
ENDFORM. " FORM file_extract
*&--------------------------------------------------------------------*
*& FORM validate_material.
*&--------------------------------------------------------------------*
* This suborutine is used to validate material
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM validate_material.
IF s_matnr IS NOT INITIAL.
SELECT SINGLE matnr
INTO g_wa_sel-matnr
FROM mara
WHERE matnr IN s_matnr[].
IF sy-subrc NE 0.
MESSAGE text-t10 TYPE 'E'.
ENDIF.
ENDIF.
ENDFORM. " FORM validate_material.
*&--------------------------------------------------------------------*
*& FORM validate_plant.
*&--------------------------------------------------------------------*
* This subroutine is used to validate plant
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM validate_plant.
SELECT SINGLE werks
INTO g_wa_sel-werks
FROM t001w
WHERE werks IN s_werks.
IF sy-subrc NE 0.
MESSAGE text-t11 TYPE 'E'.
ENDIF.
ENDFORM. " FORM validate_plant.
*&--------------------------------------------------------------------*
*& FORM validate_stloc
*&--------------------------------------------------------------------*
* This subroutine is used to validate storage location
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM validate_stloc .
IF s_lgort IS NOT INITIAL.
SELECT lgort
INTO g_wa_sel-lgort
UP TO 1 ROWS
FROM t001l
WHERE lgort IN s_lgort.
ENDSELECT.
IF sy-subrc NE 0.
MESSAGE text-t12 TYPE 'E'.
ENDIF.
ENDIF.
ENDFORM. " FORM validate_stloc.
*&---------------------------------------------------------------------*
*& FORM validate_val_area
*&--------------------------------------------------------------------*
* This subroutine is used to validate valuation area
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM validate_val_area .
IF s_bwkey[] IS NOT INITIAL.
SELECT SINGLE bwkey
INTO g_wa_sel-bwkey
FROM t001k
WHERE bwkey IN s_bwkey[].
IF sy-subrc NE 0.
MESSAGE text-t13 TYPE 'E'.
ENDIF.
ENDIF.
ENDFORM. " FORM validate_val_area
*&---------------------------------------------------------------------*
*& FORM validate_val_type
*&--------------------------------------------------------------------*
* This subroutine is used to validate valuation type
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM validate_val_type .
IF s_bwtar[] IS NOT INITIAL.
SELECT SINGLE bwtar
INTO g_wa_sel-bwtar
FROM t149d
WHERE bwtar IN s_bwtar[].
IF sy-subrc NE 0.
MESSAGE text-t14 TYPE 'E'.
ENDIF.
ENDIF.
ENDFORM. " FORM validate_val_type
*&--------------------------------------------------------------------*
*& FORM display_data.
*&--------------------------------------------------------------------*
* This subroutine is used to display data
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM display_data.
DATA :
l_key TYPE salv_s_layout_key.
TRY .
* 1. Instantiate the ALV Global Class
* -----------------------------------------
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = go_alv
CHANGING
t_table = g_it_final.
* 2. This Function is for the Tool Bar
* -----------------------------------------
* Get Object Reference to the Tool Bar Functions
CALL METHOD go_alv->get_functions
RECEIVING
value = go_functions.
* Activate all ALV Tool Bar Functions
CALL METHOD go_functions->set_all
EXPORTING
value = if_salv_c_bool_sap=>true.
* 3. This is for the ALV Layout Functions
* -----------------------------------------
* Get the Object Reference for the ALV Layout
CALL METHOD go_alv->get_layout
RECEIVING
value = go_layout.
* Set the Key
l_key-report = sy-repid.
go_layout->set_key( l_key ).
* Set the Save Layout Option
go_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
* Activate Option of Saving Default Setting
go_layout->set_default( abap_true ).
* 4. Update Column Related Data
* -----------------------------------------
CALL METHOD go_alv->get_columns
RECEIVING
value = go_columns.
* Set the Key Fixation
go_columns->set_key_fixation( abap_true ).
TRY.
* Snapshot Date- Set Column Text
go_column ?= go_columns->get_column( columnname = 'SDATE' ).
go_column->set_long_text( text-t15 ).
go_column->set_medium_text( text-t15 ).
go_column->set_short_text( text-t16 ).
go_column->set_output_length( 13 ).
* Sales order Blocked Qty- Set Column Text
go_column ?= go_columns->get_column( columnname = 'KASPE' ).
go_column->set_long_text( text-t17 ).
go_column->set_medium_text( text-t18 ).
go_column->set_short_text( text-t19 ).
go_column->set_output_length( 25 ).
* Sales order Quality Ins Qty- Set Column Text
go_column ?= go_columns->get_column( columnname = 'KAINS' ).
go_column->set_long_text( text-t20 ).
go_column->set_medium_text( text-t21 ).
go_column->set_short_text( text-t22 ).
go_column->set_output_length( 29 ).
* Sales Order Unrestricted Qty- Set Column Text
go_column ?= go_columns->get_column( columnname = 'KALAB' ).
go_column->set_long_text( text-t23 ).
go_column->set_medium_text( text-t24 ).
go_column->set_short_text( text-t25 ).
go_column->set_output_length( 25 ).
* Subcon Vendor- Set Column Text
go_column ?= go_columns->get_column( columnname = 'LIFNR' ).
go_column->set_long_text( text-t26 ).
go_column->set_medium_text( text-t26 ).
go_column->set_short_text( text-t27 ).
go_column->set_output_length( 13 ).
* SubCon Unrest Qty- Set Column Text
go_column ?= go_columns->get_column( columnname = 'LBLAB' ).
go_column->set_long_text( text-t28 ).
go_column->set_medium_text( text-t29 ).
go_column->set_short_text( text-t30 ).
go_column->set_output_length( 17 ).
* Customer- Set Column Text
go_column ?= go_columns->get_column( columnname = 'KUNNR' ).
go_column->set_long_text( text-t31 ).
go_column->set_medium_text( text-t31 ).
go_column->set_short_text( text-t31 ).
go_column->set_output_length( 10 ).
* Customer Quality Ins Qty - Set Column Text
go_column ?= go_columns->get_column( columnname = 'KUINS' ).
go_column->set_long_text( text-t32 ).
go_column->set_medium_text( text-t33 ).
go_column->set_short_text( text-t34 ).
go_column->set_output_length( 25 ).
* Customer Unrest Qty- Set Column Text
go_column ?= go_columns->get_column( columnname = 'KULAB' ).
go_column->set_long_text( text-t35 ).
go_column->set_medium_text( text-t36 ).
go_column->set_short_text( text-t37 ).
go_column->set_output_length( 22 ).
* V-Consign Blocked Qty - Set Column Text
go_column ?= go_columns->get_column( columnname = 'KSPEM' ).
go_column->set_long_text( text-t38 ).
go_column->set_medium_text( text-t39 ).
go_column->set_short_text( text-t40 ).
go_column->set_output_length( 23 ).
* V-Consign Quality Ins Qty - Set Column Text
go_column ?= go_columns->get_column( columnname = 'KINSM' ).
go_column->set_long_text( text-t41 ).
go_column->set_medium_text( text-t42 ).
go_column->set_short_text( text-t43 ).
go_column->set_output_length( 25 ).
* V-Consign Unrest Qty - Set Column Text
go_column ?= go_columns->get_column( columnname = 'KLABS' ).
go_column->set_long_text( text-t44 ).
go_column->set_medium_text( text-t45 ).
go_column->set_short_text( text-t46 ).
go_column->set_output_length( 20 ).
* Local Currency- Set Column Text
go_column ?= go_columns->get_column( columnname = 'WAERS' ).
go_column->set_long_text( text-t47 ).
go_column->set_medium_text( text-t47 ).
go_column->set_short_text( text-t48 ).
go_column->set_output_length( 14 ).
* Price UOM- Set Column Text
go_column ?= go_columns->get_column( columnname = 'PEINH' ).
go_column->set_long_text( text-t49 ).
go_column->set_medium_text( text-t49 ).
go_column->set_short_text( text-t49 ).
go_column->set_output_length( 9 ).
* Current Price- Set Column Text
go_column ?= go_columns->get_column( columnname = 'ZPLP1' ).
go_column->set_long_text( text-t50 ).
go_column->set_medium_text( text-t50 ).
go_column->set_short_text( text-t51 ).
go_column->set_output_length( 13 ).
* Standard Price- Set Column Text
go_column ?= go_columns->get_column( columnname = 'STPRS' ).
go_column->set_long_text( text-t52 ).
go_column->set_medium_text( text-t52 ).
go_column->set_short_text( text-t53 ).
go_column->set_output_length( 14 ).
* In transit Qty- Set Column Text
go_column ?= go_columns->get_column( columnname = 'UMLME' ).
go_column->set_long_text( text-t54 ).
go_column->set_medium_text( text-t54 ).
go_column->set_short_text( text-t55 ).
go_column->set_output_length( 15 ).
* Block Qty - Set Column Text
go_column ?= go_columns->get_column( columnname = 'SPEME' ).
go_column->set_long_text( text-t56 ).
go_column->set_medium_text( text-t56 ).
go_column->set_short_text( text-t56 ).
go_column->set_output_length( 10 ).
* QI Qty - Set Column Text
go_column ?= go_columns->get_column( columnname = 'INSME' ).
go_column->set_long_text( text-t57 ).
go_column->set_medium_text( text-t57 ).
go_column->set_short_text( text-t57 ).
go_column->set_output_length( 5 ).
* Unrest Qty - Set Column Text
go_column ?= go_columns->get_column( columnname = 'LABST' ).
go_column->set_medium_text( text-t58 ).
go_column->set_long_text( text-t58 ).
go_column->set_short_text( text-t58 ).
go_column->set_output_length( 10 ).
* Base UOM - Set Column Text
go_column ?= go_columns->get_column( columnname = 'MEINS' ).
go_column->set_long_text( text-t59 ).
go_column->set_medium_text( text-t59 ).
go_column->set_short_text( text-t59 ).
go_column->set_output_length( 8 ).
* Storage loc - Set Column Text
go_column ?= go_columns->get_column( columnname = 'LGORT' ).
go_column->set_long_text( text-t60 ).
go_column->set_medium_text( text-t60 ).
go_column->set_short_text( text-t61 ).
go_column->set_output_length( 11 ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
* Do Nothing
ENDTRY.
* Modify Display Settings
* -----------------------------------------
CALL METHOD go_alv->get_display_settings
RECEIVING
value = go_display.
go_display->set_striped_pattern( abap_true ).
* 6. Display the ALV Data
* -----------------------------------------
go_alv->display( ).
CATCH cx_salv_msg .
MESSAGE i113(ei). " No data found
ENDTRY.
ENDFORM. " FORM display_data
*&--------------------------------------------------------------------*
*& FORM get_mat_valuation_data
*&--------------------------------------------------------------------*
* This subroutine fetches material valuation data from table MBEW
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM get_mat_valuation_data .
SELECT matnr
bwkey
stprs
peinh
zplp1
INTO TABLE g_it_mbew
FROM mbew
FOR ALL ENTRIES IN g_it_materials
WHERE matnr EQ g_it_materials-matnr
AND bwkey IN s_bwkey
AND bwtar IN s_bwtar.
ENDFORM. " FORM get_mat_valuation_data
*&--------------------------------------------------------------------*
*& FORM get_vendor_stock_data
*&--------------------------------------------------------------------*
* This subroutine fetches special stocks with vendor data from
* table MSLB
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM get_vendor_stock_data .
SELECT matnr
werks
charg
sobkz
lifnr
lblab
INTO TABLE g_it_mslb
FROM mslb
FOR ALL ENTRIES IN g_it_mard_mska
WHERE matnr EQ g_it_mard_mska-matnr
AND werks EQ g_it_mard_mska-werks.
ENDFORM. " FORM get_vendor_stock_data
*&--------------------------------------------------------------------*
*& FORM get_customer_stock_data
*&--------------------------------------------------------------------*
* This subroutine fetches special stocks with customer data from
* table MSKU
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM get_customer_stock_data .
SELECT matnr
werks
charg
sobkz
kunnr
kulab
kuins
INTO TABLE g_it_msku
FROM msku
FOR ALL ENTRIES IN g_it_mard_mska
WHERE matnr EQ g_it_mard_mska-matnr
AND werks EQ g_it_mard_mska-werks.
ENDFORM. " FORM get_customer_stock_data
*&--------------------------------------------------------------------*
*& FORM get_currency_data
*&--------------------------------------------------------------------*
* This subroutine fetches currency key data from T001 based on
* company code that is retrieved from table T001K
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM get_currency_data .
IF s_bwkey IS NOT INITIAL.
SELECT bwkey
bukrs
INTO TABLE g_it_t001k
FROM t001k
WHERE bwkey IN s_bwkey[].
ELSE.
IF g_it_mbew IS NOT INITIAL.
SELECT bwkey
bukrs
INTO TABLE g_it_t001k
FROM t001k
FOR ALL ENTRIES IN g_it_mbew
WHERE bwkey EQ g_it_mbew-bwkey.
ENDIF.
ENDIF.
IF g_it_t001k IS NOT INITIAL.
SELECT bukrs
waers
INTO TABLE g_it_t001
FROM t001
FOR ALL ENTRIES IN g_it_t001k
WHERE bukrs EQ g_it_t001k-bukrs.
ENDIF.
ENDFORM. " FORM get_currency_data
*&--------------------------------------------------------------------*
*& FORM get_mat_uom_data
*&--------------------------------------------------------------------*
* This subroutine fetches UOM data for the materials
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM get_mat_uom_data .
SELECT matnr
meins
INTO TABLE g_it_mara
FROM mara
FOR ALL ENTRIES IN g_it_materials
WHERE matnr EQ g_it_materials-matnr.
ENDFORM. " FORM get_mat_uom_data
*&--------------------------------------------------------------------*
*& FORM get_mat_descriptions
*&--------------------------------------------------------------------*
* This subroutine fetches all the material descriptions
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM get_mat_descriptions .
SELECT matnr
maktx
FROM makt
INTO TABLE g_it_makt
FOR ALL ENTRIES IN g_it_materials
WHERE matnr EQ g_it_materials-matnr
AND spras EQ sy-langu.
ENDFORM. " FORM get_mat_descriptions
*&--------------------------------------------------------------------*
*& Form GET_MAT_STOCK_DATA
*&--------------------------------------------------------------------*
* This subroutine retrieves storage location data and sales order
* stock data from tables MARD and MSKA
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM get_mat_stock_data .
SELECT mard~matnr
mard~werks
mard~lgort
mard~labst
mard~umlme
mard~insme
mard~speme
mard~klabs
mard~kinsm
mard~kspem
mska~charg
mska~sobkz
mska~kalab
mska~kains
mska~kaspe
INTO TABLE g_it_mard_mska
FROM mard
LEFT OUTER JOIN mska
ON mard~matnr EQ mska~matnr
AND mard~werks EQ mska~werks
AND mard~lgort EQ mska~lgort
WHERE mard~matnr IN s_matnr
AND mard~werks IN s_werks
AND mard~lgort IN s_lgort.
IF sy-subrc EQ 0.
LOOP AT g_it_mard_mska INTO g_wa_mard_mska.
DELETE g_it_mard_mska
WHERE umlme IS INITIAL
AND labst IS INITIAL
AND insme IS INITIAL
AND speme IS INITIAL
AND klabs IS INITIAL
AND kinsm IS INITIAL
AND kspem IS INITIAL
AND kains IS INITIAL
AND kaspe IS INITIAL
AND kalab IS INITIAL.
ENDLOOP.
ENDIF.
ENDFORM. " FORM get_mat_stock_data
*&--------------------------------------------------------------------*
*& FORM fill_heading
*&--------------------------------------------------------------------*
* Creating Header for Output file
*---------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*---------------------------------------------------------------------*
FORM fill_heading .
CLEAR g_wa_heading.
g_wa_heading-matnr = text-t04. " Material
g_wa_heading-maktx = text-t05. " Mat. Description
g_wa_heading-werks = text-t06. " Plant
g_wa_heading-lgort = text-t60. " Storage loc
g_wa_heading-meins = text-t59. " Base UOM
g_wa_heading-labst = text-t58. " Unrest Qty
g_wa_heading-insme = text-t57. " QI Qty
g_wa_heading-speme = text-t56. " Block Qty
g_wa_heading-umlme = text-t54. " In transit Qty
g_wa_heading-stprs = text-t52. " Standard Price
g_wa_heading-zplp1 = text-t50. " Current Price
g_wa_heading-peinh = text-t49. " Price UOM
g_wa_heading-waers = text-t47. " Local Currency
g_wa_heading-klabs = text-t44. " V-Consign Unrest Qty
g_wa_heading-kinsm = text-t41. " V-Consign Quality Ins Qty
g_wa_heading-kspem = text-t38. " V-Consign Blocked Qty
g_wa_heading-kulab = text-t35. " Customer Unrest Qty
g_wa_heading-kuins = text-t32. " Customer Quality Ins Qty
g_wa_heading-kunnr = text-t31. " Customer
g_wa_heading-lblab = text-t28. " SubCon Unrest Qty
g_wa_heading-lifnr = text-t26. " Subcon Vendor
g_wa_heading-kalab = text-t23. " Sales Order Unrest Qty
g_wa_heading-kains = text-t20. " Sales order Quality Ins Qty
g_wa_heading-kaspe = text-t17. " Sales order Blocked Qty
g_wa_heading-sdate = text-t15. " Snapshot Date
APPEND g_wa_heading TO g_it_heading.
ENDFORM. " FORM fill_heading
***********************************************************************
INCLUDE /XXXXXX/MMM005_CLS_IMP
***********************************************************************
*---------------------------------------------------------------------*
* CLASS LCL_REPORT IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS lcl_report IMPLEMENTATION.
*---------------------------------------------------------------------*
* Data selection
*---------------------------------------------------------------------*
METHOD save_file.
DATA:
file_out TYPE REF
TO /XXXXXX/cl_file_utilities,
l_logf TYPE string,
l_file TYPE string,
l_count TYPE i,
l_delimiter TYPE char1,
l_fileloc TYPE char2.
CASE 'X'.
WHEN p_tab.
l_delimiter = cl_abap_char_utilities=>horizontal_tab.
WHEN p_delm.
l_delimiter = p_delim.
ENDCASE.
g_delimiter = l_delimiter.
IF p_as IS NOT INITIAL.
l_fileloc = 'LG'.
l_file = im_file.
l_logf = im_dir.
ELSEIF p_ps IS NOT INITIAL.
l_fileloc = 'PC'.
CONCATENATE p_pdir '\' im_file INTO l_logf.
ENDIF.
CREATE OBJECT file_out
EXPORTING
i_delimiter = l_delimiter
i_fileloc = l_fileloc
i_filename = l_logf
i_file_name_param_1 = l_file
i_heading_lines = 1
i_it_file_data = im_it_save_tab
i_it_headings = im_it_heading
i_prompt_overwrite = space
EXCEPTIONS
unrecognised_location = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE text-t08 TYPE 'E'.
ENDIF.
CALL METHOD file_out->download
EXCEPTIONS
no_authority = 1
authorisation_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE text-t08 TYPE 'E'.
ENDIF.
DESCRIBE TABLE im_it_save_tab LINES l_count.
MESSAGE i010(2b) WITH l_count text-t09 l_logf l_file.
ENDMETHOD. " SAVE_FILE
ENDCLASS. " LCL_REPORT IMPLEMENTATION
* CLASS LCL_REPORT IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS lcl_report IMPLEMENTATION.
*---------------------------------------------------------------------*
* Data selection
*---------------------------------------------------------------------*
METHOD save_file.
DATA:
file_out TYPE REF
TO /XXXXXX/cl_file_utilities,
l_logf TYPE string,
l_file TYPE string,
l_count TYPE i,
l_delimiter TYPE char1,
l_fileloc TYPE char2.
CASE 'X'.
WHEN p_tab.
l_delimiter = cl_abap_char_utilities=>horizontal_tab.
WHEN p_delm.
l_delimiter = p_delim.
ENDCASE.
g_delimiter = l_delimiter.
IF p_as IS NOT INITIAL.
l_fileloc = 'LG'.
l_file = im_file.
l_logf = im_dir.
ELSEIF p_ps IS NOT INITIAL.
l_fileloc = 'PC'.
CONCATENATE p_pdir '\' im_file INTO l_logf.
ENDIF.
CREATE OBJECT file_out
EXPORTING
i_delimiter = l_delimiter
i_fileloc = l_fileloc
i_filename = l_logf
i_file_name_param_1 = l_file
i_heading_lines = 1
i_it_file_data = im_it_save_tab
i_it_headings = im_it_heading
i_prompt_overwrite = space
EXCEPTIONS
unrecognised_location = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE text-t08 TYPE 'E'.
ENDIF.
CALL METHOD file_out->download
EXCEPTIONS
no_authority = 1
authorisation_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE text-t08 TYPE 'E'.
ENDIF.
DESCRIBE TABLE im_it_save_tab LINES l_count.
MESSAGE i010(2b) WITH l_count text-t09 l_logf l_file.
ENDMETHOD. " SAVE_FILE
ENDCLASS. " LCL_REPORT IMPLEMENTATION
*********************************************************************
METHOD download.
DATA: lt_file_data TYPE zty_it_string,
l_fileextern TYPE fileextern,
l_subrc TYPE syst-subrc.
FIELD-SYMBOLS: <file_data> LIKE LINE OF lt_file_data.
IF heading_lines > 0.
APPEND LINES OF it_headings FROM 1 TO heading_lines
TO lt_file_data.
ENDIF.
APPEND LINES OF it_file_data TO lt_file_data.
IF fileloc = 'PC'. "Upload File from PC
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = filename
confirm_overwrite = prompt_overwrite
no_auth_check = space
trunc_trailing_blanks_eol = space
CHANGING
data_tab = lt_file_data
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
not_supported_by_gui = 22
error_no_gui = 23
OTHERS = 24.
CASE sy-subrc.
WHEN 1.
MESSAGE 'ERROR - FILE WRITE ERROR'(025) TYPE 'E'.
WHEN 2.
MESSAGE 'ERROR - NO BATCH'(026) TYPE 'E'.
WHEN 3.
MESSAGE 'ERROR - GUI REFUSE FILETRANSFER'(027) TYPE 'E'.
WHEN 4.
MESSAGE 'ERROR - INVALID TYPE'(028) TYPE 'E'.
WHEN 5.
MESSAGE 'ERROR - NO AUTHORITY'(029) TYPE 'E'.
WHEN 6 OR 24.
MESSAGE 'ERROR - UNKNOWN ERROR'(030) TYPE 'E'.
WHEN 7.
MESSAGE 'ERROR - HEADER NOT ALLOWED'(031) TYPE 'E'.
WHEN 8.
MESSAGE 'ERROR - SEPARATOR NOT ALLOWED'(032) TYPE 'E'.
WHEN 9.
MESSAGE 'ERROR - FILESIZE NOT ALLOWED'(033) TYPE 'E'.
WHEN 10.
MESSAGE 'ERROR - HEADER TOO LONG'(034) TYPE 'E'.
WHEN 11.
MESSAGE 'ERROR - DP ERROR CREATE'(035) TYPE 'E'.
WHEN 12.
MESSAGE 'ERROR - DP ERROR SEND'(036) TYPE 'E'.
WHEN 13.
MESSAGE 'ERROR - DP ERROR WRITE'(037) TYPE 'E'.
WHEN 14.
MESSAGE 'ERROR - UNKNOWN DP ERROR'(038) TYPE 'E'.
WHEN 15.
MESSAGE 'ERROR - ACCESS DENIED'(039) TYPE 'E'.
WHEN 16.
MESSAGE 'ERROR - DP OUT OF MEMORY'(040) TYPE 'E'.
WHEN 17.
MESSAGE 'ERROR - DISK FULL'(041) TYPE 'E'.
WHEN 18.
MESSAGE 'ERROR - DP TIMEOUT'(042) TYPE 'E'.
WHEN 19.
MESSAGE 'ERROR - FILE NOT FOUND'(043) TYPE 'E'.
WHEN 20.
MESSAGE 'ERROR - DATAPROVIDER EXCEPTION'(044) TYPE 'E'.
WHEN 21.
MESSAGE 'ERROR - CONTROL FLUSH ERROR'(045) TYPE 'E'.
WHEN 22.
MESSAGE 'ERROR - NOT SUPPORTED BY GUI'(046) TYPE 'E'.
WHEN 23.
MESSAGE 'ERROR - NO GUI'(047) TYPE 'E'.
ENDCASE.
ELSE.
l_fileextern = filename.
CALL FUNCTION 'AUTHORITY_CHECK_DATASET'
EXPORTING
activity = 'WRITE'
filename = l_fileextern
EXCEPTIONS
no_authority = 1
activity_unknown = 2
OTHERS = 3.
CASE sy-subrc.
WHEN 1.
RAISE no_authority.
WHEN 2 OR 3.
RAISE authorisation_error.
ENDCASE.
CALL METHOD me->OPEN_DATASET_OUTPUT
EXPORTING
file_name = filename
unicode_format = unicode
IMPORTING
ex_subrc = l_subrc .
IF l_subrc <> 0.
* Unable to open input file
MESSAGE 'ERROR - Unable to Open Input File'(020) TYPE 'E'.
ENDIF.
LOOP AT lt_file_data ASSIGNING <file_data>.
TRANSFER <file_data> TO filename.
ENDLOOP.
* Close file
CLOSE DATASET filename.
ENDIF.
ENDMETHOD.
DATA: lt_file_data TYPE zty_it_string,
l_fileextern TYPE fileextern,
l_subrc TYPE syst-subrc.
FIELD-SYMBOLS: <file_data> LIKE LINE OF lt_file_data.
IF heading_lines > 0.
APPEND LINES OF it_headings FROM 1 TO heading_lines
TO lt_file_data.
ENDIF.
APPEND LINES OF it_file_data TO lt_file_data.
IF fileloc = 'PC'. "Upload File from PC
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = filename
confirm_overwrite = prompt_overwrite
no_auth_check = space
trunc_trailing_blanks_eol = space
CHANGING
data_tab = lt_file_data
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
not_supported_by_gui = 22
error_no_gui = 23
OTHERS = 24.
CASE sy-subrc.
WHEN 1.
MESSAGE 'ERROR - FILE WRITE ERROR'(025) TYPE 'E'.
WHEN 2.
MESSAGE 'ERROR - NO BATCH'(026) TYPE 'E'.
WHEN 3.
MESSAGE 'ERROR - GUI REFUSE FILETRANSFER'(027) TYPE 'E'.
WHEN 4.
MESSAGE 'ERROR - INVALID TYPE'(028) TYPE 'E'.
WHEN 5.
MESSAGE 'ERROR - NO AUTHORITY'(029) TYPE 'E'.
WHEN 6 OR 24.
MESSAGE 'ERROR - UNKNOWN ERROR'(030) TYPE 'E'.
WHEN 7.
MESSAGE 'ERROR - HEADER NOT ALLOWED'(031) TYPE 'E'.
WHEN 8.
MESSAGE 'ERROR - SEPARATOR NOT ALLOWED'(032) TYPE 'E'.
WHEN 9.
MESSAGE 'ERROR - FILESIZE NOT ALLOWED'(033) TYPE 'E'.
WHEN 10.
MESSAGE 'ERROR - HEADER TOO LONG'(034) TYPE 'E'.
WHEN 11.
MESSAGE 'ERROR - DP ERROR CREATE'(035) TYPE 'E'.
WHEN 12.
MESSAGE 'ERROR - DP ERROR SEND'(036) TYPE 'E'.
WHEN 13.
MESSAGE 'ERROR - DP ERROR WRITE'(037) TYPE 'E'.
WHEN 14.
MESSAGE 'ERROR - UNKNOWN DP ERROR'(038) TYPE 'E'.
WHEN 15.
MESSAGE 'ERROR - ACCESS DENIED'(039) TYPE 'E'.
WHEN 16.
MESSAGE 'ERROR - DP OUT OF MEMORY'(040) TYPE 'E'.
WHEN 17.
MESSAGE 'ERROR - DISK FULL'(041) TYPE 'E'.
WHEN 18.
MESSAGE 'ERROR - DP TIMEOUT'(042) TYPE 'E'.
WHEN 19.
MESSAGE 'ERROR - FILE NOT FOUND'(043) TYPE 'E'.
WHEN 20.
MESSAGE 'ERROR - DATAPROVIDER EXCEPTION'(044) TYPE 'E'.
WHEN 21.
MESSAGE 'ERROR - CONTROL FLUSH ERROR'(045) TYPE 'E'.
WHEN 22.
MESSAGE 'ERROR - NOT SUPPORTED BY GUI'(046) TYPE 'E'.
WHEN 23.
MESSAGE 'ERROR - NO GUI'(047) TYPE 'E'.
ENDCASE.
ELSE.
l_fileextern = filename.
CALL FUNCTION 'AUTHORITY_CHECK_DATASET'
EXPORTING
activity = 'WRITE'
filename = l_fileextern
EXCEPTIONS
no_authority = 1
activity_unknown = 2
OTHERS = 3.
CASE sy-subrc.
WHEN 1.
RAISE no_authority.
WHEN 2 OR 3.
RAISE authorisation_error.
ENDCASE.
CALL METHOD me->OPEN_DATASET_OUTPUT
EXPORTING
file_name = filename
unicode_format = unicode
IMPORTING
ex_subrc = l_subrc .
IF l_subrc <> 0.
* Unable to open input file
MESSAGE 'ERROR - Unable to Open Input File'(020) TYPE 'E'.
ENDIF.
LOOP AT lt_file_data ASSIGNING <file_data>.
TRANSFER <file_data> TO filename.
ENDLOOP.
* Close file
CLOSE DATASET filename.
ENDIF.
ENDMETHOD.
*********************************************************************
In the manufacturing industry, data regulation and traceability requirements can be quite stringent on manufacturers to maintain strict security and traceability standards and keep historical records for long term audit and warranty purposes. PLM data migrations are often ‘brown fields’ and business process optimization and rationalization require lean data models combined with robust archiving strategies.
ReplyDeleteWhat are your thoughts?
SAP training in Chennai
SAP FICO training in Chennai