Left Outer Joins
Left Outer Joins
Left Outer Joins
*&---------------------------------------------------------------------*
*& Include ZPPRO_PP_R_0022_RM07DOCS_FRM
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form F_DATA_SELECTION
*&---------------------------------------------------------------------*
* Import Data from MB51 for given values in Selection screen
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_data_selection .
*--------------------------------------------------------------------*
* Local Variable Declaration
*--------------------------------------------------------------------*
CONSTANTS : lc_flag(9) TYPE c VALUE 'MB51_FLAG', " Flag(9) of type
Character
lc_memid(16) TYPE c VALUE 'MB51_EXPORT_LIST'. " Memid(16) of type
Character
*--------------------------------------------------------------------*
* Local Variable Declaration
*--------------------------------------------------------------------*
DATA : flag TYPE char1. "To import list from MB51
*--------------------------------------------------------------------*
* Local table Declaration
*--------------------------------------------------------------------*
* This table is to export value from mb51. The name shd be same as that of MB51
DATA : export_list TYPE STANDARD TABLE OF ty_export_list INITIAL SIZE 0.
* There is a export statement inside MB51, which is invoked on flag being set.
FREE export_list[].
ENDFORM.
*&---------------------------------------------------------------------*
*& Form F_VALIDATION
*&---------------------------------------------------------------------*
* Check to see if PR Creator or MRP Controller is entered
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_validation .
* PR Creator Name Validation
IF rb_ernam = abap_true.
IF s_wempf IS INITIAL.
flg_error = abap_true.
MESSAGE s025(zpp_msg) DISPLAY LIKE c_error. " Please provide PR Creator
details
LEAVE LIST-PROCESSING.
ENDIF. " IF s_wempf IS INITIAL
ELSEIF rb_dispo = abap_true.
* MRP Controller Validation
IF s_dispo IS INITIAL.
flg_error = abap_true.
MESSAGE s024(zpp_msg) DISPLAY LIKE c_error. " Please provide MRP Controller
Details
LEAVE LIST-PROCESSING.
ENDIF. " IF s_dispo IS INITIAL
ENDIF. " IF rb_ernam = abap_true
ENDFORM.
*&---------------------------------------------------------------------*
*& Form F_FILTER_PR_CREATOR
*&---------------------------------------------------------------------*
* Fetch data from MSEG and related tables for MB51 data
*----------------------------------------------------------------------*
* -->fP_EXPORT_LIST table type of export list
*----------------------------------------------------------------------*
FORM f_filter_pr_creator USING fp_export_list TYPE ty_t_export_list.
*--------------------------------------------------------------------*
* Local Constant Declaration
*--------------------------------------------------------------------*
CONSTANTS : lc_tcode TYPE rvari_vnam VALUE 'TCODE'. " ABAP: Name of Variant
Variable
*--------------------------------------------------------------------*
* Local table Declaration
*--------------------------------------------------------------------*
DATA : li_vnames TYPE zat_vname_tt, " ABAP: Name of Variant Variable
li_ranges TYPE zat_vname_range_tt.
*--------------------------------------------------------------------*
* Local Variable Declaration
*--------------------------------------------------------------------*
DATA : l_pname TYPE progname, " ABAP Program Name
lr_val TYPE zat_selopt_tt. "Range for Material Type maintained in
ZAT_CONSTANT
*--------------------------------------------------------------------*
* Local Field Symbols Declaration
*--------------------------------------------------------------------*
FIELD-SYMBOLS : <lfs_ranges> TYPE zat_vname_range. "Range Str
* Set Report Id
l_pname = sy-repid.
APPEND lc_tcode TO li_vnames.
SELECT
mseg~ablad , " Unloading Point
mseg~anln1 , " Main Asset Number
mseg~anln2 , " Asset Subnumber
mseg~aplzl , " Internal counter
mseg~aufnr , " Order Number
mseg~aufpl , " Routing number of operations in the order
mkpf~bktxt , " Document Header Text
mkpf~bldat , " Document Date in Document
mseg~bpmng , " Quantity in Purchase Order Price Unit
mseg~bprme , " Order Price Unit (Purchasing)
mseg~bstme , " Purchase Order Unit of Measure
mseg~bstmg , " Goods receipt quantity in order unit
mkpf~budat , " Posting Date in the Document
mseg~budat_mkpf, " Posting Date in the Document
mseg~bukrs , " Company Code
mseg~bwart , " Movement Type (Inventory Management)
mseg~bwlvs , " Movement Type for Warehouse Management
mseg~bwtar , " Valuation Type
mseg~charg , " Batch Number
mkpf~cpudt , " Day On Which Accounting Document Was Entered
mseg~cpudt_mkpf , " Day On Which Accounting Document Was Entered
mkpf~cputm , " Time of Entry
mseg~cputm_mkpf , " Time of Entry
mseg~dmbtr , " Amount in Local Currency
mseg~ebeln , " Purchase Order Number
mseg~ebelp , " Item Number of Purchasing Document
mseg~erfme , " Unit of Entry
mseg~erfmg , " Quantity in Unit of Entry
mseg~exbwr , " Externally Entered Posting Amount in Local Currency
mseg~exvkw , " Externally Entered Sales Value in Local Currency
mkpf~frbnr , " Number of Bill of Lading at Time of Goods Receipt
mseg~grund , " Reason for Movement
mseg~kdauf , " Sales Order Number
mseg~kdein , " Delivery Schedule for Sales Order
mseg~kdpos , " Item Number in Sales Order
mseg~kostl , " Cost Center
mseg~kunnr , " Customer
mseg~kzbew , " Movement Indicator
mseg~kzvbr , " Consumption Posting
mseg~kzzug , " Receipt Indicator
mseg~lfbnr , " Document No. of a Reference Document
mseg~lgnum , " Warehouse Number / Warehouse Complex
mseg~lgort , " Storage Location
mseg~lgtyp , " Storage Type
mseg~lifnr , " Desired Vendor
mseg~llief , " Supplying Vendor
mseg~matnr , " Material Number
mseg~mat_kdauf , " Sales Order Number of Valuated Sales Order Stock
mseg~mat_kdpos , " Sales Order Item of Valuated Sales Order Stock
mkpf~mblnr , " Number of Material Document
mseg~meins , " Purchase Requisition Unit of Measure
mseg~menge , " Purchase Requisition Quantity
mkpf~mjahr , " Material Document Year
mseg~nplnr , " Network Number for Account Assignment
mseg~ps_psp_pnr, " Work Breakdown Structure Element (WBS Element)
mseg~rsnum , " Number of Reservation/Dependent Requirement
mseg~rspos , " Item Number of Reservation/Dependent Requirement
mseg~sakto , " G/L Account Number
mseg~shkzg , " Debit/Credit Indicator
mseg~sobkz , " Special Stock Indicator
mseg~tbnum , " Transfer Requirement Number
mkpf~tcode2 , " Transaction Code
mseg~tcode2_mkpf, " Transaction Code
mkpf~usnam , " User name
mseg~usnam_mkpf , " User name
mkpf~vgart , " Transaction/Event Type
mseg~vgart_mkpf , " Transaction/Event Type
mseg~vkwrt , " Value at Sales Prices Including Value-Added Tax
mseg~waers , " Currency Key
mseg~wempf , " Goods Recipient/Ship-To Party
mseg~werks , " Plant
mkpf~xabln , " Goods Receipt/Issue Slip Number
mseg~xauto , " Item automatically created
mkpf~xblnr , " Reference Document Number
mseg~xblnr_mkpf , " Reference Document Number
mseg~zeile , " Item in Material Document
mseg~maa_urzei , " Original Line for Account Assignment Item in Material
Doc.
mseg~xmacc , " Multiple Account Assignment
makt~maktx , " Material Description (Short Text)
ekpo~meins , " Purchase Requisition Unit of Measure
ekpo~pstyp , " Item Category in Purchasing Document
ekpo~vrtkz , " Distribution indicator for multiple account assignment
ekpo~twrkz , " Partial Invoice Indicator
ekpo~weunb " Goods Receipt, Non-Valuated
FROM mseg " Document Segment: Material
LEFT OUTER JOIN mkpf " Header: Material Document
ON ( mkpf~mblnr = mseg~mblnr
AND mkpf~mjahr = mseg~mjahr )
LEFT OUTER JOIN makt " Material Descriptions
ON ( makt~matnr = mseg~matnr
AND spras = @sy-langu )
LEFT OUTER JOIN ekpo " Scheduling Agreement Schedule Lines
ON ( ekpo~ebeln = mseg~ebeln
AND ekpo~ebelp = mseg~ebelp )
LEFT OUTER JOIN eban " Purchase Requisition
ON ( eban~banfn = ekpo~banfn )
INTO TABLE @i_final
FOR ALL ENTRIES IN @fp_export_list
WHERE mseg~mblnr = @fp_export_list-mblnr
AND mseg~mjahr = @fp_export_list-mjahr
AND mseg~zeile = @fp_export_list-zeile
AND ( mseg~kzbws <> ''
OR mseg~kzvbr <> '' )
AND eban~ernam IN @s_ernam
AND mseg~wempf IN @s_wempf
AND mseg~tcode2_mkpf NOT IN @lr_val.
IF sy-subrc <> 0.
flg_error = abap_true.
ENDIF. " IF sy-subrc <> 0
ENDIF. " IF fp_export_list IS NOT INITIAL
ENDFORM.
*&---------------------------------------------------------------------*
*& Form F_FILTER_MRP_CONTROLLER
*&---------------------------------------------------------------------*
* Fetch MRP Controller Details
*----------------------------------------------------------------------*
* -->FP_EXPORT_LIST type table of export list
*----------------------------------------------------------------------*
FORM f_filter_mrp_controller USING fp_export_list TYPE ty_t_export_list .
IF fp_export_list IS NOT INITIAL.
SELECT
mseg~ablad , " Unloading Point
mseg~anln1 , " Main Asset Number
mseg~anln2 , " Asset Subnumber
mseg~aplzl , " Internal counter
mseg~aufnr , " Order Number
mseg~aufpl , " Routing number of operations in the order
mkpf~bktxt , " Document Header Text
mkpf~bldat , " Document Date in Document
mseg~bpmng , " Quantity in Purchase Order Price Unit
mseg~bprme , " Order Price Unit (Purchasing)
mseg~bstme , " Purchase Order Unit of Measure
mseg~bstmg , " Goods receipt quantity in order unit
mkpf~budat , " Posting Date in the Document
mseg~budat_mkpf, " Posting Date in the Document
mseg~bukrs , " Company Code
mseg~bwart , " Movement Type (Inventory Management)
mseg~bwlvs , " Movement Type for Warehouse Management
mseg~bwtar , " Valuation Type
mseg~charg , " Batch Number
mkpf~cpudt , " Day On Which Accounting Document Was Entered
mseg~cpudt_mkpf , " Day On Which Accounting Document Was Entered
mkpf~cputm , " Time of Entry
mseg~cputm_mkpf , " Time of Entry
mseg~dmbtr , " Amount in Local Currency
mseg~ebeln , " Purchase Order Number
mseg~ebelp , " Item Number of Purchasing Document
mseg~erfme , " Unit of Entry
mseg~erfmg , " Quantity in Unit of Entry
mseg~exbwr , " Externally Entered Posting Amount in Local Currency
mseg~exvkw , " Externally Entered Sales Value in Local Currency
mkpf~frbnr , " Number of Bill of Lading at Time of Goods Receipt
mseg~grund , " Reason for Movement
mseg~kdauf , " Sales Order Number
mseg~kdein , " Delivery Schedule for Sales Order
mseg~kdpos , " Item Number in Sales Order
mseg~kostl , " Cost Center
mseg~kunnr , " Customer
mseg~kzbew , " Movement Indicator
mseg~kzvbr , " Consumption Posting
mseg~kzzug , " Receipt Indicator
mseg~lfbnr , " Document No. of a Reference Document
mseg~lgnum , " Warehouse Number / Warehouse Complex
mseg~lgort , " Storage Location
mseg~lgtyp , " Storage Type
mseg~lifnr , " Desired Vendor
mseg~llief , " Supplying Vendor
mseg~matnr , " Material Number
mseg~mat_kdauf , " Sales Order Number of Valuated Sales Order Stock
mseg~mat_kdpos , " Sales Order Item of Valuated Sales Order Stock
mkpf~mblnr , " Number of Material Document
mseg~meins , " Purchase Requisition Unit of Measure
mseg~menge , " Purchase Requisition Quantity
mkpf~mjahr , " Material Document Year
mseg~nplnr , " Network Number for Account Assignment
mseg~ps_psp_pnr, " Work Breakdown Structure Element (WBS Element)
mseg~rsnum , " Number of Reservation/Dependent Requirement
mseg~rspos , " Item Number of Reservation/Dependent Requirement
mseg~sakto , " G/L Account Number
mseg~shkzg , " Debit/Credit Indicator
mseg~sobkz , " Special Stock Indicator
mseg~tbnum , " Transfer Requirement Number
mkpf~tcode2 , " Transaction Code
mseg~tcode2_mkpf, " Transaction Code
mkpf~usnam , " User name
mseg~usnam_mkpf , " User name
mkpf~vgart , " Transaction/Event Type
mseg~vgart_mkpf , " Transaction/Event Type
mseg~vkwrt , " Value at Sales Prices Including Value-Added Tax
mseg~waers , " Currency Key
mseg~wempf , " Goods Recipient/Ship-To Party
mseg~werks , " Plant
mkpf~xabln , " Goods Receipt/Issue Slip Number
mseg~xauto , " Item automatically created
mkpf~xblnr , " Reference Document Number
mseg~xblnr_mkpf , " Reference Document Number
mseg~zeile , " Item in Material Document
mseg~maa_urzei , " Original Line for Account Assignment Item in Material
Doc.
mseg~xmacc , " Multiple Account Assignment
makt~maktx , " Material Description (Short Text)
ekpo~meins , " Purchase Requisition Unit of Measure
ekpo~pstyp , " Item Category in Purchasing Document
ekpo~vrtkz , " Distribution indicator for multiple account assignment
ekpo~twrkz , " Partial Invoice Indicator
ekpo~weunb " Goods Receipt, Non-Valuated
FROM mseg " Document Segment: Material
IF sy-subrc <> 0.
flg_error = abap_true.
ENDIF. " IF sy-subrc <> 0
ENDIF. " IF fp_export_list IS NOT INITIAL
ENDFORM.
*&---------------------------------------------------------------------*
*& Form F_REPORT_DISPLAY
*&---------------------------------------------------------------------*
* Display data in Report
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_report_display .
*--------------------------------------------------------------------*
* Local Variable Declaration
*--------------------------------------------------------------------*
DATA : lwa_layout TYPE slis_layout_alv, "Layout
l_variant TYPE disvariant. "Variant
lwa_layout-colwidth_optimize = abap_true.
l_variant-report = sy-repid.
l_variant-variant = p_var.
* Report
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = lwa_layout
it_fieldcat = i_fld
i_default = 'X'
i_save = 'A'
is_variant = l_variant
TABLES
t_outtab = i_final
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
flg_error = abap_true.
ENDIF. " IF sy-subrc <> 0
ENDFORM.
*&---------------------------------------------------------------------*
*& Form F_BUILD_FIELD_CATALOG
*&---------------------------------------------------------------------*
* Build Field Catalog
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_build_field_catalog .
ENDFORM.
*&---------------------------------------------------------------------*
*& Form F_APPEND_FIELDCAT
*&---------------------------------------------------------------------*
* Append Field catalog
*----------------------------------------------------------------------*
* --> fp_tabname Table Name
* --> fp_fieldname Field Name
* --> fp_Seltext_l Seltext large
*----------------------------------------------------------------------*
CLEAR lwa_fld.
lwa_fld-tabname = fp_tabname.
lwa_fld-fieldname = fp_fieldname.
lwa_fld-seltext_l = fp_seltext_l.
ENDFORM.