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

alv program

Hi,

I want to create an alv report where in which i want to select the data from knvp(kunnr,vkorg) and knvv(loevm) tables.The selection screen should have following fields.

kunnr(knvp),vkorg(knvp),loevm(knvv).The o/p should have following fields.knvp(kunnr,vkorg,parvw,kunn2),knvv(loevm).Can anyone tell me how to create an alv report program(sample program) for this?

Regards,

Hema

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 Sep 19, 2007 at 12:26 PM

    Hello,

    ALV Demo program

    BCALV_DEMO_HTML

    BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode

    BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode

    BCALV_GRID_DEMO Simple ALV Control Call Demo Program

    BCALV_TREE_DEMO Demo for ALV tree control

    BCALV_TREE_SIMPLE_DEMO

    BC_ALV_DEMO_HTML_D0100

    Please refer

    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907

    For object oriented concepts refer this link https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b6cae890-0201-0010-ef8b-f970a9c41d47

    Reward if useful..

    regards,

    Lijo

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 12:28 PM

    hi,

    look at this.

    &----


    *& Report ZALV_DS

    *&

    &----


    *&

    *&

    &----


    REPORT zalv_ds LINE-SIZE 35.

    TYPE-POOLS:slis.

    TABLES:mara,

    makt,

    marc.

    DATA:BEGIN OF itab OCCURS 0,

    matnr LIKE mara-matnr,

    maktx LIKE makt-maktx,

    werks LIKE marc-werks,

    mtart LIKE mara-mtart,

    matkl LIKE mara-matkl,

    meins LIKE mara-meins,

    ntgew LIKE mara-ntgew,

    • rowcolor(4) TYPE c,

    cellcolors TYPE lvc_t_scol,

    END OF itab.

    DATA:t_fcat TYPE slis_t_fieldcat_alv,

    t_eve TYPE slis_t_event.

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

    SELECT-OPTIONS:mat FOR mara-matnr. " no intervals no-extension.

    *PARAMETERS:mat LIKE mara-matnr.

    SELECTION-SCREEN:END OF BLOCK blk1.

    INITIALIZATION.

    PERFORM build_cata USING t_fcat.

    PERFORM build_event.

    START-OF-SELECTION.

    PERFORM data_retrieval.

    PERFORM display_data.

    &----


    *& Form build_cata

    &----


    • text

    ----


    • -->TEMP_FCAT text

    ----


    FORM build_cata USING temp_fcat TYPE slis_t_fieldcat_alv.

    sy-tvar0 = sy-uname.

    WRITE sy-datum TO sy-tvar1.

    DATA:wa_fcat TYPE slis_fieldcat_alv.

    wa_fcat-tabname = 'ITAB'.

    wa_fcat-fieldname = 'MATNR'.

    wa_fcat-seltext_m = 'Material'.

    APPEND wa_fcat TO temp_fcat.

    wa_fcat-tabname = 'ITAB'.

    wa_fcat-fieldname = 'MAKTX'.

    wa_fcat-seltext_m = 'Description'.

    APPEND wa_fcat TO temp_fcat.

    wa_fcat-tabname = 'ITAB'.

    wa_fcat-fieldname = 'WERKS'.

    wa_fcat-seltext_m = 'Plant'.

    APPEND wa_fcat TO temp_fcat.

    wa_fcat-tabname = 'ITAB'.

    wa_fcat-fieldname = 'MTART'.

    wa_fcat-seltext_m = 'Type'.

    APPEND wa_fcat TO temp_fcat.

    wa_fcat-tabname = 'ITAB'.

    wa_fcat-fieldname = 'MATKL'.

    wa_fcat-seltext_m = 'Group'.

    APPEND wa_fcat TO temp_fcat.

    wa_fcat-tabname = 'ITAB'.

    wa_fcat-fieldname = 'MEINS'.

    wa_fcat-seltext_m = 'Measurement Unit'.

    APPEND wa_fcat TO temp_fcat.

    wa_fcat-tabname = 'ITAB'.

    wa_fcat-fieldname = 'NTGEW'.

    wa_fcat-seltext_m = 'Net Value'.

    APPEND wa_fcat TO temp_fcat.

    ENDFORM. "build_cata

    &----


    *& Form build_event

    &----


    • text

    ----


    FORM build_event.

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    i_list_type = 0

    IMPORTING

    et_events = t_eve

    EXCEPTIONS

    list_type_wrong = 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. "build_event

    &----


    *& Form data_retrieval

    &----


    • text

    ----


    FORM data_retrieval.

    SELECT maramatnr maramtart maramatkl marameins mara~ntgew

    maktmaktx marcwerks

    INTO CORRESPONDING FIELDS OF TABLE itab

    FROM mara INNER JOIN makt ON

    maramatnr = maktmatnr

    INNER JOIN marc ON

    maramatnr = marcmatnr

    WHERE mara~matnr IN mat.

    SORT itab BY matnr.

    DELETE ADJACENT DUPLICATES FROM itab.

    ENDFORM. "data_retrieval

    &----


    *& Form display_data

    &----


    • text

    ----


    FORM display_data.

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

    *******************************For setting Cell Color*******************************************

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

    DATA ls_cellcolor TYPE lvc_s_scol .

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    i_callback_program = 'ZALV_DS'

    it_fieldcat = t_fcat

    it_events = t_eve

    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_data

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 12:29 PM

    After fetching data from the tables :

    go through the sample program below and proceed in the same way with ur final internal table.......

    REPORT ZALV .

    TABLES : VBAP.

    TYPE-POOLS : SLIS.

    DATA : BEGIN OF ITAB OCCURS 0,

    VBELN LIKE VBAP-VBELN,

    POSNR LIKE VBAP-POSNR,

    ERNAM LIKE VBAP-ERNAM,

    ERDAT LIKE VBAP-ERDAT.

    DATA : END OF ITAB.

    DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

    WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

    DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.

    SELECT-OPTIONS : S_VBELN FOR VBAP-VBELN.

    START-OF-SELECTION.

    SELECT VBELN

    POSNR

    ERNAM

    ERDAT

    FROM VBAP

    INTO CORRESPONDING FIELDS OF TABLE ITAB

    WHERE VBELN IN S_VBELN.

    PERFORM MODIFY_CAT.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER = ' '

    • I_BUFFER_ACTIVE = ' '

    • I_CALLBACK_PROGRAM = ' '

    • I_CALLBACK_PF_STATUS_SET = ' '

    • I_CALLBACK_USER_COMMAND = ' '

    • I_CALLBACK_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_END_OF_LIST = ' '

    • I_STRUCTURE_NAME =

    • I_BACKGROUND_ID = ' '

    • I_GRID_TITLE =

    • I_GRID_SETTINGS =

    IS_LAYOUT = WA_LAYOUT

    IT_FIELDCAT = IT_FIELDCAT

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT = 'X'

    • I_SAVE = ' '

    • IS_VARIANT =

    • IT_EVENTS =

    • IT_EVENT_EXIT =

    • IS_PRINT =

    • IS_REPREP_ID =

    • I_SCREEN_START_COLUMN = 0

    • I_SCREEN_START_LINE = 0

    • I_SCREEN_END_COLUMN = 0

    • I_SCREEN_END_LINE = 0

    • IT_ALV_GRAPHICS =

    • IT_HYPERLINK =

    • IT_ADD_FIELDCAT =

    • IT_EXCEPT_QINFO =

    • I_HTML_HEIGHT_TOP =

    • I_HTML_HEIGHT_END =

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

    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.

    *END-OF-SELECTION.

    *LOOP AT ITAB.

    *WRITE : / ITAB-VBELN,

    • ITAB-POSNR,

    • ITAB-ERNAM,

    • ITAB-ERDAT.

    *ENDLOOP.

    &----


    *& Form MODIFY_CAT

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM MODIFY_CAT .

    WA_FIELDCAT-TABNAME = 'ITAB'..

    WA_FIELDCAT-FIELDNAME = 'VBELN'.

    WA_FIELDCAT-SELTEXT_L = 'SALES DOC'.

    WA_FIELDCAT-COL_POS = 1.

    WA_FIELDCAT-OUTPUTLEN = 10.

    APPEND WA_FIELDCAT TO IT_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'ITAB'..

    WA_FIELDCAT-FIELDNAME = 'POSNR'.

    WA_FIELDCAT-SELTEXT_L = 'ITEM'.

    WA_FIELDCAT-COL_POS = 2.

    WA_FIELDCAT-OUTPUTLEN = 6.

    APPEND WA_FIELDCAT TO IT_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'ITAB'..

    WA_FIELDCAT-FIELDNAME = 'ERNAM'.

    WA_FIELDCAT-SELTEXT_L = 'PERSON NAME'.

    WA_FIELDCAT-COL_POS = 3.

    WA_FIELDCAT-OUTPUTLEN = 12.

    APPEND WA_FIELDCAT TO IT_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'ITAB'..

    WA_FIELDCAT-FIELDNAME = 'ERDAT'.

    WA_FIELDCAT-SELTEXT_L = 'DATE'.

    WA_FIELDCAT-COL_POS = 4.

    WA_FIELDCAT-OUTPUTLEN = 8.

    APPEND WA_FIELDCAT TO IT_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_LAYOUT-ZEBRA = 'X'.

    *WA_LAYOUT-INFO_FIELDNAME = 'COLOR'.

    ENDFORM. " MODIFY_CAT

    Regards

    vasu

    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.