‎2007 Jul 23 6:42 AM
Hi,
based on this fields i want simple report?
EMP
surname
Intials
NHI No
GROSS
AN/SAL
SPARE
EMP PEN
AVC
Co Pay
DOL
Sex-
DOB
Pen SA
Thanks
sree
‎2007 Jul 23 6:58 AM
HI
First you have to build some thing by your own then only any one can help you for the same i.e. about the scenario and the related tables.
Secondly are you planning any selection screen or some alv type.
Please clarify.
Regards
Dinesh
‎2007 Jul 23 9:55 AM
It's absolutely EASY. I've got a Generalized class which I'll list below. Simply add that as an INCLUDE into your program then you only need a few lines of code WHATEVER YOUR INTERNAL TABLE, and you've got built in event handlers etc etc if you need them..
First Code 1 BLANK screen with a custom container CCONTAINER1.
Here's a sample program. Just change the structure of my table to your structure.
Program ZJIMBOTESTX.
DEFINE col_name.
read table it_fldcat into wa_it_fldcat index &1.
wa_it_fldcat-coltext = &2.
modify it_fldcat from wa_it_fldcat index &1.
end-of-definition.
FIELD-SYMBOLS :
<fs1> TYPE ANY,
<fs2> TYPE STANDARD TABLE,
<dyn_table> TYPE STANDARD TABLE,
<dyn_field>,
<dyn_wa>.
INCLUDE ZZJIMBOXX_INCL. " ====> class code shown after this
program in the same post
INCLUDE <icon>.
Define your ITAB here into a structure s_elements.
TYPES: BEGIN OF s_elements,
kunnr TYPE kna1-kunnr,
name1 TYPE kna1-name1,
stras TYPE kna1-stras,
telf1 TYPE kna1-telf1,
ort01 TYPE kna1-ort01,
pstlz TYPE kna1-pstlz,
END OF s_elements.
DATA: z_object type ref to zcl_dog, "Instantiate our class
t_elements TYPE TABLE OF s_elements, "refers to our ITAB
wa_elements TYPE s_elements,
wa_dyn_table_line TYPE REF TO DATA,
it_fldcat TYPE lvc_t_fcat,
new_table TYPE REF TO DATA,
dy_table TYPE REF TO data,
dy_line TYPE REF TO data.
START-OF-SELECTION.
CALL SCREEN 100.
END-OF-SELECTION..
MODULE status_0100 OUTPUT.
ASSIGN wa_elements TO <fs1>.
*Instantiate our zcl_dog class
CREATE OBJECT
z_object
EXPORTING
z_object = z_object.
CALL METHOD z_object->build_dynamic_structures
CHANGING it_fldcat = it_fldcat.
PERFORM populate_dynamic_itab.
Display ALV grid with our EXIT tool button
CALL METHOD z_object->display_grid
CHANGING it_fldcat = it_fldcat.
ENDMODULE.
MODULE user_command_0100 INPUT.
PAI not needed as we are using EVENTS
ENDMODULE.
FORM populate_dynamic_itab.
Change this section to populate YOUR ITAB.
If you do it this way the move-corresponding will work
otherwise move fields manually.
SELECT kunnr name1 stras telf1 ort01 pstlz
UP TO 200 rows
FROM kna1
INTO CORRESPONDING FIELDS OF TABLE <dyn_table>.
ENDFORM.
Now I 've done your ENTIRE program for you and you can use this approach for ANY tables.
Finally insert this CLASS definition into an INCLUDE ZJIMBOXXX_INCL.
*
CLASS zcl_dog DEFINITION.
PUBLIC SECTION.
METHODS:
constructor
IMPORTING z_object type ref to zcl_dog,
i_parent type ref to cl_gui_custom_container,
display_grid
CHANGING it_fldcat type lvc_t_fcat,
build_dynamic_structures
CHANGING it_fldcat TYPE lvc_t_fcat.
PRIVATE SECTION.
METHODS:
on_user_command FOR EVENT before_user_command OF cl_gui_alv_grid
IMPORTING e_ucomm
sender,
on_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object
e_interactive,
on_dubbelklik FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row
e_column
es_row_no,
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed,
handle_data_changed_finished
FOR EVENT data_changed_finished OF cl_gui_alv_grid
IMPORTING e_modified
et_good_cells,
verwerk
IMPORTING program type sy-repid,
download_to_excel,
return_structure,
create_dynamic_fcat
EXPORTING it_fldcat TYPE lvc_t_fcat,
create_dynamic_table
IMPORTING it_fldcat TYPE lvc_t_fcat
EXPORTING dy_table TYPE REF TO DATA.
DATA:
lr_rtti_struc TYPE REF TO cl_abap_structdescr, "RTTI
zog LIKE LINE OF lr_rtti_struc->components, "RTTI
wa_it_fldcat TYPE lvc_s_fcat,
it_fldcat TYPE lvc_t_fcat,
dy_table TYPE REF TO data,
dy_line TYPE REF TO data,
struct_grid_lset TYPE lvc_s_layo,
grid_container1 TYPE REF TO cl_gui_custom_container,
grid1 TYPE REF TO cl_gui_alv_grid.
data: ls_layout type kkblo_layout,
lt_fieldcat_wa type kkblo_fieldcat,
l_mode type raw4,
celltab type LVC_T_STYL,
wa_celltab type lvc_s_styl,
lt_fieldcat type kkblo_t_fieldcat.
data: l_tabname type slis_tabname.
TYPES:
struc LIKE zog.
DATA:
zogt TYPE TABLE OF struc.
ENDCLASS.
CLASS zcl_dog IMPLEMENTATION.
METHOD constructor.
CALL METHOD super->constructor
EXPORTING
i_appl_events = 'X'
i_parent = i_parent.
.
CREATE OBJECT grid_container1
EXPORTING
container_name = 'CCONTAINER1'.
CREATE OBJECT grid1
EXPORTING
i_parent = grid_container1.
SET HANDLER z_object->on_user_command for grid1.
SET HANDLER z_object->on_toolbar for grid1.
SET HANDLER Z_OBJECT->handle_data_changed_finished FOR grid1.
SET HANDLER Z_OBJECT->on_dubbelklik FOR grid1.
CALL METHOD grid1->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
ENDMETHOD.
METHOD on_dubbelklik.
break-point 1.
ENDMETHOD.
METHOD handle_data_changed.
Insert user code here if required
this method is entered if user ENTERS DATA.
ENDMETHOD.
METHOD handle_data_changed_finished.
Insert user code here if required
Method entered here after data entry has finished.
ENDMETHOD.
METHOD return_structure.
lr_rtti_struc ?= cl_abap_structdescr=>DESCRIBE_BY_DATA( <fs1> ).
zogt[] = lr_rtti_struc->components.
ASSIGN zogt[] TO <fs2>.
ENDMETHOD.
METHOD create_dynamic_fcat.
LOOP AT <fs2> INTO zog.
CLEAR wa_it_fldcat.
wa_it_fldcat-fieldname = zog-name .
wa_it_fldcat-datatype = zog-type_kind.
wa_it_fldcat-inttype = zog-type_kind.
wa_it_fldcat-intlen = zog-length.
wa_it_fldcat-decimals = zog-decimals.
wa_it_fldcat-coltext = zog-name.
wa_it_fldcat-lowercase = 'X'.
APPEND wa_it_fldcat TO it_fldcat .
assign it_fldcat[] to <field_catalog>.
ENDLOOP.
assign it_fldcat[] to <field_catalog>.
ENDMETHOD.
METHOD download_to_excel.
break-point 5.
call function 'LVC_TRANSFER_TO_KKBLO'
exporting
it_fieldcat_lvc = <field_catalog>
is_layout_lvc = m_cl_variant->ms_layout
is_tech_complete = ' '
importing
es_layout_kkblo = ls_layout
et_fieldcat_kkblo = lt_fieldcat.
loop at lt_fieldcat into lt_fieldcat_wa.
clear lt_fieldcat_wa-tech_complete.
if lt_fieldcat_wa-tabname is initial.
lt_fieldcat_wa-tabname = '1'.
modify lt_fieldcat from lt_fieldcat_wa.
endif.
l_tabname = lt_fieldcat_wa-tabname.
endloop.
call function 'ALV_XXL_CALL'
exporting
i_tabname = l_tabname
is_layout = ls_layout
it_fieldcat = lt_fieldcat
i_title = sy-title
tables
it_outtab = <dyn_table>
exceptions
fatal_error = 1
no_display_possible = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type 'S' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
to be implemented
ENDMETHOD.
METHOD create_dynamic_table.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fldcat
IMPORTING
ep_table = dy_table.
ENDMETHOD.
METHOD build_dynamic_structures.
CALL METHOD me->return_structure.
CALL METHOD me->create_dynamic_fcat
IMPORTING
it_fldcat = it_fldcat.
CALL METHOD me->create_dynamic_table
EXPORTING
it_fldcat = it_fldcat
IMPORTING
dy_table = dy_table.
ASSIGN dy_table->* TO <dyn_table>.
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.
ENDMETHOD.
METHOD display_grid.
struct_grid_lset-edit = 'X'. "To enable editing in ALV
struct_grid_lset-grid_title = 'Bulkwijzigingen inkoopprijzen'.
struct_grid_lset-ctab_fname = 'T_CELLCOLORS'.
struct_grid_lset-stylefname = 'CELLTAB'.
CALL METHOD grid1->set_ready_for_input
EXPORTING
i_ready_for_input = '1'.
loop at <dyn_table> into <dyn_wa>.
refresh celltab.
wa_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
wa_celltab-fieldname = 'KUNNR'.
insert wa_celltab into table celltab.
wa_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
wa_celltab-fieldname = 'NAME1'.
insert wa_celltab into table celltab.
INSERT LINES OF celltab INTO wa_celltab-celltab.
MODIFY <dyn_table> > index sy-index.
endloop.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
is_layout = struct_grid_lset
CHANGING
it_outtab = <dyn_table>
it_fieldcatalog = it_fldcat.
ENDMETHOD.
METHOD on_user_command.
CASE e_ucomm.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'EXCEL'.
CALL METHOD me->download_to_excel.
WHEN 'SAVE'.
WHEN 'VERW'.
CALL METHOD me->verwerk
EXPORTING
PROGRAM = SY-REPID.
ENDCASE.
ENDMETHOD. "on_user_command
METHOD on_toolbar.
DATA: ls_toolbar TYPE stb_button.
CLEAR ls_toolbar.
MOVE 0 TO ls_toolbar-butn_type.
MOVE 'EXIT' TO ls_toolbar-function.
MOVE SPACE TO ls_toolbar-disabled.
MOVE icon_system_end TO ls_toolbar-icon.
MOVE 'Click2Exit' TO ls_toolbar-quickinfo.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
MOVE 0 TO ls_toolbar-butn_type.
MOVE 'SAVE' TO ls_toolbar-function.
MOVE SPACE TO ls_toolbar-disabled.
MOVE icon_system_save TO ls_toolbar-icon.
MOVE 'Save data' TO ls_toolbar-quickinfo.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
MOVE 0 TO ls_toolbar-butn_type.
MOVE 'EDIT' TO ls_toolbar-function.
MOVE SPACE TO ls_toolbar-disabled.
MOVE icon_toggle_display_change TO ls_toolbar-icon.
MOVE 'Edit data' TO ls_toolbar-quickinfo.
MOVE 'EDIT' TO ls_toolbar-text.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
MOVE 0 TO ls_toolbar-butn_type.
MOVE 'VERW' TO ls_toolbar-function.
MOVE SPACE TO ls_toolbar-disabled.
MOVE icon_businav_process to ls_toolbar-icon.
MOVE 'Verw.' TO ls_toolbar-quickinfo.
MOVE 'VERW' TO ls_toolbar-text.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
MOVE 0 TO ls_toolbar-butn_type.
MOVE 'EXCEL' TO ls_toolbar-function.
MOVE SPACE TO ls_toolbar-disabled.
MOVE icon_xxl TO ls_toolbar-icon.
MOVE 'Excel' TO ls_toolbar-quickinfo.
MOVE 'EXCEL' TO ls_toolbar-text.
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDMETHOD.
METHOD verwerk.
PERFORM verwerk IN PROGRAM (program).
LEAVE PROGRAM.
ENDMETHOD.
ENDCLASS.
Easy isn't it.
Now you'll never have to spend much time on these type of reports again.
The class also contains methods where you canm do things if the user enters data etc etc.
Cheers
JIMBO
‎2007 Jul 23 5:08 PM
Hi,
I think that you must separate your tasks in parts:
1 - The Selection parameters;
<b>TABLES kna1.
</b>
Parameters Definitions
<b>SELECT-OPTIONS s_kunnr FOR kna1-kunnr OBLIGATORY.</b>
2 - Data Definitions;
Internal table Definition
<b>DATA: table_kna1 TYPE TABLE OF kna1.</b>
Line Type Definition
<b>DATA: line_kna1 TYPE kna1.</b>
3 - Data Selections;
<b>START-OF-SELECTION.</b>
Selections
<b> SELECT *
FROM kna1
INTO TABLE table_kna1
WHERE kunnr IN s_kunnr.
</b>
4 - Treatment of the found registers, and data's exhibition.
<b> IF NOT table_kna1[] IS INITIAL.</b>
it reads each line in internal table <u>table_kna1</u> and places it in line table <u>line_kna1</u>
<b>LOOP AT table_kna1 INTO line_kna1.</b>
Write line_kna1-kunnr and line_kna1-name1 on screen
<b>WRITE: / line_kna1-kunnr, line_kna1-name1.</b>
<b>ENDLOOP.</b>
<b>ELSE.</b>
Error tratament -> PRESS F1 IN (MESSEGE)
<b>ENDIF.</b>
Finally :
<b>1000 DROGARIAS PACHECO S/A
1001 DISTR FARM PANARELLO LTDA
1002 BAYER COLOMBIA
1003 DISTR ALFA MEDICAMENTOS LTDA </b>
Ok, This is a simple report, but, it's common to use:
Function module -> <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=reuse_alv_grid_display&adv=false&sortby=cm_rnd_rankvalue">reuse_alv_grid_display</a>;
Class (ABAP Objects concept necessary ) -> <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4544e790-0201-0010-c29c-e46c389f5a96">CL_GUI_ALV_GRID</a> or <a href="https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=alvObjectModel+&adv=false&sortby=cm_rnd_rankvalue">CL_SALV*</a> classes.
Regards.
Marcelo Ramos