Skip to Content
author's profile photo Former Member
Former Member

urgent: how to connect the following function module to the report.

function module: 'MERCHANDISE_GROUP_HIER_ART_SE'

i have the T023T-MATKL data in the final internal table. can any one x-plain me legibly about, how can i connect this function module to report reg the input and output parameters(where and how) as this is my first report development.

here i am attaching the code for reference.

please respond me at the earliest as today was my delivery date

----


  • Report : ZR_QLYQTY_PURCH_DETAILS *

  • Author : S.N.RAMCHARAN REDDY *

  • Application : MM *

  • Date created : 10/06/2008 *

  • Description : Report To Display Purchase Details Merchandise-Wise *

  • Request no. : DEVK903830 *

----


  • Modification history *

----


  • Request no. |DeliveryDate| Programmer | Description *

----


  • | | | *

----


REPORT ZR_QLYQTY_PURCH_DETAILS.

----


  • Tables

----


TABLES: MKPF, " Article Document Table: Header

MSEG, " Document Segment Table: Article

EKKO, " Purchasing Document Table: Header

MARA, " Material Master Table :General Article Data

T023T. " Merchandise Category Description

----


  • SELECTION SCREEN

----


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

PARAMETERS: P_CODE TYPE EKKO-BUKRS OBLIGATORY, " company code

P_BSART TYPE EKKO-BSART OBLIGATORY, " purchase order document type

P_MTART TYPE MARA-MTART OBLIGATORY. " article type

SELECT-OPTIONS S_BUDAT FOR MKPF-BUDAT OBLIGATORY. " date

SELECTION-SCREEN END OF BLOCK B1.

----


  • Structures and Internal tables (DECLARETIONS)

----


TYPES:BEGIN OF ST_MARA1,

MATNR TYPE MARA-MATNR, " Article Number

MTART TYPE MARA-MTART, " Article Type

MATKL TYPE MARA-MATKL, " Merchandise Category

END OF ST_MARA1.

TYPES: BEGIN OF ST_ST2,

MATNR TYPE WB2_V_MKPF_MSEG2-MATNR_I, " Article Number

ZEILE TYPE WB2_V_MKPF_MSEG2-ZEILE_I, " Item in Article Document

EBELN TYPE WB2_V_MKPF_MSEG2-EBELN_I, " Purchase Order Number

BWART TYPE WB2_V_MKPF_MSEG2-BWART_I, " Movement Type

MENGE TYPE WB2_V_MKPF_MSEG2-MENGE_I, " Quantity

DMBTR TYPE WB2_V_MKPF_MSEG2-DMBTR_I, " Amount in Local Currency

END OF ST_ST2.

TYPES:BEGIN OF ST_EKKO3,

EBELN TYPE EKKO-EBELN, " purchase order number

END OF ST_EKKO3.

TYPES:BEGIN OF ST_T023T4,

MATKL TYPE T023T-MATKL, " Merchandise Category

WGBEZ TYPE T023T-WGBEZ, " Merchandise Category DESCRIPTION

END OF ST_T023T4.

TYPES:BEGIN OF ST_MSEG5,

BWART TYPE MSEG-BWART, " Movement Type

DMBTR TYPE MSEG-DMBTR, " Amount in local currency

MENGE TYPE MSEG-MENGE, " Quantity

END OF ST_MSEG5.

TYPES: BEGIN OF ST_FINAL,

MATNR TYPE MARA-MATNR,

MTART TYPE MARA-MTART,

WGBEZ TYPE T023T-WGBEZ, " Merchandise Category DESCRIPTION

MENGE TYPE I, " Quantity

DMBTR TYPE MSEG-DMBTR, " Amount in local currency

END OF ST_FINAL.

TYPES:TT_MARA1 TYPE TABLE OF ST_MARA1,

TT_ST2 TYPE TABLE OF ST_ST2,

TT_EKKO3 TYPE TABLE OF ST_EKKO3,

TT_T023T4 TYPE TABLE OF ST_T023T4,

TT_MSEG5 TYPE TABLE OF ST_MSEG5,

TT_FINAL TYPE TABLE OF ST_FINAL.

DATA:WA_MARA1 TYPE ST_MARA1,

WA_ST2 TYPE ST_ST2,

WA_EKKO3 TYPE ST_EKKO3,

WA_T023T4 TYPE ST_T023T4,

WA_MSEG5 TYPE ST_MSEG5,

WA_FINAL TYPE ST_FINAL,

WA_FINAL1 TYPE ST_FINAL.

DATA:IT_MARA1 TYPE TT_MARA1,

IT_ST2 TYPE TT_ST2,

IT_EKKO3 TYPE TT_EKKO3,

IT_T023T4 TYPE TT_T023T4,

IT_MSEG5 TYPE TT_MSEG5,

IT_FINAL TYPE TT_FINAL,

IT_FINAL1 TYPE TT_FINAL.

DATA:V_BSART TYPE BSART,

V_MTART TYPE MTART.

----


  • Decalring Data Area for List viewer... *

----


TYPE-POOLS: SLIS.

DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

FIELDCAT_LN LIKE LINE OF FIELDCAT,

EVENTCAT TYPE SLIS_T_EVENT,

EVENTCAT_LN LIKE LINE OF EVENTCAT.

DATA: COL_POS TYPE I VALUE 0.

*INITIALIZATION.

----


  • Building Field Catelogs.

----


PERFORM BUILD_FIELDCAT.

PERFORM BUILD_FIELDCAT2.

PERFORM BUILD_FIELDCAT3.

PERFORM REPORT_HEADING.

PERFORM TOPOFPAGE.

START-OF-SELECTION.

PERFORM GETDATA.

----


  • Start List Viewer.

----


END-OF-SELECTION.

PERFORM START_LIST_VIEWER.

&----


*& Form VALIDATION

&----


  • text

----


FORM VALIDATION.

SELECT SINGLE BUKRS FROM T001

INTO P_CODE

WHERE BUKRS EQ P_CODE.

IF SY-SUBRC NE 0.

MESSAGE 'Enter a valid company code' TYPE 'E'.

ENDIF.

  • SELECT SINGLE BUDAT FROM MKPF

  • INTO S_BUDAT

  • WHERE BUDAT IN S_BUDAT.

  • IF sy-subrc NE 0.

  • MESSAGE 'Enter valid DATE' TYPE 'E'.

  • ENDIF.

SELECT SINGLE BSART FROM T161

INTO V_BSART

WHERE BSART = P_BSART.

IF NOT ( V_BSART = 'ZWM' OR V_BSART = 'ZWP' OR

V_BSART = 'ZWPP' OR V_BSART = 'ZWR' ).

  • IF sy-subrc NE 0.

MESSAGE 'Enter valid PURCHASE ORDER DOCUMENT TYPE' TYPE 'E'.

ENDIF.

SELECT SINGLE MTART FROM MARA

INTO V_MTART

WHERE MTART = P_MTART.

IF SY-SUBRC NE 0.

MESSAGE 'Enter valid Article type' TYPE 'E'.

ENDIF.

ENDFORM. "VALIDATION

&----


*& Form GETDATA

&----


----


  • Selection into Internal Table

----


FORM GETDATA.

*S1 retrieving Article Number and Merchandise Category with referene to the article TYPE.

SELECT MATNR

MTART

MATKL

FROM MARA

INTO TABLE IT_MARA1

WHERE MTART = P_MTART.

  • IF SY-SUBRC NE 0.

  • WRITE /'Article Number and Merchandise Category does not exist

  • with referene to the given Article TYPE'.

  • endif.

*S2 retrieving Article Number,Item in Article Document,PO Number,Movement Type,Quantity and

Amount in Local Currency from the structure WB2_V_MKPF_MSEG2**

*with reference to company code,date, movement types '101','102' and the document type 'we'.

IF NOT IT_MARA1[] IS INITIAL.

SELECT MATNR_I

ZEILE_I

EBELN_I

BWART_I

MENGE_I

DMBTR_I

FROM WB2_V_MKPF_MSEG2

INTO TABLE IT_ST2

FOR ALL ENTRIES IN IT_MARA1

WHERE BUKRS_I = P_CODE

AND MATNR_I = IT_MARA1-MATNR

AND BUDAT IN S_BUDAT

AND ( BWART_I = '101' OR BWART_I = '102' )

AND BLART = 'WE'.

  • IF SY-SUBRC NE 0.

  • WRITE /''.

  • endif.

ENDIF.

*S3 retrieving the PO document number with reference to

  • material document number and PO document type.

IF NOT IT_ST2[] IS INITIAL.

SELECT EBELN

FROM EKKO

INTO TABLE IT_EKKO3

FOR ALL ENTRIES IN IT_ST2

WHERE EBELN = IT_ST2-EBELN

AND BSART =

P_BSART.

  • IF SY-SUBRC NE 0.

  • WRITE /'check '.

  • endif.

ENDIF.

  • *** PO number and PO document number are the same.****

*S4 Retrieving (Merchandise Category and) 1.Merchandise Category Description

  • with ref. to Merchandise Category.

IF NOT IT_MARA1[] IS INITIAL.

SELECT MATKL

WGBEZ

FROM T023T

INTO TABLE IT_T023T4

FOR ALL ENTRIES IN IT_MARA1

WHERE MATKL = IT_MARA1-MATKL.

ENDIF.

SORT IT_ST2 BY MATNR. " sorting IT_ST2 using the article number.

SORT IT_EKKO3 BY EBELN. " sorting IT_EKKO3 using PO number.

SORT IT_MARA1 BY MATNR. " sortinf IT_MARA1 using article number.

LOOP AT IT_EKKO3 INTO WA_EKKO3.

LOOP AT IT_ST2 INTO WA_ST2 WHERE EBELN = WA_EKKO3-EBELN.

  • IF SY-SUBRC = 0.

WA_FINAL1-MATNR = WA_ST2-MATNR. " article number.

  • ENDIF.

READ TABLE IT_MARA1 INTO WA_MARA1 WITH KEY MATNR = WA_ST2-MATNR.

IF SY-SUBRC = 0.

READ TABLE IT_T023T4 INTO WA_T023T4 WITH KEY MATKL = WA_MARA1-MATKL.

IF SY-SUBRC = 0.

WA_FINAL1-MTART = WA_MARA1-MTART. " article type.

WA_FINAL1-WGBEZ = WA_T023T4-WGBEZ. " merchantise description.

ENDIF.

ENDIF.

IF WA_ST2-BWART = '101'.

WA_FINAL1-MENGE = WA_FINAL1-MENGE + WA_ST2-MENGE. " Quantity.

WA_FINAL1-DMBTR = WA_FINAL1-DMBTR + WA_ST2-DMBTR. " Amount in localcurrency.

ELSE.

WA_FINAL1-MENGE = WA_FINAL1-MENGE - WA_ST2-MENGE.

WA_FINAL1-DMBTR = WA_FINAL1-DMBTR - WA_ST2-DMBTR.

ENDIF.

  • AT END OF MATNR.

APPEND WA_FINAL1 TO IT_FINAL1.

CLEAR WA_FINAL1.

  • ENDAT.

CLEAR: WA_ST2, WA_MARA1, WA_T023T4.

ENDLOOP.

ENDLOOP.

SORT IT_FINAL1 BY MTART.

LOOP AT IT_FINAL1 INTO WA_FINAL1.

WA_FINAL-MTART = WA_FINAL1-MTART.

WA_FINAL-MENGE = WA_FINAL-MENGE + WA_FINAL1-MENGE.

WA_FINAL-WGBEZ = WA_FINAL1-WGBEZ.

WA_FINAL-DMBTR = WA_FINAL-DMBTR + WA_FINAL1-DMBTR.

AT END OF MTART.

COLLECT WA_FINAL INTO IT_FINAL.

CLEAR: WA_FINAL.

ENDAT.

ENDLOOP.

ENDFORM. "GETDATA

&----


*& Form REPORT_HEADING

&----


FORM REPORT_HEADING .

EVENTCAT_LN-NAME = 'TOP_OF_PAGE'.

EVENTCAT_LN-FORM = 'TOPOFPAGE'.

APPEND EVENTCAT_LN TO EVENTCAT.

CLEAR EVENTCAT_LN.

ENDFORM. " REPORT_HEADING

&----


*& Form TOPOFPAGE

&----


FORM TOPOFPAGE.

DATA: PO_LINE TYPE SLIS_LISTHEADER,

PO_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,

V_DATE1(10) TYPE C,

V_DATE2(10) TYPE C,

V_FINAL1(10) TYPE C,

V_FINAL(30) TYPE C.

CONCATENATE S_BUDAT-LOW6(2) S_BUDAT-LOW4(2) S_BUDAT-LOW+0(4) INTO V_DATE1 SEPARATED BY'-'.

IF S_BUDAT-HIGH IS INITIAL.

*CLEAR: V_FINAL,V_FINAL1.

MOVE V_DATE1 TO V_FINAL1.

V_FINAL = V_FINAL1.

ELSE.

*CLEAR V_FINAL.

CONCATENATE S_BUDAT-HIGH6(2) S_BUDAT-HIGH4(2) S_BUDAT-HIGH+0(4) INTO V_DATE2 SEPARATED BY'-'.

CONCATENATE V_DATE1 'TO' V_DATE2 INTO V_FINAL SEPARATED BY ' '.

ENDIF.

CLEAR PO_LINE.

PO_LINE-TYP = 'H'.

PO_LINE-INFO = TEXT-002.

PO_LINE-KEY = 'REPORT :'.

APPEND PO_LINE TO PO_TOP_OF_PAGE.

CLEAR PO_LINE.

PO_LINE-TYP = 'S'.

PO_LINE-KEY = 'Company Code :'.

PO_LINE-INFO = P_CODE.

APPEND PO_LINE TO PO_TOP_OF_PAGE.

CLEAR PO_LINE.

PO_LINE-TYP = 'S'.

PO_LINE-KEY = 'PO Document Type :'.

PO_LINE-INFO = P_BSART.

APPEND PO_LINE TO PO_TOP_OF_PAGE.

CLEAR PO_LINE.

PO_LINE-TYP = 'S'.

PO_LINE-KEY = 'Article Type :'.

PO_LINE-INFO = P_MTART.

APPEND PO_LINE TO PO_TOP_OF_PAGE.

CLEAR PO_LINE.

PO_LINE-TYP = 'S'.

PO_LINE-KEY = 'Date :'.

PO_LINE-INFO = V_FINAL.

APPEND PO_LINE TO PO_TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = PO_TOP_OF_PAGE.

ENDFORM. "TOPOFPAGE

&----


*& Form BUILD_FIELDCAT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM BUILD_FIELDCAT .

ADD 1 TO COL_POS.

FIELDCAT_LN-TABNAME = 'IT_FINAL'.

FIELDCAT_LN-FIELDNAME = 'WGBEZ'.

  • FIELDCAT_LN-KEY = 'X'.

FIELDCAT_LN-COL_POS = COL_POS.

  • FIELDCAT_LN-HOTSPOT = 'X'.

FIELDCAT_LN-OUTPUTLEN = '24'.

FIELDCAT_LN-SELTEXT_M = 'MERCHANDISE CATEGORY DESC.'.

APPEND FIELDCAT_LN TO FIELDCAT.

ENDFORM. "BUILD_FIELDCAT

&----


*& Form BUILD_FIELDCAT2

&----


  • text

----


FORM BUILD_FIELDCAT2.

ADD 1 TO COL_POS.

FIELDCAT_LN-TABNAME = 'IT_FINAL'.

FIELDCAT_LN-FIELDNAME = 'MENGE'.

FIELDCAT_LN-DO_SUM = 'X'.

FIELDCAT_LN-COL_POS = COL_POS.

  • FIELDCAT_LN-HOTSPOT = 'X'.

FIELDCAT_LN-OUTPUTLEN = '15'.

FIELDCAT_LN-SELTEXT_M = 'QUANTITY'.

APPEND FIELDCAT_LN TO FIELDCAT.

ENDFORM. "BUILD_FIELDCAT2

&----


*& Form BUILD_FIELDCAT3

&----


  • text

----


FORM BUILD_FIELDCAT3.

ADD 1 TO COL_POS.

FIELDCAT_LN-TABNAME = 'IT_FINAL'.

FIELDCAT_LN-FIELDNAME = 'DMBTR'.

FIELDCAT_LN-DO_SUM = 'X'.

FIELDCAT_LN-COL_POS = COL_POS.

  • FIELDCAT_LN-HOTSPOT = 'X'.

FIELDCAT_LN-OUTPUTLEN = '20'.

FIELDCAT_LN-SELTEXT_M = 'AMOUNT IN LOCAL CURRENCY'.

APPEND FIELDCAT_LN TO FIELDCAT.

ENDFORM. "BUILD_FIELDCAT3

&----


*& Form START_LIST_VIEWER

&----


  • text

----


FORM START_LIST_VIEWER.

DATA: PGM LIKE SY-REPID.

PGM = SY-REPID.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = PGM

IT_FIELDCAT = FIELDCAT

IT_EVENTS = EVENTCAT

TABLES

T_OUTTAB = IT_FINAL.

ENDFORM. "START_LIST_VIEWER

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 08:05 AM

    hi check this..

    first see what r the inputs that had to be given into the function module ..and see what r the out puts that we need to take it...then pass the input of the function module from the program and get the out put of the function module to the program by declaring the same variables in the program as well in the function mdoule...

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.