Skip to Content

Grid using Object Oriented View

Can anyone send me program for grid using object oriented view.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2008 at 04:11 AM

    hi Sandeep,

    please look at this code

    REPORT Z_PICK_LIST .

    TABLES: RESB.

    SELECTION-SCREEN BEGIN OF BLOCK BL1 WITH FRAME TITLE TEXT-BL1.

    SELECT-OPTIONS: S_WERKS FOR RESB-WERKS," Plant

    S_AUFNR FOR RESB-AUFNR," Order number

    S_BDTER FOR RESB-BDTER." Req. date

    SELECTION-SCREEN END OF BLOCK BL1.

    PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT DEFAULT '/STANDARD'.

    DATA: BEGIN OF OUT OCCURS 10,

    AUFNR LIKE RESB-AUFNR, " Order number

    MATNR LIKE RESB-MATNR, " Material

    BDMNG LIKE RESB-BDMNG, " Requirements in UM

    MEINS LIKE RESB-MEINS, " Unit of Measure (UM)

    ERFMG LIKE RESB-ERFMG, " Requirements in UE

    ERFME LIKE RESB-ERFME, " Unit of Entry (UE)

    MAKTX LIKE MAKT-MAKTX, " Mat. description

    END OF OUT.

    INCLUDE Z_ALV_VARIABLES.

    INITIALIZATION.

    REPNAME = SY-REPID.

    PERFORM INITIALIZE_FIELDCAT USING FIELDTAB[].

    PERFORM BUILD_EVENTTAB USING EVENTS[].

    PERFORM BUILD_COMMENT USING HEADING[].

    PERFORM INITIALIZE_VARIANT.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.

    PERFORM F4_FOR_VARIANT.

    AT SELECTION-SCREEN.

    PERFORM PAI_OF_SELECTION_SCREEN.

    START-OF-SELECTION.

    PERFORM GET_ORDERS.

    PERFORM GET_MATERIAL_DESCRIPTION.

    END-OF-SELECTION.

    PERFORM BUILD_LAYOUT USING LAYOUT.

    PERFORM BUILD_PRINT USING PRINTS.

    PERFORM WRITE_USING_ALV.

    -


    FORM INITIALIZE_FIELDCAT *

    -


    ........ *

    -


    --> P_TAB *

    -


    FORM INITIALIZE_FIELDCAT USING P_TAB TYPE SLIS_T_FIELDCAT_ALV.

    DATA: CAT TYPE SLIS_FIELDCAT_ALV.

    CLEAR CAT.

    ENDFORM. " INITIALIZE_FIELDCAT

    &----


    *& Form GET_ORDERS

    &----


    text

    -


    FORM GET_ORDERS.

    SELECT AUFNR MATNR BDMNG MEINS ERFMG ERFME

    FROM RESB

    APPENDING TABLE OUT

    WHERE XLOEK EQ SPACE " deletion indicator

    AND XWAOK EQ 'X' " goods movement indicator

    AND WERKS IN S_WERKS " plant

    AND BDTER IN S_BDTER " req. date

    AND AUFNR IN S_AUFNR. " pr. order

    ENDFORM. " GET_ORDERS

    &----


    *& Form GET_MATERIAL_DESCRIPTION

    &----


    text

    -


    FORM GET_MATERIAL_DESCRIPTION.

    SORT OUT BY MATNR.

    LOOP AT OUT.

    SELECT SINGLE MAKTX

    INTO OUT-MAKTX

    FROM MAKT

    WHERE MATNR EQ OUT-MATNR

    AND SPRAS EQ 'EN'.

    MODIFY OUT.

    ENDLOOP.

    SORT OUT BY AUFNR MATNR.

    ENDFORM. " GET_MATERIAL_DESCRIPTION

    -


    FORM TOP_OF_PAGE *

    -


    ........ *

    -


    FORM TOP_OF_PAGE.

    DATA: L_POS TYPE P.

    first line

    WRITE:/ TEXT-001. " Plant:

    IF S_WERKS-HIGH NE SPACE.

    WRITE: S_WERKS-LOW, TEXT-TO1, S_WERKS-HIGH.

    ELSEIF S_WERKS-LOW NE SPACE.

    LOOP AT S_WERKS.

    WRITE: S_WERKS-LOW.

    ENDLOOP.

    ELSEIF S_WERKS-LOW EQ SPACE.

    WRITE: TEXT-ALL.

    ENDIF.

    L_POS = ( SY-LINSZ DIV 2 ) - ( STRLEN( TEXT-TIT ) DIV 2 ).

    POSITION L_POS. WRITE: TEXT-TIT.

    L_POS = SY-LINSZ - 20.

    POSITION L_POS. WRITE: TEXT-011, SY-UNAME RIGHT-JUSTIFIED. " User:

    second line

    WRITE:/ TEXT-002. " Order:

    IF S_AUFNR-HIGH NE SPACE.

    WRITE: S_AUFNR-LOW, TEXT-TO1, S_AUFNR-HIGH.

    ELSEIF S_AUFNR-LOW NE SPACE.

    LOOP AT S_AUFNR.

    WRITE: S_AUFNR-LOW.

    ENDLOOP.

    ELSEIF S_AUFNR-LOW EQ SPACE.

    WRITE: TEXT-ALL.

    ENDIF.

    L_POS = SY-LINSZ - 20.

    POSITION L_POS. WRITE: TEXT-012,SY-DATUM. " Date:

    third line

    WRITE:/ TEXT-003. " Req. Date:

    IF S_BDTER-HIGH(1) NE '0'.

    WRITE: S_BDTER-LOW, TEXT-TO1, S_BDTER-HIGH.

    ELSEIF S_BDTER-LOW(1) NE '0'.

    LOOP AT S_BDTER.

    WRITE: S_BDTER-LOW.

    ENDLOOP.

    ELSEIF S_BDTER-LOW(1) EQ '0'.

    WRITE: TEXT-ALL.

    ENDIF.

    L_POS = SY-LINSZ - 20.

    POSITION L_POS. WRITE: TEXT-013, SY-PAGNO. " Page:

    ENDFORM. " TOP_OF_PAGE

    -


    FORM END_OF_LIST *

    -


    ........ *

    -


    FORM END_OF_LIST.

    DATA: L_POS TYPE P.

    ULINE.

    WRITE:/ '|', TEXT-021. " Delivered by:

    L_POS = SY-LINSZ DIV 2.

    POSITION L_POS. WRITE: '|', TEXT-031. " Received by:

    L_POS = SY-LINSZ.

    POSITION L_POS. WRITE: '|'.

    WRITE:/ '|'.

    L_POS = SY-LINSZ DIV 2.

    POSITION L_POS. WRITE: '|'.

    L_POS = SY-LINSZ.

    POSITION L_POS. WRITE: '|'.

    ULINE.

    WRITE:/ '|', TEXT-012. " Date:

    L_POS = SY-LINSZ DIV 2.

    POSITION L_POS. WRITE: '|', TEXT-012. " Date:

    L_POS = SY-LINSZ.

    POSITION L_POS. WRITE: '|'.

    WRITE:/ '|'.

    L_POS = SY-LINSZ DIV 2.

    POSITION L_POS. WRITE: '|'.

    L_POS = SY-LINSZ.

    POSITION L_POS. WRITE: '|'.

    ULINE.

    ENDFORM. " END_OF_LIST

    &----


    *& Form WRITE_USING_ALV

    &----


    text

    -


    FORM WRITE_USING_ALV.

    Look this code*****

    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

    EXPORTING

    I_PROGRAM_NAME = REPNAME

    I_INTERNAL_TABNAME = 'OUT'

    I_INCLNAME = REPNAME

    CHANGING

    CT_FIELDCAT = FIELDTAB.

    IF SY-SUBRC 0.

    WRITE: 'SY-SUBRC: ', SY-SUBRC,

    'REUSE_ALV_FIELDCATALOG_MERGE'.

    ENDIF.

    LOOk this code also.*********

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = REPNAME

    i_callback_pf_status_set = 'PF_STATUS_SET'

    i_callback_user_command = 'USER_COMMAND'

    I_STRUCTURE_NAME = 'OUT'

    IS_LAYOUT = LAYOUT

    IT_FIELDCAT = FIELDTAB

    I_DEFAULT = 'A'

    I_SAVE = G_SAVE

    IS_VARIANT = G_VARIANT

    IT_EVENTS = EVENTS[]

    IS_PRINT = PRINTS

    TABLES

    T_OUTTAB = OUT.

    IF SY-SUBRC 0.

    WRITE: 'SY-SUBRC: ', SY-SUBRC, 'REUSE_ALV_LIST_DISPLAY'.

    ENDIF.

    ENDFORM. " WRITE_USING_ALV

    ***************report over***************

    HOPE THIS CODE HELPS U

    Reward if its useful.............

    thanks and regards

    suma sailaja

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2008 at 04:16 AM

    Hi Sandeep,

    Hope the below code might be useful..

    DATA : g_dock TYPE REF TO cl_gui_docking_container,

    g_split TYPE REF TO cl_gui_easy_splitter_container,

    g_cont1 TYPE REF TO cl_gui_container,

    g_cont2 TYPE REF TO cl_gui_container,

    g_grid1 TYPE REF TO cl_gui_alv_grid,

    g_grid2 TYPE REF TO cl_gui_alv_grid.

    • i_mara is an internal table of structure MARA

    SELECT * FROM mara INTO TABLE i_mara.

    • i_kna1 is an internal table of structure KNA1

    SELECT * FROM kna1 INTO TABLE i_kna1.

    • To create an Object of type Docking Container

    CREATE OBJECT g_dock

    EXPORTING

    side = cl_gui_docking_container=>dock_at_top

    extension = 200 .

    • To Create an Object of Type Split Container. Here we can see that the Docking

    *Container Created above has been used as a parent .

    CREATE OBJECT g_split

    EXPORTING

    parent = g_dock

    orientation = 1 .

    • Easy Split container splits one Control into 2 manageable controls, each of them is used

    • to handle one GUI Container each

    g_cont1 = g_split->top_left_container.

    g_cont2 = g_split->bottom_right_container.

    • To Create an Object of type Grid . Here we can see that the Left Split Container

    • Created above has been used as a parent .

    CREATE OBJECT g_grid1

    EXPORTING

    i_parent = g_cont1 .

    • To Create an Object of type Grid . Here we can see that the Right Split Container

    • Created above has been used as a parent .

    CREATE OBJECT g_grid2

    EXPORTING

    i_parent = g_cont2 .

    • The method of Grid Control Object is used to display the Data.

    CALL METHOD g_grid1->set_table_for_first_display

    EXPORTING

    i_structure_name = 'MARA'

    CHANGING

    it_outtab = i_mara[] .

    • The method of Grid Control Object is used to display the Data.

    CALL METHOD g_grid2->set_table_for_first_display

    EXPORTING

    i_structure_name = 'KNA1'

    CHANGING

    it_outtab = i_kna1[] .

    Reward if useful.

    Thankyou,

    Regards.

    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.