cancel
Showing results for 
Search instead for 
Did you mean: 

querry

Former Member
0 Kudos

Hi Expert,

I am selecting layout in selection screen itself.

I have given all functionality an my code.

But when i select that layout it is not picking.

So plz tell me where am i wrong.

Here is my code.

REPORT ZGMMRP0034 LINE-SIZE 255 NO STANDARD PAGE HEADING

MESSAGE-ID z01.

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

  • Program Name : ZGMMRP0034 *

  • Created on : 05.06.2007 *

  • Created by : sandeep Garg

*

  • Change request : TP1K986685 *

  • Application Module : MM *

  • Release : 4.6C *

  • Description : Program display's information related to

  • : Material Master Import Codes

  • : This Report uses ALV. *

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

*REPORT AQZZZGU_MM_001==ZGQ_MM_IM_019=

TABLES:marc, "Plant Data for Material

makt, "Material Descriptions

mara, "General Material Data

ekko, "Purchasing Document Header

EKPO, "Purchasing Document Item

t604, "Foreign Trade: Commodity Code

lfa1, "Vendor Master

t023t, "Material Group Descriptions

t001w, "Plants/Branches

cdpos, "Change document items

cdhdr. "Change document header

TYPE-POOLS: slis.

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

SELECT-OPTIONS:

s_werks FOR marc-werks, "Plant

s_spras FOR makt-spras, "Language Key

s_matnr FOR mara-matnr, "Material Number

s_ersda FOR mara-ersda, "Material Creation Date

s_vpsta FOR mara-vpsta, "Maintenance Status

s_matkl FOR mara-matkl, "Material Group

s_land1 FOR t604-land1, "Country Key

s_stawn FOR marc-stawn, "Commodity Code

s_wgbez FOR t023t-wgbez, "Text: Material group

s_ebeln FOR ekko-ebeln, "Purchase order

s_aedat FOR ekko-ebeln, "Creation Date

s_lifnr FOR ekko-lifnr. "Vendor

SELECTION-SCREEN END OF BLOCK block1.

*******sandeep for list view.********

SELECTION-SCREEN BEGIN OF BLOCK 2 WITH FRAME TITLE TEXT-019.

PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT.

SELECTION-SCREEN END OF BLOCK 2.

*******sandeep for list view.********

DATA: BEGIN OF itab_mara OCCURS 0,

matnr LIKE mara-matnr,

mfrpn LIKE mara-mfrpn,

mfrnr LIKE mara-mfrnr,

matkl LIKE mara-matkl,

werks LIKE marc-werks,

stawn LIKE marc-stawn,

mtver LIKE marc-mtver,

herkl LIKE marc-herkl,

maktx LIKE makt-maktx,

END OF itab_mara.

DATA: BEGIN OF itab_t023t OCCURS 0,

matkl LIKE t023t-matkl,

wgbez LIKE t023t-wgbez,

END OF itab_t023t.

*DATA: BEGIN OF itab_ekpo OCCURS 0,

  • ebeln LIKE ekpo-ebeln,

  • matnr LIKE ekpo-matnr,

  • END OF itab_ekpo.

*DATA: ITAB_EKPO TYPE STANDARD TABLE OF EKPO WITH HEADER LINE.

DATA: BEGIN OF itab_ekpo OCCURS 0,

ebeln LIKE ekpo-ebeln,

matnr LIKE ekpo-matnr,

lifnr LIKE ekko-lifnr,

END OF itab_ekpo.

DATA: BEGIN OF itab_lfa1 OCCURS 0,

lifnr LIKE lfa1-lifnr,

name1 LIKE lfa1-name1,

END OF itab_lfa1.

DATA: BEGIN OF itab_t604 OCCURS 0,

stawn LIKE t604-stawn,

text1 LIKE T604T-text1,

END OF itab_t604.

DATA: BEGIN OF itab_cdpos OCCURS 0,

objectclas LIKE cdpos-objectclas,

objectid TYPE cdpos-objectid,

changenr TYPE cdpos-CHANGENR,

END OF itab_cdpos.

DATA: BEGIN OF itab_cdhdr OCCURS 0,

changenr LIKE cdhdr-changenr,

username LIKE cdhdr-username,

udate LIKE cdhdr-udate,

OBJECTID like CDHDR-OBJECTID,

END OF itab_cdhdr.

*DATA:BEGIN OF itab_makt OCCURS 0,

  • maktx LIKE makt-maktx,

  • END OF itab_makt.

DATA: BEGIN OF itab_final OCCURS 0,

werks LIKE marc-werks,

stawn LIKE marc-stawn,

mtver LIKE marc-mtver,

herkl LIKE marc-herkl,

matnr LIKE mara-matnr,

mfrpn LIKE mara-mfrpn,

mfrnr LIKE mara-mfrnr,

matkl LIKE mara-matkl,

ebeln LIKE ekpo-ebeln,

lifnr LIKE ekko-lifnr,

name1 LIKE lfa1-name1,

  • stawn LIKE t604-stawn,

text1 LIKE T604T-text1,

maktx LIKE makt-maktx,

wgbez LIKE t023t-wgbez,

changenr LIKE cdhdr-changenr,

username LIKE cdhdr-username,

udate LIKE cdhdr-udate,

END OF itab_final.

*

**DATA: wa_marc LIKE itab_marc.

*DATA: wa_mara LIKE itab_mara.

*DATA: wa_ekko LIKE itab_ekko.

*DATA: wa_ekpo LIKE itab_ekpo.

*DATA: wa_lfa1 LIKE itab_lfa1.

*DATA: wa_t604 LIKE itab_t604.

**DATA: wa_makt LIKE itab_makt.

  • DATA:ve_ausw TYPE c,

  • ve_lines TYPE i.

DATA: fieldcat TYPE slis_t_fieldcat_alv,

fieldcat_ln LIKE LINE OF fieldcat.

DATA : col_pos TYPE i.

DATA: G_REPID LIKE SY-REPID,

G_SAVE(1) TYPE C,

GX_VARIANT LIKE DISVARIANT,

G_VARIANT LIKE DISVARIANT,

G_EXIT(1) TYPE C.

********VALIDATION***************

INITIALIZATION.

G_REPID = SY-REPID.

G_SAVE = 'A'.

AT SELECTION-SCREEN ON s_werks.

IF s_werks-low <> space.

SELECT SINGLE * from T001W

WHERE werks = s_werks-low.

IF sy-subrc <> 0.

MESSAGE e011 WITH 'Invalid Plant Code'

s_werks-low '' ''.

ENDIF.

ENDIF.

IF s_werks-high <> space.

SELECT SINGLE * from T001W

WHERE werks = s_werks-high.

IF sy-subrc <> 0.

MESSAGE e011 WITH 'Invalid Plant Code'

s_werks-high '' ''.

ENDIF.

ENDIF.

AT SELECTION-SCREEN ON s_matnr.

IF s_matnr-low <> space.

SELECT single * from MARA

WHERE matnr = s_matnr-low.

IF sy-subrc <> 0.

MESSAGE e011 WITH 'Invalid Material number'

s_matnr '' ''.

ENDIF.

ENDIF.

IF s_matnr-high <> space.

SELECT single * from MARA

WHERE matnr = s_matnr-high.

IF sy-subrc <> 0.

MESSAGE e011 WITH 'Invalid Material number'

s_matnr-high '' ''.

ENDIF.

ENDIF.

START-OF-SELECTION.

PERFORM extract_data.

END-OF-SELECTION.

PERFORM build_print.

PERFORM build_fieldcat.

PERFORM start_list_viewer.

*********SANDEEP LIST VIEWER*********

PERFORM VARIANT_INIT.

  • Get default variant

GX_VARIANT = G_VARIANT.

CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

EXPORTING

I_SAVE = G_SAVE

CHANGING

CS_VARIANT = GX_VARIANT

EXCEPTIONS

NOT_FOUND = 2.

IF SY-SUBRC = 0.

P_VARI = GX_VARIANT-VARIANT.

ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.

PERFORM F4_FOR_VARIANT.

AT SELECTION-SCREEN.

PERFORM PAI_OF_SELECTION_SCREEN.

  • ********** END SANDEEP LIST VIEWER**********

----


  • FORM extract_data *

----


  • ........ *

----


FORM extract_data.

SELECT a~matnr a~mfrpn a~mfrnr a~matkl

b~werks b~stawn b~mtver b~herkl

c~maktx

INTO corresponding fields of table itab_mara

FROM ( mara

as a

INNER JOIN marc as b

on a~matnr = b~matnr )

INNER JOIN makt as c

on a~matnr = c~matnr

WHERE werks IN s_werks

AND a~matnr IN s_matnr

AND b~stawn IN s_stawn

AND a~ersda IN s_ersda

AND a~matkl IN s_matkl

AND c~spras IN s_spras.

clear: itab_mara.

  • SELECT ebeln matnr

  • INTO CORRESPONDING FIELDS OF table itab_ekpo

  • from ekpo

  • FOR ALL ENTRIES IN itab_mara

  • WHERE matnr = itab_mara-matnr.

*

  • DELETE ADJACENT DUPLICATES FROM itab_ekpo.

*

  • SELECT lifnr ebeln

  • INTO table itab_ekko

  • from ekko

  • FOR ALL ENTRIES IN itab_ekpo

  • WHERE ebeln = itab_ekpo-ebeln.

SELECT wgbez matkl

INTO table itab_t023t

FROM t023t

FOR ALL ENTRIES IN itab_mara

WHERE matkl = itab_mara-matkl

AND wgbez IN s_wgbez.

SELECT a~ebeln a~matnr b~lifnr

INTO CORRESPONDING FIELDS OF table itab_ekpo

from ekpo as a

INNER JOIN ekko as b

ON a~ebeln = b~ebeln

FOR ALL ENTRIES IN itab_mara

WHERE a~matnr = itab_mara-matnr.

sort itab_mara.

SELECT lifnr name1

INTO table itab_lfa1

FROM lfa1

FOR ALL ENTRIES IN itab_mara

WHERE lifnr = itab_mara-mfrnr

OR lifnr = itab_ekpo-lifnr.

  • sort itab_ekko.

  • SELECT lifnr name1

  • appending table itab_lfa1

  • FROM LFA1

  • FOR ALL ENTRIES IN itab_ekko

  • WHERE lifnr = itab_ekko-lifnr.

*

sort itab_lfa1.

SELECT astawn btext1

INTO table itab_t604

FROM t604 as a

INNER JOIN t604t as b

on astawn = bstawn

FOR ALL ENTRIES IN itab_mara

WHERE a~stawn = itab_mara-stawn.

  • SELECT maktx

  • INTO table itab_makt

  • FROM makt

  • FOR ALL ENTRIES IN itab_mara

  • WHERE matnr = itab_mara-matnr.

*loop at itab_mara.

*DATA: field(10) type c.

  • REPLACE itab_mara-matnr with ' ' INTO field.

  • field1 = CONDENSE field NO-GAPS.

  • ENDLOOP.

*

SELECT objectclas objectid changenr

INTO TABLE itab_cdpos

from cdpos

WHERE TABNAME = 'MARC'

AND FNAME = 'STAWN'

AND OBJECTID IN S_MATNR.

IF sy-subrc = 0.

SELECT changenr username udate OBJECTID

INTO TABLE itab_cdhdr

FROM cdhdr

FOR ALL ENTRIES IN itab_cdpos

WHERE changenr = itab_cdpos-changenr

AND OBJECTCLAS = itab_cdpos-objectclas

AND objectid = itab_cdpos-objectid.

*sort itab_cdhdr descending by udate.

ENDIF.

ENDFORM.

FORM build_print.

LOOP AT itab_mara ."into wa_mara.

itab_final-matnr = itab_mara-matnr.

itab_final-mfrpn = itab_mara-mfrpn.

itab_final-mfrnr = itab_mara-mfrnr.

itab_final-matkl = itab_mara-matkl.

itab_final-werks = itab_mara-werks.

itab_final-stawn = itab_mara-stawn.

itab_final-mtver = itab_mara-mtver.

itab_final-herkl = itab_mara-herkl.

itab_final-maktx = itab_mara-maktx.

READ TABLE itab_t023t with key matkl = itab_final-matkl.

itab_final-wgbez = itab_t023t-wgbez.

READ TABLE itab_ekpo with key matnr = itab_final-matnr.

itab_final-ebeln = itab_ekpo-ebeln.

itab_final-lifnr = itab_ekpo-lifnr.

  • READ TABLE itab_ekko with key ebeln = itab_ekpo-ebeln.

  • itab_final-lifnr = itab_ekko-lifnr.

READ TABLE itab_lfa1 with key lifnr = itab_ekpo-lifnr.

  • itab_final-lifnr = itab_lfa1-lifnr.

itab_final-name1 = itab_lfa1-name1.

READ TABLE itab_t604 WITH KEY stawn = itab_mara-stawn.

itab_final-text1 = ITAB_t604-text1.

  • LOOP AT ITAB_CDPOS.

READ TABLE itab_cdhdr WITH KEY OBJECTID = itab_MARA-MATNR.

itab_final-username = itab_cdhdr-username.

itab_final-udate = itab_cdhdr-udate.

APPEND itab_final.

ENDLOOP.

ENDFORM.

FORM start_list_viewer.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = G_REPID

IT_FIELDCAT = fieldcat

I_DEFAULT = 'X'

I_SAVE = G_SAVE

  • IT_EVENTS = itab_eventcat

IS_VARIANT = G_VARIANT

TABLES

T_OUTTAB = itab_final

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.

FORM build_fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'MARC'.

fieldcat_ln-ref_fieldname = 'WERKS'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'WERKS'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-003.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 04.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'MARA'.

fieldcat_ln-ref_fieldname = 'MATNR'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'MATNR'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-004.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 18.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'MAKT'.

fieldcat_ln-ref_fieldname = 'MAKTX'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'MAKTX'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-005.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 40.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'MARA'.

fieldcat_ln-ref_fieldname = 'MATKL'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'MATKL'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-006.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 09.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'T023T'.

fieldcat_ln-ref_fieldname = 'WGBEZ'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'WGBEZ'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-007.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 20.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'MARA'.

fieldcat_ln-ref_fieldname = 'MFRPN'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'MFRPN'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-008.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 40.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'MARA'.

fieldcat_ln-ref_fieldname = 'MFRNR'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'MFRNR'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-009.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 10.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'LFA1'.

fieldcat_ln-ref_fieldname = 'NAME1'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'NAME1'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-010.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 35.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'MARC'.

fieldcat_ln-ref_fieldname = 'MTVER'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'MTVER'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-011.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 04.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'EKPO'.

fieldcat_ln-ref_fieldname = 'EBELN'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'EBELN'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-012.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 10.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'EKKO'.

fieldcat_ln-ref_fieldname = 'LIFNR'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'LIFNR'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-013.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 10.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'MARC'.

fieldcat_ln-ref_fieldname = 'HERKL'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'HERKL'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-014.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 3.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'CDHDR'.

fieldcat_ln-ref_fieldname = 'USERNAME'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'USERNAME'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-017.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 12.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'CDHDR'.

fieldcat_ln-ref_fieldname = 'UDATE'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'UDATE'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-018.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 08.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'MARC'.

fieldcat_ln-ref_fieldname = 'STAWN'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'STAWN'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-015.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 17.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'TEXT1'.

fieldcat_ln-ref_fieldname = 'T604T'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'T604T'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-016.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 40.

APPEND fieldcat_ln TO fieldcat.

ENDFORM.

**********SANDEEP LIST VIEWER*********

FORM F4_FOR_VARIANT.

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

IS_VARIANT = G_VARIANT

I_SAVE = G_SAVE

  • I_DISPLAY_VIA_GRID = ' '

IMPORTING

E_EXIT = G_EXIT

ES_VARIANT = GX_VARIANT

EXCEPTIONS

NOT_FOUND = 1 .

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ELSE.

IF G_EXIT = SPACE.

P_VARI = GX_VARIANT-VARIANT.

ENDIF.

ENDIF.

ENDFORM.

FORM PAI_OF_SELECTION_SCREEN.

*

IF NOT P_VARI IS INITIAL.

MOVE G_VARIANT TO GX_VARIANT.

MOVE P_VARI TO GX_VARIANT-VARIANT.

CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'

EXPORTING

I_SAVE = G_SAVE

CHANGING

CS_VARIANT = GX_VARIANT.

G_VARIANT = GX_VARIANT.

ELSE.

PERFORM VARIANT_INIT.

ENDIF.

ENDFORM. "PAI_OF_SELECTION_SCREEN

FORM VARIANT_INIT.

*

CLEAR G_VARIANT.

G_VARIANT-REPORT = G_REPID.

ENDFORM. " VARIANT_INIT

Thanks,

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello ,

See the bold one code and you need to use under initilization event.

REPORT ZGMMRP0034 LINE-SIZE 255 NO STANDARD PAGE HEADING

MESSAGE-ID z01.

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

  • Program Name : ZGMMRP0034 *

  • Created on : 05.06.2007 *

  • Created by : sandeep Garg

*

  • Change request : TP1K986685 *

  • Application Module : MM *

  • Release : 4.6C *

  • Description : Program display's information related to

  • : Material Master Import Codes

  • : This Report uses ALV. *

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

*REPORT AQZZZGU_MM_001==ZGQ_MM_IM_019=

TABLES:marc, "Plant Data for Material

makt, "Material Descriptions

mara, "General Material Data

ekko, "Purchasing Document Header

EKPO, "Purchasing Document Item

t604, "Foreign Trade: Commodity Code

lfa1, "Vendor Master

t023t, "Material Group Descriptions

t001w, "Plants/Branches

cdpos, "Change document items

cdhdr. "Change document header

TYPE-POOLS: slis.

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

SELECT-OPTIONS:

s_werks FOR marc-werks, "Plant

s_spras FOR makt-spras, "Language Key

s_matnr FOR mara-matnr, "Material Number

s_ersda FOR mara-ersda, "Material Creation Date

s_vpsta FOR mara-vpsta, "Maintenance Status

s_matkl FOR mara-matkl, "Material Group

s_land1 FOR t604-land1, "Country Key

s_stawn FOR marc-stawn, "Commodity Code

s_wgbez FOR t023t-wgbez, "Text: Material group

s_ebeln FOR ekko-ebeln, "Purchase order

s_aedat FOR ekko-ebeln, "Creation Date

s_lifnr FOR ekko-lifnr. "Vendor

SELECTION-SCREEN END OF BLOCK block1.

*******sandeep for list view.********

SELECTION-SCREEN BEGIN OF BLOCK 2 WITH FRAME TITLE TEXT-019.

PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT.

SELECTION-SCREEN END OF BLOCK 2.

*******sandeep for list view.********

DATA: BEGIN OF itab_mara OCCURS 0,

matnr LIKE mara-matnr,

mfrpn LIKE mara-mfrpn,

mfrnr LIKE mara-mfrnr,

matkl LIKE mara-matkl,

werks LIKE marc-werks,

stawn LIKE marc-stawn,

mtver LIKE marc-mtver,

herkl LIKE marc-herkl,

maktx LIKE makt-maktx,

END OF itab_mara.

DATA: BEGIN OF itab_t023t OCCURS 0,

matkl LIKE t023t-matkl,

wgbez LIKE t023t-wgbez,

END OF itab_t023t.

*DATA: BEGIN OF itab_ekpo OCCURS 0,

  • ebeln LIKE ekpo-ebeln,

  • matnr LIKE ekpo-matnr,

  • END OF itab_ekpo.

*DATA: ITAB_EKPO TYPE STANDARD TABLE OF EKPO WITH HEADER LINE.

DATA: BEGIN OF itab_ekpo OCCURS 0,

ebeln LIKE ekpo-ebeln,

matnr LIKE ekpo-matnr,

lifnr LIKE ekko-lifnr,

END OF itab_ekpo.

DATA: BEGIN OF itab_lfa1 OCCURS 0,

lifnr LIKE lfa1-lifnr,

name1 LIKE lfa1-name1,

END OF itab_lfa1.

DATA: BEGIN OF itab_t604 OCCURS 0,

stawn LIKE t604-stawn,

text1 LIKE T604T-text1,

END OF itab_t604.

DATA: BEGIN OF itab_cdpos OCCURS 0,

objectclas LIKE cdpos-objectclas,

objectid TYPE cdpos-objectid,

changenr TYPE cdpos-CHANGENR,

END OF itab_cdpos.

DATA: BEGIN OF itab_cdhdr OCCURS 0,

changenr LIKE cdhdr-changenr,

username LIKE cdhdr-username,

udate LIKE cdhdr-udate,

OBJECTID like CDHDR-OBJECTID,

END OF itab_cdhdr.

*DATA:BEGIN OF itab_makt OCCURS 0,

  • maktx LIKE makt-maktx,

  • END OF itab_makt.

DATA: BEGIN OF itab_final OCCURS 0,

werks LIKE marc-werks,

stawn LIKE marc-stawn,

mtver LIKE marc-mtver,

herkl LIKE marc-herkl,

matnr LIKE mara-matnr,

mfrpn LIKE mara-mfrpn,

mfrnr LIKE mara-mfrnr,

matkl LIKE mara-matkl,

ebeln LIKE ekpo-ebeln,

lifnr LIKE ekko-lifnr,

name1 LIKE lfa1-name1,

  • stawn LIKE t604-stawn,

text1 LIKE T604T-text1,

maktx LIKE makt-maktx,

wgbez LIKE t023t-wgbez,

changenr LIKE cdhdr-changenr,

username LIKE cdhdr-username,

udate LIKE cdhdr-udate,

END OF itab_final.

*

**DATA: wa_marc LIKE itab_marc.

*DATA: wa_mara LIKE itab_mara.

*DATA: wa_ekko LIKE itab_ekko.

*DATA: wa_ekpo LIKE itab_ekpo.

*DATA: wa_lfa1 LIKE itab_lfa1.

*DATA: wa_t604 LIKE itab_t604.

**DATA: wa_makt LIKE itab_makt.

  • DATA:ve_ausw TYPE c,

  • ve_lines TYPE i.

DATA: fieldcat TYPE slis_t_fieldcat_alv,

fieldcat_ln LIKE LINE OF fieldcat.

DATA : col_pos TYPE i.

DATA: G_REPID LIKE SY-REPID,

G_SAVE(1) TYPE C,

GX_VARIANT LIKE DISVARIANT,

G_VARIANT LIKE DISVARIANT,

G_EXIT(1) TYPE C.

********VALIDATION***************

INITIALIZATION.

G_REPID = SY-REPID.

G_SAVE = 'A'.

<b>PERFORM VARIANT_INIT.

  • Get default variant

GX_VARIANT = G_VARIANT.

CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

EXPORTING

I_SAVE = G_SAVE

CHANGING

CS_VARIANT = GX_VARIANT

EXCEPTIONS

NOT_FOUND = 2.

IF SY-SUBRC = 0.

P_VARI = GX_VARIANT-VARIANT.

ENDIF.</b>

AT SELECTION-SCREEN ON s_werks.

IF s_werks-low <> space.

SELECT SINGLE * from T001W

WHERE werks = s_werks-low.

IF sy-subrc <> 0.

MESSAGE e011 WITH 'Invalid Plant Code'

s_werks-low '' ''.

ENDIF.

ENDIF.

IF s_werks-high <> space.

SELECT SINGLE * from T001W

WHERE werks = s_werks-high.

IF sy-subrc <> 0.

MESSAGE e011 WITH 'Invalid Plant Code'

s_werks-high '' ''.

ENDIF.

ENDIF.

AT SELECTION-SCREEN ON s_matnr.

IF s_matnr-low <> space.

SELECT single * from MARA

WHERE matnr = s_matnr-low.

IF sy-subrc <> 0.

MESSAGE e011 WITH 'Invalid Material number'

s_matnr '' ''.

ENDIF.

ENDIF.

IF s_matnr-high <> space.

SELECT single * from MARA

WHERE matnr = s_matnr-high.

IF sy-subrc <> 0.

MESSAGE e011 WITH 'Invalid Material number'

s_matnr-high '' ''.

ENDIF.

ENDIF.

START-OF-SELECTION.

PERFORM extract_data.

END-OF-SELECTION.

PERFORM build_print.

PERFORM build_fieldcat.

PERFORM start_list_viewer.

*********SANDEEP LIST VIEWER*********

    • Get default variant

*GX_VARIANT = G_VARIANT.

*

*CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

*EXPORTING

*I_SAVE = G_SAVE

*CHANGING

*CS_VARIANT = GX_VARIANT

*

*EXCEPTIONS

*NOT_FOUND = 2.

*

*IF SY-SUBRC = 0.

*P_VARI = GX_VARIANT-VARIANT.

*ENDIF.

*

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.

PERFORM F4_FOR_VARIANT.

AT SELECTION-SCREEN.

PERFORM PAI_OF_SELECTION_SCREEN.

  • ********** END SANDEEP LIST VIEWER**********

----


  • FORM extract_data *

----


  • ........ *

----


FORM extract_data.

SELECT a~matnr a~mfrpn a~mfrnr a~matkl

b~werks b~stawn b~mtver b~herkl

c~maktx

INTO corresponding fields of table itab_mara

FROM ( mara

as a

INNER JOIN marc as b

on a~matnr = b~matnr )

INNER JOIN makt as c

on a~matnr = c~matnr

WHERE werks IN s_werks

AND a~matnr IN s_matnr

AND b~stawn IN s_stawn

AND a~ersda IN s_ersda

AND a~matkl IN s_matkl

AND c~spras IN s_spras.

clear: itab_mara.

  • SELECT ebeln matnr

  • INTO CORRESPONDING FIELDS OF table itab_ekpo

  • from ekpo

  • FOR ALL ENTRIES IN itab_mara

  • WHERE matnr = itab_mara-matnr.

*

  • DELETE ADJACENT DUPLICATES FROM itab_ekpo.

*

  • SELECT lifnr ebeln

  • INTO table itab_ekko

  • from ekko

  • FOR ALL ENTRIES IN itab_ekpo

  • WHERE ebeln = itab_ekpo-ebeln.

SELECT wgbez matkl

INTO table itab_t023t

FROM t023t

FOR ALL ENTRIES IN itab_mara

WHERE matkl = itab_mara-matkl

AND wgbez IN s_wgbez.

SELECT a~ebeln a~matnr b~lifnr

INTO CORRESPONDING FIELDS OF table itab_ekpo

from ekpo as a

INNER JOIN ekko as b

ON a~ebeln = b~ebeln

FOR ALL ENTRIES IN itab_mara

WHERE a~matnr = itab_mara-matnr.

sort itab_mara.

SELECT lifnr name1

INTO table itab_lfa1

FROM lfa1

FOR ALL ENTRIES IN itab_mara

WHERE lifnr = itab_mara-mfrnr

OR lifnr = itab_ekpo-lifnr.

  • sort itab_ekko.

  • SELECT lifnr name1

  • appending table itab_lfa1

  • FROM LFA1

  • FOR ALL ENTRIES IN itab_ekko

  • WHERE lifnr = itab_ekko-lifnr.

*

sort itab_lfa1.

SELECT astawn btext1

INTO table itab_t604

FROM t604 as a

INNER JOIN t604t as b

on astawn = bstawn

FOR ALL ENTRIES IN itab_mara

WHERE a~stawn = itab_mara-stawn.

  • SELECT maktx

  • INTO table itab_makt

  • FROM makt

  • FOR ALL ENTRIES IN itab_mara

  • WHERE matnr = itab_mara-matnr.

*loop at itab_mara.

*DATA: field(10) type c.

  • REPLACE itab_mara-matnr with ' ' INTO field.

  • field1 = CONDENSE field NO-GAPS.

  • ENDLOOP.

*

SELECT objectclas objectid changenr

INTO TABLE itab_cdpos

from cdpos

WHERE TABNAME = 'MARC'

AND FNAME = 'STAWN'

AND OBJECTID IN S_MATNR.

IF sy-subrc = 0.

SELECT changenr username udate OBJECTID

INTO TABLE itab_cdhdr

FROM cdhdr

FOR ALL ENTRIES IN itab_cdpos

WHERE changenr = itab_cdpos-changenr

AND OBJECTCLAS = itab_cdpos-objectclas

AND objectid = itab_cdpos-objectid.

*sort itab_cdhdr descending by udate.

ENDIF.

ENDFORM.

FORM build_print.

LOOP AT itab_mara ."into wa_mara.

itab_final-matnr = itab_mara-matnr.

itab_final-mfrpn = itab_mara-mfrpn.

itab_final-mfrnr = itab_mara-mfrnr.

itab_final-matkl = itab_mara-matkl.

itab_final-werks = itab_mara-werks.

itab_final-stawn = itab_mara-stawn.

itab_final-mtver = itab_mara-mtver.

itab_final-herkl = itab_mara-herkl.

itab_final-maktx = itab_mara-maktx.

READ TABLE itab_t023t with key matkl = itab_final-matkl.

itab_final-wgbez = itab_t023t-wgbez.

READ TABLE itab_ekpo with key matnr = itab_final-matnr.

itab_final-ebeln = itab_ekpo-ebeln.

itab_final-lifnr = itab_ekpo-lifnr.

  • READ TABLE itab_ekko with key ebeln = itab_ekpo-ebeln.

  • itab_final-lifnr = itab_ekko-lifnr.

READ TABLE itab_lfa1 with key lifnr = itab_ekpo-lifnr.

  • itab_final-lifnr = itab_lfa1-lifnr.

itab_final-name1 = itab_lfa1-name1.

READ TABLE itab_t604 WITH KEY stawn = itab_mara-stawn.

itab_final-text1 = ITAB_t604-text1.

  • LOOP AT ITAB_CDPOS.

READ TABLE itab_cdhdr WITH KEY OBJECTID = itab_MARA-MATNR.

itab_final-username = itab_cdhdr-username.

itab_final-udate = itab_cdhdr-udate.

APPEND itab_final.

ENDLOOP.

ENDFORM.

FORM start_list_viewer.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = G_REPID

IT_FIELDCAT = fieldcat

I_DEFAULT = 'X'

I_SAVE = G_SAVE

  • IT_EVENTS = itab_eventcat

IS_VARIANT = G_VARIANT

TABLES

T_OUTTAB = itab_final

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.

FORM build_fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'MARC'.

fieldcat_ln-ref_fieldname = 'WERKS'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'WERKS'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-003.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 04.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'MARA'.

fieldcat_ln-ref_fieldname = 'MATNR'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'MATNR'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-004.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 18.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'MAKT'.

fieldcat_ln-ref_fieldname = 'MAKTX'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'MAKTX'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-005.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 40.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'MARA'.

fieldcat_ln-ref_fieldname = 'MATKL'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'MATKL'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-006.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 09.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'T023T'.

fieldcat_ln-ref_fieldname = 'WGBEZ'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'WGBEZ'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-007.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 20.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'MARA'.

fieldcat_ln-ref_fieldname = 'MFRPN'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'MFRPN'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-008.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 40.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'MARA'.

fieldcat_ln-ref_fieldname = 'MFRNR'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'MFRNR'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-009.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 10.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'LFA1'.

fieldcat_ln-ref_fieldname = 'NAME1'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'NAME1'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-010.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 35.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'MARC'.

fieldcat_ln-ref_fieldname = 'MTVER'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'MTVER'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-011.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 04.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'EKPO'.

fieldcat_ln-ref_fieldname = 'EBELN'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'EBELN'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-012.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 10.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'EKKO'.

fieldcat_ln-ref_fieldname = 'LIFNR'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'LIFNR'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-013.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 10.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'MARC'.

fieldcat_ln-ref_fieldname = 'HERKL'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'HERKL'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-014.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 3.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'CDHDR'.

fieldcat_ln-ref_fieldname = 'USERNAME'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'USERNAME'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-017.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 12.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'CDHDR'.

fieldcat_ln-ref_fieldname = 'UDATE'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'UDATE'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-018.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 08.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'MARC'.

fieldcat_ln-ref_fieldname = 'STAWN'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'STAWN'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-015.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 17.

APPEND fieldcat_ln TO fieldcat.

ADD 1 TO col_pos.

fieldcat_ln-ref_tabname = 'TEXT1'.

fieldcat_ln-ref_fieldname = 'T604T'.

fieldcat_ln-tabname = 'ITAB_FINAL'.

fieldcat_ln-fieldname = 'T604T'.

fieldcat_ln-col_pos = col_pos.

fieldcat_ln-seltext_l = text-016.

fieldcat_ln-ddictxt = 'L'.

fieldcat_ln-outputlen = 40.

APPEND fieldcat_ln TO fieldcat.

ENDFORM.

**********SANDEEP LIST VIEWER*********

FORM F4_FOR_VARIANT.

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

IS_VARIANT = G_VARIANT

I_SAVE = G_SAVE

  • I_DISPLAY_VIA_GRID = ' '

IMPORTING

E_EXIT = G_EXIT

ES_VARIANT = GX_VARIANT

EXCEPTIONS

NOT_FOUND = 1 .

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ELSE.

IF G_EXIT = SPACE.

P_VARI = GX_VARIANT-VARIANT.

ENDIF.

ENDIF.

ENDFORM.

FORM PAI_OF_SELECTION_SCREEN.

*

IF NOT P_VARI IS INITIAL.

MOVE G_VARIANT TO GX_VARIANT.

MOVE P_VARI TO GX_VARIANT-VARIANT.

CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'

EXPORTING

I_SAVE = G_SAVE

CHANGING

CS_VARIANT = GX_VARIANT.

G_VARIANT = GX_VARIANT.

ELSE.

PERFORM VARIANT_INIT.

ENDIF.

ENDFORM. "PAI_OF_SELECTION_SCREEN

FORM VARIANT_INIT.

*

CLEAR G_VARIANT.

G_VARIANT-REPORT = G_REPID.

ENDFORM. " VARIANT_INIT