Age: 165 Joined: 04 Oct 2007 Posts: 1218 Location: Санкт-Петербург
Posted: Sat Mar 27, 2010 1:45 am Post subject:
Hello! Do you have more detail functional specification?
What is the 'last purchasing date'?
You can find already existing reports at this forum using key 'NETPR & EKPO '. _________________ Молитва - это запрос разработчику на изменение кода программы.
TYPE-POOLS: slis.
DATA: BEGIN OF itekpo OCCURS 0,
ebeln TYPE ekpo-ebeln, " po no.
aedat TYPE ekpo-aedat, " change date
lifnr TYPE ekko-lifnr, " vendor code
bedat TYPE ekko-bedat, " po date
matnr TYPE ekpo-matnr, " material no.
bukrs TYPE ekpo-bukrs, " company code
werks TYPE ekpo-werks, " plant
meins TYPE ekpo-meins, " unit
netpr TYPE ekpo-netpr, " net price
prdat TYPE ekpo-prdat, " price date = creat date
netpr2 TYPE ekpo-netpr, " net price
prdat2 TYPE ekpo-prdat, " price date = creat date
END OF itekpo.
DATA: BEGIN OF itab OCCURS 0,
ebeln TYPE ekpo-ebeln, " po no.
aedat TYPE ekpo-aedat, " change date
lifnr TYPE ekko-lifnr, " vendor code
bedat TYPE ekko-bedat, " po date
matnr TYPE ekpo-matnr, " material no.
bukrs TYPE ekpo-bukrs, " company code
werks TYPE ekpo-werks, " plant
meins TYPE ekpo-meins, " unit
netpr TYPE ekpo-netpr, " net price
prdat TYPE ekpo-prdat, " price date = creat date
netpr2 TYPE ekpo-netpr, " net price
prdat2 TYPE ekpo-prdat, " price date = creat date
END OF itab.
*********ALV Declaration*************************
DATA: it_fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
wa_fieldcatalog LIKE LINE OF it_fieldcatalog,
wa_layout TYPE slis_layout_alv,
it_rec TYPE TABLE OF itab,
it_rec1 TYPE TABLE OF itab,
wa_rec LIKE LINE OF itab,
wa_itab LIKE LINE OF itab.
DATA : it_sort TYPE slis_t_sortinfo_alv,
wa_sort TYPE slis_sortinfo_alv.
CONSTANTS: lc_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.
*********ALV Declaration*************************
SELECTION-SCREEN : BEGIN OF BLOCK b WITH FRAME TITLE text-100.
SELECT-OPTIONS:
company FOR ekpo-bukrs NO INTERVALS DEFAULT '1000',
plant FOR ekpo-werks NO INTERVALS DEFAULT '1021',
mat_no FOR ekpo-matnr DEFAULT '70000456',
date FOR ekpo-prdat.
SELECTION-SCREEN END OF BLOCK b .
START-OF-SELECTION.
SELECT ebeln aedat matnr bukrs werks netpr prdat
FROM ekpo INTO CORRESPONDING FIELDS OF TABLE itekpo
WHERE
bukrs IN company AND
werks IN plant AND
matnr IN mat_no AND
prdat IN date .
END-OF-SELECTION.
*--{ VGA:insert
DATA: l_aedat TYPE ekpo-aedat.
*--} VGA:end
LOOP AT itekpo.
*--{ VGA:insert
SELECT ekpo~netpr ekpo~prdat ekpo~aedat
INTO (itekpo-netpr2, itekpo-prdat2, l_aedat)
FROM ekpo
INNER JOIN ekbe ON ekbe~ebeln = ekpo~ebeln
AND ekbe~ebelp = ekpo~ebelp
WHERE ekbe~matnr = itekpo-matnr
AND ekpo~aedat <= itekpo-aedat
AND ekpo~netpr <> itekpo-netpr
ORDER BY ekpo~aedat DESCENDING.
EXIT.
ENDSELECT.
*--} VGA:end
MOVE : itekpo-ebeln TO itab-ebeln,
itekpo-aedat TO itab-aedat,
itekpo-lifnr TO itab-lifnr,
itekpo-bedat TO itab-bedat,
itekpo-matnr TO itab-matnr,
itekpo-bukrs TO itab-bukrs,
itekpo-werks TO itab-werks,
itekpo-meins TO itab-meins,
itekpo-netpr TO itab-netpr,
itekpo-prdat TO itab-prdat,
itekpo-netpr2 TO itab-netpr2,
itekpo-prdat2 TO itab-prdat2.
APPEND itab.
ENDLOOP.
IF NOT itab[] IS INITIAL.
PERFORM sort.
PERFORM populate_field_catalog.
PERFORM fill_layout.
PERFORM display_alv.
ELSE.
WRITE: ' NO DATA'.
ENDIF.
*&---------------------------------------------------------------------*
*& Form populate_field_catalog
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM populate_field_catalog .
wa_fieldcatalog-fieldname = 'PRDAT2'.
wa_fieldcatalog-seltext_m = 'last po date'.
wa_fieldcatalog-no_zero = 'X'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'NETPR2'.
wa_fieldcatalog-seltext_m = 'last po price'.
wa_fieldcatalog-do_sum = 'X'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
ENDFORM. " populate_field_catalog
*&---------------------------------------------------------------------*
*& Form fill_layout
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM fill_layout .
wa_layout-no_input = 'X'.
wa_layout-colwidth_optimize = 'X'.
wa_layout-zebra = 'X'.
ENDFORM. " fill_layout
*& Form display_alv
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM display_alv .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_user_command = 'USER_COMMAND'
is_layout = wa_layout
it_fieldcat = it_fieldcatalog[]
i_default = 'X'
i_save = 'A'
it_sort = it_sort
TABLES
t_outtab = itab
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.
*--{ VGA:insert
*&------------------------------------------------------------------*
*& Form user_command
*&------------------------------------------------------------------*
* Called on user_command ALV event.
* Executes custom commands.
*-------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN '&IC1'.
*dbl. click processing
*get selected item
READ TABLE itab INDEX rs_selfield-tabindex INTO wa_itab.
IF sy-subrc <> 0.
EXIT.
ENDIF.
CASE rs_selfield-fieldname.
WHEN 'EBELN'.
SET PARAMETER ID 'BES' FIELD itab-ebeln.
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDCASE.
*do nothing
ENDCASE.
ENDFORM. "user_command
*--} VGA:end
_________________ Молитва - это запрос разработчику на изменение кода программы.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.