Application Development and Automation 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: 
Read only

Material desc.,

Former Member
0 Likes
715

Hi Frds

In my report im displaying Material Number and Material desc., of PR .

For Example

In PR 10 line items are there with different material code and different material desc.,In my output of the report ,im getting the first material desc., to all line items.

can anyone tell me how to get the different mateirla desc., of all line item .

Thanks

Pari Vendhan.R

4 REPLIES 4
Read only

Former Member
0 Likes
627

Hi,

Could you post your code here.

Regards.

Read only

0 Likes
627

Hi Akshay Raj

This my code ,correct my mistake ,

TABLES: ekko,ekpo,eban,mara,makt.

DATA : co_code1 LIKE ekko-bukrs, "Company Code

plant1 LIKE eban-werks, "Plant

pr_date1 LIKE eban-badat, "Purchase Requestion Date

pr_no1 like eban-banfn. "Purchase Number

selection-screen begin of block 01 with frame.

selection-screen begin of block 02 with frame title text-001.

SELECT-OPTIONS COMPANY FOR co_code1 obligatory.

SELECT-OPTIONS PLANT FOR plant1 obligatory.

SELECT-OPTIONS PR_DATE FOR pr_date1.

SELECT-OPTIONS PR_NO FOR pr_no1.

SELECTION-SCREEN END OF BLOCK 02.

SELECTION-SCREEN END OF BLOCK 01.

TYPE-POOLS: slis. "Declarations

*Internal table Declaration

data: BEGIN OF itab occurs 0,

banfn TYPE eban-banfn, "PURCHASE REQUESTIN NUMBER

badat TYPE eban-badat, "PURCHASE DATE

bnfpo TYPE eban-BNFPO, "LINE ITEM NO

matnr TYPE eban-matnr, "MATERIAL NUMBER

maktx TYPE makt-maktx, "MATERIAL DESCRIBE

txz01 type ekpo-txz01, "SHORT TEXT

ebeln TYPE eban-ebeln, "PURCHASE ORDER NUMBER

bedat TYPE ekko-bedat, "PURCHASE ORDER DATE

werks TYPE eban-werks, "PLANT

END OF itab.

data : begin of ieban occurs 0,

banfn like eban-banfn,

badat like eban-badat,

BNFPO like eban-BNFPO,

matnr like eban-matnr,

ebeln like eban-ebeln,

werks like eban-werks,

end of ieban.

data : begin of imakt occurs 0,

matnr like makt-matnr,

maktx like makt-maktx,

end of imakt.

data : begin of iekko occurs 0,

ebeln like ekko-ebeln,

bedat like ekko-bedat,

bukrs like ekko-bukrs,

end of iekko.

data : begin of iekpo occurs 0,

ebeln like ekpo-ebeln,

txz01 like ekpo-txz01,

end of iekpo.

*ALV data declarations

DATA:BODY TYPE SLIS_T_FIELDCAT_ALV,

HEADER TYPE SLIS_FIELDCAT_ALV,

gd_layout TYPE slis_layout_alv,

gd_repid LIKE sy-repid.

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

*Start-of-selection.

START-OF-SELECTION.

perform get_eban.

PERFORM get_ekko.

PERFORM get_ekpo.

perform get_makt.

perform data_retrieval.

PERFORM FIELDCATALOG.

perform build_layout.

PERFORM ALVDISPLAY.

&----


  • Build Fieldcatalog for Report

----


FORM fieldcatalog.

HEADER-COL_POS = '1'.

HEADER-SELTEXT_L = 'PR_NO'.

HEADER-TABNAME = 'ITAB'.

HEADER-FIELDNAME = 'BANFN'.

APPEND HEADER TO BODY.

CLEAR HEADER.

HEADER-COL_POS = '2'.

HEADER-SELTEXT_L = 'PR_DATE'.

HEADER-TABNAME = 'ITAB'.

HEADER-FIELDNAME = 'BADAT'.

APPEND HEADER TO BODY.

CLEAR HEADER.

HEADER-COL_POS = '3'.

HEADER-SELTEXT_L = 'LINE#'.

HEADER-TABNAME = 'ITAB'.

HEADER-FIELDNAME = 'BNFPO'.

APPEND HEADER TO BODY.

CLEAR HEADER.

HEADER-COL_POS = '4'.

HEADER-SELTEXT_L = 'MATERIAL_NO'.

HEADER-TABNAME = 'ITAB'.

HEADER-FIELDNAME = 'MATNR'.

APPEND HEADER TO BODY.

CLEAR HEADER.

HEADER-COL_POS = '5'.

HEADER-SELTEXT_L = 'MATERIAL_DESC'.

HEADER-TABNAME = 'ITAB'.

HEADER-FIELDNAME = 'TXZ01'.

APPEND HEADER TO BODY.

CLEAR HEADER.

HEADER-COL_POS = '6'.

HEADER-SELTEXT_L = 'PO_NUMBER'.

HEADER-TABNAME = 'ITAB'.

HEADER-FIELDNAME = 'EBELN'.

APPEND HEADER TO BODY.

CLEAR HEADER.

HEADER-COL_POS = '7'.

HEADER-SELTEXT_L = 'PO_DATE'.

HEADER-TABNAME = 'ITAB'.

HEADER-FIELDNAME = 'BEDAT'.

APPEND HEADER TO BODY.

CLEAR HEADER.

HEADER-COL_POS = '8'.

HEADER-SELTEXT_L = 'PLANT'.

HEADER-TABNAME = 'ITAB'.

HEADER-FIELDNAME = 'WERKS'.

APPEND HEADER TO BODY.

CLEAR HEADER.

ENDFORM. "build_fieldcatalog

&----


*& Form BUILD_LAYOUT

&----


  • Build layout for grid report

----


form build_layout.

gd_layout-no_input = 'X'.

gd_layout-colwidth_optimize = 'X'.

endform. " BUILD_LAYOUT

&----


*& Form DISPLAY_ALV_REPORT

&----


  • Display report using ALV grid

----


form ALVDISPLAY.

gd_repid = sy-repid.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = 'ZPRWISEPODETAILS'

  • i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM

  • i_callback_user_command = 'USER_COMMAND'

  • i_grid_title = outtext

is_layout = gd_layout

it_fieldcat = BODY

  • it_special_groups = gd_tabgroup

  • IT_EVENTS = GT_XEVENTS

i_save = 'X'

  • is_variant = z_template

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_REPORT

&----


*& Form DATA_RETRIEVAL

&----


  • Retrieve data form EKPO table and populate itab it_ekko

----


form data_retrieval.

sort ieban by badat banfn bnfpo.

loop at ieban.

loop at iekko where ebeln = ieban-ebeln.

itab-banfn = ieban-banfn.

itab-badat = ieban-badat.

at new ebeln.

itab-ebeln = ieban-ebeln.

endat.

itab-bedat = iekko-bedat.

itab-bnfpo = ieban-bnfpo.

itab-werks = ieban-werks.

itab-matnr = ieban-matnr.

read table iekpo with key ebeln = ieban-ebeln.

itab-txz01 = iekpo-txz01.

  • read table imakt with key matnr = ieban-matnr.

  • itab-maktx = imakt-maktx.

APPEND ITAB.

endloop.

ENDLOOP.

clear : itab.

clear : ieban, iekko, imakt.

endform. " DATA_RETRIEVAL

&----


*& Form get_eban

&----


  • text

----


form get_eban.

select banfn badat BNFPO matnr ebeln werks FROM eban into table ieban

where banfn in PR_NO and

badat in pr_date and

werks in plant and loekz = space.

if sy-subrc <> 0.

message 'No data Found for the selection ' type 'E'.

endif.

ENDFORM. "get_eban

&----


*& Form get_ekko

&----


  • text

----


form get_ekko.

select ebeln bedat bukrs from ekko into table IEKKO for all entries

IN ieban where ebeln = ieban-ebeln and bukrs in

COMPANY.

if sy-subrc <> 0.

message 'No data Found for the selection ' type 'E'.

endif.

ENDFORM. "get_ekko

&----


*& Form get_makt

&----


  • text

----


form get_makt.

select matnr maktx from makt into table imakt for all entries in

ieban where matnr = ieban-matnr.

endform. "get_makt

&----


*& Form get_ekpo

&----


  • text

----


form get_ekpo.

select ebeln txz01 FROM ekpo into table iekpo FOR ALL ENTRIES IN

iekko where ebeln = iekko-ebeln.

ENDFORM. "get_ekpo

Read only

dhruv_shah3
Active Contributor
0 Likes
627

Hi,

You should move the loop on the Child table so all the line items having mat description will apper.

HTH,

Regards,

Dhruv Shah

Read only

Former Member
0 Likes
627

Hi,

Check the below code...

loop at ieban.

loop at iekko where ebeln = ieban-ebeln.

itab-banfn = ieban-banfn.

itab-badat = ieban-badat.

at new ebeln.

itab-ebeln = ieban-ebeln.

endat.

itab-bedat = iekko-bedat.

itab-bnfpo = ieban-bnfpo.

itab-werks = ieban-werks.

itab-matnr = ieban-matnr.

read table iekpo with key ebeln = ieban-ebeln.

loop at iekpo where ebeln = ieban-ebeln.

itab-txz01 = iekpo-txz01.

APPEND ITAB.

endloop.

*read table imakt with key matnr = ieban-matnr.

*itab-maktx = imakt-maktx.

endloop.

ENDLOOP.

Rgds,

Bujji