*---------------------------------------------------------------------*
* Report ZVVF_CR001_STOTOPRSLIP
*---------------------------------------------------------------------*
* *
* MODULE : Production Planning *
* *
*---------------------------------------------------------------------*
* Objective : Driver program for material issue from Stores to *
* production slip.
*
* *
* Program : Update Tables ( ) Download Data ( ) Outputs List (X)*
* Technical Specs No : *
* Date Created : *
* Author :
* Location : *
*---------------------------------------------------------------------*
REPORT ZVVF_CR001_STOTOPRSLIP NO STANDARD PAGE HEADING .
*---------------------------------------------------------------------*
* Tables *
*---------------------------------------------------------------------*
TABLES : resb, "Reservation/dependent requirements
afko, "Order header data PP orders
mard, "Storage Location Data for Material
afvc, "Operation within an order
crhd, "Work Center Header
mseg, "Document Segment: Material
mkpf, "Header: Material Document
rm61e. "Pull List: General Input/Output Fields
*----------------------------------------------------------------------*
*Types *
*----------------------------------------------------------------------*
TYPES: BEGIN OF TY_MARD,
MATNR like MARD-MATNR,
LGORT like MARD-LGORT,
LABST like MARD-LABST,
END OF TY_MARD.
TYPES: BEGIN OF TY_MAKT,
MATNR LIKE MAKT-MATNR,
MAKTX like MAKT-MAKTX,
END OF TY_MAKT.
TYPES: BEGIN OF TY_AFVC,
AUFPL like AFVC-AUFPL,
APLZL like AFVC-APLZL,
ARBID like AFVC-ARBID,
END OF TY_AFVC.
**---------------------------------------------------------------------*
** INTERNAL TABLE Begin with IT *
**---------------------------------------------------------------------*
DATA : it_head TYPE standard table of zct001_02 WITH HEADER LINE.
DATA : it_item TYPE STANDARD TABLE OF zct001_01 WITH HEADER LINE.
DATA : it_afvc TYPE STANDARD TABLE OF TY_afvc WITH HEADER LINE.
DATA : it_mard TYPE STANDARD TABLE OF TY_MARD WITH HEADER LINE.
*data : it_mkpf TYPE standard table of mkpf with header line.
DATA : IT_MSEG TYPE STANDARD TABLE OF zct001_03 WITH HEADER LINE.
data : it_mseg1 TYPE standard table of zct001_03 with header line.
DATA : it_makt TYPE STANDARD TABLE OF TY_makt WITH HEADER LINE.
DATA : X_RMPUIOM TYPE STANDARD TABLE OF rmpuiom_p WITH HEADER LINE.
*---------------------------------------------------------------------*
* Structures Begin with W *
*---------------------------------------------------------------------*
DATA : WA_MSEG1 LIKE LINE OF IT_MSEG1.
*----------------------------------------------------------------------
** Constants Begin with C_
**----------------------------------------------------------------------
CONSTANTS : C_BWART1(3) TYPE C VALUE '261',
C_BWART2(3) TYPE C VALUE '311'.
**---------------------------------------------------------------------*
** Data Variables Begin with W
**---------------------------------------------------------------------*
DATA : w_form TYPE tdsfname VALUE 'ZVVF_CL001_STOTOPRSLIP'.
DATA : w_func TYPE rs38l_fnam.
DATA : w_maktx LIKE makt-maktx.
DATA : w_arbpl TYPE crhd-arbpl.
DATA : w_ktext TYPE crtx-ktext.
DATA : w_box(1) type c.
DATA : W_lines TYPE I.
DATA : PA_ENDDT TYPE rmpuiosel-enddat.
*DATA : W_WERKS LIKE RESB-WERKS.
selection-screen begin of block b1 with frame TITLE TEXT-001.
**---------------------------------------------------------------------*
** parameters *
**---------------------------------------------------------------------*
PARAMETERS: pr_werks type resb-werks obligatory.
**---------------------------------------------------------------------*
** Select-options *
**---------------------------------------------------------------------*
select-options : SO_baugr FOR resb-baugr obligatory no-extension
no intervals,
so_CPUDT for mkpf-CPUDT.
selection-screen end of block b1.
*seLECT-OPTIONS SO_BAUGR FOR RM61E-MATNR MATCHCODE OBJECT MAT1.
**---------------------------------------------------------------------*
** INITIALIZATION *
**---------------------------------------------------------------------*
*INITIALIZATION.
* PERFORM F006_INIT.
**---------------------------------------------------------------------*
** AT SELECTION-SCREEN output.
**---------------------------------------------------------------------*
*At Selection-screen output .
* PERFORM F000_SCREEN.
**---------------------------------------------------------------------*
** AT SELECTION-SCREEN. *
**---------------------------------------------------------------------*
At Selection-screen .
PERFORM F001_VALIDATE.
**---------------------------------------------------------------------*
** START-OF-SELECTION *
**---------------------------------------------------------------------*
START-OF-SELECTION .
PERFORM F002_FETCH_DATA.
**---------------------------------------------------------------------*
** END-OF-SELECTION *
**---------------------------------------------------------------------*
END-OF-SELECTION.
PERFORM F003_DISPLAY.
**---------------------------------------------------------------------*
** AT USER-COMMAND. *
**---------------------------------------------------------------------*
AT USER-COMMAND.
PERFORM F004_SELECTION.
**---------------------------------------------------------------------*
**CALLING THE FUNCTION MODULES *
**---------------------------------------------------------------------*
PERFORM F005_CALL_FUNCTION.
*-----REFRESHING THE INTERNAL TABLE AFTER SENDING IT TO THE SMARTFORM.
refresh it_mseg.
*&---------------------------------------------------------------------*
*& Form F000_SCREEN
*&---------------------------------------------------------------------*
FORM F000_SCREEN .
loop at screen.
IF SCREEN-GROUP1 = 'SC1'.
SCREEN-INPUT = 0.
ENDIF.
MODIFY SCREEN.
endloop.
ENDFORM. " F000_SCREEN
*&---------------------------------------------------------------------*
*& Form F001_VALIDATE
*&---------------------------------------------------------------------*
FORM F001_VALIDATE .
*----SELECTING THE COMPONENT MATERIALS AND THEIR NET REQUIREMENT.
SELECT matnr lgort erfme SUM( bdmng ) AS bdmng SUM( ENMNG ) AS ENMNG
INTO CORRESPONDING FIELDS OF TABLE it_item
FROM resb
WHERE werks = pr_werks AND
xloek = space AND
kzear = space AND
* BDTER <= PA_ENDDT AND
bwart = C_BWART1 and
baugr in SO_baugr
GROUP BY matnr lgort erfme.
IF sy-subrc <> 0.
MESSAGE e000(zmsg_c001_prtostosl).
ENDIF.
ENDFORM. " VALIDATE
*&---------------------------------------------------------------------*
*& Form F002_FETCH_DATA
*&---------------------------------------------------------------------*
FORM F002_FETCH_DATA .
*---- CALCULATING THE VALUE OF NETQTY.
LOOP AT IT_ITEM.
IT_ITEM-MENGE = IT_ITEM-BDMNG - IT_ITEM-ENMNG.
MODIFY IT_ITEM TRANSPORTING MENGE.
ENDLOOP.
*------CHECKING WHETHER THE RESTRICTED MATERIAL(AVAILABLE MATERIAL) IS
*------LESS THAN THE NET REQUIREMENT.IF LESS THEN SELECT THE MATERIAL
*------AND ALSO CALCULATE THE MISSING QUANTITY FROM THE NET QUANTITY OF
*------THE MATERIAL SELECTED.
IF it_item[] IS NOT INITIAL.
SELECT matnr lgort labst FROM mard
INTO CORRESPONDING FIELDS OF TABLE it_mard
FOR ALL ENTRIES IN it_item
WHERE werks = pr_werks AND
matnr = it_item-matnr AND
lgort = it_item-lgort AND
labst <= it_item-menge.
IF sy-subrc = 0.
LOOP AT it_item.
READ TABLE it_mard WITH KEY matnr = it_item-matnr
lgort = it_item-lgort.
IF sy-subrc <> 0.
DELETE it_item .
ENDIF.
ENDLOOP.
*-------BASED ON THE MATERIAL AND STO.LOCATION SELECT THE ORDERS AND
*--------THEIR RELATED INFO FROM RESB.
SELECT * INTO CORRESPONDING FIELDS OF TABLE it_head
FROM resb
FOR ALL ENTRIES IN it_item
WHERE matnr = it_item-matnr AND
werks = pr_werks AND
lgort = it_item-lgort AND
baugr in SO_baugr AND
xloek = space AND
kzear = space AND
bwart = C_BWART1.
sort it_head by aufnr.
delete adjacent duplicates from it_head comparing aufnr.
*--------SELECTING THE DESCRIPTION OF THE PEGGED MATERIAL SELECTED IN
*--------- THE PREVIOUS QUERY AND SELECTING Routing number of operations
*---------in the order AND General counter for order AND Object ID of
*---------the resource FROM AFVC DEPENDING UPON THE VALUES IN IT_RESB.
SELECT MATNR MAKTX FROM makt INTO CORRESPONDING FIELDS OF TABLE IT_MAKT
FOR ALL ENTRIES IN IT_HEAD
WHERE matnr = it_HEAD-baugr.
SELECT AUFPL APLZL ARBID INTO CORRESPONDING FIELDS OF TABLE IT_AFVC
FROM AFVC
FOR ALL ENTRIES IN IT_HEAD
WHERE AUFPL = IT_HEAD-AUFPL AND
APLZL = IT_HEAD-APLZL.
LOOP AT it_head.
READ TABLE IT_MAKT WITH KEY MATNR = IT_HEAD-BAUGR BINARY SEARCH.
IF sy-subrc = 0.
it_head-maktx = IT_makt-maktx.
MODIFY it_head TRANSPORTING maktx.
ENDIF.
ENDLOOP.
*------SELECT THE WORKCENTERS FROM CRHD BASED UPON THE 'ARBID' ObjectID
*------OF THE RESOURCE AND INSERT IT INTO IT_RESB.
LOOP AT it_afvc.
SELECT f~arbpl p~ktext
INTO (w_arbpl, w_ktext)
FROM crhd AS f INNER JOIN crtx AS p
ON f~objid = p~objid
WHERE f~objid = it_afvc-arbid.
ENDSELECT.
READ TABLE it_head WITH KEY aufpl = it_afvc-aufpl
aplzl = it_afvc-aplzl BINARY SEARCH.
IF sy-subrc = 0.
it_head-arbpl = w_arbpl.
it_head-ktext = w_ktext.
MODIFY it_head TRANSPORTING arbpl ktext
where aufpl = it_afvc-aufpl and
aplzl = it_afvc-aplzl.
ENDIF.
ENDLOOP.
else.
message e000(zmsg_c001_prtostosl).
ENDIF.
else.
message e000(zmsg_c001_prtostosl).
ENDIF.
SET PF-STATUS 'CHECK'.
*-------Getting the material document numbers from mkpf based on the
*-------Entered on dates and where Trans./Ev. Type is 'wa' Document
*-------type is 'wa' and Doc. type rev. is 'pr'.
* select * into corresponding fields of table it_mkpf
* from mkpf
* where cpudt in so_cpudt and
* VGART = 'WA' AND
* BLART = 'WA' AND
* BLAUM = 'PR'.
**------------select all the materials from mseg and their related info
**------------based on the material documents selected.
SELECT P~MATNR P~ERFME P~MENGE P~LGORT P~CHARG P~WERKS
F~cpudt
INTO corresponding fields of table it_mseg1
FROM mkpf AS F INNER JOIN
mseg AS P
ON F~mblnr = P~mblnr
WHERE F~VGART = 'WA' AND
F~BLART = 'WA' AND
F~CPUDT IN SO_CPUDT AND
F~BLAUM = 'PR' AND
P~XAUTO <> 'X' AND
P~BWART = C_BWART2.
ENDFORM. " FETCH_DATA
*&---------------------------------------------------------------------*
*& Form F003_DISPLAY
*&---------------------------------------------------------------------*
FORM F003_DISPLAY .
*------After selecting all the materials from mseg comparing them with
*------the item details(table containg the component details)table.and
*-------just displaying that materials only.
LOOP AT IT_Mseg1.
READ TABLE IT_item witH KEY MATNR = IT_MSEG1-MATNR .
IF SY-SUBRC <> 0.
DELETE IT_MSEG1.
ENDIF.
ENDLOOP.
FORMAT COLOR 4.
WRITE : /2 text-002,
10 text-003,
25 text-004,
40 text-005,
55 text-006,
65 text-007,
80 text-008,
90 text-009.
FORMAT COLOR OFF.
LOOP AT IT_MSEG1.
WRITE : /2 w_box as checkbox,
10 IT_Mseg1-matnr,
25 it_mseg1-cpudt,
40 it_mseg1-CHARG,
55 it_mseg1-LGORT,
65 it_mseg1-MENGE LEFT-JUSTIFIED,
80 it_mseg1-erfme,
90 it_mseg1-werks.
ENDLOOP.
w_lines = sy-linno - 1 .
ENDFORM. " DISPLAY
*&---------------------------------------------------------------------*
*& Form F004_SELECTION
*&---------------------------------------------------------------------*
FORM F004_SELECTION .
**---------------------------------------------------------------------*
** Local Variables Begin with lW
**---------------------------------------------------------------------*
DATA : lw_NUM TYPE I.
*---------After selecting the materials from the list displayed,and
*----------after clicking read button,getting the selected rows into an
*----------internal table
CASE sy-ucomm.
WHEN 'READ'.
w_BOX = SPACE.
SET PF-STATUS 'CHECK' EXCLUDING 'READ'.
DO w_LINES TIMES.
lw_num = SY-INDEX + 1.
READ LINE lw_num FIELD VALUE w_box.
IF w_BOX = 'X'.
LOOP AT IT_MSEG1 INTO WA_MSEG1 .
IF SY-TABIX = SY-INDEX.
APPEND WA_MSEG1 TO IT_MSEG.
ENDIF.
ENDLOOP.
ENDIF.
ENDDO.
ENDCASE.
*-----After getting the materials into internal table,getting the
*------description of all the materials
SELECT MATNR MAKTX FROM makt INTO CORRESPONDING FIELDS OF TABLE IT_MAKT
FOR ALL ENTRIES IN IT_MSEG
WHERE matnr = it_mseg-matnr.
loop at it_mseg.
READ TABLE IT_MAKT WITH KEY MATNR = IT_MSEG-MATNR .
IF sy-subrc = 0.
it_mseg-maktx = IT_MAKT-MAKTX.
MODIFY it_mseg TRANSPORTING maktx.
ENDIF.
* READ TABLE X_RMPUIOM WITH KEY MATNR = IT_mseg-MATNR .
*
* IF SY-SUBRC = 0.
* IT_mseg-EQUAN = X_RMPUIOM-EQUAN.
* MODIFY it_mseg TRANSPORTING EQUAN.
* endif.
ENDLOOP.
ENDFORM. " SELECTION
*&---------------------------------------------------------------------*
*& Form F005_CALL_FUNCTION
*&---------------------------------------------------------------------*
FORM F005_CALL_FUNCTION .
*---------------------------------------------------------------------*
* CALL TO FUNCTION-MODULE SSF_FUNCTION_MODULE_NAME
*---------------------------------------------------------------------*
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = W_FORM
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
FM_NAME = w_func
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 TO FUNCTION-MODULE GOT FROM SSF_FUNCTION_MODULE_NAME*
*---------------------------------------------------------------------*
CALL FUNCTION w_func
* 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_HEAD = it_head
IT_MSEG = it_mseg
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
*&---------------------------------------------------------------------*
*& Form F006_INIT
*&---------------------------------------------------------------------*
FORM F006_INIT .
IMPORT X_RMPUIOM FROM MEMORY ID 'ZRMPUIOM'.
IMPORT PA_ENDDT FROM MEMORY ID 'ZENDDT'.
IMPORT SO_BAUGR FROM MEMORY ID 'ZBAUGR'.
LOOP AT X_RMPUIOM.
READ TABLE X_RMPUIOM INDEX 1.
pr_werks = X_RMPUIOM-WERKS.
ENDLOOP.
*SO_baugr1 = SO_BAUGR.
ENDFORM. " F006_INIT
No comments:
Post a Comment