*---------------------------------------------------------------------*
* Report ZVVF_CR002_MATRETSLIP
*---------------------------------------------------------------------*
* *
* MODULE : Production Planning *
* *
*---------------------------------------------------------------------*
* Objective : Driver program for material return slip for R.Ms/P.Ms*
* from production to stores.
* *
* Program : Update Tables ( ) Download Data ( ) Outputs List (X)*
* Technical Specs No : *
* Date Created : *
* Author :
*
* Location : *
* LDB : *
* *
*---------------------------------------------------------------------*
REPORT ZVVF_CR002_MATRETSLIP .
*----------------------------------------------------------------------*
* TABLES *
*----------------------------------------------------------------------*
TABLES: MSEG, "Document Segment Material: Item Data
MKPF,
MARA, "Material Document: Header Data
MAKT. "Material Descriptions
*----------------------------------------------------------------------*
* INTERNAL TABLES: Begin with IT_ *
*----------------------------------------------------------------------*
DATA: it_plant type standard table of ZCT002_01 with header line,
it_matl type standard table of ZCT002_01 with header line.
DATA : BEGIN OF IT_MARA OCCURS 0,
MATNR TYPE MARA-MATNR,
END OF IT_MARA.
*----------------------------------------------------------------------*
* DATA: Begin with W_ *
*----------------------------------------------------------------------*
DATA: w_fmname TYPE RS38L_FNAM,
w_formname TYPE TDSFNAME VALUE 'ZVVF_CL002_MATRETSLIP'.
*----------------------------------------------------------------------*
* WORK AREAS: Begin with WA_
*
*----------------------------------------------------------------------*
DATA: wa_plant type zty_plant.
*----------------------------------------------------------------------*
* SELECT-OPTIONS: Begin with SO_ *
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK MaterialMovements WITH FRAME TITLE
TEXT-001.
PARAMETERS : so_werks TYPE MSEG-WERKS OBLIGATORY. "Plant Code
*SELECT-OPTIONS: so_matnr FOR MSEG-MATNR . "Material Code
*SELECT-OPTIONS: SO_MTART FOR MARA-MTART OBLIGATORY NO-EXTENSION
*NO INTERVALS.
SELECT-OPTIONS: SO_MTART FOR MARA-MTART OBLIGATORY No intervals.
SELECT-OPTIONS: so_budat FOR MKPF-BUDAT OBLIGATORY. "Posting Date
SELECT-OPTIONS: so_lgort FOR MSEG-LGORT . "Storage Location
SELECT-OPTIONS: so_bwart FOR MSEG-BWART OBLIGATORY. "Movenment Type
SELECT-OPTIONS: so_usnam FOR MKPF-USNAM . "UserName
SELECTION-SCREEN END OF BLOCK MaterialMovements.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
*------Call Subroutine to populate the internal tables as per the user
*------selection so_vbeln
PERFORM f001_fill_itab.
*----------------------------------------------------------------------*
* START-OF-SELECTION *
*----------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM CALL_FUNCTION.
*&---------------------------------------------------------------------*
*& Form f001_fill_itab
*&---------------------------------------------------------------------*
FORM f001_fill_itab .
*---------SELECTING PLANT MATERIAL DOCUMENT NO BATCH NO UOM POSTING DATE
*---------AND USER NAME FROM MKPF MSEG AND T001W
* SELECT a~werks a~matnr a~mblnr a~charg a~menge a~meins b~budat
*c~name1
* INTO corresponding fields of TABLE it_plant
* FROM ( MSEG as a inner join MKPF as b
* on a~mblnr = b~mblnr and
* a~mjahr = b~mjahr )
* inner join t001w as c
* on a~werks = c~werks
* WHERE b~budat IN so_budat
* AND a~xauto <> 'X'
* AND a~werks = so_werks
* AND a~lgort IN so_lgort
* AND a~matnr IN so_matnr
* AND a~bwart IN so_bwart
* AND b~usnam IN so_usnam.
*SELECT MATNR FROM MARA INTO CORRESPONDING FIELDS OF
* TABLE IT_MARA WHERE MTART IN SO_MTART.
SELECT a~werks a~matnr a~mblnr a~charg a~menge a~meins b~budat c~name1
INTO corresponding fields of TABLE it_plant
FROM ( MSEG as a inner join MKPF as b
on a~mblnr = b~mblnr and
a~mjahr = b~mjahr )
inner join t001w as c
on a~werks = c~werks
WHERE a~matnr IN ( SELECT MATNR FROM MARA WHERE MTART IN SO_MTART )
AND b~budat IN so_budat
AND a~xauto <> 'X'
AND a~werks = so_werks
AND a~lgort IN so_lgort
AND a~bwart IN so_bwart
AND b~usnam IN so_usnam.
IF SY-SUBRC NE '0'.
MESSAGE E001(ZVVF_MATRETSLIP_MSG).
*-------SELECTING ALL THE MATERIALS AND RESPECTED MATERIAL DESCRIPTION
ELSE.
select matnr maktx into corresponding fields of table it_matl
from makt.
*-------READING THE INTERNAL TABLE IT_MAT1 AND APPENDING THE MATERIAL
*-------DESCRIPTION FOR EACH MATERIAL
loop at it_plant into wa_plant.
read table it_matl with key matnr = wa_plant-matnr.
wa_plant-maktx = it_matl-maktx.
modify it_plant from wa_plant.
endloop.
ENDIF.
ENDFORM. " f001_fill_itab
*&---------------------------------------------------------------------*
*& Form CALL_FUNCTION
*&---------------------------------------------------------------------*
FORM CALL_FUNCTION .
*---------- CALL FUNCTION MODULE TO GET THE NAME OF THE SMARTFORM
*-----------FUNCTION MODULE
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = w_formname
IMPORTING
FM_NAME = w_fmname
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*--------- CALL THE SMARTFORM FUNCTION MODULE TO PROCESS & DISPLAY THE
*----------SMARTFORM
CALL FUNCTION w_fmname
* EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
* CONTROL_PARAMETERS =
* MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
* OUTPUT_OPTIONS =
* USER_SETTINGS = 'X'
* IMPORTING
* DOCUMENT_OUTPUT_INFO =
* JOB_OUTPUT_INFO =
* JOB_OUTPUT_OPTIONS =
TABLES
IT_PLANT = it_plant
* EXCEPTIONS
* FORMATTING_ERROR = 1
* INTERNAL_ERROR = 2
* SEND_ERROR = 3
* USER_CANCELED = 4
* OTHERS = 5
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " CALL_FUNCTION
No comments:
Post a Comment