SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

i want the po report with material last purchase net price



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP
View previous topic :: View next topic  
Author Message
pranaypanchbhai
Участник
Участник



Joined: 26 Mar 2010
Posts: 9

PostPosted: Fri Mar 26, 2010 2:07 pm    Post subject: i want the po report with material last purchase net price Reply with quote

hiiiiiiiiiiiii can anybody send me code in that i want the po report with material last purchase net price and last purchasing date

i have the code but not getting how to find last po price and date

plz send me details code
Back to top
View user's profile Send private message
vga
Мастер
Мастер


Age: 170
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Sat Mar 27, 2010 1:45 am    Post subject: Reply with quote

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 '.

_________________
Молитва - это запрос разработчику на изменение кода программы.
Back to top
View user's profile Send private message Blog Visit poster's website
vga
Мастер
Мастер


Age: 170
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Sat Mar 27, 2010 3:52 pm    Post subject: Reply with quote

Hi!
If I have understude you comment correctly,
pranaypanchbhai wrote:
material last price and date is the price and date that the previous po price and date for that material

you can use table EKBE. But you should to create index by Material in EKBE.

My code is marked as 'VGA'

Code:
*&---------------------------------------------------------------------*
*& Report  ZDEMO
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zdemo.

TABLES: ekko, ekpo, t007s, t001.

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 = 'EBELN'.
  wa_fieldcatalog-seltext_m  = 'PO NUMBER'.
*--{ VGA:insert
  wa_fieldcatalog-hotspot = 'X'.
*--} VGA:end
  APPEND wa_fieldcatalog TO it_fieldcatalog.
  CLEAR wa_fieldcatalog.

  wa_fieldcatalog-fieldname =  'PRDAT'.
  wa_fieldcatalog-seltext_m  = 'PO Date'.
  wa_fieldcatalog-do_sum = 'X'.
  APPEND wa_fieldcatalog TO it_fieldcatalog.
  CLEAR wa_fieldcatalog.

  wa_fieldcatalog-fieldname =  'AEDAT'.
  wa_fieldcatalog-seltext_m  = 'CREAT Date'.
  wa_fieldcatalog-do_sum = 'X'.
  APPEND wa_fieldcatalog TO it_fieldcatalog.
  CLEAR wa_fieldcatalog.

  wa_fieldcatalog-fieldname =  'MATNR'.
  wa_fieldcatalog-seltext_m  = 'MATERIAL CODE'.
  wa_fieldcatalog-no_zero      = 'X'.
  APPEND wa_fieldcatalog TO it_fieldcatalog.
  CLEAR wa_fieldcatalog.

  wa_fieldcatalog-fieldname =  'NETPR'.
  wa_fieldcatalog-seltext_m  = 'Net Price'.
  wa_fieldcatalog-do_sum = 'X'.
  APPEND wa_fieldcatalog TO it_fieldcatalog.
  CLEAR wa_fieldcatalog.

  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.

ENDFORM.                    " display_alv
*&---------------------------------------------------------------------*
*&      Form  sort
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM sort .
  wa_sort-spos = '1'.
  wa_sort-tabname = 'ITAB'.
  wa_sort-fieldname = 'EBELN'.
  wa_sort-up = 'X'.
  wa_sort-subtot = 'X'.
*wa_SORT-no_out = 'X'.

  APPEND wa_sort TO it_sort.
  CLEAR wa_sort.


ENDFORM.                    " SORT

*--{ 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

_________________
Молитва - это запрос разработчику на изменение кода программы.
Back to top
View user's profile Send private message Blog Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
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.