Skip to Content
0
Former Member
Apr 26, 2007 at 06:22 AM

HI SDN FRNDS

71 Views

hi frnds

i created one alv program. for single ouptlist it was ok. but if i want sencodary list i am getting problem.

this is my program whenever i click the material no of the basic list i want to dispaly the secondary list for marc based on basic list.

TABLES: MARA,MARC.

TYPE-POOLS : SLIS.

*TYPES

TYPES : BEGIN OF TY_MARA,

MATNR TYPE MARA-MATNR,

ERSDA TYPE MARA-ERSDA,

ERNAM TYPE MARA-ERNAM,

END OF TY_MARA.

TYPES : BEGIN OF TY_MARC,

MATNR TYPE MARC-MATNR,

WERKS TYPE MARC-WERKS,

EKGRP TYPE MARC-EKGRP,

DISPO TYPE MARC-DISPO,

END OF TY_MARC.

*WORK AREA FOR MARA

DATA : T_MARA TYPE STANDARD TABLE OF TY_MARA INITIAL SIZE 0,

W_MARA TYPE TY_MARA.

*WORK AREA FOR MARA

DATA : T_MARC TYPE STANDARD TABLE OF TY_MARC INITIAL SIZE 0,

W_MARC TYPE TY_MARC.

*REGARDING SLIS.

DATA: TB_FIELD_CAT TYPE SLIS_T_FIELDCAT_ALV,

LS_FIELDCAT_ALV TYPE SLIS_FIELDCAT_ALV,

TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,

LS_LINE TYPE SLIS_LISTHEADER,

I_SORT TYPE SLIS_T_SORTINFO_ALV,

I_LAYOUT TYPE SLIS_LAYOUT_ALV.

DATA REPID LIKE SY-REPID.

*SELECT-OPTIONS.

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

*SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.

*SELECTION-SCREEN END OF BLOCK BLK0.

*INITIALIZATION.

INITIALIZATION.

REPID = SY-REPID.

I_LAYOUT-ZEBRA = 'X'.

*START-OF-SELECTION.

START-OF-SELECTION.

PERFORM FIELD_CATALOG USING TB_FIELD_CAT.

PERFORM COMMENT_BUILD USING TOP_OF_PAGE.

PERFORM GET_DATA.

PERFORM DISP_DATA.

  • PERFORM T_SORT_BUILD USING I_SORT.

  • PERFORM TOP_OF_PAGE.

  • PERFORM USER_COMMAND.

&----


*& Form GET_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_DATA.

SELECT MATNR

ERSDA

ERNAM

FROM MARA

INTO TABLE T_MARA UP TO 10 ROWS.

IF SY-SUBRC EQ 0.

WRITE :/ 'Total No of Lines.. ',SY-DBCNT.

ULINE.

ENDIF.

ENDFORM. " GET_DATA

&----


*& Form FIELD_CATALOG

&----


  • text

----


  • -->P_TB_FIELD_CAT text

----


FORM FIELD_CATALOG USING L_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

CLEAR LS_FIELDCAT_ALV.

LS_FIELDCAT_ALV-FIELDNAME = 'MATNR'.

LS_FIELDCAT_ALV-SELTEXT_L = 'Material No.'.

LS_FIELDCAT_ALV-KEY = 'X'.

LS_FIELDCAT_ALV-COL_POS = 1.

APPEND LS_FIELDCAT_ALV TO L_FIELDCAT.

CLEAR LS_FIELDCAT_ALV.

LS_FIELDCAT_ALV-FIELDNAME = 'ERSDA'.

LS_FIELDCAT_ALV-SELTEXT_L = 'Created on'.

LS_FIELDCAT_ALV-KEY = 'X'.

LS_FIELDCAT_ALV-COL_POS = 2.

APPEND LS_FIELDCAT_ALV TO L_FIELDCAT.

CLEAR LS_FIELDCAT_ALV.

LS_FIELDCAT_ALV-FIELDNAME = 'ERNAM'.

LS_FIELDCAT_ALV-SELTEXT_L = 'Created by'.

LS_FIELDCAT_ALV-KEY = 'X'.

LS_FIELDCAT_ALV-COL_POS = 3.

APPEND LS_FIELDCAT_ALV TO L_FIELDCAT.

CLEAR LS_FIELDCAT_ALV.

I_LAYOUT-ZEBRA = 'X'.

ENDFORM. " FIELD_CATALOG

&----


*& Form COMMENT_BUILD

&----


  • text

----


  • -->P_TOP_OF_PAGE text

----


FORM COMMENT_BUILD USING I_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.

DATA: LS_LINE TYPE SLIS_LISTHEADER.

CLEAR : LS_LINE.

LS_LINE-TYP = 'H'.

*LS_LINE-KEY: not used for this type

LS_LINE-INFO = 'Material Master Information'.

APPEND LS_LINE TO I_LIST_TOP_OF_PAGE.

CLEAR : LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = 'Key 1'.

LS_LINE-INFO = 'Information List.'.

APPEND LS_LINE TO I_LIST_TOP_OF_PAGE.

CLEAR : LS_LINE.

LS_LINE-TYP = 'A'.

LS_LINE-KEY = 'Key 2'.

LS_LINE-INFO = 'Status List. '.

APPEND LS_LINE TO I_LIST_TOP_OF_PAGE.

ENDFORM. " COMMENT_BUILD

&----


*& Form DISP_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DISP_DATA.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = REPID

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

I_BACKGROUND_ID = 'ALV_BACKGROUND'

IT_FIELDCAT = TB_FIELD_CAT

IT_SORT = I_SORT[]

TABLES

T_OUTTAB = T_MARA

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. " DISP_DATA

&----


*& Form TOP_OF_PAGE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

I_LOGO = 'ENJOYSAP_LOGO'

IT_LIST_COMMENTARY = TOP_OF_PAGE.

ENDFORM. " TOP_OF_PAGE

&----


*& Form USER_COMMAND

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

CASE R_UCOMM.

WHEN '&IC1'. "doubleclick

ENDCASE.

ENDFORM. " USER_COMMAND

this is my program whenever i click material no of the basic list i want to dispaly the secondary list for marc based on basic list.