2007 Mar 01 7:04 AM
Guyz!!!
plzzz help me out...
I have no idea about ALV with oops...
can ny1 give me a vague idea wat the use of oops in alv's is..
and how'll we implement dat??
and wud be helpful if some1 give me spoon feed material regarding the same...
now...dont ask me to go thru the threads...i already did...
materials were so complicated for a fresher in thr...
regards
zid
Guyz!!!
plzzz help me out...
I have no idea about ALV with oops...
can ny1 give me a vague idea wat the use of oops in alv's is..
and how'll we implement dat??
and wud be helpful if some1 give me spoon feed material regarding the same...
now...dont ask me to go thru the threads...i already did...
materials were so complicated for a fresher in thr...
regards
zid
2007 Mar 01 7:12 AM
Hi,
You can desing the ALV reports using the ABAP Objects, i.e using Classes/Interfaces/Methods/Events etc.
You should be aware of these things means you should have little knowledge of Java to code this.
First we define the class.
then define the methods with parameters (import/Export)
Define the Events and handlers to handle messages.
You have to write the program in SE38 using this class and methods.
for ALV you can use the std class.
Again there are two types classes we use. Local classes and Global classes.
Better to use global Classes only.
Go through the sample code;
Report:
&----
*& Report ZCL_MAT_ALV
&----
report zcl_mat_alv.
data : obj type ref to zcl_mat_alv.
parameters : p_matnr like mara-matnr.
start-of-selection.
set screen 100.
&----
*& Module STATUS_0100 OUTPUT
&----
text
----
module status_0100 output.
set pf-status 'MENU'.
if obj is initial.
create object obj
exporting
p_cont ='MAT_CONT'.
endif.
call method obj->get_data
exporting
p_matnr = p_matnr.
endmodule. " STATUS_0100 OUTPUT
&----
*& Module USER_COMMAND_0100 INPUT
&----
text
----
module user_command_0100 input.
case sy-ucomm.
when 'BACK'.
leave program.
endcase.
endmodule. " USER_COMMAND_0100 INPUT
Class Declaration(SE24):
Attributes:
Methods:
Methods definition:
method constructor.
create object o_cont
exporting
PARENT =
container_name = p_cont
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.
else.
create object o_grid
exporting
I_SHELLSTYLE = 0
I_LIFETIME =
i_parent = o_cont
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.
endif.
endmethod.
method get_data.
select * from mard
into corresponding fields of table it_mat
where matnr = p_matnr.
if not it_mat[] is initial.
call method show_grid.
endif.
endmethod.
method show_grid.
data : it_fldcat type lvc_t_fcat.
data : wa_fldcat like line of it_fldcat.
data : it_sort type lvc_t_sort,
wa_sort like line of it_sort.
call function 'LVC_FIELDCATALOG_MERGE'
exporting
I_BUFFER_ACTIVE = I_BUFFER_ACTIVE
i_structure_name = 'ZMARD'
I_CLIENT_NEVER_DISPLAY = 'X'
I_BYPASSING_BUFFER = I_BYPASSING_BUFFER
I_INTERNAL_TABNAME = I_INTERNAL_TABNAME
changing
ct_fieldcat = it_fldcat[]
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
exit.
else.
loop at it_fldcat into wa_fldcat.
case wa_fldcat-fieldname.
when 'MATNR'.
wa_fldcat-reptext = 'Material No'.
wa_fldcat-ref_table = 'X'.
when 'WERKS'.
wa_fldcat-reptext = 'Plant'.
wa_fldcat-ref_table = 'X'.
when 'LGORT'.
wa_fldcat-reptext = 'Storage.Loc.'.
when 'LABST'.
wa_fldcat-reptext = 'Qty'.
wa_fldcat-do_sum = 'X'.
endcase.
modify it_fldcat from wa_fldcat index sy-tabix.
endloop.
wa_sort-fieldname = 'MATNR'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
append wa_sort to it_sort.
endif.
call method o_grid->set_table_for_first_display
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME = 'ZMATERIAL2'
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 = it_mat[]
it_fieldcatalog = it_fldcat[]
it_sort = 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.
endmethod.
Create a Screen 0100 which has a custom control with the name MAT_CONT.
Regards,
Anji
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |