Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Hi Friends

Former Member
0 Kudos
239

Will u Guys please send some Simple Clasical reports please.

5 REPLIES 5

Former Member
0 Kudos
75

Hi,

&----


*& Report ZSD_VENDOR

*&

&----


*&

*&

&----


REPORT zsd_vendor.

----


  • TABLES DECLARATION *

----


TABLES : lfa1, "Vendor Master (General Section)

lfb1. "Vendor Master (Company Code)

----


  • SELECTION SCREEN *

----


SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.

SELECT-OPTIONS : s_date FOR sy-datum obligatory.

SELECT-OPTIONS : s_lifnr FOR lfa1-lifnr.

SELECT-OPTIONS : s_code FOR lfb1-bukrs.

SELECTION-SCREEN END OF BLOCK blk1.

----


  • STRUCTURE DECLARATION *

----


TYPE-POOLS: slis.

TYPES : BEGIN OF t_lfb1,

lifnr TYPE lfb1-lifnr, "Account Number of Vendor or Creditor

END OF t_lfb1.

TYPES : BEGIN OF t_ekko,

lifnr TYPE ekko-lifnr, "Account Number of Vendor or Creditor

END OF t_ekko.

TYPES : BEGIN OF t_lfb,

lifnr TYPE lfb1-lifnr, "Account Number of Vendor or Creditor

bukrs TYPE lfb1-bukrs, "Company Code

erdat TYPE lfb1-erdat, "Date on which the Record Was Created

END OF t_lfb.

TYPES : BEGIN OF t_lfa1,

lifnr TYPE lfa1-lifnr, "Account Number of Vendor or Creditor

land1 TYPE lfa1-land1, "Country Key

name1 TYPE lfa1-name1, "Name

stras TYPE lfa1-stras, "House number and street

ort01 TYPE lfa1-ort01, "City

ort02 TYPE lfa1-ort02, "District

pfach TYPE lfa1-pfach, "PO Box

pstlz TYPE lfa1-pstlz, "Postal Code

regio TYPE lfa1-regio, "Region

stras1 TYPE lfa1-stras, "Street

erdat TYPE lfb1-erdat, "Date on which the Record Was Created

bukrs TYPE lfb1-bukrs, "Company Code

END OF t_lfa1.

----


  • INTERNAL TABLE DECLARATION *

----


DATA : it_lfb1 TYPE TABLE OF t_lfb1.

DATA : it_ekko TYPE TABLE OF t_ekko.

DATA : it_lfa1 TYPE TABLE OF t_lfa1.

DATA : it_lfb TYPE TABLE OF t_lfb.

DATA : it_final TYPE TABLE OF t_lfa1.

DATA : it_fieldcat TYPE TABLE OF slis_fieldcat_alv.

DATA : gd_layout TYPE slis_layout_alv.

----


  • WORK AREA DECLARATION *

----


DATA : x_lfa1 TYPE t_lfa1.

DATA : x_lfb TYPE t_lfb.

DATA : x_fieldcat TYPE slis_fieldcat_alv.

----


  • LOCAL VARIABLE DECLARATION *

----


DATA : fld1 TYPE lfa1-stras, "#EC NEEDED

fld2 TYPE lfa1-stras.

----


  • START OF SELECTION *

----


START-OF-SELECTION.

*-----get all Vendor with in the date range

SELECT lifnr

FROM payr INTO TABLE it_lfb1

WHERE zaldt IN s_date AND

lifnr IN s_lifnr AND

zbukr IN s_code.

    • SELECT lifnr

    • FROM lfb1 INTO TABLE it_lfb1

    • WHERE erdat IN s_date AND

    • zwels = 'C' AND

    • lifnr IN s_lifnr AND

    • bukrs IN s_code.

*-----get all Vendor with in the date range

SELECT lifnr

FROM ekko INTO TABLE it_ekko

WHERE aedat IN s_date AND

lifnr IN s_lifnr.

DELETE it_ekko WHERE lifnr = ''.

DELETE it_lfb1 WHERE lifnr = ''.

APPEND LINES OF it_lfb1 TO it_ekko.

SORT it_ekko.

DELETE ADJACENT DUPLICATES FROM it_ekko.

IF it_ekko[] IS NOT INITIAL.

*-----get Details of vendors

SELECT lifnr

land1

name1

stras

ort01

ort02

pfach

pstlz

regio

FROM lfa1 INTO TABLE it_lfa1

FOR ALL ENTRIES IN it_ekko

WHERE lifnr = it_ekko-lifnr.

*-----Get company code

SELECT lifnr zbukr laufd

FROM payr INTO TABLE it_lfb

FOR ALL ENTRIES IN it_ekko

WHERE lifnr = it_ekko-lifnr AND

zbukr IN s_code AND zaldt IN s_date.

  • SELECT lifnr

  • bukrs

  • erdat

  • FROM lfb1 INTO TABLE it_lfb

  • FOR ALL ENTRIES IN it_ekko

  • WHERE zwels = 'C' AND

  • lifnr = it_ekko-lifnr AND

  • bukrs IN s_code.

ENDIF .

SORT it_lfb BY lifnr ASCENDING

bukrs ASCENDING

erdat DESCENDING .

DELETE ADJACENT DUPLICATES FROM it_lfb COMPARING lifnr bukrs.

LOOP AT it_lfa1 INTO x_lfa1.

LOOP AT it_lfb INTO x_lfb WHERE lifnr = x_lfa1-lifnr.

x_lfa1-erdat = x_lfb-erdat.

IF x_lfa1-erdat NOT IN s_date.

x_lfa1-erdat = ''.

ENDIF.

CLEAR : fld1,fld2.

SPLIT x_lfa1-stras AT space INTO fld1 fld2 .

x_lfa1-stras1 = fld2.

x_lfa1-bukrs = x_lfb-bukrs.

APPEND x_lfa1 TO it_final.

ENDLOOP.

ENDLOOP.

----


  • ALV *

----


PERFORM fieldcat.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

is_layout = gd_layout

it_fieldcat = it_fieldcat

i_save = 'A'

TABLES

t_outtab = it_final. "it_lfa1.

&----


*& Form fieldcat

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fieldcat .

CLEAR : x_fieldcat,it_fieldcat.

DEFINE mm.

x_fieldcat-fieldname = &1.

x_fieldcat-tabname = 'ILFA1'.

x_fieldcat-seltext_l = &2.

x_fieldcat-no_zero = &3.

append x_fieldcat to it_fieldcat.

END-OF-DEFINITION.

mm 'LIFNR' text-002 '' .

mm 'NAME1' text-003 '' .

mm 'STRAS1' text-004 '' .

mm 'ORT01' text-005 '' .

mm 'ORT02' text-006 '' .

mm 'PFACH' text-007 '' .

mm 'PSTLZ' text-008 '' .

mm 'REGIO' text-009 '' .

mm 'LAND1' text-010 '' .

mm 'BUKRS' text-011 '' .

mm 'ERDAT' text-012 '' .

gd_layout-colwidth_optimize = 'X'.

gd_layout-zebra = 'X'.

ENDFORM. " fieldcat

REgards,

Ashok

Former Member
0 Kudos
75

Hi

See this sample report

&----


*& Report ZMM_PO_REPORT

&----


REPORT ZMM_PO_REPORT message-Id yb

NO STANDARD PAGE HEADING

LINE-COUNT 60(1)

LINE-SIZE 230.

************************************************************************

  • D A T A B A S E T A B L E S D E C L A R A T I O N

************************************************************************

TABLES: lfa1, " Vendor Master

t161, " PO Doc Types

t024, " Purchase Groups

ekko. " PO Header

************************************************************************

  • T Y P E S D E C L A R A T I O N S

************************************************************************

  • Purchase Orders Main Structure

TYPES: BEGIN OF s_po,

ebeln TYPE ebeln, " PO No.

ebelp TYPE ebelp, " PO Item

bstyp TYPE bstyp, " PO Category

bukrs TYPE bukrs, " Company Code

bsart TYPE bbsrt, " PO Type

lifnr TYPE lifnr, " Vendor No

ekgrp TYPE bkgrp, " Purchase Group

waers TYPE waers, " Currency

bedat TYPE etbdt, " PO Date

txz01 TYPE txz01, " Material Text

werks TYPE ewerk, " Plant

lgort TYPE lgort_d, " Storage Location

matkl TYPE matkl, " Material Group

menge TYPE bamng, " PR Quantity

meins TYPE bamei, " UOM

bprme TYPE bbprm, " Price Unit

netpr TYPE netpr, " Net price

peinh TYPE peinh, " Price Unit UOM

pstyp TYPE pstyp, " Item Category

knttp TYPE knttp, " Account Assignment Category

END OF s_po.

  • Purchase Orders History Structure

TYPES: BEGIN OF s_account,

ebeln TYPE ebeln, " PO No.

ebelp TYPE ebelp, " PO Item

gjahr TYPE mjahr, " Fiscal Year

belnr TYPE mblnr, " PO Invoice No

menge TYPE menge_d, " PR Quantity

wrbtr TYPE wrbtr, " Price in Local Currency

dmbtr TYPE dmbtr, " Price in Foreign Currency

waers TYPE waers, " Currency

shkzg TYPE shkzg, " Dr/Cr Indicator

END OF s_account.

  • Purchase Orders History Structure(Item Sum)

TYPES: BEGIN OF s_inv_sum,

ebeln TYPE ebeln, " PO No.

ebelp TYPE ebelp, " PO Item

menge TYPE menge_d, " PR Quantity

wrbtr TYPE wrbtr, " Price in Foreign Currency

waers TYPE waers, " Currency

END OF s_inv_sum.

  • Purchase Orders Main Structure

TYPES: BEGIN OF s_rep,

lifnr TYPE lifnr, " Vendor No

ebeln TYPE ebeln, " PO No.

ebelp TYPE ebelp, " PO Item

bstyp TYPE bstyp, " PO Category

bsart TYPE bbsrt, " PO Type

ekgrp TYPE bkgrp, " Purchase Group

waers TYPE waers, " Currency

bedat TYPE etbdt, " PO Date

txz01 TYPE txz01, " Material Text

werks TYPE ewerk, " Plant

lgort TYPE lgort_d, " Storage Location

matkl TYPE matkl, " Material Group

menge TYPE bamng, " PR Quantity

meins TYPE bamei, " UOM

bprme TYPE bbprm, " Price Unit

netpr TYPE netpr, " Net price

peinh TYPE peinh, " Price Unit UOM

pstyp TYPE pstyp, " Item Category

knttp TYPE knttp, " Account Assignment Category

name1 TYPE name1, " Plant

orewr TYPE netpr, " To be Invoiced Price

curr TYPE waers, " Inv Doc Currency

END OF s_rep.

************************************************************************

  • D A T A D E C L A R A T I O N S

************************************************************************

DATA: gv_title1 TYPE sylisel, " Report title

gv_dial. " Color flag

************************************************************************

  • C O N S T A N T S D E C L A R A T I O N S

************************************************************************

CONSTANTS: c_x VALUE 'X', " Flag X

c_h VALUE 'H', " Debit

c_vgabe TYPE vgabe VALUE '2'. " Transaction Type

************************************************************************

  • I N T E R N A L T A B L E S D E C L A R A T I O N S

************************************************************************

DATA: i_po TYPE STANDARD TABLE OF s_po WITH HEADER LINE,

" Purchase Order

i_inv TYPE STANDARD TABLE OF s_inv_sum WITH HEADER LINE,

" PO Invoice Values

i_rep TYPE STANDARD TABLE OF s_rep WITH HEADER LINE,

" PO Invoice Values

i_ekbe TYPE STANDARD TABLE OF s_account WITH HEADER LINE.

" PO Invoice Values

************************************************************************

  • S E L E C T I O N S C R E E N *

************************************************************************

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS: s_lifnr FOR lfa1-lifnr MATCHCODE OBJECT kred,

s_ebeln FOR ekko-ebeln MATCHCODE OBJECT mekk,

s_bsart FOR t161-bsart,

s_ekgrp FOR t024-ekgrp,

s_bedat FOR ekko-bedat.

SELECTION-SCREEN END OF BLOCK b1.

************************************************************************

  • I N I T I A L I Z A T I O N *

************************************************************************

INITIALIZATION.

************************************************************************

  • A T S E L E C T I O N - S C R E E N *

************************************************************************

AT SELECTION-SCREEN.

  • Validate the screen fields

PERFORM validate_screen.

************************************************************************

  • S T A R T - O F - S E L E C T I O N *

************************************************************************

START-OF-SELECTION.

  • Fetch main data

PERFORM fetch_data.

************************************************************************

  • T O P - O F - P A G E *

************************************************************************

TOP-OF-PAGE.

  • Header of the List

PERFORM header.

************************************************************************

  • E N D - O F - P A G E *

************************************************************************

  • Footer

END-OF-PAGE.

ULINE.

************************************************************************

  • E N D - O F - S E L E C T I O N *

************************************************************************

END-OF-SELECTION.

  • Display the Report Output data

PERFORM display_data.

***********************************************************************

  • At Line-Selection

***********************************************************************

AT LINE-SELECTION.

  • When double clicked on EBELN display the details of Purchase Doc

PERFORM line_sel.

&----


*& Form validate_screen

&----


  • Validation of Selection Screen fields

----


FORM validate_screen .

  • Validation of Vendor Number

CLEAR lfa1-lifnr.

IF NOT s_lifnr[] IS INITIAL.

SELECT lifnr UP TO 1 ROWS

INTO lfa1-lifnr

FROM lfa1

WHERE lifnr IN s_lifnr.

ENDSELECT.

IF sy-subrc <> 0.

MESSAGE e000 WITH 'Invalid Vendor'(002).

ENDIF.

ENDIF.

  • Validation of PO Number

CLEAR ekko-ebeln.

IF NOT s_ebeln[] IS INITIAL.

SELECT ebeln UP TO 1 ROWS

INTO ekko-ebeln

FROM ekko

WHERE ebeln IN s_ebeln.

ENDSELECT.

IF sy-subrc <> 0.

MESSAGE e000 WITH 'Invalid Document Number'(003).

ENDIF.

ENDIF.

  • Validation of PO Document Type

CLEAR t161-bsart.

IF NOT s_bsart[] IS INITIAL.

SELECT bsart UP TO 1 ROWS

INTO t161-bsart

FROM t161

WHERE bsart IN s_bsart.

ENDSELECT.

IF sy-subrc <> 0.

MESSAGE e000 WITH 'Invalid Purchase Document Type'(004).

ENDIF.

ENDIF.

  • Validation of Purchasing Group

CLEAR t024-ekgrp.

IF NOT s_ekgrp[] IS INITIAL.

SELECT ekgrp UP TO 1 ROWS

INTO t024-ekgrp

FROM t024

WHERE ekgrp IN s_ekgrp.

ENDSELECT.

IF sy-subrc <> 0.

MESSAGE e000 WITH 'Invalid Purchasing Group'(005).

ENDIF.

ENDIF.

ENDFORM. " validate_screen

&----


*& Form fetch_data

&----


  • Fetching the PO related data from Database Tables

----


FORM fetch_data .

CLEAR i_po.

REFRESH i_po.

SELECT a~ebeln " PO No.

b~ebelp " PO Item

a~bstyp " PO Category

a~bukrs " Company Code

a~bsart " PO Type

a~lifnr " Vendor No

a~ekgrp " Purchase Group

a~waers " Currency

a~bedat " PO Date

b~txz01 " Material Text

b~werks " Plant

b~lgort " Storage Location

b~matkl " Material Group

b~menge " PR Quantity

b~meins " UOM

b~bprme " Price Unit

b~netpr " Net price

b~peinh " Price Unit UOM

b~pstyp " Item Category

b~knttp " Account Assignment Category

INTO TABLE i_po

FROM ekko AS a JOIN ekpo AS b

ON a~ebeln = b~ebeln

WHERE a~ebeln IN s_ebeln AND

a~lifnr IN s_lifnr AND

a~ekgrp IN s_ekgrp AND

a~bsart IN s_bsart AND

a~bedat IN s_bedat.

SORT i_po BY ebeln ebelp.

break-point.

IF NOT i_po[] IS INITIAL.

  • Fetch the PO History/Invoice Details from EKBE Table

CLEAR i_ekbe.

REFRESH i_ekbe.

SELECT ebeln " PO No.

ebelp " PO Item

gjahr " Fiscal Year

belnr " PO Invoice No

menge " PR Quantity

wrbtr " Price in Local Currency

dmbtr " Price in Foreign Currency

waers " Currency

shkzg " Dr/Cr Indicator

INTO TABLE i_ekbe

FROM ekbe

FOR ALL ENTRIES IN i_po

WHERE ebeln = i_po-ebeln AND

ebelp = i_po-ebelp AND

vgabe = c_vgabe.

break-point.

IF sy-subrc = 0.

SORT i_ekbe BY ebeln ebelp.

LOOP AT i_ekbe.

IF i_ekbe-shkzg = c_h.

i_ekbe-wrbtr = i_ekbe-wrbtr * -1.

ENDIF.

MODIFY i_ekbe.

ENDLOOP.

break-point.

  • Sum up the Item wise Invoice totals

LOOP AT i_ekbe.

AT END OF ebelp.

READ TABLE i_ekbe INDEX sy-tabix.

SUM.

MOVE-CORRESPONDING i_ekbe TO i_inv.

APPEND i_inv.

ENDAT.

CLEAR i_inv.

ENDLOOP.

SORT i_inv BY ebeln ebelp.

break-point.

ENDIF.

ENDIF.

  • Move the Vendor Name and Invoice Values to I_rep Internal Table

LOOP AT i_po.

MOVE-CORRESPONDING i_po TO i_rep.

CLEAR i_inv.

READ TABLE i_inv WITH KEY ebeln = i_po-ebeln

ebelp = i_po-ebelp.

IF sy-subrc = 0.

i_rep-orewr = ( i_po-menge - i_inv-menge ) * i_po-netpr.

i_rep-curr = i_inv-waers.

ELSE.

i_rep-orewr = i_po-menge * i_po-netpr.

i_rep-curr = i_po-waers.

ENDIF.

break-point.

  • Get the Vendor Name

CLEAR lfa1-name1.

SELECT SINGLE name1 FROM lfa1 INTO lfa1-name1

WHERE lifnr = i_po-lifnr.

IF sy-subrc = 0.

i_rep-name1 = lfa1-name1.

ENDIF.

APPEND i_rep.

CLEAR i_rep.

break-point.

ENDLOOP.

SORT i_rep BY lifnr ebeln ebelp.

DELETE i_rep WHERE orewr LE 0.

break-point.

ENDFORM. " fetch_data

&----


*& Form display_data

&----


  • Display the Report Output data

----


FORM display_data .

DATA: lv_flag, " New Flag

lv_rec TYPE i. " No of Records

CLEAR lv_rec.

IF i_rep[] IS INITIAL.

MESSAGE e000 WITH 'No Data found'(022).

ELSE.

LOOP AT i_rep.

  • Toggle Color

PERFORM toggle_color.

IF lv_flag <> space.

NEW-LINE.

ENDIF.

  • At New Purchase Document

AT NEW ebeln.

WRITE:/1 sy-vline, 2(10) i_rep-ebeln INTENSIFIED OFF.

lv_flag = c_x.

lv_rec = lv_rec + 1.

ENDAT.

WRITE: 1 sy-vline,

12 sy-vline,13(4) i_rep-bsart,

17 sy-vline,18(10) i_rep-lifnr,

28 sy-vline,29(35) i_rep-name1,

64 sy-vline,65(4) i_rep-ekgrp,

69 sy-vline,70(10) i_rep-bedat,

80 sy-vline,81(5) i_rep-ebelp,

86 sy-vline,87(40) i_rep-txz01,

127 sy-vline,128(9) i_rep-matkl,

137 sy-vline,138(1) i_rep-pstyp,

139 sy-vline,140(1) i_rep-knttp,

141 sy-vline,142(4) i_rep-werks,

146 sy-vline,147(4) i_rep-lgort,

151 sy-vline,152(13) i_rep-menge UNIT i_rep-meins,

165 sy-vline,166(3) i_rep-meins,

169 sy-vline,170(15) i_rep-netpr CURRENCY i_rep-waers,

185 sy-vline,186(4) i_rep-waers,

190 sy-vline,191(5) i_rep-peinh,

196 sy-vline,197(4) i_rep-bprme,

201 sy-vline,202(15) i_rep-orewr CURRENCY i_rep-curr,

217 sy-vline,218(4) i_rep-curr,

222 sy-vline,223(7) i_rep-bstyp centered,

230 sy-vline.

NEW-LINE.

hide: i_rep-ebeln.

ENDLOOP.

ULINE.

FORMAT COLOR OFF.

WRITE : /2 'Total Number of Purchasing Documents:'(025) COLOR 3,

lv_rec COLOR 3.

ENDIF.

ENDFORM. " display_data

&----


*& Form header

&----


  • Write the Report Header

----


FORM header .

FORMAT RESET.

  • header

WRITE:/1(230) 'LIST OF PURCHASE DOCUMENTS PER VENDOR'(006) CENTERED.

SKIP.

FORMAT COLOR COL_HEADING.

ULINE.

WRITE:/1 sy-vline,2(10) 'Pur.Doc.No'(006) CENTERED,

12 sy-vline,13(4) 'Type'(007),

17 sy-vline,18(10) 'Vendor'(008) CENTERED,

28 sy-vline,29(35) 'Name'(009) CENTERED,

64 sy-vline,65(4) 'PGrp'(010) CENTERED,

69 sy-vline,70(10) 'Doc.Date'(012) CENTERED,

80 sy-vline,81(5) 'Item'(011),

86 sy-vline,87(40) 'Material Short Text'(024) CENTERED,

127 sy-vline,128(9) 'Mat.Group'(013),

137 sy-vline,138(1) 'I',

139 sy-vline,140(1) 'A',

141 sy-vline,142(4) 'Plnt'(014),

146 sy-vline,147(4) 'SLoc'(015),

151 sy-vline,152(13) 'Quantity'(016) CENTERED,

165 sy-vline,166(3) 'UoM'(017),

169 sy-vline,170(15) 'Net Value'(018) CENTERED,

185 sy-vline,186(4) 'Curr'(019),

190 sy-vline,191(5) 'Per'(020),

196 sy-vline,197(4) 'Unit'(021),

201 sy-vline,202(15) 'To be Invoiced'(023) CENTERED,

217 sy-vline,218(4) 'Curr'(019),

222 sy-vline,223(7) 'Doc.Cat'(026),

230 sy-vline.

ULINE.

ENDFORM. " header

&----


*& Form toggle_color

&----


  • This routine alters the color of the records in the list

----


FORM toggle_color.

IF gv_dial = space.

FORMAT COLOR COL_NORMAL INTENSIFIED OFF.

gv_dial = c_x.

ELSE.

FORMAT COLOR 1 INTENSIFIED OFF.

CLEAR gv_dial.

ENDIF.

ENDFORM. " toggle_color

&----


*& Form LINE_SEL

&----


*When double clicked on EBELN field display the details of Purchase Doc

----


FORM line_sel.

CASE sy-lsind.

WHEN '1'.

DATA: lv_field(20),

lv_value(10),

lv_bstyp like i_rep-bstyp.

clear: lv_bstyp,lv_value, lv_field.

GET CURSOR FIELD lv_field VALUE lv_value.

IF lv_field = 'I_REP-EBELN'.

IF NOT lv_value IS INITIAL.

READ LINE sy-index FIELD VALUE i_rep-bstyp

INTO lv_bstyp.

  • READ CURRENT LINE FIELD VALUE i_rep-bstyp INTO lv_bstyp.

if lv_bstyp = 'F'.

SET PARAMETER ID 'BES' FIELD lv_value.

CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.

elseif ( lv_bstyp = 'K' or lv_bstyp = 'L' ).

SET PARAMETER ID 'VRT' FIELD lv_value.

CALL TRANSACTION 'ME33' AND SKIP FIRST SCREEN.

elseif lv_bstyp = 'A'.

SET PARAMETER ID 'ANF' FIELD lv_value.

CALL TRANSACTION 'ME43' AND SKIP FIRST SCREEN.

endif.

ENDIF.

ENDIF.

ENDCASE.

ENDFORM. " line_sel

<b>Reward points for useful Answers</b>

Regards

Anji

Former Member
0 Kudos
75

Hi,

check out the report zSales Document_report.

TABLES: VBAK,

VBAP,

KNA1.

DATA: BEGIN OF itab_vbak OCCURS 0,

vbeln TYPE vbak-vbeln,

ernam TYPE vbak-ernam,

audat TYPE vbak-audat,

netwr TYPE vbak-netwr,

vkorg TYPE vbak-vkorg,

kunnr TYPE vbak-kunnr,

END OF itab_vbak.

DATA: BEGIN OF itab_vbap OCCURS 0,

vbeln TYPE vbap-vbeln,

posnr TYPE vbap-posnr,

matnr TYPE vbap-matnr,

arktx TYPE vbap-arktx,

kwmeng TYPE vbap-kwmeng,

cmkua TYPE vbap-cmkua,

END OF itab_vbap.

DATA: BEGIN OF itab_kna1 OCCURS 0,

kunnr TYPE kna1-kunnr,

land1 TYPE kna1-land1,

name1 TYPE kna1-name1,

END OF itab_kna1.

DATA: BEGIN OF IT_FINAL OCCURS 0,

vbeln TYPE vbak-vbeln,

ernam TYPE vbak-ernam,

audat TYPE vbak-audat,

netwr TYPE vbak-netwr,

vkorg TYPE vbak-vkorg,

kunnr TYPE vbak-kunnr,

posnr TYPE vbap-posnr,

matnr TYPE vbap-matnr,

arktx TYPE vbap-arktx,

kwmeng TYPE vbap-kwmeng,

cmkua TYPE vbap-cmkua,

land1 TYPE kna1-land1,

name1 TYPE kna1-name1,

END OF IT_FINAL.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS:S_VBELN FOR VBAK-VBELN,

S_AUDAT FOR VBAK-AUDAT,

P_KUNNR for VBAK-KUNNR.

*PARAMETERS: P_KUNNR LIKE VBAK-KUNNR.

SELECTION-SCREEN END OF BLOCK B1.

START-OF-SELECTION.

PERFORM DATA_FETCH.

PERFORM DISPLAY.

&----


*& Form DATA_FETCH

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form DATA_FETCH .

SELECT vbeln

ernam

audat

netwr

vkorg

kunnr FROM VBAK INTO CORRESPONDING FIELDS OF TABLE ITAB_VBAK

WHERE VBELN IN S_VBELN

AND AUDAT IN S_AUDAT

AND KUNNR in P_KUNNR.

IF SY-SUBRC EQ 0.

IF ITAB_VBAK[] IS NOT INITIAL.

SELECT VBELN

posnr

matnr

arktx

kwmeng

cmkua FROM VBAP INTO CORRESPONDING FIELDS OF TABLE ITAB_VBAP

FOR ALL ENTRIES IN ITAB_VBAK

WHERE VBELN = ITAB_VBAK-VBELN.

ENDIF.

ENDIF.

LOOP AT ITAB_VBAK.

IT_FINAL-vbeln = ITAB_VBAK-vbeln.

IT_FINAL-ernam = ITAB_VBAK-ernam.

IT_FINAL-audat = ITAB_VBAK-audat.

IT_FINAL-netwr = ITAB_VBAK-netwr.

IT_FINAL-vkorg = ITAB_VBAK-vkorg.

IT_FINAL-kunnr = ITAB_VBAK-kunnr.

SELECT KUNNR

NAME1

LAND1 FROM KNA1

INTO (ITAB_KNA1-kunnr, ITAB_KNA1-NAME1, ITAB_KNA1-LAND1 )

  • FOR ALL ENTRIES IN ITAB_VBAK

WHERE KUNNR = ITAB_VBAK-KUNNR.

IT_FINAL-NAME1 = ITAB_KNA1-NAME1.

IT_FINAL-LAND1 = ITAB_KNA1-LAND1.

endselect .

READ TABLE ITAB_VBAP WITH KEY VBELN = IT_FINAL-VBELN.

if sy-subrc = 0 .

IT_FINAL-POSNR = ITAB_VBAP-POSNR.

IT_FINAL-MATNR = ITAB_VBAP-MATNR.

IT_FINAL-ARKTX = ITAB_VBAP-ARKTX.

IT_FINAL-KWMENG = ITAB_VBAP-KWMENG.

IT_FINAL-CMKUA = ITAB_VBAP-CMKUA.

endif.

append IT_FINAL .

ENDLOOP.

endform.

FORM DISPLAY .

loop at IT_FINAL .

write : /

IT_FINAL-vbeln ,

IT_FINAL-ernam ,

IT_FINAL-audat ,

IT_FINAL-netwr ,

IT_FINAL-vkorg ,

IT_FINAL-kunnr ,

IT_FINAL-posnr ,

IT_FINAL-matnr ,

IT_FINAL-arktx ,

IT_FINAL-kwmeng,

IT_FINAL-cmkua ,

IT_FINAL-land1 ,

IT_FINAL-name1 .

endloop .

ENDFORM. " DISPLAY

for detail list please check out the link below it will help you

http://help.sap.com/saphelp_nw04/helpdata/en/9f/dba2eb35c111d1829f0000e829fbfe/content.htm

****************please reward points if the information is helpful to you**************

Former Member
0 Kudos
75

Hi,

Find a simple classical report.


*& ---------------  DATABASE TABLES USED --------------------------------------------- &*
TABLES: imak,        " Appropriation requests - general data
        proj,       " Project definition
        jcds,        " Change Documents for System/User Statuses (Table JEST)
        pa0002,       " HR Master Record: Infotype 0002 (Personal Data)
        zadci,        "ADCI adjusment table of PS module
        pa0001.       " HR Master Record: Infotype 0001 (Org. Assignment)

*& ------------------  DECLARATION OF INTERNAL TABLES -------------------------------- &*

DATA: BEGIN OF itab_imak OCCURS 0,
        posnr TYPE imak-posnr,
        posid TYPE imak-posid,
        objnr TYPE imak-objnr,
        erdat TYPE imak-erdat,
        ernam TYPE imak-ernam,
        pernr TYPE pa0001-pernr,                            " 12.06.07

      END OF itab_imak.

DATA: BEGIN OF itab_proj OCCURS 0,
        pspnr TYPE proj-pspnr,
        pspid TYPE proj-pspid,
        objnr TYPE proj-objnr,
        erdat TYPE proj-erdat,
        ernam TYPE proj-ernam,
      END OF itab_proj.

DATA: BEGIN OF itab_jcds OCCURS 0,
        objnr TYPE jcds-objnr,
        udate TYPE jcds-udate,
        utime TYPE jcds-utime,
        stat TYPE jcds-stat,
        inact TYPE jcds-inact,

      END OF itab_jcds.

DATA: BEGIN OF itab_name OCCURS 0,
        pernr TYPE pa0002-pernr,
        uname TYPE pa0002-uname,
*        ename TYPE pa0002-ename,
      END OF itab_name.

DATA: BEGIN OF itab_creation  OCCURS 0,
          udate TYPE jcds-udate,
      END OF itab_creation.

DATA: BEGIN OF itab_preaudit  OCCURS 0,
          udate TYPE jcds-udate,
      END OF itab_preaudit.

DATA: itab_status LIKE itab_jcds OCCURS 0 WITH HEADER LINE.
DATA: itab_prad LIKE itab_jcds OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF it_final OCCURS 0,
           pernr TYPE pa0002-pernr,
          ernam TYPE proj-ernam,
          pspid TYPE proj-pspid,
          pspnr TYPE proj-pspnr,
          posid TYPE proj-pspid,
          ename TYPE pa0001-ename,                          "12/6/7
          usr00 LIKE prps-usr00,
          erdat TYPE proj-erdat,
          apprvdat TYPE jcds-udate,
          preaudat TYPE jcds-udate,
          differ TYPE i,
          text TYPE zadci-text,
          preaudit TYPE jcds-udate,
       END OF it_final.

*& --------------- VARIABLE TO STORE THE DIFFERENCES B/W STATUS DATES ----------------- &*
DATA: diff TYPE dats.
DATA: diff_days TYPE i.
DATA: c TYPE i VALUE 0.
DATA: c1 TYPE i VALUE 0.
DATA: appldate TYPE dats.
DATA: prdate TYPE dats.
DATA: creadate TYPE dats.
DATA: days TYPE i VALUE 0.
DATA: temp_posnr(24) TYPE c.DATA: out_posnr TYPE imak-posnr.
DATA: empadci TYPE p DECIMALS 2.
DATA: deptadci TYPE p DECIMALS 2.
DATA: count TYPE i VALUE 0.
DATA: add TYPE i VALUE 0.
DATA: add_dept TYPE i VALUE 0.
DATA: dep_count TYPE i VALUE 0.
DATA: v_pspid LIKE prps-posid.
DATA: name TYPE pa0001-ename.


*& -----------------  SELECTION SCREEN ----------------------------------------------- &*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME  TITLE text-001.

SELECT-OPTIONS: s_date FOR proj-erdat.   " obligatory.
SELECT-OPTIONS: s_pernr FOR pa0002-pernr.    "QUALITY/PRODUCTION SERVER

*SELECT-OPTIONS: S_NAME FOR PROJ-ERNAM.    " development server

SELECTION-SCREEN END OF BLOCK b1.

*& --------------------------  START-OF-SELECTION ------------------------------------ &*
START-OF-SELECTION.

  PERFORM data_fetch.
  PERFORM display.


*&---------------------------------------------------------------------*
*&      Form  data_fetch
*&---------------------------------------------------------------------*
*       This subroutine is used to data fetch from the database
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM data_fetch .

*& --------------  PERNR/UNAME  IN USER INPUT -------------------------- &*
  IF s_pernr IS NOT INITIAL .        " QUALITY/PRODUCTION  SERVER
    SELECT       pernr
                 uname
                 FROM pa0002 INTO CORRESPONDING FIELDS OF TABLE itab_name
                 WHERE pernr IN s_pernr.                    " QUALITY/PRODUCTION  SERVER

*  IF S_NAME IS NOT INITIAL.          " DEVELOPMENT SEREVR

    LOOP AT itab_name.

*      SELECT SINGLE ename FROM pa0001 INTO CORRESPONDING FIELDS OF pa0001 WHERE pernr = itab_name-pernr."12/06/07

      SELECT SINGLE ename FROM pa0001 INTO name WHERE pernr = itab_name-pernr.

      SHIFT itab_name-pernr BY 3 PLACES.                    " 5/6/7

      IF itab_name-pernr EQ '90516'.                " FOR JATINDER

        SELECT pspnr
               pspid
               objnr
               erdat
               ernam
               FROM proj INTO CORRESPONDING FIELDS OF TABLE itab_proj
               WHERE  erdat IN s_date
               AND ernam = 'JATINDER'.

      ELSE.                                    " for others except jatinder

        SELECT   pspnr
                 pspid
                 objnr
                 erdat
                 ernam
                 FROM proj INTO CORRESPONDING FIELDS OF TABLE itab_proj
                 WHERE  erdat IN s_date
                 AND ernam = itab_name-pernr.

      ENDIF.

      LOOP AT itab_proj.
*& ------------ for zps21 ----------------------------------------- &*
        CALL FUNCTION 'CONVERSION_EXIT_REQNR_INPUT'
          EXPORTING
            input  = itab_proj-pspid
          IMPORTING
            output = out_posnr.

        SELECT       posnr
                     posid
                     objnr
                     erdat
                     ernam
                     FROM imak INTO CORRESPONDING FIELDS OF TABLE itab_imak
                     WHERE posnr  = out_posnr.

        LOOP AT itab_imak.
          SELECT  objnr
                  udate
                  utime
                  stat
                  inact
                  FROM jcds INTO CORRESPONDING FIELDS OF TABLE itab_jcds
                  WHERE objnr = itab_imak-objnr
                  AND inact = ' '.
*                  AND UDATE IN S_DATE.                        " APPROVAL DATE WITHIN SELECTION DATE RANGE


          itab_status[] = itab_jcds[].
          SORT itab_status BY udate utime.
          c = sy-dbcnt.

          LOOP AT itab_status.
            READ TABLE itab_status INDEX c.
* SOC FOR CHECKING ONLY APROVAL DATE

            IF itab_status-stat = 'IO364'.
              appldate = itab_status-udate.
            ELSE.
              CLEAR appldate.
            ENDIF.
*EOC FOR CHECKING ONLY APROVAL DATE

*& ------------------ SOC FOR  APPROVAL DATE WITHIN SELETION DATE ---------- &*
            IF appldate GT s_date-high OR appldate LT s_date-low.
              CLEAR appldate.
            ENDIF.
*& ------------------ EOC FOR  APPROVAL DATE WITHIN SELETION DATE ---------- &*
            EXIT.
            c = c - 1.
          ENDLOOP.
        ENDLOOP.
        it_final-apprvdat = appldate.
*& ------------end  for zps21 ---------------------------------------------  &*
        SELECT   objnr
                 udate
                 utime
                 stat
                 inact
                 FROM jcds INTO CORRESPONDING FIELDS OF TABLE itab_jcds
                 WHERE objnr = itab_proj-objnr
                 AND stat = 'E0003'.
*                          AND inact = ' '.

*& ----------- SOC FOR CREATION DATE ON 13/6/7 ------------------------------- &*
        SELECT  udate
                FROM jcds INTO CORRESPONDING FIELDS OF TABLE itab_creation
                WHERE objnr = itab_proj-objnr
                AND stat = 'I0001 '
                AND inact = ' '.
        LOOP AT itab_creation.

          it_final-erdat = itab_creation-udate.
          creadate = itab_creation-udate.

        ENDLOOP.


*& ----------- EOC FOR CREATION DATE ON 13/6/7 ------------------------------ &*

*& ----------------- SOC FOR submitted for preaudit DATE ON 13/6/7 -------------- &*
        SELECT  udate
                FROM jcds INTO CORRESPONDING FIELDS OF TABLE itab_preaudit
                WHERE objnr = itab_proj-objnr
                AND stat = 'E0002'
                AND inact = ' '.
        itab_prad[] = itab_jcds[].
        SORT itab_prad BY udate utime.                      " 22.05.07
        c1 = sy-dbcnt.
        LOOP AT itab_prad.
          READ TABLE itab_prad INDEX  c1.
          prdate = itab_prad-udate.

*& --------- SOC FOR  preaudit DATE WITHIN SELETION DATE  ---------------- &*
**          IF prdate GT s_date-high OR prdate LT s_date-low.
**            CLEAR prdate.
**          ENDIF.
*& -------- EOC FOR  preaudit DATE WITHIN SELETION DATE ----------------- &*
          EXIT.
        ENDLOOP.
        it_final-preaudat = prdate.
*& ------------------------ EOC FOR submitted for preaudit DATE ON 13/6/7 ------------- &*


*& ------------- SOC FOR PREAUDIT DATE ON 13/6/7 -------------------------------------- &*

        LOOP AT itab_preaudit.
**& --------- SOC FOR  SUBMITTED FOR  PREAUDIT DATE WITHIN SELETION DATE  ------------ &*
**          IF itab_preaudit-udate GT s_date-high OR itab_preaudit-udate LT s_date-low.
**            CLEAR itab_preaudit-udate.
**          ENDIF.
**& -------- EOC FOR  SUBMITTED FOR  PREAUDIT DATE WITHIN SELETION DATE -------------- &*

          it_final-preaudit = itab_preaudit-udate.
        ENDLOOP.
*& ------------- EOC FOR  PREAUDIT DATE ON 13/6/7 -------------------------------------- &*

        IF prdate IS NOT INITIAL AND creadate IS NOT INITIAL.

          CALL FUNCTION 'HR_SGPBS_YRS_MTHS_DAYS'
            EXPORTING
              beg_da              = creadate
              end_da              = prdate
           IMPORTING
*         NO_DAY              =
*         NO_MONTH            =
*         NO_YEAR             =
             no_cal_day          = days
           EXCEPTIONS
             dateint_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.
        ENDIF.
        CLEAR : prdate,
                appldate,
                creadate.

        SELECT SINGLE zdays
                      text  FROM zadci INTO CORRESPONDING FIELDS OF zadci
                      WHERE pspid = itab_proj-pspid.
        IF sy-subrc EQ 0 .
          it_final-differ = days - 1 - zadci-zdays.
          it_final-text = zadci-text.
        ELSE.
          IF zadci-zdays IS  INITIAL AND days NE 0.
            it_final-differ = days - 1.
          ENDIF.
        ENDIF.


        it_final-pspid = itab_proj-pspid.
        it_final-pspnr = itab_proj-pspnr.
        it_final-pernr = itab_name-pernr.
*        IT_FINAL-POSID  = ITAB_PROJ-POSID .
*        it_final-erdat = itab_proj-erdat.
        it_final-ename = name.                              "13/06/07

        APPEND it_final.

        CLEAR : it_final,
                itab_proj,
                days.

*      ENDIF.          " QUALITY/PRODUCTION  SERVER
      ENDLOOP.
    ENDLOOP.
    " FOR JATINDER
*& ------------------  " PERNR/UNAME IS NOT IN USER INPUT --------------------------- &*
  ELSE.

    SELECT    pspnr
              pspid
              objnr
              erdat
              ernam FROM proj INTO CORRESPONDING FIELDS OF TABLE itab_proj
              WHERE  erdat IN s_date.

    LOOP AT itab_proj.
      IF itab_proj-ernam EQ 'JATINDER'.          "'JATINDER'

        it_final-pernr = '90516'.                "'JATINDER'
      ELSE.                                        "'JATINDER'

        SELECT   pernr
                 uname
                 FROM pa0002 INTO CORRESPONDING FIELDS OF TABLE itab_name
                 WHERE  pernr  EQ  itab_proj-ernam.          " QUALITY/PRODUCTION  SERVER


        IF sy-subrc EQ 0.             " QUALITY/PRODUCTION  SERVER

          LOOP AT itab_name.
*          SELECT SINGLE ename FROM pa0001 INTO CORRESPONDING FIELDS OF pa0001 WHERE pernr = itab_name-pernr."12/06/07

            SELECT SINGLE ename FROM pa0001 INTO name WHERE pernr = itab_name-pernr."12/06/07

            SHIFT itab_name-pernr BY 3 PLACES.
            it_final-pernr = itab_name-pernr.        " QUALITY/PRODUCTION  SERVER
          ENDLOOP.

        ENDIF.                                      "'JATINDER'

*& ------------ for zps21 ----------------------------------------------------- &*
        CALL FUNCTION 'CONVERSION_EXIT_REQNR_INPUT'
          EXPORTING
            input  = itab_proj-pspid
          IMPORTING
            output = out_posnr.

        SELECT posnr
               posid
               objnr
               erdat
               ernam FROM imak INTO CORRESPONDING FIELDS OF TABLE itab_imak
               WHERE posnr  = out_posnr.

        LOOP AT itab_imak.
          SELECT  objnr
                  udate
                  utime
                  stat
                  inact FROM jcds INTO CORRESPONDING FIELDS OF TABLE itab_jcds
                  WHERE objnr = itab_imak-objnr

                  AND inact = ' '.
*                  AND UDATE IN S_DATE.                        " APPROVAL DATE WITHIN SELECTION DATE RANGE
          itab_status[] = itab_jcds[].
          SORT itab_status BY udate utime.
          c = sy-dbcnt.
          LOOP AT itab_status.

            READ TABLE itab_status INDEX c.
* SOC FOR CHECKING ONLY APROVAL DATE
            IF itab_status-stat = 'IO364'.
              appldate = itab_status-udate.
            ELSE.
              CLEAR appldate.
            ENDIF.
* EOC FOR CHECKING ONLY APROVAL DATE

* SOC FOR  APPROVAL DATE WITHIN SELETION DATE
            IF appldate GT s_date-high OR appldate LT s_date-low.
              CLEAR  appldate .
            ENDIF.
* EOC FOR  APPROVAL DATE WITHIN SELETION DATE
            EXIT.

            c = c - 1.
          ENDLOOP.
          it_final-apprvdat = appldate.
        ENDLOOP.


        SELECT  objnr
                udate
                utime
                stat
                inact FROM jcds INTO CORRESPONDING FIELDS OF TABLE itab_jcds
                WHERE objnr = itab_proj-objnr
                AND stat = 'E0003'.

*                 AND inact = ' '.
*& ----------------------- SOC FOR CREATION DATE ON 13/6/7 --------------------- &*
        SELECT  udate
                FROM jcds INTO CORRESPONDING FIELDS OF TABLE itab_creation
                WHERE objnr = itab_proj-objnr
                AND stat = 'I0001 '
                AND inact = ' '.
*& --------------------- EOC FOR CREATION DATE ON 13/6/7 ----------------------- &*

*& --------------------- SOC FOR submitted for preaudit DATE ON 13/6/7 ------------ &*
        SELECT  udate
                FROM jcds INTO CORRESPONDING FIELDS OF TABLE itab_preaudit
                WHERE objnr = itab_proj-objnr
                AND stat = 'E0002'
                AND inact = ' '.

*& --------------- EOC FOR submitted for preaudit DATE ON 13/6/7 ------------ &*

        itab_prad[] = itab_jcds[].
        SORT itab_prad BY udate utime.                      " 22.05.07
        c1 = sy-dbcnt.
        LOOP AT itab_prad.
          READ TABLE itab_prad INDEX c1.
          prdate = itab_prad-udate.
*& ------------ SOC FOR  preaudit DATE WITHIN SELETION DATE --------- &*
**          IF prdate GT s_date-high OR prdate LT s_date-low.
**            CLEAR prdate.
**          ENDIF.
*& ------------ EOC FOR   preaudit DATE WITHIN SELETION DATE --------- &*
          EXIT.
        ENDLOOP.

        it_final-preaudat = prdate.
*& ---------------  SOC FOR CREATION DATE ON 13/6/7 ----------------- &*

        LOOP AT itab_creation.
          it_final-erdat = itab_creation-udate.
          creadate = itab_creation-udate.
        ENDLOOP.
*& ----------------- EOC FOR CREATION DATE ON 13/6/7 ---------------- &*


*& ------------- SOC FOR PREAUDIT DATE ON 13/6/7 -------------------------------------- &*

        LOOP AT itab_preaudit.
**& --------- SOC FOR  SUBMITTED FOR  PREAUDIT DATE WITHIN SELETION DATE  ------------ &*
**          IF itab_preaudit-udate GT s_date-high OR itab_preaudit-udate LT s_date-low.
**            CLEAR itab_preaudit-udate.
**          ENDIF.
**& -------- EOC FOR  SUBMITTED FOR  PREAUDIT DATE WITHIN SELETION DATE -------------- &*

          it_final-preaudit = itab_preaudit-udate.
        ENDLOOP.
*& ------------- EOC FOR  PREAUDIT DATE ON 13/6/7 -------------------------------------- &*


        IF prdate IS NOT INITIAL AND creadate IS NOT INITIAL.

          CALL FUNCTION 'HR_SGPBS_YRS_MTHS_DAYS'
            EXPORTING
              beg_da              = creadate
              end_da              = prdate
           IMPORTING
*         NO_DAY              =
*         NO_MONTH            =
*         NO_YEAR             =
             no_cal_day          = days
           EXCEPTIONS
             dateint_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.
        ENDIF.

        CLEAR:  prdate,
                appldate,
                creadate.

        SELECT SINGLE zdays
                      text  FROM zadci INTO CORRESPONDING FIELDS OF zadci WHERE pspid = itab_proj-pspid.
        IF sy-subrc EQ 0 .


          it_final-differ = days - 1 - zadci-zdays.
          it_final-text = zadci-text.
        ELSE.
          IF zadci-zdays IS  INITIAL AND days NE 0.
            it_final-differ = days - 1.
          ENDIF.
        ENDIF.

        it_final-pspid = itab_proj-pspid.
        it_final-pspnr = itab_proj-pspnr.
*        IT_FINAL-POSID  = ITAB_PROJ-POSID .
*        it_final-erdat = itab_proj-erdat.
        it_final-ename = name.                              "13/06/07
        APPEND it_final.
        CLEAR: it_final,
               itab_proj,
               days,
               name.
      ENDIF.          " QUALITY/PRODUCTION  SERVER

    ENDLOOP.
  ENDIF.

*&  ------- delete records where approval date is not within the selection range.

  LOOP AT it_final.
    IF it_final-apprvdat = '00000000'.
      DELETE it_final INDEX sy-tabix.
    ENDIF.
  ENDLOOP.
ENDFORM.                    " data_fetch
*&---------------------------------------------------------------------*
*&      Form  DISPLAY
*&---------------------------------------------------------------------*
*       This subroutine is used to display the result
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM display .

  ULINE.
  FORMAT COLOR COL_HEADING.
  WRITE:       sy-vline,
             2  'EMPLOYEE',
            10  sy-vline,

            12  '  NAME  OF THE EMPLOYEE',

            42  sy-vline,
            43  'PROJECT DEFINITION',
            63  sy-vline,
            65  ' CREATION ',
            75  sy-vline,
            76  ' APPROVAL ',
            86  sy-vline,
            88  ' PREAUDIT ',
            100  sy-vline,
            102  'SUBMITTED FOR ',
            115  sy-vline,
            118  '  DIFFERENCE ',

            133  sy-vline,
            134  '   REASON   OF   ',
            155  sy-vline.

  WRITE: /1 sy-vline,
          2 ' NUMBER',
         10 sy-vline,
         42 sy-vline,
         63 sy-vline,
         67 'DATE(1)',
         75 sy-vline,
         78 'DATE(2)',
         86 sy-vline,
         90   'DATE(3)' ,
        100 sy-vline,
        104 'PREAUDIT',
        115 sy-vline,
        116 '[in days,(3 - 1)]',
        133 sy-vline,
        134 '    ADJUSMENT',
        155 sy-vline.

  ULINE.
*  SORT IT_FINAL BY ERNAM.            "  DEVELOPMENT SERVER
  SORT it_final BY pernr.            " QUALITY/PRODUCTION  SERVER
  LOOP AT it_final.
    CLEAR name.
    FORMAT COLOR COL_NORMAL.
*   WRITE:/2 IT_FINAL-Ernam,               "development server

    WRITE:/2 it_final-pernr,             " QUALITY/PRODUCTION  SERVER

          13 it_final-ename,

          44 it_final-pspid,

          64 it_final-erdat,

          76 it_final-apprvdat,

          88 it_final-preaudat,

         103 it_final-preaudit,

         115 it_final-differ,

         135 it_final-text.

    name = it_final-ename.            " CLP CLEAR ALL THE FIELDS EXCEPT AT NEW/END OF FIELD
**********************************************
    DATA: a1 TYPE string.
    DATA: a2 TYPE string.
    DATA: a3 TYPE string.
    DATA: a4 TYPE string.
    DATA: a5 TYPE string.
    DATA: a6 TYPE string.
    DATA: nam TYPE string.

    SPLIT name AT space INTO a1 a2 a3 a4 a5 a6.
    CONCATENATE a1 a2 a3 a4 a5 a6 INTO nam SEPARATED BY space.
**********************************************
    IF it_final-differ IS NOT INITIAL.
      count = count + 1.
      dep_count = dep_count + 1.
      add = add + it_final-differ.
      add_dept = add_dept  + it_final-differ.

    ENDIF.
    AT END OF pernr.      " QUALITY/PRODUCTION  SERVER

*    AT END OF ERNAM.        "  DEVELOPMENT SERVER
      empadci = add / count.
      FORMAT COLOR   COL_TOTAL INTENSIFIED ON  .
      ULINE.
      WRITE:/50 'EADCI OF ', it_final-pernr , ' ( ', nam, ')', '=' ,empadci.        " QUALITY/PRODUCTION  SERVER

*      WRITE:/100 'EADCI OF ', IT_FINAL-ERNAM ,'=' ,EMPADCI.        ""  DEVELOPMENT SERVER

      ULINE.
      count = 0.
      add = 0.
    ENDAT.

  ENDLOOP.
  ULINE.
  SKIP.

  deptadci = add_dept / dep_count.
  IF s_pernr IS  INITIAL.
    FORMAT COLOR   COL_GROUP .
    WRITE:/50 '  EADCI  OF CEG GROUP  = ', deptadci.
    SKIP.
    ULINE.
  ENDIF.

<i><b>Reward point for useful answer

Debjani Lahiri</b></i>

former_member235056
Active Contributor
0 Kudos
75

Hi,

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

*

  • 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

*

*

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: , .

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 .

ASSIGN ITAB-F_NEW(ITAB-OUTLEN) TO .

WRITE: / TEXT-023 UNDER 'Changes',

.

WRITE: / TEXT-024 UNDER 'Changes',

.

WHEN 'E'.

ASSIGN ITAB-F_OLD(ITAB-OUTLEN) TO .

WRITE: TEXT-023 UNDER 'Changes',

.

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.

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.

*

  • END OF PROGRAM

Pls reward points.

Regards,

Ameet