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

Purchase Order History Mass Display



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> PP
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Mon Sep 03, 2007 11:34 pm    Post subject: Purchase Order History Mass Display Reply with quote

Instead of checking your Purchase Order History one at a time, you can now mass display or print them with this customized abap report.

Code:
*
* Mass display or print Purchase Order History
*
* You can request report by :
* 1. Change date
* 2. User Name
* 3. Purchase Order Number
* 4. Vendor Code
*
* Written by : SAP Basis, ABAP Programming and Other IMG Stuff
* www.sap-img.com
*
REPORT zpochange LINE-SIZE 132 NO STANDARD PAGE HEADING
LINE-COUNT 065(001)
MESSAGE-ID vr.

TABLES: dd04t,
        cdhdr,
        cdpos,
        dd03l,
        dd41v,
        t685t,
        vbpa,
        tpart,
        konvc,
        ekko.

SELECT-OPTIONS: xudate FOR cdhdr-udate,
                xname FOR cdhdr-username,
                xebeln FOR ekko-ebeln,
                xlifnr FOR ekko-lifnr.

SELECTION-SCREEN SKIP.
* TEXT-001 - Sorting Sequence
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
  PARAMETERS: sudate RADIOBUTTON GROUP r1,
              sname RADIOBUTTON GROUP r1,
              sobid RADIOBUTTON GROUP r1.
SELECTION-SCREEN END OF BLOCK blk1.

DATA: wflag,
      wchangenr LIKE cdhdr-changenr.

DATA: indtext(60) TYPE c.

DATA: BEGIN OF icdhdr OCCURS 50.
        INCLUDE STRUCTURE cdhdr.
DATA: END OF icdhdr.

DATA: BEGIN OF icdshw OCCURS 50.
        INCLUDE STRUCTURE cdshw.
DATA: END OF icdshw.

DATA: BEGIN OF ekkey,
  ebeln LIKE eket-ebeln,
  ebelp LIKE eket-ebelp,
  etenr LIKE eket-etenr,
END OF ekkey.

DATA: BEGIN OF itab OCCURS 50,
  BEGIN OF ekkey,
    ebeln LIKE eket-ebeln,
    ebelp LIKE eket-ebelp,
    etenr LIKE eket-etenr,
  END OF ekkey,
  changenr LIKE cdhdr-changenr,
  udate LIKE cdhdr-udate,
  utime LIKE cdhdr-utime,
  username LIKE cdhdr-username,
  chngind LIKE cdshw-chngind,
  ftext LIKE cdshw-ftext,
  outlen LIKE cdshw-outlen,
  f_old LIKE cdshw-f_old,
  f_new LIKE cdshw-f_new,
END OF itab.

DATA: old_objectid LIKE cdhdr-objectid.

FIELD-SYMBOLS: <f_old>, <f_new>.

SELECT * FROM ekko
WHERE ebeln IN xebeln
  AND lifnr IN xlifnr.
  CLEAR cdhdr.
  CLEAR cdpos.
  cdhdr-objectclas = 'EINKBELEG'.
  cdhdr-objectid = ekko-ebeln.
  PERFORM getchgdocs.
ENDSELECT.

IF sudate = 'X'.
  SORT itab BY udate ekkey-ebeln changenr ekkey-ebelp
  ekkey-etenr.
ELSEIF sname = 'X'.
  SORT itab BY username ekkey-ebeln changenr ekkey-ebelp
  ekkey-etenr.
ELSE.
  SORT itab BY ekkey-ebeln changenr ekkey-ebelp ekkey-etenr.
ENDIF.

LOOP AT itab.
  CLEAR: indtext, ekkey.
  CASE itab-chngind.
    WHEN 'U'.
      indtext(50) = itab-ftext.
      indtext+51 = text-020.
      CONDENSE indtext.
    WHEN 'D'.
      indtext = text-021.
    WHEN 'E'.
      indtext(5) = itab-ftext.
      indtext+51 = text-021.
      CONDENSE indtext.
    WHEN 'I'.
      indtext = text-022.
  ENDCASE.
  RESERVE 4 LINES.
  IF wchangenr NE itab-changenr.
    wchangenr = itab-changenr.
    ekkey = itab-ekkey.
    WRITE:/ itab-udate UNDER 'Change Date',
    itab-utime UNDER 'Time',
    itab-username UNDER 'User Name',
    itab-ekkey-ebeln UNDER 'PO No',
    itab-ekkey-ebelp UNDER 'Item',
    itab-ekkey-etenr UNDER 'Sch No',
    indtext UNDER 'Changes'.
  ELSEIF itab-ekkey NE ekkey.
    WRITE:/ itab-ekkey-ebelp UNDER 'Item',
    itab-ekkey-etenr UNDER 'Sch No',
    indtext UNDER 'Changes'.
  ENDIF.

  CASE itab-chngind.
    WHEN 'U'.
      ASSIGN itab-f_old(itab-outlen) TO <f_old>.
      ASSIGN itab-f_new(itab-outlen) TO <f_new>.
      WRITE: / text-023 UNDER 'Changes',
      <f_old>.
      WRITE: / text-024 UNDER 'Changes',
      <f_new>.
    WHEN 'E'.
      ASSIGN itab-f_old(itab-outlen) TO <f_old>.
      WRITE: text-023 UNDER 'Changes',
      <f_old>.
  ENDCASE.
  SKIP.
ENDLOOP.


TOP-OF-PAGE.
  WRITE:/ sy-datum,sy-uzeit,
  50 'P U R C H A S E O R D E R H I S T O R Y',
  120 'Page', sy-pagno.
  WRITE: / sy-repid,
  60 'Purchase Orders Changes'.
  SKIP.
  ULINE.
  IF sudate = 'X'.
    WRITE:/001 'Change Date',
    014 'Time',
    024 'User Name',
    038 'PO No',
    050 'Item',
    057 'Sch No',
    065 'Changes'.
  ELSEIF sobid = 'X'.
    WRITE:/001 'PO No',
    013 'Item',
    020 'Sch No',
    028 'Change Date',
    041 'Time',
    051 'User Name',
    065 'Changes'.
  ELSE.
    WRITE:/001 'User Name',
    015 'Change Date',
    028 'Time',
    038 'PO No',
    050 'Item',
    057 'Sch No',
    065 'Changes'.
  ENDIF.
  ULINE.

*&---------------------------------------------------------------------*
*&      Form  GETCHGDOCS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM getchgdocs.
  CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'
    EXPORTING
      date_of_change    = cdhdr-udate
      objectclass       = cdhdr-objectclas
      objectid          = cdhdr-objectid
      time_of_change    = cdhdr-utime
      username          = cdhdr-username
    TABLES
      i_cdhdr           = icdhdr
    EXCEPTIONS
      no_position_found = 1
      OTHERS            = 2.

  CHECK sy-subrc EQ 0.
  DELETE icdhdr WHERE change_ind EQ 'I'.
  CHECK NOT icdhdr[] IS INITIAL.
  LOOP AT icdhdr.
    CHECK icdhdr-udate IN xudate.
    CHECK icdhdr-username IN xname.
    CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'
      EXPORTING
        changenumber      = icdhdr-changenr
      IMPORTING
        header            = cdhdr
      TABLES
        editpos           = icdshw
      EXCEPTIONS
        no_position_found = 1
        OTHERS            = 2.
    CHECK sy-subrc EQ 0.
    LOOP AT icdshw.
      CHECK icdshw-text_case EQ space.
      MOVE-CORRESPONDING icdshw TO itab.
      MOVE-CORRESPONDING icdhdr TO itab.
      MOVE icdshw-tabkey+3 TO itab-ekkey.
      APPEND itab.
    ENDLOOP.
  ENDLOOP.
ENDFORM.                    "GETCHGDOCS
*
* END OF PROGRAM
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> PP 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 cannot 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.