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

HI SDN FRNDS

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Apr 26, 2007 at 06:27 AM

    Hi,

    See the attached code and modify your code for interactive part.

    report yh645_secndry_alv.

    type-pools: slis.

    data: fieldcat type slis_t_fieldcat_alv,

    fieldcat_ln like line of fieldcat,

    fs_layout type slis_layout_alv,

    t_layoout like standard table

    of fs_layout.

    data: begin of fs_spfli,

    carrid type spfli-carrid,

    connid type spfli-connid,

    countryfr type spfli-countryfr,

    cityfrom type spfli-cityfrom,

    airpfrom type spfli-airpfrom,

    countryto type spfli-countryto,

    cityto type spfli-cityto,

    airpto type spfli-airpto,

    fltime type spfli-fltime,

    deptime type spfli-deptime,

    arrtime type spfli-arrtime,

    distance type spfli-distance,

    distid type spfli-distid,

    fltype type spfli-fltype,

    period type spfli-period,

    checkbox,

    color(3),

    end of fs_spfli.

    data:

    begin of fs_table,

    carrid type spfli-carrid,

    connid type spfli-connid,

    end of fs_table.

    data: begin of fs_sflight,

    check,

    color(3).

    include type sflight.

    data:end of fs_sflight.

    data:

    begin of fs_table1,

    carrid type sflight-carrid,

    connid type sflight-connid,

    fldate type sflight-fldate,

    end of fs_table1.

    data:

    t_spfli like standard table

    of fs_spfli.

    data:

    t_table like standard table

    of fs_table.

    data:

    t_table1 like standard table

    of fs_table1.

    data:

    t_sflight like standard table

    of fs_sflight.

    data:

    t_sbook like standard table

    of sbook.

    data t_layout type slis_layout_alv.

    select *

    into corresponding fields of table t_spfli

    from spfli.

    perform start_list_viewer.

    perform get_spfli_details.

    &----


    *& Form SUB1

    &----


    • text

    ----


    • -->RT_EXTAB text

    ----


    form sub1 using rt_extab type slis_t_extab.

    data: flight type slis_extab.

    flight-fcode = 'SFLIGHT'.

    append flight to rt_extab.

    set pf-status 'SFLIGHT'. " EXCLUDING RT_EXTAB.

    endform. "SUB1

    &----


    *& Form START_LIST_VIEWER

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form start_list_viewer .

    data: pgm like sy-repid.

    pgm = sy-repid.

    fs_layout-box_fieldname = 'CHECKBOX'.

    fs_layout-info_fieldname = 'COLOR'.

    call function 'REUSE_ALV_LIST_DISPLAY'

    exporting

    i_callback_program = pgm

    i_callback_pf_status_set = 'SUB1'

    i_callback_user_command = 'USER_COMMAND'

    i_structure_name = 'SPFLI'

    is_layout = fs_layout

    tables

    t_outtab = t_spfli

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

    *******Process Call Back Events (Begin)**************************

    form user_command using ucomm like sy-ucomm

    selfield type slis_selfield.

    case ucomm.

    when 'SFLIGHT'.

    selfield-refresh = 'X'.

    perform get_spfli_details.

    select *

    from sflight

    into corresponding fields of table t_sflight

    for all entries in t_table

    where carrid eq t_table-carrid

    and connid eq t_table-connid.

    perform display_sflight.

    when 'SBOOK'.

    selfield-refresh = 'X'.

    perform get_sflight_details.

    select *

    from sbook

    into corresponding fields of table t_sbook

    for all entries in t_table1

    where carrid eq t_table1-carrid

    and connid eq t_table1-connid

    and fldate eq t_table1-fldate.

    perform display_sbook.

    endcase.

    endform. "USER_COMMAND

    &----


    *& Form SUB2

    &----


    • text

    ----


    • -->RT_EXTAB text

    ----


    form sub2 using rt_extab type slis_t_extab.

    data: flight type slis_extab.

    flight-fcode = 'SBOOK'.

    append flight to rt_extab.

    set pf-status 'SBOOK'. " EXCLUDING RT_EXTAB.

    endform. "SUB2

    &----


    *& Form DISPLAY_SFLIGHT

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form display_sflight .

    data: pgm like sy-repid.

    pgm = sy-repid.

    clear t_layout.

    fs_layout-box_fieldname = 'CHECK'.

    fs_layout-info_fieldname = 'COLOR'.

    call function 'REUSE_ALV_LIST_DISPLAY'

    exporting

    i_callback_program = pgm

    i_callback_pf_status_set = 'SUB2'

    i_callback_user_command = 'USER_COMMAND'

    i_structure_name = 'SFLIGHT'

    is_layout = fs_layout

    tables

    t_outtab = t_sflight

    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_SFLIGHT

    &----


    *& Form GET_SPFLI_DETAILS

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form get_spfli_details .

    loop at t_spfli into fs_spfli.

    if fs_spfli-checkbox = 'X'.

    fs_spfli-color = 'C51'.

    fs_spfli-checkbox = '1'.

    fs_table-carrid = fs_spfli-carrid.

    fs_table-connid = fs_spfli-connid.

    append fs_table to t_table.

    modify t_spfli from fs_spfli.

    endif.

    endloop.

    endform. " GET_SFLIGHT_DETAILS

    &----


    *& Form GET_SFLIGHT_DETAILS

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form get_sflight_details .

    loop at t_sflight into fs_sflight.

    if fs_sflight-check = 'X'.

    fs_sflight-color = 'C71'.

    fs_sflight-check = '1'.

    fs_table1-carrid = fs_sflight-carrid.

    fs_table1-connid = fs_sflight-connid.

    fs_table1-fldate = fs_sflight-fldate.

    append fs_table1 to t_table1.

    modify t_sflight from fs_sflight.

    endif.

    endloop.

    endform. " GET_SFLIGHT_DETAILS

    &----


    *& Form DISPLAY_SBOOK

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form display_sbook .

    data: pgm like sy-repid.

    pgm = sy-repid.

    call function 'REUSE_ALV_LIST_DISPLAY'

    exporting

    i_callback_program = pgm

    i_structure_name = 'SBOOK'

    tables

    t_outtab = t_sbook

    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_SBOOK

    reward if useful

    regards,

    ANJI

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 26, 2007 at 06:30 AM

    Hi,

    write this code , when u dounleclick, select teh data based on the fiedl on which u have clicked...

    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

    RS_SELFIELD TYPE SLIS_SELFIELD.

    CASE R_UCOMM.

    WHEN '&IC1'. "doubleclick

    .

    <b> read table t_mara index rs_SELFIELD-TABINDEX.</b> " this reads the line on which u have doubleclicked

    • if sy-subrc = 0.

    <b> PERFORM F_SERIAL.</b> <b>in this select the data from MARC</b>

    PERFORM F_FIELDCAT_SER. " <b>build catalog for secondary list</b>

    <b>CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'</b> " this dislays secondary list

    EXPORTING

    I_CALLBACK_PROGRAM = G_REPID

    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

    IT_FIELDCAT = T_FIELDCAT_SER[]

    TABLES

    T_OUTTAB = <b>T_marc</b>

    • 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.

    ENDIF.

    ENDIF.

    ENDCASE.

    ENDFORM. " USER_COMMAND

    Hope it helps.

    Regards,

    Sonika

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 26, 2007 at 06:44 AM

    Hi,

    Based on the seelcted material number get the corresponding entries from the Table MARC.

    bulid the catalog for MARC table.

    call the FM 'REUSE_ALV_GRID_DISPLAY'.

    write this code betwen WHEN '&IC1'. "doubleclick

    ENDCASE.

    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.