REPORT ZVVF_CR001_PRTOSTOSLIP .
*---------------------------------------------------------------------*
* Report ZVVF_CR001_PRTOSTOSLIP
*
*---------------------------------------------------------------------*
* *
* MODULE : Production Planning *
* *
*---------------------------------------------------------------------*
* Objective : Driver program for fetching data for production to *
* stores slip.
*
* *
* Program : Update Tables( ) Download Data( ) Outputs List (X) *
* Technical Specs No : *
* Date Created : *
* Author : *
* Location : *
* LDB : *
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* 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
*----------------------------------------------------------------------*
*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_item TYPE STANDARD TABLE OF ZCT001_01 WITH HEADER LINE.
DATA : it_mard TYPE STANDARD TABLE OF TY_MARD WITH HEADER LINE.
DATA : it_resb TYPE STANDARD TABLE OF zct001_02 WITH HEADER LINE.
DATA : it_makt TYPE STANDARD TABLE OF TY_MAKT WITH HEADER LINE.
DATA : it_afvc TYPE STANDARD TABLE OF TY_AFVC WITH HEADER LINE.
DATA : X_RMPUIOS TYPE STANDARD TABLE OF rmpuios_p WITH HEADER LINE.
*-------FOR PDF CONVERSION.
DATA : IT_PDF TYPE STANDARD TABLE OF RSPORQ WITH HEADER LINE.
*---------------------------------------------------------------------*
* WORK AREAS Begin with WA *
*---------------------------------------------------------------------*
DATA : wa_makt LIKE LINE OF IT_MAKT.
DATA : WA_SSFCRESCL TYPE SSFCRESCL."FOR PDF OUTPUT.
DATA : WA_SPOOLID TYPE RSPOID. "FOR PDF OUTPUT.
*----------------------------------------------------------------------*
*Constants Begin with C_
*----------------------------------------------------------------------*
CONSTANTS : C_BWART(3) TYPE C VALUE '261'.
*---------------------------------------------------------------------*
* Data Variables Begin with W
*
*---------------------------------------------------------------------*
DATA : w_func TYPE rs38l_fnam.
DATA : w_form TYPE tdsfname VALUE 'ZVVF_CL001_PRTOSTOSLIP'.
DATA : w_arbpl TYPE crhd-arbpl.
DATA : w_ktext TYPE crtx-ktext.
DATA : PA_ENDDT TYPE rmpuiosel-enddat,
W_REPID LIKE SY-REPID,
W_SPOOLID TYPE RQIDENT.
selection-screen begin of block b1 with frame TITLE TEXT-001.
**---------------------------------------------------------------------*
** parameters *
**---------------------------------------------------------------------*
PARAMETERS: pr_werks type resb-werks MODIF ID SC1,
PR_baugr type resb-baugr MODIF ID SC1.
**---------------------------------------------------------------------*
** Select-options *
**---------------------------------------------------------------------*
select-options : so_aufnr for resb-aufnr.
selection-screen end of block b1.
*---------------------------------------------------------------------*
* INITIALIZATION *
*---------------------------------------------------------------------*
INITIALIZATION.
W_REPID = SY-REPID.
PERFORM F001_INIT.
**---------------------------------------------------------------------*
** AT SELECTION-SCREEN output.
**---------------------------------------------------------------------*
At Selection-screen output .
PERFORM F002_SCREEN.
*---------------------------------------------------------------------*
* At selection screen *
*---------------------------------------------------------------------*
At Selection-screen.
PERFORM F003_VALIDATE.
*---------------------------------------------------------------------*
* START-OF-SELECTION *
*---------------------------------------------------------------------*
START-OF-SELECTION .
PERFORM F004_FETCH_DATA.
*---------------------------------------------------------------------*
* END-OF-SELECTION *
*---------------------------------------------------------------------*
END-OF-SELECTION.
*---------------------------------------------------------------------*
*CALLING THE FUNCTION MODULES *
*---------------------------------------------------------------------*
PERFORM F005_CALL_FUNCTION.
*----------------------------------------------------------------------*
* Start of fetching the data.
*----------------------------------------------------------------------*
FORM F004_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.
it_item-missq = it_item-MENGE - it_mard-labst.
MODIFY it_item TRANSPORTING missq.
ELSE.
DELETE it_item .
ENDIF.
ENDLOOP.
*---------SELECTING THE MATERIAL DESCRIPTION OF THE MATERIALS SELECTED
*----------IN THE PREVIOUS QUERY.
SELECT MATNR MAKTX FROM makt INTO CORRESPONDING FIELDS OF TABLE IT_MAKT
FOR ALL ENTRIES IN IT_ITEM
WHERE matnr = it_item-matnr.
LOOP AT it_item.
READ TABLE X_RMPUIOS WITH KEY MATNR = IT_ITEM-MATNR
LGORT = it_item-lgort .
IF SY-SUBRC = 0.
IT_ITEM-EQUAN = X_RMPUIOS-EQUAN.
MODIFY it_item TRANSPORTING EQUAN.
ENDIF.
READ TABLE IT_MAKT WITH KEY MATNR = IT_ITEM-MATNR .
IF sy-subrc = 0.
it_item-maktx = IT_MAKT-MAKTX.
MODIFY it_item TRANSPORTING maktx.
ENDIF.
ENDLOOP.
REFRESH IT_MAKT."AS WE ARE USING THE SAME INTERNAL TABLE FOR
" GETTING DESCRIPTION IN IT_RESB ALSO
*-------BASED ON THE MATERIAL AND STO.LOCATION SELECT THE ORDERS AND
*--------THEIR RELATED INFO FROM RESB.
SELECT * INTO CORRESPONDING FIELDS OF TABLE it_resb
FROM resb
FOR ALL ENTRIES IN it_item
WHERE matnr = it_item-matnr AND
werks = pr_werks AND
lgort = it_item-lgort AND
baugr = pr_baugr AND
aufnr in SO_aufnr AND
xloek = space AND
kzear = space AND
bwart = C_BWART.
IF SY-SUBRC = 0.
sort it_resb by aufnr.
delete adjacent duplicates from it_resb comparing aufnr.
ENDIF.
*--------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_RESB
WHERE matnr = it_resb-baugr.
SELECT AUFPL APLZL ARBID INTO CORRESPONDING FIELDS OF TABLE IT_AFVC
FROM AFVC
FOR ALL ENTRIES IN IT_RESB
WHERE AUFPL = IT_RESB-AUFPL AND
APLZL = IT_RESB-APLZL.
LOOP AT it_resb.
READ TABLE IT_MAKT WITH KEY MATNR = IT_RESB-BAUGR .
IF sy-subrc = 0.
it_resb-maktx = IT_makt-maktx.
MODIFY it_resb 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_resb WITH KEY aufpl = it_afvc-aufpl
aplzl = it_afvc-aplzl .
IF sy-subrc = 0.
it_resb-arbpl = w_arbpl.
it_resb-ktext = w_ktext.
MODIFY it_resb 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.
ENDFORM. " F004_FETCH_DATA
*&---------------------------------------------------------------------
*
*& Form F003_VALIDATE
*&---------------------------------------------------------------------
FORM F003_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_bwart and
baugr = pr_baugr
GROUP BY matnr lgort erfme.
IF sy-subrc <> 0.
MESSAGE e000(zmsg_c001_prtostosl).
ENDIF.
ENDFORM. " F003_VALIDATE
*&---------------------------------------------------------------------*
*& 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 = WA_SSFCRESCL "FOR PDF OUTPUT
* JOB_OUTPUT_OPTIONS =
TABLES
IT_ITEM = it_item
IT_RESB = it_resb
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.
*------------FOR PDF OUTPUT.
LOOP AT WA_SSFCRESCL-SPOOLIDS INTO WA_SPOOLID.
PERFORM CONVERT_OTF_TO_PDF USING WA_SPOOLID.
ENDLOOP.
ENDFORM. " F005_CALL_FUNCTION
*&---------------------------------------------------------------------*
*& Form F002_SCREEN
*&---------------------------------------------------------------------*
FORM F002_SCREEN .
loop at screen.
IF SCREEN-GROUP1 = 'SC1'.
SCREEN-INPUT = 0.
ENDIF.
MODIFY SCREEN.
endloop.
ENDFORM. " F002_SCREEN
*&---------------------------------------------------------------------*
*& Form F001_INIT
*&---------------------------------------------------------------------*
FORM F001_INIT .
IMPORT X_RMPUIOS FROM MEMORY ID 'ZRMPUIOS'.
IMPORT PA_ENDDT FROM MEMORY ID 'ZENDDT'.
LOOP AT X_RMPUIOS.
READ TABLE X_RMPUIOS INDEX 1.
pr_baugr = X_RMPUIOS-BAUGR.
pr_werks = X_RMPUIOS-WERKS.
ENDLOOP.
ENDFORM. " F001_INIT
*&---------------------------------------------------------------------*
*& Form CONVERT_OTF_TO_PDF
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_WA_SPOOLID text
*----------------------------------------------------------------------*
FORM CONVERT_OTF_TO_PDF USING P_SPOOLID.
DATA PDF LIKE TLINE OCCURS 100 WITH HEADER LINE.
DATA : NAME LIKE TST01-DNAME.
DATA : NUMBYTES TYPE I,
PDFSPOOLID LIKE TSP01-RQIDENT,
JOBNAME LIKE TBTCJOB-JOBNAME,
JOBCOUNT LIKE TBTCJOB-JOBCOUNT,
IS_OTF,
CANCEL.
DATA : W_IFILE TYPE FILENAME-FILEEXTERN,
W_FORMAT TYPE FILENAME-FILEFORMAT.
DATA : LW_FILE like IBIPPARMS-PATH.
data : lw_file1 type STRING.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = P_SPOOLID
* NO_DIALOG =
* DST_DEVICE =
* PDF_DESTINATION =
IMPORTING
PDF_BYTECOUNT = NUMBYTES
PDF_SPOOLID = PDFSPOOLID
* OTF_PAGECOUNT =
BTC_JOBNAME = JOBNAME
BTC_JOBCOUNT = JOBCOUNT
TABLES
PDF = PDF
EXCEPTIONS
ERR_NO_OTF_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DSTDEVICE = 5
USER_CANCELLED = 6
ERR_SPOOLERROR = 7
ERR_TEMSEERROR = 8
ERR_BTCJOB_OPEN_FAILED = 9
ERR_BTCJOB_SUBMIT_FAILED = 10
ERR_BTCJOB_CLOSE_FAILED = 11
OTHERS = 12
.
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 FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = LW_FILE1
IMPORTING
FILE_NAME = LW_FILE
.
*lw_file1 = lw_file.
LW_FILE1 = LW_FILE.
*IF LW_FILE1 IS NOT NULL.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = NUMBYTES
FILENAME = LW_FILE1
FILETYPE = 'BIN'
* APPEND = ' '
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* IMPORTING
* FILELENGTH =
TABLES
DATA_TAB = PDF
* FIELDNAMES =
* 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
* OTHERS = 22
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*ELSE.
* MESSAGE e001(zmsg_c001_prtostosl).
*ENDIF.
ENDFORM. " CONVERT_OTF_TO_PDF
No comments:
Post a Comment