if you want to publish or Add something on ERP, SAP , SAP FUNCTIONAL, SAP ABAP then mail us along with your email-id. contain must be yours email-id :- avinashkr_raj@yahoo.com(any email) email-id :- avinaskr_raj.abap@blogger.com
Go on link..
link us with ...
Thursday, December 30, 2010
Report for tracking of advance licenses
REPORT ZVVF_MR018_ADVLICSUM .
*---------------------------------------------------------------------*
* Report ZVVF_MR018_ADVLICSUM *
*---------------------------------------------------------------------*
* *
* MODULE : Material Management *
* *
*---------------------------------------------------------------------*
* Objective : Report for tracking of advance licenses * *
* *
* Program : Update Tables( ) Download Data( ) Outputs List (X) *
* *
* Technical Specs No : *
* *
* Date Created : *
* *
* Author : *
* *
* Location : *
* *
* LDB : *
*---------------------------------------------------------------------*
*----------------------------------------------------------------------*
* Type-pools
*----------------------------------------------------------------------*
TYPE-POOLS : slis.
*---------------------------------------------------------------------*
* Tables *
*---------------------------------------------------------------------*
tables : ekko,
ekpo,
mseg,
lfa1,
mara,
zvvf_mt018_advli.
*----------------------------------------------------------------------*
*Types *
*----------------------------------------------------------------------*
types : begin of ty_data,
LICENSENO type zvvf_mt018_advli-LICENSENO,
MATNR type zvvf_mt018_advli-MATNR,
VALIDFROM type zvvf_mt018_advli-VALIDFROM,
VALIDto type zvvf_mt018_advli-VALIDto,
QTYALLOWED type zvvf_mt018_advli-QTYALLOWED,
MEINS TYPE zvvf_mt018_advli-MEINS,
QTYRESTRICTED type zvvf_mt018_advli-QTYRESTRICTED,
QTYRESERVED type zvvf_mt018_advli-QTYRESERVED,
LICENSEVALUE TYPE zvvf_mt018_advli-LICENSEVALUE,
WAERS TYPE zvvf_mt018_advli-WAERS,
EXCHANGERATE TYPE zvvf_mt018_advli-EXCHANGERATE,
LICENSEVALIN TYPE zvvf_mt018_advli-LICENSEVALIN,
EBELN TYPE EKKO-EBELN,
KNUMV TYPE KONV-KNUMV,
EBELP TYPE EKPO-EBELP,
MENGE type ekpo-menge,
RATE TYPE EKPO-NETPR,
MENGE1 TYPE MSEG-MENGE,
VALUE type mseg-dmbtr,
BALQTY type P DECIMALS 4,
BALVAL type P DECIMALS 4,
end of ty_data.
TYPES : BEGIN OF TY_MSEG,
EBELN LIKE MSEG-EBELN,
EBELP LIKE MSEG-EBELP,
MATNR LIKE MSEG-MATNR,
MENGE LIKE MSEG-MENGE,
DMBTR LIKE MSEG-DMBTR,
END OF TY_MSEG.
TYPES : BEGIN OF TY_EKPO,
MATNR LIKE EKPO-MATNR,
EBELP LIKE EKPO-EBELP,
MENGE LIKE EKPO-MENGE,
END OF TY_EKPO.
types : begin of ty_ekko,
ebeln like ekko-ebeln,
aedat like ekko-aedat,
end of ty_ekko.
types : begin of ty_lfa1,
lifnr like lfa1-lifnr,
name1 like lfa1-name1,
end of ty_lfa1.
TYPES : BEGIN OF TY_KONV,
KNUMV LIKE KONV-KNUMV,
KPOSN LIKE KONV-KPOSN,
KBETR LIKE KONV-KBETR,
END OF TY_KONV.
*----------------------------------------------------------------------*
*Internal tables
*----------------------------------------------------------------------*
data : it_data type standard table of ty_data with header line.
DATA : IT_DATA1 TYPE STANDARD TABLE OF TY_DATA WITH HEADER LINE.
DATA : IT_MAIN TYPE STANDARD TABLE OF TY_DATA WITH HEADER LINE.
DATA : IT_EKkO TYPE STANDARD TABLE OF TY_EKkO WITH HEADER LINE.
data : it_lfa1 type standard table of ty_lfa1 with header line.
DATA : IT_MSEG TYPE STANDARD TABLE OF TY_MSEG WITH HEADER LINE.
DATA : IT_KONV TYPE STANDARD TABLE OF TY_KONV WITH HEADER LINE.
*---------------------------------------------------------------------*
* WORK AREAS Begin with WA *
*---------------------------------------------------------------------*
*----------------------------------------------------------------------*
*Constants Begin with C_
*----------------------------------------------------------------------*
DATA: C_DESC(100) TYPE C VALUE 'ADVANCE LICENSE-SUMMARY DETAILS',
C_INFO(65) TYPE C.
*---------------------------------------------------------------------*
* Data Variables Begin with w_
*
*---------------------------------------------------------------------*
DATA : w_fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
w_layout TYPE slis_layout_alv,
w_list_header TYPE slis_t_listheader,
w_events TYPE slis_t_event,
w_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE',
w_repid LIKE sy-repid.
*---------------------------------------------------------------------*
* parameters *
*---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001 .
SELECTION-SCREEN SKIP 1.
SELECT-OPTIONS : SO_LISNO FOR ZVVF_MT018_ADVLI-LICENSENO OBLIGATORY.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN END OF block B1.
*---------------------------------------------------------------------*
* Select-options *
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* INITIALIZATION *
*---------------------------------------------------------------------*
INITIALIZATION.
w_repid = sy-repid.
refresh : it_data,it_mseg.
clear : it_data,it_mseg.
PERFORM F002_eventtab_build_temp USING w_events[].
*---------------------------------------------------------------------*
* AT SELECTION-SCREEN output.
*---------------------------------------------------------------------*
At Selection-screen output .
*---------------------------------------------------------------------*
* At selection screen *
*---------------------------------------------------------------------*
At Selection-screen.
PERFORM F007_LIST_HEADING.
PERFORM F008_VALIDATION.
*---------------------------------------------------------------------*
* START-OF-SELECTION *
*---------------------------------------------------------------------*
START-OF-SELECTION .
PERFORM F003_FIELDCAT_INIT.
PERFORM F001_GET_DATA.
PERFORM F004_DISPLAY_DATA USING W_LIST_HEADER[].
*---------------------------------------------------------------------*
* END-OF-SELECTION *
*---------------------------------------------------------------------*
END-OF-SELECTION.
PERFORM F005_DISPLAY_LIST.
*----------------------------------------------------------------------*
* TOP-OF-PAGE *
*----------------------------------------------------------------------*
TOP-OF-PAGE.
*----------------------------------------------------------------------*
* TOP-OF-PAGE *
*----------------------------------------------------------------------*
END-OF-PAGE.
*&---------------------------------------------------------------------*
*& Form F001_GET_DATA
*&---------------------------------------------------------------------*
FORM F001_GET_DATA .
SELECT EBELN EBELP MATNR MENGE
INTO CORRESPONDING FIELDS OF TABLE IT_MSEG
FROM MSEG
FOR ALL ENTRIES IN IT_DATA
WHERE EBELN = IT_DATA-EBELN AND
EBELP = IT_DATA-EBELP AND
MATNR = IT_DATA-MATNR AND
BWART IN ('101','102','105','106').
IF SY-SUBRC = 0.
*CALCULATING THE QUANTITIES
SORT IT_MSEG BY EBELN EBELP.
LOOP AT IT_MSEG.
AT END OF EBELP.
SUM.
READ TABLE IT_DATA WITH KEY EBELN = IT_MSEG-EBELN
EBELP = IT_MSEG-EBELP BINARY SEARCH.
IF SY-SUBRC = 0.
IT_DATA-MENGE1 = IT_MSEG-MENGE.
IT_DATA-BALQTY = IT_DATA-QTYRESTRICTED - IT_DATA-MENGE1.
MODIFY IT_DATA TRANSPORTING MENGE1 BALQTY
WHERE EBELN = IT_MSEG-EBELN.
ENDIF.
ENDAT.
ENDLOOP.
ENDIF.
SELECT * INTO CORRESPONDING FIELDS OF TABLE IT_KONV
FROM KONV
FOR ALL ENTRIES IN IT_DATA
WHERE KNUMV = IT_DATA-KNUMV
AND KSCHL IN ('ZP00','ZINS','ZFB1','ZFA1','ZFC1','ZP01').
*CALCULATING THE VALUES
IF SY-SUBRC = 0.
SORT IT_DATA.
SORT IT_KONV BY KNUMV KPOSN.
LOOP AT IT_KONV.
AT END OF KPOSN.
SUM.
READ TABLE IT_DATA WITH KEY KNUMV = IT_KONV-KNUMV EBELP = IT_KONV-KPOSN BINARY SEARCH.
IF SY-SUBRC = 0.
IT_DATA-RATE = IT_KONV-KBETR.
IT_DATA-VALUE = IT_KONV-KBETR * IT_DATA-MENGE1.
IT_DATA-BALVAL = IT_DATA-LICENSEVALUE - IT_DATA-VALUE.
MODIFY IT_DATA TRANSPORTING RATE VALUE BALQTY BALVAL WHERE KNUMV = IT_KONV-KNUMV AND
EBELP = IT_KONV-KPOSN.
ENDIF.
ENDAT.
ENDLOOP.
ENDIF.
PERFORM F006_DELETING_LEADING_ZEROS.
ENDFORM. " F001_GET_DATA
*&---------------------------------------------------------------------*
*& Form F002_eventtab_build_temp
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_W_EVENTS[] text
*----------------------------------------------------------------------*
FORM F002_eventtab_build_temp USING RT_EVENTS TYPE SLIS_T_EVENT .
DATA : LW_EVENT TYPE SLIS_ALV_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = RT_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
READ TABLE RT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE INTO LW_EVENT.
IF SY-SUBRC = 0.
MOVE W_TOP_OF_PAGE TO LW_EVENT-FORM.
APPEND LW_EVENT TO RT_EVENTS.
ENDIF.
ENDFORM. " F002_eventtab_build_temp
*&---------------------------------------------------------------------*
*& Form F003_FIELDCAT_INIT
*&---------------------------------------------------------------------*
FORM F003_FIELDCAT_INIT .
DATA : lw_fieldcat TYPE slis_fieldcat_alv.
CLEAR lw_fieldcat.
lw_fieldcat-fieldname = 'LICENSENO'.
lw_fieldcat-seltext_m = 'Advance License NO'.
lw_fieldcat-outputlen = 35.
APPEND lw_fieldcat TO w_fieldcatalog.
* CLEAR lw_fieldcat.
* lw_fieldcat-fieldname = 'MATNR'.
* lw_fieldcat-seltext_m = 'Material Number'.
* lw_fieldcat-outputlen = 18.
* APPEND lw_fieldcat TO w_fieldcatalog.
*
CLEAR lw_fieldcat.
lw_fieldcat-fieldname = 'VALIDFROM'.
lw_fieldcat-seltext_m = 'Valid From'.
lw_fieldcat-outputlen = 8.
APPEND lw_fieldcat TO w_fieldcatalog.
CLEAR lw_fieldcat.
lw_fieldcat-fieldname = 'VALIDTO'.
lw_fieldcat-seltext_m = 'Valid To'.
lw_fieldcat-outputlen = 8.
APPEND lw_fieldcat TO w_fieldcatalog.
CLEAR lw_fieldcat.
lw_fieldcat-fieldname = 'QTYALLOWED'.
lw_fieldcat-seltext_m = 'Qty Allowed'.
lw_fieldcat-outputlen = 13.
APPEND lw_fieldcat TO w_fieldcatalog.
CLEAR lw_fieldcat.
lw_fieldcat-fieldname = 'QTYRESTRICTED'.
lw_fieldcat-seltext_m = 'Qty Restricted'.
lw_fieldcat-outputlen = 13.
APPEND lw_fieldcat TO w_fieldcatalog.
CLEAR lw_fieldcat.
lw_fieldcat-fieldname = 'QTYRESERVED'.
lw_fieldcat-seltext_m = 'Qty Reserved'.
lw_fieldcat-outputlen = 13.
APPEND lw_fieldcat TO w_fieldcatalog.
CLEAR lw_fieldcat.
lw_fieldcat-fieldname = 'MEINS'.
lw_fieldcat-seltext_m = 'UOM'.
lw_fieldcat-outputlen = 3.
APPEND lw_fieldcat TO w_fieldcatalog.
CLEAR lw_fieldcat.
lw_fieldcat-fieldname = 'LICENSEVALUE'.
lw_fieldcat-seltext_m = 'License Value in($)'.
lw_fieldcat-outputlen = 11.
APPEND lw_fieldcat TO w_fieldcatalog.
CLEAR lw_fieldcat.
lw_fieldcat-fieldname = 'WAERS'.
lw_fieldcat-seltext_m = 'Currency Key'.
lw_fieldcat-outputlen = 5.
APPEND lw_fieldcat TO w_fieldcatalog.
CLEAR lw_fieldcat.
lw_fieldcat-fieldname = 'EXCHANGERATE'.
lw_fieldcat-seltext_m = 'Exchange Rate'.
lw_fieldcat-outputlen = 5.
APPEND lw_fieldcat TO w_fieldcatalog.
CLEAR lw_fieldcat.
lw_fieldcat-fieldname = 'LICENSEVALIN'.
lw_fieldcat-seltext_m = 'License Value in(INR)'.
lw_fieldcat-outputlen = 13.
APPEND lw_fieldcat TO w_fieldcatalog.
* CLEAR lw_fieldcat.
* lw_fieldcat-fieldname = 'RATE'.
* lw_fieldcat-seltext_m = 'RATE PER MT'.
* lw_fieldcat-outputlen = 11.
* APPEND lw_fieldcat TO w_fieldcatalog.
CLEAR lw_fieldcat.
lw_fieldcat-fieldname = 'MENGE'.
lw_fieldcat-seltext_m = 'PO Qty'.
lw_fieldcat-outputlen = 13.
APPEND lw_fieldcat TO w_fieldcatalog.
CLEAR lw_fieldcat.
lw_fieldcat-fieldname = 'MENGE1'.
lw_fieldcat-seltext_m = 'GR Qty'.
lw_fieldcat-outputlen = 13.
APPEND lw_fieldcat TO w_fieldcatalog.
CLEAR lw_fieldcat.
lw_fieldcat-fieldname = 'VALUE'.
lw_fieldcat-seltext_m = 'GR Value'.
lw_fieldcat-outputlen = 13.
APPEND lw_fieldcat TO w_fieldcatalog.
CLEAR lw_fieldcat.
lw_fieldcat-fieldname = 'BALQTY'.
lw_fieldcat-seltext_m = 'Balance Qty'.
lw_fieldcat-outputlen = 13.
APPEND lw_fieldcat TO w_fieldcatalog.
CLEAR lw_fieldcat.
lw_fieldcat-fieldname = 'BALVAL'.
lw_fieldcat-seltext_m = 'Balance Value'.
lw_fieldcat-outputlen = 11.
APPEND lw_fieldcat TO w_fieldcatalog.
ENDFORM. " F003_FIELDCAT_INIT
*&---------------------------------------------------------------------*
*& Form F004_DISPLAY_DATA
*&---------------------------------------------------------------------*
FORM F004_DISPLAY_DATA USING lt_top_of_page TYPE slis_t_listheader.
DATA : lw_line TYPE slis_listheader.
CLEAR lw_line.
lw_line-typ = 'H'.
lw_line-info = C_DESC.
APPEND lw_line TO lt_top_of_page.
CLEAR lw_line.
CLEAR lw_line.
lw_line-typ = 'S'.
lw_line-info = C_INFO.
APPEND lw_line TO lt_top_of_page.
CLEAR lw_line.
ENDFORM. " F004_DISPLAY_DATA
*&---------------------------------------------------------------------*
*& Form F005_DISPLAY_LIST
*&---------------------------------------------------------------------*
FORM F005_DISPLAY_LIST .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = W_REPID
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
I_BACKGROUND_ID = 'ALV_BACKGROUND'
* I_GRID_TITLE =
* I_GRID_SETTINGS =
IS_LAYOUT = W_LAYOUT
IT_FIELDCAT = W_FIELDCATALOG[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
I_SAVE = 'U'
* IS_VARIANT =
IT_EVENTS = W_EVENTS[]
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_MAIN
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
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. " F005_DISPLAY_LIST
*&---------------------------------------------------------------------*
*& Form F006_DELETING_LEADING_ZEROS
*&---------------------------------------------------------------------*
FORM F006_DELETING_LEADING_ZEROS .
IT_DATA1[] = IT_DATA[].
SORT IT_DATA BY LICENSENO MATNR.
LOOP AT IT_DATA.
AT END OF MATNR.
SUM.
* SHIFT IT_DATA-MATNR LEFT DELETING LEADING '0'.
READ TABLE IT_DATA1 WITH KEY LICENSENO = IT_DATA-LICENSENO
MATNR = IT_DATA-MATNR.
MOVE IT_DATA1-LICENSENO TO IT_MAIN-LICENSENO.
SHIFT IT_DATA1-MATNR LEFT DELETING LEADING '0'.
MOVE IT_DATA1-MATNR TO IT_MAIN-MATNR.
MOVE IT_DATA1-VALIDFROM TO IT_MAIN-VALIDFROM.
MOVE IT_DATA1-VALIDTO TO IT_MAIN-VALIDTO.
MOVE IT_DATA1-QTYALLOWED TO IT_MAIN-QTYALLOWED.
MOVE IT_DATA1-QTYRESTRICTED TO IT_MAIN-QTYRESTRICTED.
MOVE IT_DATA1-QTYRESERVED TO IT_MAIN-QTYRESERVED.
MOVE IT_DATA1-MEINS TO IT_MAIN-MEINS.
MOVE IT_DATA1-LICENSEVALUE TO IT_MAIN-LICENSEVALUE.
MOVE IT_DATA1-WAERS TO IT_MAIN-WAERS.
MOVE IT_DATA1-EXCHANGERATE TO IT_MAIN-EXCHANGERATE.
MOVE IT_DATA1-LICENSEVALIN TO IT_MAIN-LICENSEVALIN.
MOVE IT_DATA-MENGE TO IT_MAIN-MENGE.
MOVE IT_DATA-MENGE1 TO IT_MAIN-MENGE1.
MOVE IT_DATA-VALUE TO IT_MAIN-VALUE.
MOVE IT_DATA-BALQTY TO IT_MAIN-BALQTY.
MOVE IT_DATA-BALVAL TO IT_MAIN-BALVAL.
APPEND IT_MAIN.
* MODIFY IT_DATA TRANSPORTING MATNR .
ENDAT.
ENDLOOP.
ENDFORM. " F006_DELETING_LEADING_ZEROS
*&---------------------------------------------------------------------*
*& Form F007_LIST_HEADING
*&---------------------------------------------------------------------*
FORM F007_LIST_HEADING .
IF SO_LISNO-HIGH NE SPACE.
CONCATENATE 'Advance Licenses for :' SO_LISNO-LOW 'TO' SO_LISNO-HIGH INTO C_INFO SEPARATED BY SPACE.
ELSE.
CONCATENATE 'Advance Licenses for :' SO_LISNO-LOW INTO C_INFO .
ENDIF.
ENDFORM. " F007_LIST_HEADING
*&--------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&--------------------------------------------------------------------*
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = W_LIST_HEADER
* I_LOGO =
* I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
*&---------------------------------------------------------------------*
*& Form F008_VALIDATION
*&---------------------------------------------------------------------*
FORM F008_VALIDATION .
SELECT P~LICENSENO P~MATNR P~VALIDFROM P~VALIDTO P~QTYALLOWED
P~QTYRESTRICTED P~MEINS P~QTYRESERVED P~LICENSEVALUE
P~WAERS P~EXCHANGERATE
P~LICENSEVALIN
Q~EBELP Q~MENGE
R~EBELN R~KNUMV
INTO CORRESPONDING FIELDS OF TABLE IT_DATA
FROM ZVVF_MT018_ADVLI as p
inner join ekpo as q
on q~idnlf = p~licenseno AND
q~matnr = p~matnr
INNER JOIN EKKO AS R
ON R~EBELN = Q~EBELN
where p~licenseno IN SO_lisno.
IF SY-SUBRC NE 0.
MESSAGE E000(ZVVF_MS018_MSGCLA).
ENDIF.
ENDFORM. " F008_VALIDATION
Labels:
MM Reports
Subscribe to:
Post Comments (Atom)
link us...
For Visitors
if you want to publish or Add something on ERP, SAP , SAP FUNCTIONAL, SAP ABAP then mail us along with your email-id. contain must be yours
email-id :- avinashkr_raj@yahoo.com(any email)
email-id :- avinaskr_raj.abap@blogger.com ( use only gmail)
email-id :- avinashkr_raj@yahoo.com(any email)
email-id :- avinaskr_raj.abap@blogger.com ( use only gmail)
No comments:
Post a Comment