Google

SAMPLE EXAMPLE FOR PURCHASE_ORDER_DETAILS

Purchase Oreder Details

REPORT zmmr_po

NO STANDARD PAGE HEADING

LINE-COUNT 27(3)

LINE-SIZE 80

MESSAGE-ID zmsg .

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

*PROGRAM ID: ZMMR_PO

*TITLE: PURCHASE ORDER DETAILS

*CREATION DATE: 06/09/2007

*AUTHOR: MARGANI SAMBASIVARAO

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

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

*DESCRIPTION:Interactive report to display the Purchase Order Details.

*The first page displays the basic list consist of Purchasing

*Organisation, Organisation Group and Net amount Total of the Purchase

*order for these combinations. In the secondary list the details of the

*purchase orders are displayed for the selected criteria. On selection

*of purchase order # transaction 'ME23n' is started skipping the first

*screen

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

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

*AUTHORITY CHECKS:

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


*-------------TABLES REQUIRED-----------------------------

TABLES : ekko,ekpo.


*-------------DECLARATION OF VARIABLES-----------


DATA: w_ebeln TYPE ekko-ebeln.

DATA: w_ekorg type ekko-ekorg.

DATA: w_ekgrp type ekko-ekgrp.

DATA : res TYPE i.


*-------------DECLARATION OF SELECTION CRITERIA-----------


SELECT-OPTIONS : s_ebeln FOR w_ebeln, "OBLIGATORY PURCHASE ORDER

"NO.

s_ekorg FOR ekko-ekorg, "OBLIGATORY "PURCHASING

"ORGANIZATION

s_ekgrp FOR ekko-ekgrp. "PURCHASING GROUP.


*-------------DEClERATION OF INTERNAL TABLES-------------


DATA : BEGIN OF i_ekko OCCURS 0,

ekorg LIKE ekko-ekorg,

ekgrp LIKE ekko-ekgrp,

netpr LIKE ekpo-netpr,

END OF i_ekko.


DATA : BEGIN OF i_ekpo OCCURS 0,

ebeln LIKE ekpo-ebeln,

ebelp LIKE ekpo-ebelp,

matnr LIKE ekpo-matnr,

txz01 LIKE ekpo-txz01,

menge LIKE ekpo-menge,

netpr LIKE ekpo-netpr,

END OF i_ekpo.


AT SELECTION-SCREEN.


PERFORM validate.

*-------POPULATING INTERNAL TABLE----------


START-OF-SELECTION.


SELECT DISTINCT ekko~ekorg ekko~ekgrp SUM( netpr )

INTO (i_ekko-ekorg , i_ekko-ekgrp , i_ekko-netpr)

FROM ekko

INNER JOIN ekpo ON ekko~ebeln = ekpo~ebeln

WHERE

ekko~ebeln IN s_ebeln AND

ekko~ekorg IN s_ekorg AND

ekko~ekgrp IN s_ekgrp

GROUP BY ekorg ekgrp.

APPEND i_ekko.

CLEAR i_ekko.


ENDSELECT.


IF sy-dbcnt = 0.

WRITE :/5 text-002.

ENDIF.

*-----------------------------------------------------------------

*TOP OF PAGE

TOP-OF-PAGE.

PERFORM header.


*-----------------------------------------------------------------

*END OF PAGE

END-OF-PAGE.

PERFORM footer.


*-----------------------------------------------------------------

*END OF SELECTION

END-OF-SELECTION.

PERFORM basic_list.


*AT LINE-SELECTION

TOP-OF-PAGE DURING LINE-SELECTION.


PERFORM s_header.


AT LINE-SELECTION.

IF sy-lsind = 1.

PERFORM second_list.

ELSE.

SET PARAMETER ID 'BES' FIELD sy-lisel+1(10).

CALL

TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.

ENDIF.


PERFORM s_list.

PERFORM s_footer.

*/////////// subroutines ////////////////////

FORM header.


WRITE:/5 sy-datum,

/5 sy-uzeit.

SKIP 1.

WRITE:/35 text-001.

SKIP.

FORMAT COLOR 1.

ULINE /1(60).

WRITE:/1 sy-vline,2 text-004,

20 sy-vline,21 text-005,

40 sy-vline,41 text-006,

60 sy-vline.

ULINE /1(60).


ENDFORM. " HEADER


*&---------------------------------------------------------------------*

*& Form FOOTER

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM footer.

ULINE /1(60).

WRITE:/ text-013,sy-pagno.


ENDFORM. " FOOTER


*&---------------------------------------------------------------------*

*& Form BASIC_LIST

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM basic_list.


SORT i_ekko BY ekorg ekgrp .

LOOP AT i_ekko.

*----COLOR STRIPS

res = sy-tabix MOD 2.


IF res = 0.

FORMAT INTENSIFIED ON COLOR 2.

ELSE.

FORMAT INTENSIFIED OFF COLOR 2.

ENDIF.


WRITE:/1 sy-vline,2 i_ekko-ekorg HOTSPOT ON,

20 sy-vline,21 i_ekko-ekgrp HOTSPOT ON,

40 sy-vline,41 i_ekko-netpr CURRENCY ekko-waers,

60 sy-vline.

HIDE: i_ekko-ekorg,i_ekko-ekgrp.

* FORMAT RESET.


ENDLOOP.

ULINE /1(60).


ENDFORM. " BASIC_LIST

*&---------------------------------------------------------------------*

*& Form SECOND_LIST

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM second_list.

SELECT DISTINCT ekpo~ebeln ekpo~ebelp ekpo~matnr ekpo~txz01 ekpo~menge

ekpo~netpr

INTO (i_ekpo-ebeln ,

i_ekpo-ebelp ,

i_ekpo-matnr ,

i_ekpo-txz01 ,

i_ekpo-menge ,

i_ekpo-netpr)

FROM ekko

INNER JOIN ekpo ON ekko~ebeln = ekpo~ebeln

WHERE

ekko~ekorg = i_ekko-ekorg AND

ekko~ekgrp = i_ekko-ekgrp.


APPEND i_ekpo.

CLEAR i_ekpo.


ENDSELECT.


ENDFORM. " SECOND_LIST

*&---------------------------------------------------------------------*

*& Form S_HEADER

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM s_header.

WRITE:/5 sy-datum,

/5 sy-uzeit.

SKIP 1.

WRITE:/35 text-001.

SKIP.

FORMAT COLOR 1.

ULINE /1(80).

WRITE:/1 sy-vline,2 text-007,

12 sy-vline,13 text-008,

27 sy-vline,28 text-009,

40 sy-vline,41 text-010,

55 sy-vline,56 text-011,

65 sy-vline,66 text-012,

80 sy-vline.

ULINE /1(80).

FORMAT RESET.

ENDFORM. " S_HEADER

*&---------------------------------------------------------------------*

*& Form S_LIST

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM s_list.

SORT i_ekpo BY ebeln .

LOOP AT i_ekpo.

*----COLOR STRIPS

res = sy-tabix MOD 2.


IF res = 0.

FORMAT INTENSIFIED ON COLOR 2.

ELSE.

FORMAT INTENSIFIED OFF COLOR 2.

ENDIF.

* ULINE /1(80).

WRITE:/1 sy-vline,2 i_ekpo-ebeln,

12 sy-vline,13 i_ekpo-ebelp,

27 sy-vline,28 i_ekpo-matnr,

40 sy-vline,41 i_ekpo-txz01,

55 sy-vline,56 i_ekpo-menge UNIT ekpo-meins LEFT-JUSTIFIED,

65 sy-vline,66 i_ekpo-netpr CURRENCY ekko-waers,

80 sy-vline.

HIDE i_ekpo-ebeln.

* FORMAT RESET.


ENDLOOP.

REFRESH i_ekpo.

ULINE /1(80).

ENDFORM. " S_LIST

*&---------------------------------------------------------------------*

*& Form S_FOOTER

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM s_footer.


ULINE /1(80).

WRITE:/ text-013,sy-pagno.


ENDFORM. " S_FOOTER

*&---------------------------------------------------------------------*

*& Form validate

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM validate.

w_ebeln = 0.

w_ekorg = 0.

*-----vALIDATE PO Number

SELECT ebeln INTO w_ebeln UP TO 1 ROWS FROM ekko

WHERE ebeln IN s_ebeln.

ENDSELECT.


IF sy-subrc <> 0.

MESSAGE e003.

ENDIF.


*----Validate Purchasing Organisation (Check Table T024E)

SELECT ekorg INTO w_ekorg UP TO 1 ROWS FROM t024e

WHERE ekorg IN s_ekorg.

ENDSELECT.


IF sy-subrc <> 0.

MESSAGE e003.

ENDIF.


*----Validate Purchasing Group (Check Table T024)

SELECT ekgrp INTO w_ekgrp UP TO 1 ROWS FROM t024

WHERE ekgrp IN s_ekgrp.

ENDSELECT.


IF sy-subrc <> 0.

MESSAGE e004.

ENDIF.


ENDFORM. " validate