Require some tutorials to use ALV grids to access database

I am new to ALV grids
I want step by step method to use ALV grids in ABAP reports to access database.

Hi,
pls go throgugh this link.
http://www.erpgenie.com/abap/controls/alvgrid.htm
sample program
Sample programs on ALV Grid
report zbnstest.
TABLES AND DATA DECLARATION.
*TABLES: mara,makt.",marc.
data syrepid like sy-repid.
data sydatum(10). " LIKE sy-datum.
data sypagno(3) type n.
WHEN USING MORE THAN ONE TABLE IN ALV WE NEEED TO DECLARE THE TYPE
GROUP (TYPE-POOLS--------->SLIS)
type-pools : slis.
INTERNAL TABLE DECLARATION.
INTERNAL TABLE TO HOLD THE VALUES FROM THE MARA TABLE
data: begin of t_mara occurs 0,
matnr like mara-matnr,
meins like mara-meins,
mtart like mara-mtart,
matkl like mara-matkl,
end of t_mara.
INTERNAL TABLE TO HOLD THE CONTENTS FROM THE EKKO TABLE
data : begin of t_marc occurs 0,
matnr like mara-matnr,
werks like marc-werks,
minbe like marc-minbe.
data: end of t_marc.
INTERNAL TABLE TO HOLD THE VALUES FROM MAKT TABLE.
data : begin of t_makt occurs 0,
matnr like mara-matnr,
maktx like makt-maktx,
spras like makt-spras,
end of t_makt.
INTERNAL TABLE WHICH ACTUALLY MERGES ALL THE OTHER INTERNAL TABLES.
data: begin of itab1 occurs 0,
matnr like mara-matnr,
meins like mara-meins,
maktx like makt-maktx,
spras like makt-spras,
werks like marc-werks,
minbe like marc-minbe,
end of itab1.
THE FOLLOWING DECLARATION IS USED FOR DEFINING THE FIELDCAT
AND THE LAYOUT FOR THE ALV.
HERE AS slis_t_fieldcat_alv IS A INTERNAL TABLE WITHOUT A HEADER LINE
WE EXPLICITELY DEFINE AN INTERNAL TABLE OF THE SAME STRUCTURE AS THAT
OF slis_t_fieldcat_alv BUT WITH A HEADER LINE IN THE DEFINITION.
THIS IS DONE TO MAKE THE CODE SIMPLER.
OTHERWISE WE MAY HAVE TO DEFINE THE STRUCTURE AS IN THE NORMAL SAP
PROGRAMS.
IN THE FIELDCATALOG TABLE WE ACTUALLY PASS THE FIELDS FROM ONE OR
MORE TABLES AND CREATE A STRUCTURE
IN THE LAYOUT STRUCTURE WE BASICALLY DEFINE THE FORMATTING OPTIONS
LIKE DISPLAY IN THE ZEBRA PATTERN ,THE HOTSPOT OPTIONS ETC.
data: fieldcatalog type slis_t_fieldcat_alv with header line,
fieldlayout type slis_layout_alv.
DECLARING THE EVENTTABLE INTERNL TABLE FOR USING EVENTS LIKE
TOP-OF-PAGE ETC.
data : eventstab type slis_t_event with header line.
DECLARING AN INTERNAL TABLE TO HOLD THE DATA FOR THE TOP-OF-PAGE
data : heading type slis_t_listheader with header line.
data : heading1 type slis_t_listheader with header line.
data : heading2 type slis_t_listheader with header line.
data : heading3 type slis_t_listheader with header line.
data : heading4 type slis_t_listheader with header line.
data : heading5 type slis_t_listheader with header line.
data : heading6 type slis_t_listheader with header line.
data : heading7 type slis_t_listheader with header line.
data : heading8 type slis_t_listheader with header line.
STRUCTURE TO PASS THE COLOR ATTRIBUTES FOR DISPLAY.
data : colorstruct type slis_coltypes.
INITIALIZATION. *
initialization.
syrepid = sy-repid.
sypagno = sy-pagno.
clear fieldcatalog.
START-OF-SELECTION. *
start-of-selection.
SUBROUTINE TO POPULATE THE COLORSTRUCT
perform fill_colorstruct using colorstruct.
SUBROUTINE TO POPULATE THE FIELDS OF THE FIELD CATALOGUE
perform populate_fieldcatalog.
SUBROUTINE TO SELECT DATA FROM VARIOUS TABLES AND POPULATE IT IN THE
INTERNAL TABLE.
perform selectdata_and_sort.
SUBROUTINE TO POPULATE THE LAYOUT STRUCTURE.
perform populate_layout using fieldlayout.
SUBROUTINE TO CALL THE FUNCTION MERGE TO ENSURE PROPER DISPLAY.
perform merge_fieldcatalog.
SUBROUTINE TO POPULATE THE EVENTSTAB.
perform fill_eventstab tables eventstab.
SUBROUTINE TO POPULATE THE HEADING TABLES.
perform fill_headingtable tables heading using 'HEADING'.
perform fill_headingtable tables heading1 using 'HEADING1'.
perform fill_headingtable tables heading2 using 'HEADING2'.
perform fill_headingtable tables heading3 using 'HEADING3'.
perform fill_headingtable tables heading4 using 'HEADING4'.
perform fill_headingtable tables heading5 using 'HEADING5'.
perform fill_headingtable tables heading6 using 'HEADING6'.
perform fill_headingtable tables heading7 using 'HEADING7'.
perform fill_headingtable tables heading8 using 'HEADING8'.
SUBROUTINE TO DISPLAY THE LIST.
perform display_alv_list.
FORMS
IN THIS SUBROUTINE WE POPULATE THE FIELDCATALOG TABLE WITH THE NAMES
OF THE TABLE,FIELDNAME,WHETHER IT IS KEY FIELD OR NOT,HEADING AND
COLUMN JUSTIFICATION.
form populate_fieldcatalog.
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MATNR' 'X' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MEINS' ' '.
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MAKTX' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MTART' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MATKL' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'SPRAS' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'WERKS' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MINBE' ' ' .
endform. " POPULATE_FIELDCATALOG
FORM FILL_FIELDS_OF_FIELDCATALOG *
--> FIELDCATALOG *
--> P_TABNAME *
--> P_FIELDNAME *
--> P_KEY *
--> P_KEY *
form fill_fields_of_fieldcatalog tables fieldcatalog
structure fieldcatalog
using p_tabname
p_fieldname
p_key.
p_no_out.
fieldcatalog-tabname = p_tabname.
fieldcatalog-fieldname = p_fieldname.
fieldcatalog-key = p_key.
fieldcatalog-emphasize = '1234'.
*fieldcatalog-no_out = p_no_out.
append fieldcatalog.
endform. " FILL_FIELDSOFFIELDCATALOG
FORM POPULATE_LAYOUT *
--> FIELDLAYOUT *
form populate_layout using fieldlayout type slis_layout_alv.
fieldlayout-f2code = '&ETA' .
fieldlayout-zebra = 'X'.
FOR THE WINDOW TITLE.
fieldlayout-window_titlebar = 'ALV with Events'.
fieldlayout-colwidth_optimize = 'X'.
fieldlayout-no_vline = ' '.
*fieldlayout-no_input = 'X'.
fieldlayout-confirmation_prompt = ''.
fieldlayout-key_hotspot = 'X'.
This removes the column headings if the flag is set to 'X'
fieldlayout-no_colhead = ' '.
*fieldlayout-hotspot_fieldname = 'MAKTX'.
fieldlayout-detail_popup = 'X'.
fieldlayout-coltab_fieldname = 'X'.
endform. " POPULATE_LAYOUT
FORM SELECTDATA_AND_SORT *
form selectdata_and_sort.
select matnr meins mtart matkl from mara
into corresponding fields of t_mara
up to 500 rows .
select matnr maktx spras from makt
into corresponding fields of t_makt
where matnr = t_mara-matnr and
spras = sy-langu.
select matnr werks minbe from marc
into corresponding fields of t_marc
where matnr = t_mara-matnr.
append t_marc.
endselect.
append t_makt.
endselect.
append t_mara.
endselect.
perform populate_itab1.
sort itab1 by matnr.
endform. " SELECTDATA_AND_SORT
FORM MERGE_FIELDCATALOG *
form merge_fieldcatalog.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = syrepid
i_internal_tabname = 'ITAB1'
i_structure_name = 'COLORSTRUCT'
I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = syrepid
changing
ct_fieldcat = fieldcatalog[]
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
endform. " MERGE_FIELDCATALOG
IN THIS FUNCTION THE MINIMUM PARAMETERS THAT WE NEED TO PASS IS AS
FOLLOWS:-
i_callback_program --> CALLING PROGRAM NAME
i_structure_name --> STRUCTURE NAME.
is_layout --> LAYOUT NAME.
it_fieldcat ---> BODY OF THE FIELD CATALOGUE INTERNAL TABLE
form display_alv_list.
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
i_callback_program = syrepid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
i_structure_name = 'ITAB1'
is_layout = fieldlayout
it_fieldcat = fieldcatalog[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
THE FOLLOWING PARAMETER IS SET AS 'A' INORDER TO DISPLAY THE STANDARD
TOOL BAR
i_save = 'A'
IS_VARIANT = ' '
it_events = eventstab[]
IT_EVENT_EXIT =
IS_PRINT =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = itab1
exceptions
program_error = 1
others = 2.
endform. " DISPLAY_ALV_LIST
*& Form POPULATE_ITAB1
text
--> p1 text
<-- p2 text
form populate_itab1.
loop at t_mara.
loop at t_makt where matnr = t_mara-matnr.
loop at t_marc where matnr = t_mara-matnr.
move-corresponding t_mara to itab1.
move-corresponding t_makt to itab1.
move-corresponding t_marc to itab1.
append itab1.
endloop.
endloop.
endloop.
endform. " POPULATE_ITAB1
*& Form FILL_EVENTSTAB
text
-->P_EVENTSTAB text *
form fill_eventstab tables p_eventstab structure eventstab.
WHEN THE FOLLOWING FUNCTION IS CALLED THE SYSTEM POPULATES THE
INTERNAL TABLE EVENTSTAB WITH A LIST OF EVENTS NAME.
AS SHOWN BELOW WHEN USING I_LIST_TYPE = 0 THE FUNCTION RETURNS 14
EVENTS NAME.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = p_eventstab[]
exceptions
list_type_wrong = 1
others = 2.
BY CALLING THE ABOVE FUNCTION WE FIRST POPULATE THE EVENTSTAB WITH
THE PREDEFINED EVENTS AND THEN WE MOVE THE FORM NAME AS SHOWN BELOW.
WE ASSIGN A FORM NAME TO THE EVENT AS REQUIRED BY THE USER.
FORM NAME CAN BE ANYTHING.THE PERFORM STATEMENT FOR THIS FORM
IS DYNAMICALY CALLED.
read table p_eventstab with key name = slis_ev_top_of_page.
if sy-subrc = 0 .
move 'TOP_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_top_of_coverpage.
if sy-subrc = 0 .
move 'TOP_OF_COVERPAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_end_of_coverpage .
if sy-subrc = 0 .
move 'END_OF_COVERPAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_foreign_top_of_page.
if sy-subrc = 0 .
move 'FOREIGN_TOP_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_foreign_end_of_page.
if sy-subrc = 0 .
move 'FOREIGN_END_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_list_modify.
if sy-subrc = 0 .
move 'LIST_MODIFY' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_top_of_list.
if sy-subrc = 0 .
move 'TOP_OF_LIST' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_end_of_page.
if sy-subrc = 0 .
move 'END_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_end_of_list .
if sy-subrc = 0 .
move 'END_OF_LIST' to p_eventstab-form.
append p_eventstab.
endif.
endform. " FILL_EVENTSTAB
*& Form FILL_HEADINGTABLE
text
-->P_HEADING text *
form fill_headingtable tables p_heading structure heading
using tablename.
case tablename.
when 'HEADING'.
p_heading-typ = 'H'.
concatenate
' REPORT NAME:-' syrepid
' ABB Industry Pte Ltd' into p_heading-info.
append p_heading.
write sy-datum using edit mask '__/__/____' to sydatum.
concatenate
' DATE:-' sydatum ' USER: ' sy-uname 'PAGE NO:' sypagno
into p_heading-info.
append p_heading.
when 'HEADING1'.
p_heading-typ = 'H'.
p_heading-info = 'TOP-OF-COVER-PAGE'.
append p_heading.
when 'HEADING2'.
p_heading-typ = 'H'.
p_heading-info = 'END-OF-COVER-PAGE'.
append p_heading.
when 'HEADING3'.
p_heading-typ = 'H'.
p_heading-info = 'FOREIGN-TOP-OF-PAGE'.
append p_heading.
when 'HEADING4'.
p_heading-typ = 'H'.
p_heading-info = 'FOREIGN-END-OF-PAGE'.
append p_heading.
WHEN 'HEADING5'.
P_HEADING-TYP = 'H'.
P_HEADING-INFO = 'LIST-MODIFY'.
APPEND P_HEADING.
when 'HEADING6'.
p_heading-typ = 'H'.
p_heading-info = 'END-OF-PAGE'.
append p_heading.
when 'HEADING7'.
p_heading-typ = 'H'.
p_heading-info = 'END-OF-LIST'.
append p_heading.
when 'HEADING8'.
p_heading-typ = 'H'.
p_heading-info = 'TOP-OF-LIST'.
append p_heading.
endcase.
endform. " FILL_HEADINGTABLE
FORM TOP_OF_PAGE *
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading[]
exceptions
others = 1.
endform.
*& Form FILL_COLORSTRUCT
text
-->P_COLORSTRUCT text *
form fill_colorstruct using p_colorstruct type slis_coltypes .
p_colorstruct-heacolfir-col = 6.
p_colorstruct-heacolfir-int = 1.
p_colorstruct-heacolfir-inv = 1.
endform. " FILL_COLORSTRUCT
FORM TOP_OF_COVERPAGE *
form top_of_coverpage.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading1[]
exceptions
others = 1.
endform.
FORM END_OF_COVERPAGE *
form end_of_coverpage.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading2[]
exceptions
others = 1.
endform.
FORM FOREIGN_TOP_OF_PAGE *
form foreign_top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading3[]
exceptions
others = 1.
endform.
FORM FOREIGN_END_OF_PAGE *
form foreign_end_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading4[]
exceptions
others = 1.
endform.
FORM LIST_MODIFY *
*FORM LIST_MODIFY.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = HEADING5[]
EXCEPTIONS
OTHERS = 1.
*ENDFORM.
FORM END_OF_PAGE *
form end_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading6[]
exceptions
others = 1.
endform.
FORM END_OF_LIST *
form end_of_list.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading7[]
exceptions
others = 1.
endform.
FORM TOP_OF_LIST *
form top_of_list.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading8[]
exceptions
others = 1.
endform.
*--- End of Program
Thanks,
Shankar

Similar Messages

  • How to disable sorting for some columns in a ALV GRID?

    Hi i have requirement where I have to disable sorting for some columns in a ALV GRID. i am using REUSE_ALV_GRID_DISPLAY function module.
    Can anybody help me. how to acieve this? Any code snippets will really be appreciated.

    Hi,
    I have tried this but not completely successful. I think this can be done using the OOPS method.
      DATA: it_event_exit TYPE  slis_t_event_exit.
      DATA: w_exit TYPE slis_event_exit.
      w_exit-ucomm = '&ODN'.
      w_exit-before = 'X'.
      CLEAR w_exit-after.
      APPEND w_exit TO it_event_exit.
      w_exit-ucomm = '&OUP'.
      w_exit-before = 'X'.
      CLEAR w_exit-after.
      APPEND w_exit TO it_event_exit.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program          = w_repid
          i_callback_top_of_page      = 'ALV_TOP_OF_PAGE'
          i_callback_html_top_of_page = 'ALV_HTML_TOP_OF_PAGE'
          i_callback_user_command     = 'USER_COMMAND'  <- User command form
          is_layout                   = wm_layout
          it_fieldcat                 = wt_fieldcat
          it_events                   = i_events
          it_event_exit               = it_event_exit    <- Need to fill
          it_sort                     = wt_sort
          i_default                   = 'X'
    Now you can capture this events in the user command
    FORM user_command  USING r_ucomm LIKE sy-ucomm
                             rs_selfield TYPE slis_selfield.
      IF r_ucomm = '&OUP' and rs_selfield-SEL_TAB_FIELD = 'Your field name'.
      ENDIF.
    ENDFORM.                    "user_command
    In this form you will get the function code in 'r_ucomm' and the field selected for sorting in 'rs_selfield-SEL_TAB_FIELD'. But reseting 'r_ucomm' will not work.
    May be somebody else can give some help on this.
    But this will work if you follow the oop method.
    Please see this document for more info.
    http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/an easy reference for alv grid control.pdf
    Thanks
    Vinod

  • Want to display more than 300 charcters in a column using ALV grid display

    Hi Guru's,
    I am trying to display more than 500 charcters in a column using alv grid display but it in the output it is showing only 128 characters. Can you help me to display all the characters in particular column Or is there any limitation in maximum of no of charcters for a column?
    Thanks,
    Radha.

    Hi Paurl,
    Define a work area say
    wa_layout type slis_layout_alv.
    then fill this work area as
    wa_layout-zebra = X
    wa_layout-colwidth_optimize = X.
    wa_layout-max_linesize = 300.
    Then in FM 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    is_layout = wa_layout
    etc.
    you provided this for the field which is displayed in alv grid will have more than 128 characters.
    from this code i want,how it refers to particular field.
    when i mentioned field catalog-OUTPUTLEN = '300'.
    it is not displayed the field morethan 128 characters.
    it only displays 128 characters.
    please provide me clear and breif information with suitable code.
    i am trying what your sending but it is not displayed more than 128 characters.
    if you don't mind please spend for me some time for this and
    give me clear and breif information with suitable code.
    Thanks & Regards,
    Radhakrishna.

  • Dynamically change in size of the custom container using ALV GRID (OOPS)

    Hi Gurus!!!!
    I have an issue with the output of the report which is developed using ALV GRID (OOPS). I have used the custom container occupying full screen (Screen painter). When I execute the report using my PC the output displays report as expected in full screen. The problem is when we execute this report in 19 INCH monitor then there is always gap below the report.
    As per my understanding we should have a code to change the size of custom container dynamically.
    Please suggest some help on this.
    Thanks,
    Hemal Shah

    Hi,
    If you set the attributes, Resizing - Vertical and Horizontal for the customer container, than system will resize the size of the custome continer as per the resolution.
    Hope it helps,
    Sumana

  • How to add ALV button using OO in module pool program using ALV grid

    Hello Gurus!!!
                  Want some tips related how to add button using ALV Grid(OO).
    I want to display the button for search, sort ....
                 Please suggest the step -by-step procedure for implementation of these button.
                 I am designing the code for transaction FB03. Header data has been displayed but want to display the line items.
                 Kindly suggest your answers.
    Thanks,
    Sachin

    Hi,
    CLASS SELSCR_APPLICATION DEFINITION DEFERRED.
    CLASS SELSCR_APPLICATION DEFINITION.
      PUBLIC SECTION.
       METHODS:
            HANDLE_TOOLBAR
            FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID
                IMPORTING E_OBJECT  E_INTERACTIVE,
            HANDLE_USER_COMMAND
            FOR EVENT USER_COMMAND OF CL_GUI_ALV_GRID
                IMPORTING E_UCOMM.
    ENDCLASS.        "SELSCR_APPLICATION DEFINITION
    CLASS SELSCR_APPLICATION IMPLEMENTATION.
      METHOD HANDLE_TOOLBAR.
        DATA: LS_TOOLBAR  TYPE STB_BUTTON.
    append SAVE icon
        CLEAR LS_TOOLBAR.
        MOVE 'SAVE' TO LS_TOOLBAR-FUNCTION.
        MOVE ICON_SYSTEM_SAVE TO LS_TOOLBAR-ICON.
        MOVE 'Save' TO LS_TOOLBAR-QUICKINFO.
        MOVE ' '  TO LS_TOOLBAR-DISABLED.
        APPEND LS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
        CLEAR LS_TOOLBAR.
      ENDMETHOD.                    "handle_toolbar
      METHOD HANDLE_USER_COMMAND.
        CASE E_UCOMM.
          WHEN 'SAVE'.
              PERFORM UPDATE_FIELDS.
        ENDCASE.
      ENDMETHOD.
    ENDCLASS.                 "SELSCR_APPLICATION IMPLEMENTATION
    these lines should be after calling method SET_TABLE_FOR_FIRST_DISPLAY
    SET HANDLER G_APPLICATION1->HANDLE_TOOLBAR FOR GRID1.
            CALL METHOD grid1->set_toolbar_interactive.
    rgds,
    bharat.

  • Regarding output using alv grid display

    Hi experts,
        i have a program
    FS_TAB1-A = P_T1.
    IF P_T1 = 0.
      TEMP1 = 1.
      DO TEMP1 TIMES.
        FS_TAB1-A = P_T1 * DUMMY1.
        APPEND FS_TAB1 TO T_TAB1.
        DUMMY1 = DUMMY1  + 1.
      ENDDO.
    now i have to diplay the p_t1*dummy1 using alv grid display like it goes into thew  loop for ten times then i have to show it 10 times like
    10 1  102 103 104 111 112  like that can u help me

    hi,
        you have to get the result of the multiplication at each row and then concatenate the result and the factor to show the final result in multiples value and multiplication factor...

  • How to Display Sub-Columns using ALV Grid

    Hi ,
      Could someone tell me how to display sub-columns under a parent column using ALV Grid. Do we have any standard Program which has this scenario. Please let me know.
    Thanks,
    Abaper.
    Message was edited by:
            ABAP'er

    you can check all with <b>BCALV* or RSDEMO*</b> in SE38 for all Std
    check below
    BCALV_DND_01                   Drag ALV Row to Tree Folder
    BCALV_DND_02                   Drag Icons from Tree to Rows of the Grid
    BCALV_GRID_DND_TREE            ALV Grid: Drag and Drop with ALV Tree
    BCALV_GRID_DND_TREE_SIMPLE     ALV GRID: Drag and drop with ALV tree (simple)
    BCALV_TEST_COLUMN_TREE         Program BCALV_TEST_COLUMN_TREE
    Rewards if useful............
    Minal

  • Using ALV Grid for data Input

    Hi experts.
    Can someone assist me with information on using ALV grid for data input. Please give a simple example if possible.
    I am mainly interested in the part in which we can transfer data from the grid changing the internal table's data.

    Try this code:
    REPORT z_demo_alv_jg.
    TYPE-POOLS                                                          *
    TYPE-POOLS: slis.
    INTERNAL TABLES/WORK AREAS/VARIABLES                                *
    DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
          i_index TYPE STANDARD TABLE OF i WITH HEADER LINE,
          w_field TYPE slis_fieldcat_alv,
          p_table LIKE dd02l-tabname,
          dy_table TYPE REF TO data,
          dy_tab TYPE REF TO data,
          dy_line TYPE REF TO data.
    FIELD-SYMBOLS                                                       *
    FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
                   <dyn_wa> TYPE ANY,
                   <dyn_field> TYPE ANY,
                   <dyn_tab_temp> TYPE STANDARD TABLE.
    SELECTION SCREEN                                                    *
    PARAMETERS: tabname(30) TYPE c,
                lines(5)  TYPE n.
    START-OF-SELECTION                                                  *
    START-OF-SELECTION.
    Storing table name
      p_table = tabname.
    Create internal table dynamically with the stucture of table name
    entered in the selection screen
      CREATE DATA dy_table TYPE STANDARD TABLE OF (p_table).
      ASSIGN dy_table->* TO <dyn_table>.
      IF sy-subrc <> 0.
        MESSAGE i000(z_zzz_ca_messages) WITH ' No table found'.
        LEAVE TO LIST-PROCESSING.
      ENDIF.
    Create workarea for the table
      CREATE DATA dy_line LIKE LINE OF <dyn_table>.
      ASSIGN dy_line->* TO <dyn_wa>.
    Create another temp. table
      CREATE DATA dy_tab TYPE STANDARD TABLE OF (p_table).
      ASSIGN dy_tab->* TO <dyn_tab_temp>.
      SORT i_fieldcat BY col_pos.
    Select data from table
      SELECT * FROM (p_table)
      INTO TABLE <dyn_table>
      UP TO lines ROWS.
      REFRESH <dyn_tab_temp>.
    Display report
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program       = sy-repid
          i_structure_name         = p_table
          i_callback_user_command  = 'USER_COMMAND'
          i_callback_pf_status_set = 'SET_PF_STATUS'
        TABLES
          t_outtab                 = <dyn_table>
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
      IF sy-subrc <> 0.
      ENDIF.
    *&      Form  SET_PF_STATUS
          Setting custom PF-Status
         -->RT_EXTAB   Excluding table
    FORM set_pf_status USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'Z_STANDARD'.
    ENDFORM.                    "SET_PF_STATUS
    *&      Form  user_command
          Handling custom function codes
         -->R_UCOMM      Function code value
         -->RS_SELFIELD  Info. of cursor position in ALV
    FORM user_command  USING    r_ucomm LIKE sy-ucomm
                               rs_selfield TYPE slis_selfield.
    Local data declaration
      DATA: li_tab TYPE REF TO data,
            l_line TYPE REF TO data.
    Local field-symbols
      FIELD-SYMBOLS:<l_tab> TYPE table,
                    <l_wa>  TYPE ANY.
    Create table
      CREATE DATA li_tab TYPE STANDARD TABLE OF (p_table).
      ASSIGN li_tab->* TO <l_tab>.
    Create workarea
      CREATE DATA l_line LIKE LINE OF <l_tab>.
      ASSIGN l_line->* TO <l_wa>.
      CASE r_ucomm.
      When a record is selected
        WHEN '&IC1'.
        Read the selected record
          READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX
          rs_selfield-tabindex.
          IF sy-subrc = 0.
          Store the record in an internal table
            APPEND <dyn_wa> TO <l_tab>.
          Fetch the field catalog info
            CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
              EXPORTING
                i_program_name         = 'Z_DEMO_PDF_JG'
                i_structure_name       = p_table
              CHANGING
                ct_fieldcat            = i_fieldcat
              EXCEPTIONS
                inconsistent_interface = 1
                program_error          = 2
                OTHERS                 = 3.
            IF sy-subrc = 0.
            Make all the fields input enabled except key fields*
              w_field-input = 'X'.
              MODIFY i_fieldcat FROM w_field TRANSPORTING input
              WHERE key IS INITIAL.
            ENDIF.
          Display the record for editing purpose
            CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
              EXPORTING
                i_callback_program    = sy-repid
                i_structure_name      = p_table
                it_fieldcat           = i_fieldcat
                i_screen_start_column = 10
                i_screen_start_line   = 15
                i_screen_end_column   = 200
                i_screen_end_line     = 20
              TABLES
                t_outtab              = <l_tab>
              EXCEPTIONS
                program_error         = 1
                OTHERS                = 2.
            IF sy-subrc = 0.
            Read the modified data
              READ TABLE <l_tab> INDEX 1 INTO <l_wa>.
            If the record is changed then track its index no.
            and populate it in an internal table for future
            action
              IF sy-subrc = 0 AND <dyn_wa> <> <l_wa>.
                <dyn_wa> = <l_wa>.
                i_index = rs_selfield-tabindex.
                APPEND i_index.
              ENDIF.
            ENDIF.
          ENDIF.
      When save button is pressed
        WHEN 'SAVE'.
        Sort the index table
          SORT i_index.
        Delete all duplicate records
          DELETE ADJACENT DUPLICATES FROM i_index.
          LOOP AT i_index.
          Find out the changes in the internal table
          and populate these changes in another internal table
            READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX i_index.
            IF sy-subrc = 0.
              APPEND <dyn_wa> TO <dyn_tab_temp>.
            ENDIF.
          ENDLOOP.
        Lock the table
          CALL FUNCTION 'ENQUEUE_E_TABLE'
            EXPORTING
              mode_rstable   = 'E'
              tabname        = p_table
            EXCEPTIONS
              foreign_lock   = 1
              system_failure = 2
              OTHERS         = 3.
          IF sy-subrc = 0.
          Modify the database table with these changes
            MODIFY (p_table) FROM TABLE <dyn_tab_temp>.
            REFRESH <dyn_tab_temp>.
          Unlock the table
            CALL FUNCTION 'DEQUEUE_E_TABLE'
              EXPORTING
                mode_rstable = 'E'
                tabname      = p_table.
          ENDIF.
      ENDCASE.
      rs_selfield-refresh = 'X'.
    ENDFORM.                    "user_command

  • How to start to use Oracle client to access Database ?

    Folks,
    Hello. I have just installed Oracle Client into directory /home/myOracle/Oracle_Client. But I don't know how to start and configure the client to access Oracle Database.
    Can any folk tell me how to start to use Oracle client to access Database ?

    user13764998 wrote:
    I have earlier managed to install the Oracle Client (32-bit) in 32-bit clients and servers Oracle Client 10.
    The reason that it went well before was the exellent setup and configurationprograms we got with that version.It seems you are confusing the "full" Datbase Client with Instant Client.
    Now I'm trying to install the Oracle Instant Client 11g R2 both 32-bit and 64 (of the latest revision) on a 64-bit Windows 2008 Server .
    I have managed to install the driver but the setup doesn't give me any Net Configuration Assistant or Net Manager to help with the configuration.What setup? Are you not using just the zip files?
    What are you installing exactly, i.e. what install media (file) did you download?
    So I haven't succeded in configuring it despite I I read the readme-info that comes with the Instant Client files.There's not much to configure - that's sort of the point of Instant Client. Just drop a few files in a folder, set PATH and off you go.
    Doesn't <instant client dir>\sqlplus user@'hostname/servicename' work?

  • Hide some cells while displaying ALV GRID !

    Hi guyz!
        Back with lill query,
        While displaying ALV GRID using REUSE_ALV_GRID... FMs ,i need to hide
        some cells by default, when the lists is generated.But those cells should
        be  availble to be displayed by the user from ALV layout settings.
        Please advise
    Thanks
    jahan

    Hi, Check for fm documentation.
    Only relevant if layout parameter
    LAYOUT-GET_SELINFOS of IMPORTING structure IS_LAYOUT is set.
    Complex type for modifying information displayed on the selection dialog box:
    mode:              'R' = Only entries passed in internal table
                              IS_SEL_HIDE-T_ENTRIES are output on
                              the dialog box. Selection information
                              obtained by the list tool by reading the
                              selection screen again (only if the report
                              is called with selection screen) are
                              replaced by the entries passed.
                       'S' = The selection information obtained by the
                              list tool by reading the selection screen
                              of the calling report again, are modified
                              by the entries of table
                              IS_SEL_HIDE-T_ENTRIES.
    t_entries:         Table with selection information
    t_entries-mode:   'A' = Display selection information of the current
                             table row on the information dialog box.
                      'D' = Do not display selection information of the
                             the Select option or of parameter SELNAME
                             on the dialog box.
    t_entries-selname: (required only if t_entries-mode = 'D')
                       name of Select option or parameter
    The following table fields are only required if t_entries-mode = 'A'. They contain the selection information to be added.
    t_entries-field:  DDIC field name of the field for which selection
                       information is to be displayed
    t_entries-table:  DDIC table name of t_entries-field.
    t_entries-stext:  Field description on the information dialog box.
                      If t_entries-field and t_entries-table were
                      filled, this text is taken from the DDIC.
    t_entries-valuf:  Selection condition from-value (external format)
    t_entries-valut:  Selection condition to-value (external format)
    t_entries-sign0:  (I)nclusive (E)xclusive
    t_entries-optio:  All values of the option field of the Select
                      option are allowed.
    The remaining fields are used internally and are irrelevant to the caller.
    aRs

  • Simple tutorial for using alv-grid for data entry into table, please!

    Hi friends,
    I urgently need a basic, simple tutorial or step-by-step or sample code on the following:
    I want to have a alv-grid like entry list where i can add/remove additional lines/entries that then are saved into an internal table. Please help me with that, as i studied already some documents but do not really get the idea of how to do - <REMOVED BY MODERATOR>
    Thanks in advance,
    Edited by: Alvaro Tejada Galindo on Jan 11, 2008 6:18 PM

    hi clemens,
    follow this link it may be useful to u
    http://www.sap-basis-abap.com/sapab033.htm
    http://www.abapprogramming.blogspot.com/2007/04/alv-details.html
    for tutorial on alv:
    http://www.sapbrainsonline.com/TUTORIALS/TECHNICAL/ALV_tutorial.html
    i have pdf material also ican give it to you if u give your email id.
    hope this helps you
    regards,
    sravanthi

  • Suppressing some subtotals in an ALV grid

    Hi,
    Does anyone know if it is possible to suppress some of the subtotals in an ALV grid? In some cases I have redundant subtotals, and I would like to suppress one of them. I am using the event SUBTOTAL_TEXT, and this is not something I can control with the sort order.
    Thanks,
    Margaret Brooker.

    Hi Margaret,
    You might want to take a look at the Development Class (Package) in the Object Navigator (SE80) called SLIS.
    There you will find excellent ALV demo programs that illustrate many possible customizations to the Alv grid.
    Although there is not an exact supress subtotal example, you could probably create your own pushbuttons or events to embed your own logic.
    It is possible to create a local class and implement a double click event, which could delete a duplicate line or any other preferred logic that you code.
    cheers,
    Marilyn

  • Create deep structure to disable some cells in Dynamic ALV GRID

    Hi,
    I want to disable some cells in a Dynamic ALV Grid before calling "SET_tABLE_Display" Method.
    I check the BCALV_EDIT_02, where some cells are grayed out by assign the  CL_GUI_ALV_GRID-MC_STYLE_DISABLED  to the field name.
    But I want the same using Field symbol.
    I'm creating Dynamic table and dynamic structure based on the Dynamic field catalog.
    Example: <FT_TAB> TYPE STANDARD TABLE,
                    <FS_TAB> TYPE ANY,            
    DATA: INT_TAB  is my dynamic table values.
    For the INT_TAB internal table, I created dynamic Structure and dynamic field symbol table.
    LOOP AT INT_TAB.
    ASSIGN COMPONENT 'MATNR'  OF STRUCTURE <FS_TAB> TO <F_VALUE>
    <F_VALUE> = INT_TAB-MATNR.
    APPEND <FS_TAB> TO <FT_TAB>
    "Here is the problem occurs, I want to grayed out the MATNR value based on some condition.
    ENDLOOP.
    I would like to set the 'MATNR' value to be grayed out by passing the CL_GUI_ALV_GRID-MC_STYLE_DISABLED.
    and update into <FT_TAB>(       <FT_TAB> structure will have 2 structures)
    Finally the fieldsymbol should have two structure ( <F_TAB> = DYNAMIC STRUCTURE + LVC_S_STYLE )
    Display alv grid by passing <FT_TAB> to set_table_display method.
    Thanks in advance,
    Kumar.

    Hi,
    I am  not sure whether I really understand your request. Let me try to help.
    > Example: <FT_TAB> TYPE STANDARD TABLE,
    >                 <FS_TAB> TYPE ANY,            
    >
    > DATA: INT_TAB  is my dynamic table values.
    >
    >
    > LOOP AT INT_TAB.
    >  ASSIGN COMPONENT 'MATNR'  OF STRUCTURE <FS_TAB> TO <F_VALUE>
    > <F_VALUE> = INT_TAB-MATNR.
    >  APPEND <FS_TAB> TO <FT_TAB>
    Here <FT_TAB> must already be assigned to some internal table with a given (dynamic) structure. Did this happen before this piece of code?
    What I would do is to create a dynamic table (see documentation to CREATE DATA) with MATNR and the STYLE field (LVC_T_STYL). See the documentation for CREATE DATA - creation of internal tables. When collection the field descriptions for that internal table I would also build the field catalogue for the ALV.
    Then assign <FT_TAB> to that newly created internal table, <FS_TAB> to a newly created structure (same as a table line).
    Move the MATNR to component 1 (or component 'MATNR') of the table and fill the style table according to your needs. Then insert the <FS_TAB> into <FT_TAB>.
    Finally call the ALV SET_TABLE... method with your dynamic table and your field catalogue.
    Regards,
    Gerd Rother

  • Updating database table using ALV Grid class CL_ALV_CHANGED_DATA_PROTOCOL

    Hi,
    I am trying to use class CL_ALV_CHANGED_DATA_PROTOCOL to update a database table from an ALV grid.
    I have used program BCALV_EDIT_04 as an example.
    I am able to successfully processed inserted or deleted lines using the attributes
    MT_DELETED_ROWS
    MT_INSERTED_ROWS
    but I also want to process modified lines.
    I was just wondering whether anyone out there has some example code for this.
    I can see that there are the following attributes available
    MT_MOD_CELLS
    MP_MOD_ROWS.
    I would ideally like to use MP_MOD_ROWS rather than  MT_MOD_CELLS but it is not clear to me what type MP_MOD_ROWS is.
    If anyone has any example code for this sort of thing, please let me know.
    Thanks,
    Ruby

    hi Ruby,
    Yes we can use that *data reference variable *.
    It is a variable( something comparable to a pointer ) that points to a int table( table with changed contents )
    which ll be created at run-time based on the data type ot the internal table that we pass to the parameter it_outtab of method set_table_for_first_display ...
    assign er_data_changed->mp_mod_rows->* to a field-symbol and use it...
    Check the below code for example -> method refresh_changed_data
    screen flow logic.
    PROCESS BEFORE OUTPUT.
      MODULE pbo.
    PROCESS AFTER INPUT.
      MODULE pai.
    main program.
    *       CLASS lcl_event_responder DEFINITION                           *
    CLASS lcl_event_responder DEFINITION.
      PUBLIC SECTION.
        DATA  : ls_changed_cell TYPE  lvc_s_modi,
                lv_language     TYPE  spras..
        METHODS refresh_changed_data  FOR EVENT data_changed
                                      OF cl_gui_alv_grid
                                      IMPORTING er_data_changed
                                                e_ucomm.
    ENDCLASS.                    "event_responder DEFINITION
    TYPES tt_makt TYPE STANDARD TABLE OF makt.
    DATA: go_handler         TYPE REF TO lcl_event_responder,
          go_grid            TYPE REF TO cl_gui_alv_grid,
          gt_fieldcat        TYPE lvc_t_fcat,
          gv_language        TYPE spras VALUE 'E',
          gt_outtab          TYPE tt_makt,
          gs_tableline       TYPE LINE OF tt_makt.
    FIELD-SYMBOLS : <changed_rows> TYPE tt_makt.
    CALL SCREEN 100.
    *       MODULE PBO OUTPUT                                             *
    MODULE pbo OUTPUT.
      SET PF-STATUS 'BASIC'.
      PERFORM create_and_init_alv CHANGING gt_outtab[]
                                           gt_fieldcat.
    ENDMODULE.                    "pbo OUTPUT
    *       MODULE PAI INPUT                                              *
    MODULE pai INPUT.
      LEAVE PROGRAM.
    ENDMODULE.                    "pai INPUT
    FORM create_and_init_alv CHANGING pt_outtab LIKE gt_outtab[]
                                      pt_fieldcat TYPE lvc_t_fcat.
      CHECK go_grid IS NOT BOUND.
      CREATE OBJECT go_grid
        EXPORTING
          i_parent = cl_gui_container=>default_screen.
      PERFORM build_display_table.
      PERFORM build_fieldcat CHANGING pt_fieldcat.
      go_grid->set_table_for_first_display( CHANGING  it_fieldcatalog      = pt_fieldcat
                                                      it_outtab            = pt_outtab ).
      go_grid->set_ready_for_input( 1 ).
    * raises the 'data_changed' event when we select another cell/any action after changing the data
      go_grid->register_edit_event( EXPORTING i_event_id = cl_gui_alv_grid=>mc_evt_enter ).
      CREATE OBJECT go_handler.
      SET HANDLER go_handler->refresh_changed_data FOR go_grid.
    ENDFORM.                               "CREATE_AND_INIT_ALV
    FORM build_display_table.
      FREE gt_outtab.
      SELECT * FROM makt UP TO 20 ROWS INTO TABLE gt_outtab WHERE spras EQ gv_language.
    ENDFORM.                               "build_display_table
    FORM build_fieldcat CHANGING pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = 'MAKT'
        CHANGING
          ct_fieldcat      = pt_fieldcat.
      LOOP AT pt_fieldcat INTO ls_fcat.
        ls_fcat-edit       = abap_true.
        MODIFY pt_fieldcat FROM ls_fcat.
      ENDLOOP.
    ENDFORM.                               "build_fieldcat
    *       CLASS event_responder IMPLEMENTATION                          *
    CLASS lcl_event_responder IMPLEMENTATION.
      METHOD refresh_changed_data.
        ASSIGN er_data_changed->mp_mod_rows->* TO <changed_rows>.
        LOOP AT <changed_rows> INTO gs_tableline.
          BREAK-POINT.
        ENDLOOP.
      ENDMETHOD.                    "click
    ENDCLASS.                    "event_responder IMPLEMENTATION
    Cheers,
    Jose.

  • Max no of records that can be dispalyed using ALV GRID CONTROLS

    Hi ,
    Can any one please tell me the maximum no of records that are allowed to be displayed using the ALV grid controls.
    As I am getting dump for more records and I need to control the report based on the max no of records that can be actually diplayed using contols.
    Thanks,
    Kavya.

    Dear Kavya.
    If you are getting Dump because you have too many records it means that there is something wrong with the program design.
    ALV is not meant to display more than few thousands of records.
    There is no point is displaying more than few thousands because it will over-flow the users and it will do no good for them.
    If the problem is with the Internal-tables that you're using to manipulate the data, you can think of using an intermidiate DB table that will hold summarized data of the DB data and can be filled via a periodic job. This have the benfit of speeding up the ALV program too.
    thanx
    ayal.

Maybe you are looking for

  • Adobe flash player - webcam bild verpixelt,wenn ich sende

    hallo nun ich habe seit etwa einem Jahr ein Problem mit dem Adobe flash player.Bin schon am verzweifeln und hoffe dass jemand hier eine Idee hat was ich noch tun könnte. Mein Problem: Ich kann mit meinem Adobe flash player ohne Probleme Inhalte aufru

  • Can't scan from my HPC4280 with new Snow Leopard

    I downloaded the new snow leopard and now my HPC4280 All In One scanner is not working. Printer and copier works fine. I've tried the 3 fixes from the HP support but nothing is working. I went to System Preference clicked on printer/fax, click on the

  • How to use bluetooth function for the Mega player(522BT)

    Hello all!!!!!     Pls ,help me! I am from Myanmar.I can't use Mega player(522BT)for PC to the bluetooth function of this device. That is ,we can only use the phone to this device. I want to know.   Pls,help me.                          With Regards,

  • Getting AbstractMethodError exception

    hola.... i'm running this on a unix server with no display attached to it, i.e. headless server. i have Xvfb running as well. i have set he display variable in the script of the username under which the app server runs. did a whole lot of R&D and sti

  • Scanning option disappeare​d from HP Officejet Pro shortcut

    i have a new office jet pro 8600 all in one.  After installation a desk top short cut appeared that when opened enabled me to access scanning, printing, faxing... all from one spot.  After scanning for the first time from this window now it only list