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

hi guru's i am learning reports i know clasical & interactive how use oops

hi guru's i am learning reports i know clasical & interactive how to use oops concepts in that in real time oops concept using in classical and interactive . plz help me

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 22, 2007 at 04:37 AM

    HI

    yes we can wirte.

    Check standard reports with BCALV * and press F4 in SE38 Or RSDEMO * and press F4 in SE38 you will get all reports with OOPs concept.

    Object Oriented Programming is a paradigm rather than just a technology. You can write anything in OOP. When I say paradigm, i mean how you look at things. Basically how you ORIENT yourself with the things that you are trying to represent in a program. Rather just look at things as an ungrouped collection of variables, you can ENCAPSULATE them into objects. This way your code is more organized, reusable and extensible.

    Technically speaking however, If you are trying to write an interactive ABAP list, you will be facing a dillema since interactive ABAP lists require you to create/use global variables. This is usually what OOP is trying to avoid. You could use ALV which is implemented as both a CLASS and an FM. The FM is a bit easier to use.

    /community [original link is broken]

    <b>Reward if usefull</b>

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 22, 2007 at 04:37 AM

    Hi,

    Following this report is the sample for Checkbox OOps alv report.

    &----


    *& Report YMS_CHECKBOXOOPS *

    *& *

    &----


    *& *

    *& *

    &----


    REPORT YMS_CHECKBOXOOPSALV NO STANDARD PAGE HEADING.

    Description----


    • TOPICS INTRODUCED:

    • 1. Learn about the ‘Standard’ PF-Status that comes as default.

    • 2. Exclude function codes from ‘Standard’ PF-Status and customize it.

    ----


    TYPE-POOLS: slis.

    DATA: BEGIN OF i_data OCCURS 0,

    qmnum LIKE qmel-qmnum,

    qmart LIKE qmel-qmart,

    qmtxt LIKE qmel-qmtxt,

    ws_row TYPE i,

    ws_char(5) TYPE c,

    chk,

    END OF i_data.

    DATA: report_id LIKE sy-repid.

    DATA: ws_title TYPE lvc_title VALUE 'An ALV Report'.

    DATA: i_layout TYPE slis_layout_alv.

    DATA: i_fieldcat TYPE slis_t_fieldcat_alv.

    DATA: i_events TYPE slis_t_event.

    DATA: i_header TYPE slis_t_listheader.

    DATA: i_extab TYPE slis_t_extab.

    SELECT qmnum

    qmart

    qmtxt

    INTO TABLE i_data

    FROM qmel

    WHERE qmnum <= '00030000010'.

    LOOP AT i_data.

    i_data-ws_row = sy-tabix.

    i_data-ws_char = 'AAAAA'.

    MODIFY i_data.

    ENDLOOP.

    report_id = sy-repid.

    PERFORM f1000_layout_init CHANGING i_layout.

    PERFORM f2000_fieldcat_init CHANGING i_fieldcat.

    PERFORM f3000_build_header CHANGING i_header.

    PERFORM f4000_events_init CHANGING i_events.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER =

    • I_BUFFER_ACTIVE = ' '

    i_callback_program = report_id

    • 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 = ws_title

    • I_GRID_SETTINGS =

    is_layout = i_layout

    it_fieldcat = i_fieldcat

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT = 'X'

    i_save = 'A'

    • IS_VARIANT =

    it_events = i_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_ADD_FIELDCAT =

    • IT_HYPERLINK =

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

    TABLES

    t_outtab = i_data

    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.

    &----


    *& Form F1000_Layout_Init

    &----


    FORM f1000_layout_init USING i_layout TYPE slis_layout_alv.

    CLEAR i_layout.

    i_layout-colwidth_optimize = 'X'.

    i_layout-edit = 'X'.

    ENDFORM. " F1000_Layout_Init

    &----


    *& Form f2000_fieldcat_init

    &----


    FORM f2000_fieldcat_init CHANGING i_fieldcat TYPE slis_t_fieldcat_alv.

    DATA: line_fieldcat TYPE slis_fieldcat_alv.

    CLEAR line_fieldcat.

    line_fieldcat-fieldname = 'QMNUM'. " The field name and the table

    line_fieldcat-tabname = 'I_DATA'. " name are the two minimum req.

    line_fieldcat-key = 'X'. " Specifies the column as a key (Blue)

    line_fieldcat-seltext_m = 'Notification No.'. " Column Header

    APPEND line_fieldcat TO i_fieldcat.

    CLEAR line_fieldcat.

    line_fieldcat-fieldname = 'QMART'.

    line_fieldcat-ref_tabname = 'I_DATA'.

    line_fieldcat-hotspot = 'X'. " Shows the field as a hotspot.

    line_fieldcat-seltext_m = 'Notif Type'.

    APPEND line_fieldcat TO i_fieldcat.

    CLEAR line_fieldcat.

    line_fieldcat-fieldname = 'QMTXT'.

    line_fieldcat-tabname = 'I_DATA'.

    line_fieldcat-seltext_m = 'Description'.

    APPEND line_fieldcat TO i_fieldcat.

    CLEAR line_fieldcat.

    line_fieldcat-fieldname = 'WS_ROW'.

    line_fieldcat-tabname = 'I_DATA'.

    line_fieldcat-seltext_m = 'Row Number'.

    APPEND line_fieldcat TO i_fieldcat.

    CLEAR line_fieldcat.

    line_fieldcat-fieldname = 'WS_CHAR'.

    line_fieldcat-tabname = 'I_DATA'.

    line_fieldcat-seltext_l = 'Test Character Field'.

    line_fieldcat-datatype = 'CHAR'.

    line_fieldcat-outputlen = '15'. " You can specify the width of a

    APPEND line_fieldcat TO i_fieldcat. " column.

    CLEAR line_fieldcat.

    line_fieldcat-fieldname = 'CHK'.

    line_fieldcat-tabname = 'I_DATA'.

    line_fieldcat-seltext_l = 'Checkbox'.

    line_fieldcat-checkbox = 'X'. " Display this field as a checkbox

    line_fieldcat-edit = 'X'. " This option ensures that you can

    " edit the checkbox. Else it will

    " be protected.

    APPEND line_fieldcat TO i_fieldcat.

    ENDFORM. " f2000_fieldcat_init

    &----


    *& Form f3000_build_header

    &----


    FORM f3000_build_header USING i_header TYPE slis_t_listheader.

    DATA: gs_line TYPE slis_listheader.

    CLEAR gs_line.

    gs_line-typ = 'H'.

    gs_line-info = 'This is line of type HEADER'.

    APPEND gs_line TO i_header.

    CLEAR gs_line.

    gs_line-typ = 'S'.

    gs_line-key = 'STATUS 1'.

    gs_line-info = 'This is line of type STATUS'.

    APPEND gs_line TO i_header.

    gs_line-key = 'STATUS 2'.

    gs_line-info = 'This is also line of type STATUS'.

    APPEND gs_line TO i_header.

    CLEAR gs_line.

    gs_line-typ = 'A'.

    gs_line-info = 'This is line of type ACTION'.

    APPEND gs_line TO i_header.

    ENDFORM. " f3000_build_header

    &----


    *& Form f4000_events_init

    &----


    FORM f4000_events_init CHANGING i_events TYPE slis_t_event.

    DATA: line_event TYPE slis_alv_event.

    CLEAR line_event.

    line_event-name = 'TOP_OF_PAGE'.

    line_event-form = 'F4100_TOP_OF_PAGE'.

    APPEND line_event TO i_events.

    CLEAR line_event.

    line_event-name = 'PF_STATUS_SET'.

    line_event-form = 'F4200_PF_STATUS_SET'.

    APPEND line_event TO i_events.

    ENDFORM. " f3000_events_init

    ----


    • FORM F4100_TOP_OF_PAGE *

    ----


    FORM f4100_top_of_page.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    it_list_commentary = i_header.

    ENDFORM.

    ----


    • FORM F4200_PF_STATUS_SET *

    ----


    FORM f4200_pf_status_set USING i_extab TYPE slis_t_extab.

    REFRESH i_extab.

    PERFORM f4210_exclude_fcodes CHANGING i_extab.

    SET PF-STATUS 'STANDARD' OF PROGRAM 'SAPLSALV' EXCLUDING i_extab.

    ENDFORM.

    &----


    *& Form f4210_exclude_fcodes

    &----


    FORM f4210_exclude_fcodes USING i_extab TYPE slis_t_extab.

    DATA: ws_fcode TYPE slis_extab.

    CLEAR ws_fcode.

    ws_fcode = '&EB9'. " Call up Report.

    APPEND ws_fcode TO i_extab.

    ws_fcode = '&ABC'. " ABC Analysis.

    APPEND ws_fcode TO i_extab.

    ws_fcode = '&NFO'. " Info Select.

    APPEND ws_fcode TO i_extab.

    ws_fcode = '&LFO'. " Information.

    APPEND ws_fcode TO i_extab.

    ENDFORM. " f4210_exclude_fcodes

    Thanks,

    Sankar M

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 22, 2007 at 04:45 AM

    Hi,

    normal ABAP is process oriented, where is OOP-ABAP is a new methodology in ABAP which uses object oriented programming.

    we have C++, java, C#, etc as OOP languages.

    ABAP has also implemented the OOP technology.

    it uses classes, methods and interfaces instead of functiongroups and function modules.

    As part of SAP’s long-standing commitment to object technology, Release 4.0

    of R/3 will contain object-oriented enhancements to the ABAP programming

    language. SAP’s object strategy is based on SAP Business Objects and now

    covers modeling, programming, interfacing, and workflow. By using principles

    like encapsulation, inheritance, and polymorphism, the object-oriented

    extensions of ABAP will support real object-oriented development. This will

    result in improvements in the areas of reusability, maintenance, and quality of

    code. SAP offers an evolutionary approach toward objects which leverages

    SAP’s own and its customers’ investments in existing business processes,

    functionality and data.

    Refer these basics

    OO ABAP

    http://www.sapgenie.com/abap/OO/eg.htm

    http://www.sapgenie.com/abap/OO/syntax.htm

    http://www.sapgenie.com/abap/OO/index.htm

    http://www.sapgenie.com/abap/OO/defn.htm

    Detailed

    OOPS – OO ABAP

    http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt

    http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf

    http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf

    http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt

    http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf

    http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt

    http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8

    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm

    http://help.sap.com/saphelp_nw2004s/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm

    Regards,

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 22, 2007 at 04:43 AM

    Hi Sri,

    This code will help u,

    <b>For Classical Report :</b>

    Here We have used two spl classes for ALV

    <b>(CL_GUI_CUSTOM_CONTAINER ,CL_GUI_ALV_GRID),</b>

    before that we should go to <b>SE51</b> and go to layout use the <b>Custom container</b> tool for displaying the table contents here only.

    REPORT ZCLASS_ALV.

    TABLES : VBAK.

    DATA : T_VBAK TYPE TABLE OF VBAK WITH HEADER LINE.

    DATA : OBJ TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

    GRID TYPE REF TO CL_GUI_ALV_GRID.

    DATA : OK_CODE LIKE SY-UCOMM.

    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-000.

    SELECT-OPTIONS : S_VBELN FOR VBAK-VBELN.

    SELECTION-SCREEN END OF BLOCK B1.

    START-OF-SELECTION.

    SELECT * FROM VBAK INTO TABLE T_VBAK

    WHERE VBELN IN S_VBELN.

    CALL SCREEN 051.

    &----


    *& Module STATUS_0051 OUTPUT

    &----


    • text

    ----


    module STATUS_0051 output.

    SET PF-STATUS 'SALES'.

    SET TITLEBAR 'TITLE'.

    CREATE OBJECT obj

    EXPORTING

    • PARENT =

    container_name = 'CC'

    • STYLE =

    • LIFETIME = lifetime_default

    • REPID =

    • DYNNR =

    • NO_AUTODEF_PROGID_DYNNR =

    • EXCEPTIONS

    • CNTL_ERROR = 1

    • CNTL_SYSTEM_ERROR = 2

    • CREATE_ERROR = 3

    • LIFETIME_ERROR = 4

    • LIFETIME_DYNPRO_DYNPRO_LINK = 5

    • others = 6

    .

    IF sy-subrc <> 0.

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

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

    ENDIF.

    CREATE OBJECT grid

    EXPORTING

    • I_SHELLSTYLE = 0

    • I_LIFETIME =

    i_parent = obj

    • I_APPL_EVENTS = space

    • I_PARENTDBG =

    • I_APPLOGPARENT =

    • I_GRAPHICSPARENT =

    • I_NAME =

    • I_FCAT_COMPLETE = SPACE

    • EXCEPTIONS

    • ERROR_CNTL_CREATE = 1

    • ERROR_CNTL_INIT = 2

    • ERROR_CNTL_LINK = 3

    • ERROR_DP_CREATE = 4

    • others = 5

    .

    IF sy-subrc <> 0.

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

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

    ENDIF.

    CALL METHOD grid->set_table_for_first_display

    EXPORTING

    • I_BUFFER_ACTIVE =

    • I_BYPASSING_BUFFER =

    • I_CONSISTENCY_CHECK =

    I_STRUCTURE_NAME = 'VBAK'

    • IS_VARIANT =

    • I_SAVE =

    • I_DEFAULT = 'X'

    • IS_LAYOUT =

    • IS_PRINT =

    • IT_SPECIAL_GROUPS =

    • IT_TOOLBAR_EXCLUDING =

    • IT_HYPERLINK =

    • IT_ALV_GRAPHICS =

    • IT_EXCEPT_QINFO =

    • IR_SALV_ADAPTER =

    CHANGING

    it_outtab = T_VBAK[]

    • IT_FIELDCATALOG =

    • IT_SORT =

    • IT_FILTER =

    • EXCEPTIONS

    • INVALID_PARAMETER_COMBINATION = 1

    • PROGRAM_ERROR = 2

    • TOO_MANY_LINES = 3

    • others = 4

    .

    IF sy-subrc <> 0.

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

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

    ENDIF.

    endmodule. " STATUS_0051 OUTPUT

    &----


    *& Module USER_COMMAND_0051 INPUT

    &----


    • text

    ----


    module USER_COMMAND_0051 input.

    case ok_code.

    when 'EXIT'.

    leave program.

    when 'BACK'.

    leave to screen 0.

    endcase.

    endmodule. " USER_COMMAND_0051 INPUT

    <b>For Interactive Report :</b>

    REPORT zcls_alv_oops MESSAGE-ID z1.

    TABLES : mara.

    \*----


    \-

    • Types Declaration..
    \

    \*----


    \-

    TYPES :

    BEGIN OF t_mara,

    matnr TYPE matnr,

    mtart TYPE mtart,

    maktx TYPE maktx,

    END OF t_mara,

    \*

    BEGIN OF t_marc,

    matnr TYPE matnr,

    werks TYPE werks_d,

    mtart TYPE mtart,

    maktx TYPE maktx,

    END OF t_marc.

    \*----


    \-

    • Internal Tables Declaration..
    \

    \*----


    \-

    DATA :

    i_mara TYPE TABLE OF t_mara,

    i_marc TYPE TABLE OF t_marc,

    i_fcat1 TYPE lvc_t_fcat,

    i_fcat2 TYPE lvc_t_fcat.

    \*----


    \-

    • Constants Declaration..
    \

    \*----


    \-

    CONSTANTS :

    c_cont1 TYPE scrfname VALUE 'CONT1',

    c_cont2 TYPE scrfname VALUE 'CONT2'.

    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.

    SELECT-OPTIONS:

    s_matnr FOR mara-matnr NO INTERVALS.

    SELECTION-SCREEN SKIP 1.

    PARAMETERS :

    p_hotspt RADIOBUTTON GROUP r1 DEFAULT 'X',

    p_bttn RADIOBUTTON GROUP r1.

    SELECTION-SCREEN END OF BLOCK b1.

    \*

    \* Class forward referncing.

    CLASS lcl_rcvr_class DEFINITION DEFERRED.

    \*----


    \-

    \* Pointers Declaration..

    \*----


    \-

    DATA :

    lp_rcvr TYPE REF TO lcl_rcvr_class,

    lp_cont1 TYPE REF TO cl_gui_custom_container,

    lp_cont2 TYPE REF TO cl_gui_custom_container,

    lp_grid1 TYPE REF TO cl_gui_alv_grid,

    lp_grid2 TYPE REF TO cl_gui_alv_grid.

    \*----


    \-

    \* Local Class Definiton.

    \*----


    \-

    CLASS lcl_rcvr_class DEFINITION.

    PUBLIC SECTION.

    METHODS :

    hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid

    IMPORTING e_row_id e_column_id es_row_no,

    \*

    handle_double_click FOR EVENT double_click OF cl_gui_alv_grid

    IMPORTING e_row e_column.

    ENDCLASS.

    \*----


    \-

    \* Local Class Implementation.

    \*----


    \-

    CLASS lcl_rcvr_class IMPLEMENTATION.

    METHOD hotspot_click.

    DATA :

    wa_mara TYPE t_mara,

    wa_marc TYPE t_marc.

    \*

    DATA :

    l_index TYPE sy-tabix.

    \*

    READ TABLE i_mara INTO wa_mara INDEX e_row_id-index.

    IF sy-subrc EQ 0.

    REFRESH i_marc.

    SELECT matnr

    werks

    INTO TABLE i_marc

    FROM marc

    WHERE matnr EQ wa_mara-matnr.

    \*

    IF sy-subrc EQ 0.

    LOOP AT i_marc INTO wa_marc.

    l_index = sy-tabix.

    wa_marc-mtart = wa_mara-mtart.

    wa_marc-maktx = wa_mara-maktx.

    MODIFY i_marc FROM wa_marc INDEX l_index

    TRANSPORTING mtart maktx.

    ENDLOOP.

    CALL SCREEN 200.

    ELSE.

    MESSAGE e121 WITH text-005 wa_mara-matnr.

    ENDIF.

    ENDIF.

    \*

    ENDMETHOD.

    \*

    METHOD handle_double_click.

    DATA :

    wa_mara TYPE t_mara,

    wa_marc TYPE t_marc.

    \*

    DATA :

    l_index TYPE sy-tabix.

    \*

    READ TABLE i_mara INTO wa_mara INDEX e_row-index.

    IF sy-subrc EQ 0.

    REFRESH i_marc.

    SELECT matnr

    werks

    INTO TABLE i_marc

    FROM marc

    WHERE matnr EQ wa_mara-matnr.

    \*

    IF sy-subrc EQ 0.

    LOOP AT i_marc INTO wa_marc.

    l_index = sy-tabix.

    wa_marc-mtart = wa_mara-mtart.

    wa_marc-maktx = wa_mara-maktx.

    MODIFY i_marc FROM wa_marc INDEX l_index

    TRANSPORTING mtart maktx.

    ENDLOOP.

    CALL SCREEN 200.

    ELSE.

    MESSAGE e121 WITH text-005 wa_mara-matnr.

    ENDIF.

    ENDIF.

    \*

    ENDMETHOD.

    ENDCLASS.

    \*----


    \-

    \* Start of Selection

    \*----


    \-

    START-OF-SELECTION.

    \* Extract the Material Master data for the Input Material.

    SELECT a~matnr

    a~mtart

    b~maktx

    INTO TABLE i_mara

    FROM mara AS a

    INNER JOIN makt AS b

    ON a~matnr EQ b~matnr

    WHERE a~matnr IN s_matnr

    AND b~spras EQ sy-langu.

    \*

    END-OF-SELECTION.

    IF NOT i_mara\[\] IS INITIAL.

    \* Call Screen to display the Material Master data.

    CALL SCREEN 100.

    ELSE.

    MESSAGE s121 WITH text-006.

    ENDIF.

    \*&----


    \*

    \*& Module DISP_GRID OUTPUT

    \*&----


    \*

    \* text

    \*----


    \*

    MODULE disp_grid OUTPUT.

    \* Build the Field catelog for Material Master data.

    PERFORM build_fcat.

    \* Display the Material Master data using ALV.

    PERFORM disp_alv.

    \*

    ENDMODULE. " DISP_GRID OUTPUT

    \*&----


    \*

    \*& Module USER_COMMAND_0100 INPUT

    \*&----


    \*

    \* text

    \*----


    \*

    MODULE user_command_0100 INPUT.

    \*

    \*when exit or cancel is clicked program has to come out

    CASE sy-ucomm.

    WHEN 'EXIT' OR 'CANC'.

    LEAVE PROGRAM.

    WHEN 'BACK'.

    LEAVE TO SCREEN 0.

    ENDCASE.

    \*

    ENDMODULE. " USER_COMMAND_0100 INPUT

    \*&----


    \*

    \*& Form build_fcat

    \*&----


    \*

    \* text

    \*----


    \*

    \* \--> p1 text

    \* <-\- p2 text

    \*----


    \*

    FORM build_fcat.

    \*

    DATA : ws_fcat TYPE lvc_s_fcat.

    \*

    ws_fcat-fieldname = 'MATNR'.

    ws_fcat-scrtext_m = text-001.

    ws_fcat-tabname = 'I_MARA'.

    IF p_hotspt EQ 'X'.

    ws_fcat-hotspot = 'X'.

    ENDIF.

    APPEND ws_fcat TO i_fcat1.

    CLEAR ws_fcat.

    \*

    ws_fcat-fieldname = 'MTART'.

    ws_fcat-scrtext_m = text-002.

    ws_fcat-tabname = 'I_MARA'.

    APPEND ws_fcat TO i_fcat1.

    CLEAR ws_fcat.

    \*

    ws_fcat-fieldname = 'MAKTX'.

    ws_fcat-scrtext_m = text-003.

    ws_fcat-tabname = 'I_MARA'.

    APPEND ws_fcat TO i_fcat1.

    CLEAR ws_fcat.

    \*

    ENDFORM. " build_fcat

    \*&----


    \*

    \*& Form disp_alv

    \*&----


    \*

    \* text

    \*----


    \*

    \* \--> p1 text

    \* <-\- p2 text

    \*----


    \*

    FORM disp_alv.

    \*

    IF lp_cont1 IS INITIAL.

    \* Create the Container Object of Material Master.

    CREATE OBJECT lp_cont1

    EXPORTING

    container_name = c_cont1

    EXCEPTIONS

    cntl_error = 1

    cntl_system_error = 2

    create_error = 3

    lifetime_error = 4

    lifetime_dynpro_dynpro_link = 5

    others = 6 .

    IF sy-subrc NE 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ELSE.

    \* Create the Object for Grid of Material Master.

    CREATE OBJECT lp_grid1

    EXPORTING

    i_parent = lp_cont1

    EXCEPTIONS

    error_cntl_create = 1

    error_cntl_init = 2

    error_cntl_link = 3

    error_dp_create = 4

    others = 5.

    IF sy-subrc NE 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ELSE.

    \* Dipslay Material Master data by calling method.

    CALL METHOD lp_grid1->set_table_for_first_display

    CHANGING

    it_outtab = i_mara

    it_fieldcatalog = i_fcat1

    EXCEPTIONS

    invalid_parameter_combination = 1

    program_error = 2

    too_many_lines = 3

    OTHERS = 4.

    IF sy-subrc NE 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ELSE.

    \* Set Handler for the Hot Spot Event.

    CREATE OBJECT lp_rcvr.

    IF p_hotspt EQ 'X'.

    SET HANDLER lp_rcvr->hotspot_click FOR lp_grid1.

    ELSE.

    SET HANDLER lp_rcvr->handle_double_click FOR lp_grid1.

    ENDIF.

    ENDIF.

    \*

    ENDIF.

    \*

    ENDIF.

    \*

    ENDIF.

    \*

    ENDFORM. " disp_alv

    \*&----


    \*

    \*& Module STATUS_0100 OUTPUT

    \*&----


    \*

    \* text

    \*----


    \*

    MODULE status_0100 OUTPUT.

    SET PF-STATUS 'MAIN_STAT'.

    SET TITLEBAR 'T_100'.

    ENDMODULE. " STATUS_0100 OUTPUT

    \*&----


    \*

    \*& Module STATUS_0200 OUTPUT

    \*&----


    \*

    \* text

    \*----


    \*

    MODULE status_0200 OUTPUT.

    SET PF-STATUS 'PLANT_STAT'.

    SET TITLEBAR 'T_200'.

    ENDMODULE. " STATUS_0200 OUTPUT

    \*&----


    \*

    \*& Module DISP_GRID_plant OUTPUT

    \*&----


    \*

    \* text

    \*----


    \*

    MODULE disp_grid_plant OUTPUT.

    \* Build the Field catelog for Material Plant data.

    PERFORM build_fcat_plant.

    \* Display the Material Master Plant data using ALV.

    PERFORM disp_alv_plant.

    ENDMODULE. " DISP_GRID_plant OUTPUT

    \*&----


    \*

    \*& Module USER_COMMAND_0200 INPUT

    \*&----


    \*

    \* text

    \*----


    \*

    MODULE user_command_0200 INPUT.

    \*

    \*when exit or cancel is clicked program has to come out

    CASE sy-ucomm.

    WHEN 'EXIT' OR 'CANC'.

    LEAVE PROGRAM.

    WHEN 'BACK'.

    LEAVE TO SCREEN 0.

    ENDCASE.

    \*

    ENDMODULE. " USER_COMMAND_0200 INPUT

    \*&----


    \*

    \*& Form build_fcat_plant

    \*&----


    \*

    \* text

    \*----


    \*

    \* \--> p1 text

    \* <-\- p2 text

    \*----


    \*

    FORM build_fcat_plant.

    DATA : ws_fcat TYPE lvc_s_fcat.

    \*

    ws_fcat-fieldname = 'MATNR'.

    ws_fcat-scrtext_m = text-001.

    ws_fcat-tabname = 'I_MARC'.

    APPEND ws_fcat TO i_fcat2.

    CLEAR ws_fcat.

    \*

    ws_fcat-fieldname = 'WERKS'.

    ws_fcat-scrtext_m = text-004.

    ws_fcat-tabname = 'I_MARC'.

    APPEND ws_fcat TO i_fcat2.

    CLEAR ws_fcat.

    \*

    ws_fcat-fieldname = 'MTART'.

    ws_fcat-scrtext_m = text-002.

    ws_fcat-tabname = 'I_MARC'.

    APPEND ws_fcat TO i_fcat2.

    CLEAR ws_fcat.

    \*

    ws_fcat-fieldname = 'MAKTX'.

    ws_fcat-scrtext_m = text-003.

    ws_fcat-tabname = 'I_MARC'.

    APPEND ws_fcat TO i_fcat2.

    CLEAR ws_fcat.

    \*

    ENDFORM. " build_fcat_plant

    \*&----


    \*

    \*& Form disp_alv_plant

    \*&----


    \*

    \* text

    \*----


    \*

    \* \--> p1 text

    \* <-\- p2 text

    \*----


    \*

    FORM disp_alv_plant.

    IF lp_cont2 IS INITIAL.

    \* Create the Container Object of Material Plant data.

    CREATE OBJECT lp_cont2

    EXPORTING

    container_name = c_cont2

    EXCEPTIONS

    cntl_error = 1

    cntl_system_error = 2

    create_error = 3

    lifetime_error = 4

    lifetime_dynpro_dynpro_link = 5

    others = 6.

    IF sy-subrc NE 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ELSE.

    \* Create the Object for Grid of Material Plant data.

    CREATE OBJECT lp_grid2

    EXPORTING

    i_parent = lp_cont2

    EXCEPTIONS

    error_cntl_create = 1

    error_cntl_init = 2

    error_cntl_link = 3

    error_dp_create = 4

    others = 5.

    IF sy-subrc NE 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ELSE.

    \* Dipslay Material Plant data by calling method.

    CALL METHOD lp_grid2->set_table_for_first_display

    CHANGING

    it_outtab = i_marc

    it_fieldcatalog = i_fcat2

    EXCEPTIONS

    invalid_parameter_combination = 1

    program_error = 2

    too_many_lines = 3

    OTHERS = 4.

    IF sy-subrc NE 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

    \*

    ENDIF.

    \*

    ENDIF.

    \*

    ELSE.

    \* Call method 'REFRESH_TABLE_DISPLAY' to refresh the grid data.

    CALL METHOD lp_grid2->refresh_table_display.

    ENDIF.

    \*

    ENDFORM. " disp_alv_plant

    Regards,

    Vijay

    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.