Registration

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

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

* PROGRAM ID : ZMHREPORT *

* PROGRAM TITLE : Materials Handling Report *

* AUTHOR : Aveek Ghose *

* DATE : 07/06/2004 *

* CHANGE REQUEST NUMBER:

*======================================================================*

* CHANGE HISTORY LOG *

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

* MOD. NO.| DATE | NAME | CORRECTION NUMBER | CHANGE REFERENCE #*

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

* MOD-001 |DD/MM/YYYY| XXXXXX | XXXXXXXXXX | XXXXXXXXX *

* *

* DESCRIPTION: *

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

*& *

*&---------------------------------------------------------------------*REPORT ZMHREPORT MESSAGE-ID zdev.***************************************************************

* DATA DECLARATIONS

***************************************************************DATA: okcode LIKE sy-ucomm.

DATA:* Container Control...the parent...container_r TYPE REF TO cl_gui_custom_container,

container_r1 TYPE REF TO cl_gui_custom_container,* Define the Application Control (ALV) instance...grid_r TYPE REF TO cl_gui_alv_grid,

grid_r1 TYPE REF TO cl_gui_alv_grid,

gs_toolbar TYPE stb_button.*--------------------- Type pools ----------------------------*TYPE-POOLS: slis. "Type Pool for ALV*------------------- Constants -------------------------------*CONSTANTS: c_x(1) TYPE c VALUE 'X'. " Constant for X

*** SPECIFIES THE COLUMN POSITION OF THE REPORT'S FIELDS

CONSTANTS:

*COLUMN POSITION OF THE REPORT'S FIELDS DETAIL

c_dcl_pos1 TYPE sycucol VALUE '01' , " POSITION 1

c_dcl_pos2 TYPE sycucol VALUE '02' , " POSITION 2

c_dcl_pos3 TYPE sycucol VALUE '03' , " POSITION 3

c_dcl_pos4 TYPE sycucol VALUE '04' , " POSITION 4

c_dcl_pos5 TYPE sycucol VALUE '05' , " POSITION 5

c_dcl_pos6 TYPE sycucol VALUE '06' , " POSITION 6

c_dcl_pos7 TYPE sycucol VALUE '07' , " POSITION 7

c_dcl_pos8 TYPE sycucol VALUE '08' , " POSITION 8

c_dcl_pos9 TYPE sycucol VALUE '09' , " POSITION 9

c_dcl_pos10 TYPE sycucol VALUE '10' , " POSITION 10

c_dcl_pos11 TYPE sycucol VALUE '11' , " POSITION 11

c_dcl_pos12 TYPE sycucol VALUE '12' , " POSITION 12

c_dcl_pos13 TYPE sycucol VALUE '13' , " POSITION 13

c_dcl_pos14 TYPE sycucol VALUE '14' , " POSITION 14

c_dcl_pos15 TYPE sycucol VALUE '15' , " POSITION 15

c_dcl_pos16 TYPE sycucol VALUE '16' , " POSITION 16

c_dcl_pos17 TYPE sycucol VALUE '17' , " POSITION 17

c_dcl_pos18 TYPE sycucol VALUE '18' , " POSITION 18

c_dcl_pos19 TYPE sycucol VALUE '19' , " POSITION 19

c_dcl_pos20 TYPE sycucol VALUE '20' , " POSITION 20

c_dcl_pos21 TYPE sycucol VALUE '21' , " POSITION 21

c_dcl_pos22 TYPE sycucol VALUE '22' , " POSITION 22

c_dcl_pos23 TYPE sycucol VALUE '23' , " POSITION 23

c_dcl_pos24 TYPE sycucol VALUE '24' , " POSITION 24

c_dcl_pos25 TYPE sycucol VALUE '25' , " POSITION 25

c_dcl_pos26 TYPE sycucol VALUE '26' , " POSITION 26

*COLUMN POSITION OF THE REPORT'S FIELDS HEADER

c_hcl_pos1 TYPE sycucol VALUE '01' , " POSITION 01

c_hcl_pos2 TYPE sycucol VALUE '02' , " POSITION 02

c_hcl_pos3 TYPE sycucol VALUE '03' , " POSITION 03

c_hcl_pos4 TYPE sycucol VALUE '04' , " POSITION 04

*** FIELD NAME OF THE REPORTS DETAIL

c_fld_ctr TYPE slis_fieldname VALUE 'CTR',"Counter

c_fld_cur_werks TYPE slis_fieldname VALUE 'CUR_WERKS',"Curr Plant

c_fld_lgort TYPE slis_fieldname VALUE 'LGORT',"Storage Loc

c_fld_cur_lgnum TYPE slis_fieldname VALUE 'CUR_LGNUM',"Curr Ware

c_fld_rec_werks TYPE slis_fieldname VALUE 'REC_WERKS',"Rec Plant

* C_fld_im_movt TYPE slis_fieldname VALUE 'IM_MOVT',"IM Movt

* C_fld_wm_movt TYPE slis_fieldname VALUE 'WM_MOVT',"WM Movt

c_fld_in_trn TYPE slis_fieldname VALUE 'IN_TRN',"In Transit

c_fld_kunnr TYPE slis_fieldname VALUE 'KUNNR',"Customer

c_fld_kunnr_name1 TYPE slis_fieldname VALUE 'NAME1',"Customer Name

c_fld_load_no TYPE slis_fieldname VALUE 'LOAD_NO',"Load No

c_fld_lenum TYPE slis_fieldname VALUE 'LENUM',"SSCC Number

c_fld_act_menge TYPE slis_fieldname VALUE 'ACT_MENGE',"Quantity

c_fld_meins TYPE slis_fieldname VALUE 'MEINS',"UOM

* c_fld_bestq TYPE slis_fieldname VALUE 'BESTQ',"Blocking Reason

c_fld_text TYPE slis_fieldname VALUE 'TEXT',"Blocking Reason

c_fld_spgtx TYPE slis_fieldname VALUE 'SPGTX',"Blocking Text

c_fld_letyp TYPE slis_fieldname VALUE 'LETYP',"Storage Unit Type

c_fld_ebeln TYPE slis_fieldname VALUE 'EBELN',"Purchase Doc.No

c_fld_desp_date TYPE slis_fieldname VALUE 'DESP_DATE',

"Despatch Date

c_fld_desp_time TYPE slis_fieldname VALUE 'DESP_TIME',

"Despatch Time

c_fld_qproddat TYPE slis_fieldname VALUE 'QPRODDAT',"Prod Date

c_fld_qprodtime TYPE slis_fieldname VALUE 'QPRODTIME',"Prod Time

c_fld_bbd_vfdat TYPE slis_fieldname VALUE 'BBD_VFDAT',

"Best Before Date

c_fld_sed_vfdat TYPE slis_fieldname VALUE 'SED_VFDAT',

"Shelf life expiry date

c_fld_qplos TYPE slis_fieldname VALUE 'QPLOS',"Inspection Lot,

c_fld_color TYPE slis_fieldname VALUE 'COLOR',"Colour,

*** FIELD NAME OF THE REPORTS HEADER

c_fld_werks_plant TYPE slis_fieldname VALUE 'WERKS_PLANT',"Plant

c_fld_matnr TYPE slis_fieldname VALUE 'MATNR',"Material

c_fld_maktx TYPE slis_fieldname VALUE 'MAKTX',"Material Desc

c_fld_charg TYPE slis_fieldname VALUE 'CHARG',"Batch

*** SPECIFIES THE LENGTH OF COLUMN WITHIN THE REPORT'S FIELDS

c_1 TYPE outputlen VALUE '1', "OUTPUT LENGTH

c_2 TYPE outputlen VALUE '2', "OUTPUT LENGTH

c_3 TYPE outputlen VALUE '3',"OUTPUT LENGTH

*units(UOM),storage unit type

c_4 TYPE outputlen VALUE '4', "OUTPUT LENGTH

*producing plant,reciving plant

c_6 TYPE outputlen VALUE '6' ,"OUTPUT LENGTH

*desptime,production time

c_8 TYPE outputlen VALUE '8', "OUTPUT LENGTH

*desp date,production date,best before date,self expiry date,

*counter

c_10 TYPE outputlen VALUE '10',"OUTPUT LENGTH

c_15 TYPE outputlen VALUE '15',"OUTPUT LENGTH

*batch,purchasing doc

c_12 TYPE outputlen VALUE '12',"OUTPUT LENGTH

*inspection lot no

c_13 TYPE outputlen VALUE '13',"OUTPUT LENGTH

*Quantity

c_18 TYPE outputlen VALUE '18',"OUTPUT LENGTH

*material,movement desc

c_20 TYPE outputlen VALUE '20',"OUTPUT LENGTH

*SSCC NO

c_25 TYPE outputlen VALUE '25',"OUTPUT LENGTH

*reciving warehouse dec

c_35 TYPE outputlen VALUE '35',"OUTPUT LENGTH

c_40 TYPE outputlen VALUE '40',"OUTPUT LENGTH

*material desc

*** SPECIFIES THE EVENTS WITHIN THE REPORT

c_form1 TYPE slis_formname VALUE 'TOP_OF_PAGE',"EVENTS

c_form2 TYPE slis_formname VALUE 'END_OF_LIST',"EVENTS

*** INTERNAL TABLE WHCIH STORES THE REPORT AND THE SUMMARY REPORT

**** NAME OF INTERNAL TABLESTORING MAIN DATA OF REPORT PASSED TO ALV

c_tabname1 TYPE slis_tabname VALUE 'I_REPHDR' ," header

c_tabname2 TYPE slis_tabname VALUE 'I_REPDTL' ." detail

*--------------------- TABLES --------------------------------*

TABLES: mara,

makt,

lein,

lqua,

T320,

zmccnn1,

zmccnn2,

ltap,

ltak,

likp,

lips,

MKPF,

MSEG.

*--------------------- TYPES ---------------------------------*

* Type for storing pallets and Outputting it in ALV

TYPES: BEGIN OF ty_ltap,

lgort type lgort_d,

lgnum TYPE lgnum, "Warehouse Number / Warehouse Complex

tanum TYPE tanum, "Transfer Order Number

matnr TYPE matnr, "Material

charg TYPE charg_d, "Batch

werks type werks_d,

meins TYPE meins, "UoM

altme TYPE lrmei, "Alternate UoM

umrez TYPE umrez, "Numerator for UoN Conversion

umren TYPE umren, "Denominator for UoN Conversion

qdatu TYPE ltap_qdatu, "Confirmation Date

qzeit TYPE ltap_qzeit, "Confirmation Time

wdatu TYPE lvs_wdatu, "GR Date

wenum TYPE lvs_wenum, "GR Number

nltyp TYPE ltap_nltyp, "Destination storage type

nista TYPE ltap_nista, "Quantity in Alt UoM

maktx TYPE maktx, "Material Description

vlenr TYPE ltap_vlenr, "Source storage unit number

nlenr TYPE ltap_nlenr, "SSCC

qplos TYPE qplos , "Inspection Lot Number

vbeln TYPE vbeln_vl, "Delivery

nlpla type LTAP_NLPLA, " Delivery number

bestq type bestq, "Stock Type

del_flag(1), "Delete flag

END OF ty_ltap.

* Type for Retrieving Material Document Number and Year from LTAK

TYPES: BEGIN OF ty_ltak,

lgnum TYPE lgnum, "Warehouse Number / Warehouse Complex

tanum TYPE tanum, "Transfer Order Number

bwart TYPE bwart, "Movement Type (im)

bwlvs TYPE bwlvs, "movement type (wm)

mblnr TYPE mblnr, "Material Document

mjahr TYPE mjahr, "Year

del_flag(1), "Delete flag

END OF ty_ltak.

* Type for Retrieving Posting Date / Time from MKPF

TYPES: BEGIN OF ty_mkpf,

mblnr TYPE mblnr, "Material Document

mjahr TYPE mjahr, "Year

vgart TYPE vgart, "Transaction/Event Type

blart TYPE blart, "Document type

budat TYPE budat, "Posting Date (Dummy Prod. Date)

cputm TYPE cputm, "Time of Entry (Dummy Prod. Time)

END OF ty_mkpf.

* Type for Checking presence/absence in warehouse system

TYPES: BEGIN OF ty_lein,

lenum TYPE lenum, "Storage Unit Number

lgnum TYPE lgnum, "Warehouse Number / Warehouse Complex

END OF ty_lein.

* Type for Checking aufnr

TYPES: BEGIN OF ty_mseg,

mblnr TYPE mblnr, "Material Document

mjahr TYPE mjahr, "Year

matnr TYPE matnr, "Material Number

werks TYPE werks_d, "Plant

charg TYPE charg_d, "Batch Number

aufnr TYPE aufnr, "Order Number

vfdat TYPE vfdat, "Shelf Life Expiration Date

END OF ty_mseg.

* Types for checking the plant.

TYPES: BEGIN OF ty_lqua,

werks TYPE werks_d, "Plant

lgort TYPE lgort_d, "Storage Location

lgnum TYPE lgnum , "Warehouse Number / Warehouse Complex

SPGRU TYPE LVS_SPGRU, "Blocking Reason,

bestq TYPE BESTQ, "Stock indicator

lenum type lenum,

SPGTX TYPE LVS_SPGTX, "Text for blocking reason

END OF ty_lqua.

* Types for checking the producing plant or DC

TYPES: BEGIN OF ty_t001w,

werks TYPE werks_d, "Plant

nodetype TYPE nodetype, "Node type: supply chain network

END OF ty_t001w.

*type declaration to hold the header info of the report.

TYPES:BEGIN OF ty_rephdr,

werks_plant TYPE ckml_werk_prod,"plant

matnr TYPE matnr, "material no

maktx TYPE maktx, "material desc

charg TYPE charg_d, "batch

END OF ty_rephdr.

*type declaration to hold data for likp.

TYPES: BEGIN OF ty_likp,

vbeln TYPE vbeln,"delivery

kunnr TYPE kunnr,"customer

END OF ty_likp.

TYPES: BEGIN OF ty_lips,

matnr type matnr,

charg type charg_d,

werks type werks_d,

vbeln type vbeln,

END OF ty_lips.

*type declaration to retrive /NESGLB/MCCNN1 & /NESGLB/MCCNN2

TYPES: BEGIN OF ty_mccnn1_2,

load_no TYPE char35, "load no

werks TYPE werks_d, "Plant

desp_date TYPE sydatum, "desp date

desp_time TYPE syuzeit, "desp time

MATNR TYPE MATNR, "material Number

GTIN TYPE EAN11, " International Article Number

PROD_VARIANT TYPE char4, "Product Variant

CHARG TYPE CHARG_D, " Batch Number

MEINS TYPE MEINS, " Base Unit of Measure

ACT_MENGE type ACT_MENGE , "Actual Quantity

exp_menge TYPE ACT_MENGE , "Actual Quantity,

INSMK TYPE INSMK, "Stock type

LENUM TYPE LENUM, " Storage Unit Number

LETYP TYPE LVS_LETYP, "Storage Unit Type

EBELN TYPE EBELN, "Purchasing Document Number

EBELP TYPE EBELP, "Item Number of Pur Document

WERK_PLANT TYPE CKML_WERK_PROD, "Production Plant

LGORT TYPE LGORT_D, "Storage Location

QPRODDAT TYPE QPRODDAT, "Production Date

QPRODTIME TYPE syuzeit, "Production Time

QPLOS TYPE QPLOS, "Inspection Lot Number

ITEM_STAT TYPE char4, "ASN Item Status

MBLNR TYPE MBLNR, "Number of Material Document

TANUM TYPE TANUM, "Transfer Order Number

END OF ty_mccnn1_2.

*type declaration to hold the detail info of the report.

TYPES:BEGIN OF ty_repdtl,

ctr TYPE i, "counter

cur_werks TYPE werks_d, "Current plant

lgort type lgort_d, "Current Storage Location

cur_lgnum type lgnum, "Current Warehouse

lgnum TYPE lgnum , "reciving ware house no

lnumt TYPE lvs_lnumt, "reciving ware house description

rec_werks TYPE werks_d, "reciving plant

im_movt type BWART, "IM Movement,

wm_movt TYPE bwlvs, "WM Movement,

in_trn(1) TYPE c, "stock in transit

kunnr TYPE kunnr, "customer

name1 TYPE NAME1_GP, "Customer Description

load_no TYPE char35, "load no

lenum TYPE lenum, "storage unit no(SSCC No)

act_menge TYPE act_menge,"quantity

meins TYPE meins, "UOM

bestq TYPE BESTQ, "Stock Indicator

text(15) TYPE C, "Stock indicator text

spgru TYPE LVS_SPGRU, "Blocking Reason,

SPGTX TYPE LVS_SPGTX, "Text for blocking reason

letyp TYPE lvs_letyp, "storage unit type

ebeln TYPE ebeln, "purchasing doc no

desp_date TYPE sydatum, "desp date

desp_time TYPE syuzeit, "desp time

qproddat TYPE qproddat, "production date

qprodtime TYPE syuzeit, "production time

bbd_vfdat TYPE vfdat, "best before date

sed_vfdat TYPE vfdat, "shelf expiration date

qplos TYPE qplos, "inspection lot no

color TYPE slis_specialcol_alv OCCURS 3, "for cell color

END OF ty_repdtl.

TYPES:BEGIN OF ty_t3201,

werks TYPE werks_d, "plant

lgort type lgort_d,

lgnum type lgnum,

END OF ty_t3201.

*------------------- Internal tables -----------------------*

* Internal table for storing pallets and Outputting it in ALV

DATA: i_ltap TYPE STANDARD TABLE OF ty_ltap

INITIAL SIZE 0 .

DATA: i_copy_ltap TYPE STANDARD TABLE OF ty_ltap

INITIAL SIZE 0 .

* Internal table for Retrieving Posting Date / Time from MKPF

DATA: i_copy_mkpf TYPE STANDARD TABLE OF ty_mkpf

INITIAL SIZE 0 .

DATA: i_copy_ltak TYPE STANDARD TABLE OF ty_ltak

INITIAL SIZE 0 .

DATA: wa_ltap TYPE ty_ltap.

DATA: wa_ltap_others TYPE ty_ltap.

* Internal Table to hold the header info of the report.

DATA: i_rephdr TYPE STANDARD TABLE OF ty_rephdr INITIAL SIZE 0 ,

* Work Area to hold the header info of the report.

wa_rephdr TYPE ty_rephdr ,

*Internal table to hold output

i_repdtl TYPE STANDARD TABLE OF ty_repdtl WITH HEADER LINE,

** Internal Table to hold the detail info of the report

i_repdtl_itab TYPE STANDARD TABLE OF ty_repdtl INITIAL SIZE 0 ,

* Work Area to hold the detail info of the report

wa_repdtl TYPE ty_repdtl ,

wa_repdtl_ITAB TYPE ty_repdtl ,

wa_t3201 type ty_t3201.

* Internal table for sort table

DATA: i_sort TYPE slis_t_sortinfo_alv, "Sort parameters

* Events Internal Table's

i_event TYPE slis_alv_event,"EVENTS

i_zevents TYPE slis_t_event. "EVENTS

DATA: i_pagetop TYPE slis_t_listheader. "ALV top of page header table

DATA:

* Field Catalogs...

i_fieldcat_l TYPE lvc_t_fcat WITH HEADER LINE, " LVC

* Layout Structure...

layout TYPE lvc_s_layo.

DATA:

* Field Catalogs...

i_fieldcat_l2 TYPE lvc_t_fcat WITH HEADER LINE, " LVC

* Layout Structure...

layout2 TYPE lvc_s_layo,

*Internal table for layout

i_layout TYPE slis_layout_alv.

DATA: s_layout TYPE lvc_s_layo,

i_fcode TYPE ui_functions WITH HEADER LINE,

col_pos TYPE i,

*Internal table for coloring cells

i_col_layout TYPE slis_t_specialcol_alv.

*-------------------Global variable---------------------------------*

DATA: v_repid LIKE sy-repid. " To store program name

*defination

CLASS lcl_event_reciver DEFINITION.

PUBLIC SECTION.

METHODS handle_double_click FOR EVENT double_click OF cl_gui_alv_grid

IMPORTING e_row e_column.

ENDCLASS. "lcl_event_reciver DEFINITION

*declaration of an object type.

DATA: event_reciver TYPE REF TO lcl_event_reciver.

DATA: event_reciver1 TYPE REF TO lcl_event_reciver.

*implimentation

CLASS lcl_event_reciver IMPLEMENTATION.

METHOD handle_double_click.

IF e_column = 'MATNR'.

LOOP AT i_rephdr INTO wa_rephdr.

IF sy-tabix = e_row.

EXIT.

ENDIF.

ENDLOOP.

IF NOT wa_rephdr-matnr IS INITIAL.

SET PARAMETER ID 'MAT' FIELD wa_rephdr-matnr.

CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.

ENDIF.

ELSEIF e_column = 'LENUM'.

LOOP AT i_repdtl INTO wa_repdtl.

IF sy-tabix = e_row.

EXIT.

ENDIF.

ENDLOOP.

IF NOT wa_repdtl-lenum IS INITIAL.

SET PARAMETER ID 'LEN' FIELD wa_repdtl-lenum.

CALL TRANSACTION 'LS33' AND SKIP FIRST SCREEN.

ENDIF.

ENDIF.

ENDMETHOD. "handle_double_click

ENDCLASS. "lcl_event_reciver IMPLEMENTATION

*-------------------SELECTION SCREEN--------------------------------*

* Internal table for Retrieving Material Document and Year from LTAK

DATA: l_i_ltak TYPE STANDARD TABLE OF ty_ltak

INITIAL SIZE 0 .

* Internal table for Retrieving Posting Date / Time from MKPF

DATA: l_i_mkpf TYPE STANDARD TABLE OF ty_mkpf

INITIAL SIZE 0 .

* Internal table for Checking presence/absence in warehouse system

DATA: l_i_lein TYPE STANDARD TABLE OF ty_lein

INITIAL SIZE 0 .

DATA: l_wa_lien TYPE ty_lein.

* Internal table for Checking order no

DATA: l_i_mseg TYPE STANDARD TABLE OF ty_mseg

INITIAL SIZE 0 .

* Internal table for Checking plant

DATA: l_i_lqua TYPE STANDARD TABLE OF ty_lqua

INITIAL SIZE 0 .

DATA: l_i_t3201 TYPE STANDARD TABLE OF ty_t3201

INITIAL SIZE 0 .

* Internal table for Checking other plant and DC

DATA: l_i_t001w TYPE STANDARD TABLE OF ty_t001w

INITIAL SIZE 0 .

* Internal table for retriving customer info for deliveries to customer.

DATA: l_i_likp TYPE STANDARD TABLE OF ty_likp

INITIAL SIZE 0.

DATA: l_i_lips TYPE STANDARD TABLE OF ty_lips

INITIAL SIZE 0.

* Internal table for retriving data from mccnn1&2.

DATA: l_i_mccnn1_2 TYPE STANDARD TABLE OF ty_mccnn1_2

INITIAL SIZE 0.

* Work Area for Retrieving Posting Date / Time from MKPF

DATA: l_wa_mkpf TYPE ty_mkpf.

* Work Area for Retrieving order no

DATA: l_wa_mseg TYPE ty_mseg.

* Work Area for Retrieving order no

DATA: l_wa_ltak TYPE ty_ltak.

* Work Area for holding data from mccnn1&2.

DATA: l_wa_mccnn1_2 TYPE ty_mccnn1_2.

* Work Area for holding data from lein

DATA: l_wa_lein TYPE ty_lein.

* Work Area for holding data from t320

DATA: l_wa_lqua TYPE ty_lqua.

* Work Area for holding data from likp

DATA: l_wa_likp TYPE ty_likp.

DATA: l_wa_lips TYPE ty_lips.

* local variable.

DATA:l_ctr TYPE i ,

l_stock_it(1) TYPE c.


SELECTION-SCREEN: BEGIN OF BLOCK pallet WITH FRAME TITLE text-003.

*"'Pallet Trace'.

PARAMETERS: p_werks TYPE ckml_werk_prod MEMORY ID anr OBLIGATORY ,

"Production Plant

p_matnr TYPE matnr OBLIGATORY, " Material No.

p_charg TYPE charg_d OBLIGATORY. " Batch

SELECTION-SCREEN SKIP.

SELECTION-SCREEN BEGIN OF LINE.

* Production Date / Time From

SELECTION-SCREEN COMMENT 1(42) text-001.

*'Production/Confirmation Date / Time From'.

SELECTION-SCREEN POSITION 43.

PARAMETERS: p_datefr TYPE sydatum OBLIGATORY DEFAULT sy-datum.

SELECTION-SCREEN POSITION 55.

PARAMETERS: p_timefr TYPE syuzeit OBLIGATORY DEFAULT '000000'.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

* Production Date / Time To

SELECTION-SCREEN COMMENT 1(42) text-002.

*'Production/Confirmation Date / Time To'.

SELECTION-SCREEN POSITION 43.

PARAMETERS: p_dateto TYPE sydatum OBLIGATORY DEFAULT sy-datum.

SELECTION-SCREEN POSITION 55.

PARAMETERS: p_timeto TYPE syuzeit OBLIGATORY DEFAULT '235959'.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN : SKIP.

SELECT-OPTIONS: s_lenum FOR lein-lenum. " Storage unit

SELECTION-SCREEN: END OF BLOCK pallet.

*------------ AT SELECTION-SCREEN --------------------------*

*Validation of Plant.

AT SELECTION-SCREEN ON p_werks.

PERFORM validate_plant.

*Validation of Material Number.

AT SELECTION-SCREEN ON p_matnr.

PERFORM validate_material.

*Validation of Batch.

AT SELECTION-SCREEN ON p_charg.

PERFORM validate_batch.

AT SELECTION-SCREEN.

PERFORM validate_others.

*Validation of Storage Unit.

AT SELECTION-SCREEN ON s_lenum.

* PERFORM validate_storageunit.

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

START-OF-SELECTION.

* ASSIGNING V_REPID WITH SY-REPID

v_repid = sy-repid.

* subroutine to populate data for report header.

PERFORM populate_report_header.

* subroutine to populate data for report detail.

PERFORM select_data.

* create field catalogue for header

PERFORM create_header_fieldcat.

* create field catalogue for detail

PERFORM create_detail_fieldcat.

*Build up layoutinfo for the fields to be displayed

* PERFORM layout_build USING i_layout.

CALL SCREEN 100.

*------------------------- SUBROUTINES ------------------------------*

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

*& Form validate_plant

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

* SUBROUTINE TO VALIDATE PLANT

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

FORM validate_plant .

SELECT COUNT(star) UP TO 1 ROWS

FROM t001w

WHERE werks = p_werks.

IF sy-subrc <> 0.

* Issue error message and stop processing

MESSAGE e060(/eur/rgbpt_dev) ."Invalid Plant.

ELSE.

wa_rephdr-werks_plant = p_werks.

ENDIF.

ENDFORM. " validate_plant

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

*& Form validate_material

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

* Subroutine to validate material

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

FORM validate_material .

SELECT COUNT(star) UP TO 1 ROWS

FROM mara

WHERE matnr = p_matnr.

IF sy-subrc <> 0.

* Issue error message and stop processing

MESSAGE e015. "Entered Material(s) is invalid

ENDIF.

SELECT COUNT(star) UP TO 1 ROWS

FROM marc

WHERE matnr = p_matnr

AND werks = p_werks.

IF sy-subrc <> 0.

MESSAGE e041 WITH p_werks.

"Entered Material(s) do not exist for entered Plant

ENDIF.

SELECT maktx

INTO makt-maktx

FROM makt

WHERE matnr = p_matnr.

ENDSELECT.

IF sy-subrc = 0.

wa_rephdr-matnr = p_matnr.

wa_rephdr-maktx = makt-maktx.

ENDIF.

ENDFORM. " validate_material

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

*& Form validate_batch

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

* This subroutine validates the value of batch entered

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

FORM validate_batch .

*Check if value is entered for Batch.

SELECT COUNT(star) UP TO 1 ROWS

FROM mcha

WHERE charg EQ p_charg.

IF sy-subrc <> 0.

* Issue error message and stop processing

MESSAGE e058(/eur/rgbpt_dev)." Invalid Batch.

ELSE.

wa_rephdr-charg = p_charg.

ENDIF.

ENDFORM. " validate_batch

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

*& Form validate_others

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

* Subroutine to validate other things (date & time etc.)

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

FORM validate_others.

* IF ( p_datefr > p_dateto ) OR

* ( ( p_datefr = p_dateto ) AND ( p_timefr > p_timeto ) ).

* MESSAGE e027. "To Date/Time lesser than From Date/Time

* ENDIF.

*

ENDFORM. " validate_others

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

*& Form validate_storageunit

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

* This subroutine validates the value of storage unit entered

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

FORM validate_storageunit .

*Check if value is entered for storage unit.

IF NOT s_lenum IS INITIAL.

SELECT COUNT(star)

UP TO 1 ROWS

FROM lein

WHERE lenum IN s_lenum.

IF sy-subrc <> 0.

* Issue error message and stop processing

MESSAGE e059(/eur/rgbpt_dev)."Invalid storage unit.

ENDIF.

ENDIF.

ENDFORM. " validate_storageunit

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

*& Form select_data

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

* Subroutine to select data

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

FORM select_data .

* Type for declaring table I_detl

TYPES: BEGIN OF ty_detl,

matnr type matnr,

charg type charg_d,

werks type werks_d,

mblnr TYPE mblnr,

mjahr TYPE mjahr,

lgnum TYPE lgnum,

tanum TYPE tanum,

tapos TYPE tapos,

bwlvs TYPE bwlvs,

bwart TYPE bwart,

betyp TYPE lvs_betyp,

benum TYPE lvs_benum,

bestq TYPE bestq,

vltyp TYPE ltap_vltyp,

vlpla TYPE ltap_vlpla,

vlenr TYPE ltap_vlenr,

nltyp TYPE ltap_nltyp,

nlpla TYPE ltap_nlpla,

nlenr TYPE ltap_nlenr,

altme TYPE LRMEI,

vsola TYPE LTAP_vsola,

vsolm TYPE LTAP_vsolm,

nsola TYPE LTAP_nsola,

nsolm TYPE LTAP_nsolm,

VBELN TYPE VBELN,

END OF ty_detl.

* Internal table to hold detail transfer order information

DATA: i_detl TYPE STANDARD TABLE OF ty_detl WITH HEADER LINE.

*Work Area to hold the detail info of the report

DATA: wa_detl TYPE ty_detl.

DATA: BEGIN OF I_VBPA OCCURS 0.

INCLUDE STRUCTURE VBPA.

DATA: END OF I_VBPA.

* Selecting Transfer Orders (Pallets Indirectly) from LTAP

SELECT lgort

lgnum

tanum

matnr

charg

werks

meins

altme

umrez

umren

qdatu

qzeit

wdatu

wenum

nltyp

nista

maktx

vlenr

nlenr

qplos

vbeln

nlpla

bestq

INTO TABLE i_ltap

FROM ltap

WHERE matnr = p_matnr

AND werks = p_werks

AND charg = p_charg and

vlenr in s_lenum.

IF sy-subrc <> 0.

MESSAGE s042. "No Pallets found for Selection Criteria

LEAVE LIST-PROCESSING.

ENDIF.

SORT i_ltap BY nlenr.

i_copy_ltap[] = i_ltap[].

* Getting Material Document & Year from LTAK

SELECT lgnum

tanum

bwart

bwlvs

mblnr

mjahr

INTO TABLE l_i_ltak

FROM ltak

FOR ALL ENTRIES IN i_ltap

WHERE lgnum = i_ltap-lgnum

AND tanum = i_ltap-tanum.

* AND BETYP = 'F'.

IF sy-subrc = 0. "sy-subrc will always be zero

SORT l_i_ltak BY lgnum tanum.

i_copy_ltak[] = l_i_ltak[].

ENDIF.

* Getting Storage Unit Number (Pallets) from Warehouse System

SELECT lenum

lgnum

INTO TABLE l_i_lein

FROM lein

FOR ALL ENTRIES IN i_ltap

WHERE lenum = i_ltap-nlenr.

IF sy-subrc = 0.

SORT l_i_lein BY lenum.

* Getting Plant from from T320(Assignment IM Storage Location to WM

* Warehouse Number)

* Getting current plant / storage location and warehouse from quants * *

* table

SELECT werks

lgort

lgnum

SPGRU

bestq

lenum

INTO TABLE l_i_lqua

FROM lqua

FOR ALL ENTRIES IN l_i_lein

WHERE lgnum = l_i_lein-lgnum.

IF sy-subrc = 0.

SORT l_i_lqua BY werks.

ENDIF.

ENDIF.

* Getting Production Date / Time (Dummy) from MKPF

SELECT mblnr

mjahr

vgart

blart

budat

cputm

INTO TABLE l_i_mkpf

FROM mkpf

FOR ALL ENTRIES IN l_i_ltak

WHERE mblnr = l_i_ltak-mblnr

AND mjahr = l_i_ltak-mjahr.

IF sy-subrc <> 0.

MESSAGE s042. "No Pallets found for Selection Criteria

LEAVE LIST-PROCESSING.

ELSE.

* DELETE l_i_ltak WHERE bwart NE '101'

* OR bwlvs NE '103'.

LOOP AT i_ltap INTO wa_ltap.

read table l_i_ltak into l_wa_ltak with key lgnum = wa_ltap-lgnum

tanum = wa_ltap-tanum binary search.

if sy-subrc ne 0.

wa_ltap-del_flag = 'X'.

MODIFY i_ltap FROM wa_ltap transporting del_flag.

endif.

endloop.

DELETE I_LTAP WHERE DEL_FLAG = 'X'.

i_copy_mkpf = l_i_mkpf.

* DELETE l_i_mkpf WHERE vgart NE 'WF' OR

* blart NE 'WE'.

*

* DELETE l_i_mkpf WHERE budat < p_datefr OR

* budat > p_dateto OR

* ( budat = p_datefr AND cputm < p_timefr ) OR

* ( budat = p_dateto AND cputm > p_timeto ).

* IF l_i_mkpf IS INITIAL.

* MESSAGE s042. "No Pallets found for Selection Criteria

* LEAVE LIST-PROCESSING.

* ELSE.

* SORT l_i_mkpf BY mblnr mjahr.

* ENDIF.

ENDIF.

** Getting shelf life expiry date & BBD date(vfdat) from MSEG

* SELECT mblnr

* mjahr

* matnr

* werks

* charg

* aufnr

* vfdat

* INTO TABLE l_i_mseg

* FROM mseg

* FOR ALL ENTRIES IN l_i_ltak

* WHERE mblnr = l_i_ltak-mblnr

* AND mjahr = l_i_ltak-mjahr.

*

* IF sy-subrc <> 0.

* MESSAGE s042. "No Pallets found for Selection Criteria

* LEAVE LIST-PROCESSING.

* ELSE.

* SORT l_i_mseg BY mblnr mjahr.

* ENDIF.

* SORT i_ltap BY matnr charg.

SORT i_ltap BY lgnum tanum.

LOOP AT i_ltap INTO wa_ltap WHERE NOT nlenr IS INITIAL.

read table l_i_lein INTO l_wa_lein

with key lenum = wa_ltap-nlenr binary search.

if sy-subrc = 0.

select single *

FROM lqua

WHERE lgnum = l_wa_lein-lgnum and

******************************************** change DEVCR

matnr = p_matnr and

werks = p_werks and

charg = p_charg and

lenum = wa_ltap-nlenr.

********************************************** chnage DEVCR

if sy-subrc = 0.

PERFORM GET_DATA.

wa_repdtl-cur_werks = lqua-werks.

wa_repdtl-lenum = L_WA_LEIN-LENUM.

wa_repdtl-act_menge = LQUA-GESME.

**********************************************Change DEVCR

wa_repdtl-meins = wa_ltap-MEINS.

**********************************************Change DEVCR

wa_repdtl-letyp = LQUA-LETYP.

wa_repdtl-lgort = LQUA-LGORT.

wa_repdtl-cur_lgnum = LQUA-LGNUM.

wa_repdtl-SPGRU = lqua-spgru.

wa_repdtl-bestq = lqua-bestq.

l_ctr = l_ctr + 1.

wa_repdtl-ctr = l_ctr .

APPEND wa_repdtl TO i_repdtl.

wa_ltap-del_flag = 'X'.

MODIFY i_ltap FROM wa_ltap transporting del_flag.

endif.

ENDIF.

ENDLOOP.

DELETE I_LTAP WHERE DEL_FLAG = 'X'.

SELECT a~mblnr " Material document no.

a~mjahr " Material document year

a~lgnum " Warehouse no.

a~tanum " Transfer order no.

b~matnr " Material no.

b~charg

b~werks

b~tapos " Transfer order item

a~bwlvs " Movement type for WM

a~bwart " Movement type for IM

a~betyp " Requirement type

a~benum " Requirement tracking no.

b~bestq " Stock Category in the WM

b~vltyp " Source storage type

b~vlpla " Source storage bin

b~vlenr " Source storage unit

b~nltyp " Destination storage type

b~nlpla " Destination storage bin

b~nlenr " Destination storage unit

b~altme

" Alternative Unit of Measure for Stockkeeping Unit

b~vsola " Source target quantity in alternate unit

b~vsolm " Source target quantity in stockkeeping unit

b~nsola " Destination target quantity in alternative unit

b~nsolm " Destination target quantity in stockkeeping unit

b~VBELN

INTO CORRESPONDING FIELDS OF TABLE i_DETL

FROM ltak AS a INNER JOIN ltap AS b

ON a~lgnum = b~lgnum

AND a~tanum = b~tanum

FOR ALL ENTRIES IN i_ltap

WHERE b~nlenr = I_ltap-nlenr and

a~betyp = 'F'.

* a~bwart IN ('601', '641').

IF sy-subrc = 0.

SORT I_DETL BY TANUM.

ENDIF.

SELECT matnr

charg

werks

vbeln

INTO TABLE l_i_lips

FROM lips

FOR ALL ENTRIES IN i_DETL

WHERE matnr = i_detl-matnr and

charg = i_detl-charg and

werks = i_detl-werks.

IF sy-subrc = 0.

SORT l_i_lips BY vbeln.

SELECT vbeln

kunnr

INTO TABLE l_i_likp

FROM likp

FOR ALL ENTRIES IN l_i_lips

WHERE vbeln = l_i_lips-vbeln.

IF sy-subrc = 0.

SORT l_i_likp BY vbeln.

ENDIF.

ENDIF.

clear: wa_repdtl.

LOOP AT i_COPY_ltap INTO wa_ltap.

READ TABLE L_I_LIKP INTO L_WA_LIKP

WITH KEY VBELN = WA_LTAP-NLPLA.

IF SY-SUBRC = 0.

wa_repdtl-kunnr = L_WA_LIKP-KUNNR.

select single name1

into wa_repdtl-name1

from kna1

where kunnr = wa_repdtl-kunnr.

select single werks

into wa_repdtl-rec_werks

from t001w

where kunnr = wa_repdtl-kunnr.

PERFORM GET_DATA_LTAK.

l_ctr = l_ctr + 1.

wa_repdtl-ctr = l_ctr .

APPEND wa_repdtl TO i_repdtl.

clear: wa_repdtl, i_repdtl.

***********************************************Change DEVCR

wa_LTAP-DEL_FLAG = 'X'.

Modify i_copy_ltap from wa_ltap transporting del_flag.

***********************************************Change DEVCR

ENDIF.

ENDLOOP.

clear: wa_repdtl.

************************************Change DEVCR

Delete i_copy_ltap where del_flag = 'X'.

delete i_copy_ltap where nlenr is initial.

************************************ Change DEVCR

LOOP AT I_COPY_LTAP INTO WA_LTAP where nlenr is not initial.

* read table i_repdtl into wa_repdtl

* with key lenum = wa_ltap-nlenr binary search.

LOOP AT I_REPDTL INTO WA_REPDTL

WHERE LENUM = WA_LTAP-NLENR.

IF SY-SUBRC NE 0.

perform get_data.

l_ctr = l_ctr + 1.

wa_repdtl-ctr = l_ctr .

APPEND wa_repdtl TO i_repdtl.

clear: wa_repdtl, i_repdtl.

EXIT.

else.

EXIT.

ENDIF.

ENDLOOP.

ENDLOOP.

clear: wa_repdtl, i_repdtl.

* IF NOT I_LTAP[] is initial.

*

*** Retriving data from /NESGLB/MCCNN1 & /NESGLB/MCCNN2

*

* SELECT a~load_no

* a~werks

* a~desp_date

* a~desp_time

* b~MATNR

* b~GTIN

* b~PROD_VARIANT

* b~CHARG

* b~MEINS

* b~ACT_MENGE

* b~exp_MENGE

* b~INSMK

* b~LENUM

* b~LETYP

* b~EBELN

* b~EBELP

* b~WERK_PLANT

* b~LGORT

* b~QPRODDAT

* b~QPRODTIME

* b~QPLOS

* b~ITEM_STAT

* b~MBLNR

* b~TANUM

* INTO corresponding fields of TABLE l_i_mccnn1_2

* FROM zmccnn1 AS a INNER JOIN zmccnn2 AS b

* ON a~lifnr = b~lifnr

* AND a~load_no = b~load_no

* FOR ALL ENTRIES IN i_ltap

* WHERE b~lenum = i_ltap-nlenr.

* IF sy-subrc = 0.

* SORT l_i_mccnn1_2 BY lenum.

* ENDIF.

*

* ENDIF.

*

clear: wa_repdtl.

LOOP AT i_REPDTL INTO wa_repdtl.

READ TABLE l_i_mccnn1_2 INTO l_wa_mccnn1_2

WITH KEY lenum = wa_repdtl-lenum.

IF sy-subrc = 0.

PERFORM GET_DATA.

wa_repdtl-rec_werks = l_wa_mccnn1_2-werks .

wa_repdtl-desp_date = l_wa_mccnn1_2-desp_date .

wa_repdtl-desp_time = l_wa_mccnn1_2-desp_time .

wa_repdtl-load_no = l_wa_mccnn1_2-load_no .

wa_repdtl-ebeln = l_wa_mccnn1_2-ebeln .

wa_repdtl-cur_werks = L_WA_MCCNN1_2-WERK_PLANT.

wa_repdtl-MEINS = l_wa_mccnn1_2-meins.

wa_repdtl-ACT_MENGE = l_wa_mccnn1_2-exp_menge.

wa_repdtl-LENUM = l_wa_mccnn1_2-lenum.

wa_repdtl-LETYP = l_wa_mccnn1_2-letyp.

wa_repdtl-LGORT = l_wa_mccnn1_2-lgort.

wa_repdtl-QPRODDAT = l_wa_mccnn1_2-qproddat.

wa_repdtl-QPRODTIME = l_wa_mccnn1_2-qprodtime.

wa_repdtl-QPLOS = l_wa_mccnn1_2-qplos.

IF l_wa_mccnn1_2-item_stat = '01'.

wa_repdtl-in_trn = 'Y'.

wa_repdtl-cur_lgnum = ' '.

WA_REPDTL-CUR_WERKS = ' '.

WA_REPDTL-LGORT = ' '.

ENDIF.

MODIFY i_repdtl FROM wa_repdtl.

ENDIF.

ENDLOOP.

LOOP AT i_REPDTL INTO wa_repdtl.

READ TABLE I_COPY_LTAP into wa_LTAP

WITH KEY NLENR = wa_repdtl-LENUM binary search.

if sy-subrc = 0.

case WA_LTAP-bestq.

when ' '.

WA_REPDTL-text = 'Available'.

when 'Q'.

wa_repdtl-text = 'Quality'.

WHEN 'R'.

wa_repdtL-text = 'Returns'.

WHEN 'S'.

WA_REPDTL-TEXT = 'Blocked'.

endcase.

if WA_LTAP-bestq = 'S'.

SELECT SINGLE *

FROM LTAK

WHERE LGNUM = WA_LTAP-LGNUM AND

TANUM = WA_LTAP-TANUM AND

BWART IN ('344', 'Z44').

IF SY-SUBRC = 0.

SELECT SINGLE *

FROM MSEG

WHERE MBLNR = LTAK-MBLNR AND

MJAHR = LTAK-MJAHR.

IF SY-SUBRC = 0.

select single grtxt

into wa_repdtl-spgtx

from T157E

where spras = 'EN' AND

BWART IN ('344', 'Z44') AND

GRUND = MSEG-GRUND.

IF SY-SUBRC = 0.

wa_repdtl-bestq = WA_LTAP-bestq.

ENDIF.

ENDIF.

ENDIF.

ENDIF.

MODIFY i_repdtl FROM wa_repdtl transporting bestq spgtx text.

clear: wa_repdtl.

endif.

ENDLOOP.

* delete i_repdtl where lenum is initial.

DELETE I_LTAP WHERE DEL_FLAG = 'X'.

IF NOT i_repdtl IS INITIAL.

SORT i_repdtl BY lenum.

sort i_repdtl by ctr.

endif.

ENDFORM. " select_data

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

*& Form populate_report_header

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

* Subroutine to populate report header data.

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

FORM populate_report_header .

APPEND wa_rephdr TO i_rephdr.

CLEAR wa_rephdr.

ENDFORM. " populate_report_header

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

*& Module STATUS_0100 OUTPUT

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

* text

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

MODULE status_0100 OUTPUT.

SET PF-STATUS 'MAIN'.

* exclude fcodes

PERFORM exclude_fcodes.

IF container_r IS INITIAL. " has the container been filled?...

* Create object that communicates with the container control...

CREATE OBJECT container_r

EXPORTING

container_name = 'G_CONT'.

* Create object that communicates with the ALV Grid control...

CREATE OBJECT grid_r

EXPORTING

i_parent = container_r.

* Create object that communicates with the event double click in

* ALV Grid control...

CREATE OBJECT event_reciver.

SET HANDLER event_reciver->handle_double_click FOR grid_r.

* Call the method that receives the content and structure of itab..

CALL METHOD grid_r->set_table_for_first_display

EXPORTING

it_toolbar_excluding = i_fcode[]

is_layout = layout

i_buffer_active = space

i_bypassing_buffer = 'X'

CHANGING

it_outtab = i_rephdr[]

it_fieldcatalog = i_fieldcat_l[].

CALL METHOD grid_r->set_gridtitle

EXPORTING

i_gridtitle = 'Header Data'.

CALL METHOD grid_r->set_visible

EXPORTING

visible = 'X'.

CALL METHOD grid_r->set_toolbar_interactive.

ENDIF.

IF container_r1 IS INITIAL. " has the container been filled?...

* Create object that communicates with the container control...

CREATE OBJECT container_r1

EXPORTING

container_name = 'G_CONT1'.

* Create object that communicates with the ALV Grid control...

CREATE OBJECT grid_r1

EXPORTING

i_parent = container_r1.

* Create object that communicates with the event double click in

* ALV Grid control...

CREATE OBJECT event_reciver1.

SET HANDLER event_reciver1->handle_double_click FOR grid_r1.

* Call the method that receives the content and structure of itab..

CALL METHOD grid_r1->set_table_for_first_display

EXPORTING

it_toolbar_excluding = i_fcode[]

is_layout = layout2

i_buffer_active = space

i_bypassing_buffer = 'X'

CHANGING

it_outtab = i_repdtl[]

it_fieldcatalog = i_fieldcat_l2[].

CALL METHOD grid_r1->set_gridtitle

EXPORTING

i_gridtitle = 'Detail Data'.

CALL METHOD grid_r1->set_visible

EXPORTING

visible = 'X'.

CALL METHOD grid_r1->set_toolbar_interactive.

ENDIF.

ENDMODULE. " STATUS_0100 OUTPUT

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

*& Module USER_COMMAND_0100 INPUT

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

* text

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

MODULE user_command_0100 INPUT.

CASE okcode.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

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

*& Form EXCLUDE_FCODES

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

* text

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

* --> p1 text

* <-- p2 text

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

FORM exclude_fcodes .

i_fcode = cl_gui_alv_grid=>mc_fc_detail.

APPEND i_fcode.

i_fcode = cl_gui_alv_grid=>mc_fc_sort_dsc.

APPEND i_fcode.

i_fcode = cl_gui_alv_grid=>mc_mb_sum.

APPEND i_fcode.

i_fcode = cl_gui_alv_grid=>mc_fc_subtot.

APPEND i_fcode.

i_fcode = cl_gui_alv_grid=>mc_fc_loc_insert_row.

APPEND i_fcode.

i_fcode = cl_gui_alv_grid=>mc_fc_graph.

APPEND i_fcode.

i_fcode = cl_gui_alv_grid=>mc_fc_view_crystal.

APPEND i_fcode.

i_fcode = cl_gui_alv_grid=>mc_fc_loc_undo.

APPEND i_fcode.

i_fcode = cl_gui_alv_grid=>mc_fc_info.

APPEND i_fcode.

i_fcode = cl_gui_alv_grid=>mc_fc_print.

APPEND i_fcode.

i_fcode = cl_gui_alv_grid=>mc_fc_loc_copy.

APPEND i_fcode.

i_fcode = cl_gui_alv_grid=>mc_fc_loc_append_row.

APPEND i_fcode.

i_fcode = cl_gui_alv_grid=>mc_fc_loc_copy_row.

APPEND i_fcode.

i_fcode = cl_gui_alv_grid=>mc_fc_loc_insert_row.

APPEND i_fcode.

i_fcode = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.

APPEND i_fcode.

i_fcode = cl_gui_alv_grid=>mc_fc_print_prev.

APPEND i_fcode.

i_fcode = cl_gui_alv_grid=>mc_fc_refresh.

APPEND i_fcode.

i_fcode = cl_gui_alv_grid=>mc_fc_loc_cut.

APPEND i_fcode.

i_fcode = cl_gui_alv_grid=>mc_fc_view_grid.

APPEND i_fcode.

i_fcode = cl_gui_alv_grid=>mc_fc_check.

APPEND i_fcode.

i_fcode = cl_gui_alv_grid=>mc_mb_paste.

APPEND i_fcode.

i_fcode = cl_gui_alv_grid=>mc_mb_view.

APPEND i_fcode.

i_fcode = cl_gui_alv_grid=>mc_fc_loc_delete_row.

APPEND i_fcode.

ENDFORM. " EXCLUDE_FCODES

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

*& Form create_header_fieldcat

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

* Subroutine to populate field cat for header

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

FORM create_header_fieldcat .

PERFORM populate_feildcat_l USING:

c_tabname1 c_hcl_pos1 c_fld_werks_plant 'Plant' ,"c_4,

c_tabname1 c_hcl_pos2 c_fld_matnr 'Material No' ,"c_18,

c_tabname1 c_hcl_pos3 c_fld_maktx 'Material Desc' ,"c_40,

c_tabname1 c_hcl_pos4 c_fld_charg 'Batch' ."c_10.

CLEAR layout.

layout-zebra = 'X'. " Zebra print

layout-cwidth_opt = 'X'.

ENDFORM. " create_header_fieldcat

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

*& Form create_detail_fieldcat

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

* Subroutine to populate field cat for detail

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

FORM create_detail_fieldcat .

PERFORM populate_feildcat_l2 USING:

c_tabname2 c_dcl_pos1 c_fld_ctr 'Counter' ,"c_2,

c_tabname2 c_dcl_pos2 c_fld_cur_werks 'Current Plant' ,"c_4,

c_tabname2 c_dcl_pos3 c_fld_lgort 'Storage Loc' ,"c_4,

c_tabname2 c_dcl_pos4 c_fld_cur_lgnum 'Current Ware' ,"c_3,

c_tabname2 c_dcl_pos5 c_fld_rec_werks 'Reciving Plant' ,"c_4,

* c_tabname2 c_dcl_pos6 c_fld_im_movt 'IM Movement' ,"c_3,

* c_tabname2 c_dcl_pos7 c_fld_wm_movt 'WM Movement' ,"c_3,

c_tabname2 c_dcl_pos8 c_fld_in_trn 'In Tran' ,"c_1,

c_tabname2 c_dcl_pos9 c_fld_kunnr 'Customer No' ,"c_10,

c_tabname2 c_dcl_pos10 c_fld_kunnr_name1 'Cust Name' ,"c_10,

c_tabname2 c_dcl_pos11 c_fld_load_no 'Load No' ,"c_35,

c_tabname2 c_dcl_pos12 c_fld_lenum 'SSCC' ,"c_20,

c_tabname2 c_dcl_pos13 c_fld_act_menge 'Quantity' ,"c_13,

c_tabname2 c_dcl_pos14 c_fld_meins 'UOM' ,"c_3,

* c_tabname2 c_dcl_pos15 c_fld_bestq 'Stock Type' ,"c_1,

c_tabname2 c_dcl_pos15 c_fld_text 'Stock Type' ,"c_15,

c_tabname2 c_dcl_pos16 c_fld_spgtx 'Blocking Reason' ,"c_20,

c_tabname2 c_dcl_pos17 c_fld_letyp 'Storage Type' ,"c_3,

c_tabname2 c_dcl_pos18 c_fld_ebeln 'Purchase Doc' ,"c_10,

c_tabname2 c_dcl_pos19 c_fld_desp_date 'Despatch Dt' ,"c_8,

c_tabname2 c_dcl_pos20 c_fld_desp_time 'Despatch Tm' ,"c_15,

c_tabname2 c_dcl_pos21 c_fld_qproddat 'Production Dt' ,"c_8,

c_tabname2 c_dcl_pos22 c_fld_qprodtime 'Production Tm' ,"c_15,

c_tabname2 c_dcl_pos23 c_fld_bbd_vfdat 'Best Before Dt' ,"c_8,

c_tabname2 c_dcl_pos24 c_fld_sed_vfdat 'ShelfLife ExpDt' ,"c_8,

c_tabname2 c_dcl_pos25 c_fld_qplos 'Insp Lot No' ."c_12.

CLEAR layout2.

layout2-zebra = 'X'. " Zebra print

layout2-cwidth_opt = 'X'.

ENDFORM. " create_detail_fieldcat

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

*& Form populate_feildcat_l

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

* SUbroutine to populate field cat for Header

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

* -->P_REF_TABLE Table Name

* -->P_col_pos col position

* -->P_fieldname field name

* -->P_coltext col text

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

FORM populate_feildcat_l USING p_ref_table

p_col_pos

p_fieldname

p_coltext.

i_fieldcat_l-ref_table = p_ref_table.

i_fieldcat_l-col_pos = p_col_pos.

i_fieldcat_l-fieldname = p_fieldname.

i_fieldcat_l-coltext = p_coltext.

APPEND i_fieldcat_l.

CLEAR i_fieldcat_l.

ENDFORM. " populate_feildcat_l

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

*& Form populate_feildcat_l2

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

* SUbroutine to populate field cat for detail

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

* -->P_REF_TABLE Table Name

* -->P_col_pos col position

* -->P_fieldname field name

* -->P_coltext col text

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

FORM populate_feildcat_l2 USING p_ref_table

p_col_pos

p_fieldname

p_coltext.

i_fieldcat_l2-ref_table = p_ref_table.

i_fieldcat_l2-col_pos = p_col_pos.

i_fieldcat_l2-fieldname = p_fieldname.

i_fieldcat_l2-coltext = p_coltext.

APPEND i_fieldcat_l2.

CLEAR i_fieldcat_l2.

ENDFORM. " populate_feildcat_l

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

*& Form GET_DATA

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

* text

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

* --> p1 text

* <-- p2 text

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

FORM GET_DATA .

READ TABLE L_I_ltak INTO l_wa_ltak

WITH KEY lgnum = wa_ltap-lgnum

tanum = wa_ltap-tanum.

IF sy-subrc = 0.

READ TABLE l_i_mkpf INTO l_wa_mkpf

WITH KEY mblnr = l_wa_ltak-mblnr

mjahr = l_wa_ltak-mjahr.

IF sy-subrc = 0.

wa_repdtl-qproddat = l_wa_mkpf-budat."production date

wa_repdtl-qprodtime = l_wa_mkpf-cputm."production time

READ TABLE l_i_mseg INTO l_wa_mseg

WITH KEY mblnr = l_wa_mkpf-mblnr

mjahr = l_wa_mkpf-mjahr

matnr = wa_ltap-matnr.

IF sy-subrc = 0.

wa_repdtl-bbd_vfdat = l_wa_mseg-vfdat."BBD

wa_repdtl-sed_vfdat = l_wa_mseg-vfdat."SED

ENDIF.

wa_repdtl-im_movt = l_wa_ltak-BWART.

wa_repdtl-wm_movt = l_wa_ltak-BWLVS.

wa_repdtl-qplos = wa_ltap-qplos. "Inspection Lot Number

wa_repdtl-lenum = wa_ltap-nlenr . "SSCC

wa_repdtl-act_menge = wa_ltap-nista ."Quantity

wa_repdtl-meins = wa_ltap-meins . "Unit Of Measure

wa_repdtl-letyp = wa_ltap-nltyp . "storage unit type

endif.

endif.

ENDFORM. " GET_DATA

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

*& Form layout_build

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

* text

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

* -->P_I_LAYOUT text

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

* This subroutine builds the layout for column optmise and color

* display.

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

*FORM layout_build USING l_layout TYPE slis_layout_alv.

* DATA : lv_colno TYPE i.

*

* layout-cwidth_opt = 'X'.

* layout-ctab_fname = 'COLOR'.

*

* REFRESH: i_repdtl-color,

* i_col_layout.

*

* LOOP AT i_repdtl.

* IF i_repdtl-shkzg = c_h.

* lv_colno = 6. "color RED

*

* PERFORM sub_set_color USING i_col_layout

* c_field_erfmg "ERFMG

* c_field_erfme "ERFME

* c_field_meins "MEINS

* c_field_menge "MENGE

* lv_colno.

* ELSE.

* lv_colno = 5. "color GREEN

* PERFORM sub_set_color USING i_col_layout

* c_field_erfmg "ERFMG

* c_field_erfme "ERFME

* c_field_meins "MEINS

* c_field_menge "MENGE

* lv_colno.

* ENDIF.

* i_repdtl-color[] = i_col_layout[].

* MODIFY i_repdtl TRANSPORTING color.

* CLEAR: i_col_layout[].

*

* ENDLOOP.

*ENDFORM. " layout_build

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

*& Form sub_set_color

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

* text

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

* -->P_I_COL_LAYOUT text

* -->P_C_FIELD_ERFMG text

* -->P_C_FIELD_ERFME text

* -->P_C_FIELD_MEINS text

* -->P_C_FIELD_MENGE text

* -->P_LV_COLNO text

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

*FORM sub_set_color USING ls_color LIKE i_col_layout

* p_fieldname1 type slis_fieldname

* p_fieldname2 type slis_fieldname

* p_fieldname3 type slis_fieldname

* p_fieldname4 type slis_fieldname

* p_colno type i.

*

* DATA: i_lfl_color TYPE slis_specialcol_alv.

*

* CLEAR i_lfl_color.

* i_lfl_color-fieldname = p_fieldname1.

* i_lfl_color-color-col = p_colno.

* i_lfl_color-nokeycol = 'X'.

* APPEND i_lfl_color TO ls_color.

*

* CLEAR i_lfl_color.

* i_lfl_color-fieldname = p_fieldname2.

* i_lfl_color-color-col = p_colno.

* i_lfl_color-nokeycol = 'X'.

* APPEND i_lfl_color TO ls_color.

*

* CLEAR i_lfl_color.

* i_lfl_color-fieldname = p_fieldname3.

* i_lfl_color-color-col = p_colno.

* i_lfl_color-nokeycol = 'X'.

* APPEND i_lfl_color TO ls_color.

*

* CLEAR i_lfl_color.

* i_lfl_color-fieldname = p_fieldname4.

* i_lfl_color-color-col = p_colno.

* i_lfl_color-nokeycol = 'X'.

* APPEND i_lfl_color TO ls_color.

*

*ENDFORM. " SUB_SET_COLOR

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

*& Form GET_DATA_LTAK

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

* text

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

* --> p1 text

* <-- p2 text

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

FORM GET_DATA_LTAK .

READ TABLE I_COPY_ltak INTO l_wa_ltak

WITH KEY lgnum = wa_ltap-lgnum

tanum = wa_ltap-tanum.

IF sy-subrc = 0.

wa_repdtl-qproddat = wa_ltap-qdatu. "production date

wa_repdtl-qprodtime = wa_ltap-qzeit. "production time

wa_repdtl-im_movt = l_wa_ltak-BWART.

wa_repdtl-wm_movt = l_wa_ltak-BWLVS.

wa_repdtl-qplos = wa_ltap-qplos. "Inspection Lot Number

if wa_ltap-nlenr is not initial.

wa_repdtl-lenum = wa_ltap-nlenr . "SSCC

else.

wa_repdtl-lenum = wa_ltap-vlenr . "SSCC

endif.

wa_repdtl-act_menge = wa_ltap-nista ."Quantity

wa_repdtl-meins = wa_ltap-meins . "Unit Of Measure

wa_repdtl-letyp = wa_ltap-nltyp . "storage unit type

endif.

ENDFORM. " GET_DATA_LTAK

1 Comment

  1. your all zreport really too good but not any single person can use because in all zreport u use ztable and don't know which field u use