Alv output using oops for numc field
Hi,
iam displaying alv output using oops.
one of output field data type numc and length 4.
in field catalog i set lzero = 'X'.
now data is coming with leading zero. if data contains 0000 i want blank value in report output.
i tried with no_zero = 'X' blank values are display but leading zero are not display for other values.
how can i change the code.
Regards,
Suresh.
You will have to use data type char in your case.
regards,
Advait
Similar Messages
-
hi,
i have two problems in displaying ALV grid output Using Oops.
1) How to modify the fieldcatalog after we getting a field catalog using general FM.
2) initialy it is displaying 13 fields but there are 63 fields .
eventhough we chage the layout to 63 fields it is displaying only 13 fields , these 13 fields may be different based on our selection but count of displayed fileds are same . how can display 63 fields at a time .Hi,
You can chnage using below code:
loop at gt_fieldcat.
if <gt_fieldcat-field_name> = 'FIELDNAME'.
endif.
modify gt_fieldcat.
clear gt_fieldcat.
endloop.
Make sure that all the field should not have no_out = 'X' and tech = 'X'.
Thanks,
Sriram Ponna. -
Display error message in ALV grid using OOPS
Hi,
I have a requirement to display report in ALV. I have created ALV grid using OOPS with three editable cells and 1 button on toolbar. When user enter values in Ediatble cell and click on the Toolbar button, sales order item should be assigned to contract.
When the user select the row and click on toolbar button, a salesorder item should be assigned to contract and i am using BAPI and fine with BAPI. All the error message should be displayed in a popup and the corresponding failed row should change its color .
Once the user identified the failed row, he can edit the value in the ediatble cells and should reprocess in the same screen ( without going back to selection screen).
To display POP Up, I am using FM BAL_LOG_CREATE, BAL_LOG_MSG_ADD, BAL_DSP_PROFILE_NO_TREE_GET, BAL_CNTL_CREATE.
by using above 4 FM , i can display POP UP. but i cannot change the color of the failed row.
Once I identified the failed row and reprocess from the same screen , I am successful in processing the failed row, but my error log still has the reprocessed row as failed row because, error log is not refreshing.
Please suggest me how to clear error log which was created by using the above FM's and change the color of the failed row .
Thanks in AdvanceHi
Please suggest me how to clear error log which was created by using the above FM's....
U can use BAL_LOG_REFRESH
....and change the color of the failed row
You need to insert a new field for Colour Attributes in your output table and input its name in the layout structure:
IS_LAYOUT-INFO_FNAME = <field name for colour>
The field has to be a CHAR 3 and its value can be -
> Cxy
C is a constant
x is the colour number (from 1 to 9)
y is intensified (0 = off, 1 = on)
After changing the value of output table you need to run the method REFRESH_TABLE_DISPLAY for refreshing the output
Max -
Toolbar in alv display using oops alv
i have written code for displaying toolbar in alv display using oops, but it is not displaying please find the below code and let me know reason.
*& Report ZTRANSFER_ORDER2 *
REPORT ZTRANSFER_ORDER2 .
*& Report ZTRANSFER_ORDER *
TABLES:sflight.
TYPE-POOLS : icon.
* G L O B A L I N T E R N A L T A B L E S
CLASS lcl_event_receiver DEFINITION DEFERRED.
types : begin of ty_mara,
matnr type matnr,
mtart type mtart,
mbrsh type mbrsh,
matkl type matkl,
bismt type bismt,
meins type meins,
end of ty_mara.
DATA: t_mara type STANDARD TABLE OF ty_mara.
* G L O B A L D A T A
DATA: ok_code LIKE sy-ucomm,
g_wa_mara type ty_mara.
DATA : t_fcat type LVC_T_FCAT.
DATA : l_VAR TYPE disvariant.
DATA : gs_layout type lvc_s_layo.
* Declare reference variables to the ALV grid and the container
G L O B A L D A T A
DATA: ok_code LIKE sy-ucomm.
Declare reference variables to the ALV grid and the container
DATA:
go_grid TYPE REF TO cl_gui_alv_grid,
go_custom_container TYPE REF TO cl_gui_custom_container.
data : it_toolbar TYPE stb_button,
event_receiver TYPE REF TO lcl_event_receiver.
* S T A R T - O F - S E L E C T I O N.
START-OF-SELECTION.
CALL SCREEN 100 .
*CLASS lcl_event_receiver DEFINITION.
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
*handling toolbar for interactive
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
*handling menu button
handle_menu_button
FOR EVENT menu_button OF cl_gui_alv_grid
IMPORTING e_object e_ucomm,
*On click of the menu button
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
PRIVATE SECTION.
ENDCLASS.
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_toolbar.
handle toolbar
CLEAR it_toolbar.
MOVE 'DETAIL' TO it_toolbar-function.
MOVE icon_detail TO it_toolbar-icon.
MOVE 2 TO it_toolbar-butn_type.
APPEND it_toolbar TO e_object->mt_toolbar.
ENDMETHOD. "handle_toolbar
METHOD handle_menu_button.
handle own menubuttons
IF e_ucomm = 'DETAIL'.
CALL METHOD e_object->add_function
EXPORTING
fcode = 'DISPLAY'
text = 'DISPLAY'.
ENDIF.
ENDMETHOD. "handle_menu_button
METHOD handle_user_command.
*On click
CASE e_ucomm.
WHEN 'DISPLAY'.
MESSAGE 'Menu Clicked' TYPE 'I'.
ENDCASE.
ENDMETHOD. "handle_user_command
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
*& Module USER_COMMAND_0100 INPUT
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Module STATUS_0100 OUTPUT
MODULE status_0100 OUTPUT.
sET PF-STATUS 'STATUS'.
Create objects
IF go_custom_container IS INITIAL.
CREATE OBJECT go_custom_container
EXPORTING container_name = 'ALV_CONTAINER'.
CREATE OBJECT go_grid
EXPORTING
i_parent = go_custom_container.
PERFORM load_data_into_grid.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Form load_data_into_grid
FORM load_data_into_grid.
Read data from table SFLIGHT
SELECT matnr mtart mbrsh matkl bismt meins
FROM mara
INTO corresponding fields of TABLE t_mara.
PERFORM fld_cate changing T_fcat.
l_var-report = sy-repid.
gs_layout-grid_title = 'Analysis Report'.
gs_layout-NO_TOOLBAR = 'X'.
gs_layout-BOX_FNAME = 'Selection'.
Load data into the grid and display them
caLL METHOD go_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'S_MVKE'
i_save = 'A'
is_variant = l_var
is_layout = gs_layout
CHANGING
it_outtab = t_mara[]
it_fieldcatalog = t_fcat.
endform.
*& Module pai INPUT
text
MODULE pai INPUT.
data: l_valid type c.
clear ok_code.
break-point.
ok_code = sy-ucomm.
CASE ok_code.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
WHEN 'BACK'.
call method go_grid->check_changed_data
importing
e_valid = l_valid.
loop at t_mara into g_wa_mara.
endloop.
ENDCASE.
ENDMODULE. " pai INPUT
*& Form fld_cate
text
<--P_T_FCAT text
FORM fld_cate CHANGING P_T_FCAT TYPE lvc_t_fcat.
DATA : s_fcat type LVC_S_FCAT .
REFRESH: t_fcat.
CLEAR s_fcat.
s_fcat-fieldname = 'BOX1'.
s_fcat-coltext = 'Box1'.
s_fcat-seltext = 'Box1'.
s_fcat-CHECKBOX = 'X'.
s_fcat-EDIT = 'X'.
APPEND s_fcat TO P_T_FCAT.
CLEAR s_fcat.
s_fcat-row_pos = 1.
s_fcat-col_pos = 1.
s_fcat-fieldname = 'MATNR'.
s_fcat-ref_field = 'MATNR'.
s_fcat-ref_table = 'T_MARA'.
s_fcat-coltext = 'Material'.
s_fcat-seltext = 'Material'.
s_fcat-EDIT = 'X'.
APPEND s_fcat TO P_T_FCAT.
CLEAR s_fcat.
s_fcat-row_pos = 2.
s_fcat-col_pos = 2.
s_fcat-fieldname = 'MTART'.
s_fcat-ref_field = 'MTART'.
s_fcat-ref_table = 'T_MARA'.
s_fcat-coltext = 'Material type'.
s_fcat-seltext = 'Material type'.
APPEND s_fcat TO P_T_FCAT.
CLEAR s_fcat.
s_fcat-fieldname = 'BOX2'.
s_fcat-coltext = 'Box2'.
s_fcat-seltext = 'Box2'.
s_fcat-CHECKBOX = 'X'.
s_fcat-EDIT = 'X'.
APPEND s_fcat TO P_T_FCAT.
CLEAR s_fcat.
s_fcat-row_pos = 3.
s_fcat-col_pos = 3.
s_fcat-fieldname = 'MBRSH'.
s_fcat-ref_field = 'MBRSH'.
s_fcat-ref_table = 'T_MARA'.
s_fcat-coltext = 'Industry Sector'.
s_fcat-seltext = 'Industry Sector'.
APPEND s_fcat TO P_T_FCAT.
CLEAR s_fcat.
s_fcat-row_pos = 4.
s_fcat-col_pos = 4.
s_fcat-fieldname = 'MATKL'.
s_fcat-ref_field = 'MATKL'.
s_fcat-ref_table = 'T_MARA'.
s_fcat-coltext = 'Material Group'.
s_fcat-seltext = 'Material Group'.
APPEND s_fcat TO P_T_FCAT.
CLEAR s_fcat.
s_fcat-row_pos = 5.
s_fcat-col_pos = 5.
s_fcat-fieldname = 'BISMT'.
s_fcat-ref_field = 'BISMT'.
s_fcat-ref_table = 'T_MARA'.
s_fcat-coltext = 'Old material number'.
s_fcat-seltext = 'Old material number'.
APPEND s_fcat TO P_T_FCAT.
CLEAR s_fcat.
s_fcat-row_pos = 6.
s_fcat-col_pos = 6.
s_fcat-fieldname = 'MEINS'.
s_fcat-ref_field = 'MEINS'.
s_fcat-ref_table = 'T_MARA'.
s_fcat-coltext = 'Base Unit of Measure'.
s_fcat-seltext = 'Base Unit of Measure'.
APPEND s_fcat TO P_T_FCAT.
CLEAR s_fcat.
s_fcat-fieldname = 'BOX3'.
s_fcat-coltext = 'Box3'.
s_fcat-seltext = 'Box3'.
s_fcat-CHECKBOX = 'X'.
s_fcat-EDIT = 'X'.
APPEND s_fcat TO P_T_FCAT.
ENDFORM. " fld_cate .MOVE 2 TO it_toolbar-butn_type.
Try changing the 2 (menu) to 0 (button) and see if that helps
also you need to set the event handler after you create your alv object
set handler handle_toolbar for [whatever object is called].
Edited by: Kev Mycock on Jul 24, 2008 7:59 AM -
ALV report using OOPS concept.
Hi,
Please help me in writing ALV report using OOPS concept as i have never used this concept before.Please post a clear picture for this.
Thanks in advance.Hi
Refer this code:
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
Thanks
Vasudha -
Attaining Hot spot in ALV Tree Using OOPS concept
Hi All,
In our requirement we are displaying the data in ALV Tree Using OOPS.
We need to achieve hot spot on one of the header field.
I am using Class 'CL_GUI_ALV_TREE'
Ex:
CreditAccnt/ Company codes DSO DDSO
26 15 15
8000 5 5
8545 10 10
In the above example for every credit accnt in header we r displaying the values ( DSO ,DDSO) for all company codes.
Now we require hot spot on Credit Accnt 26. Such that when user clicks on the credit accnt it should navigate to another transaction.
NOTE: we havent build any field catalogue for field CreditAccnt/ Company codes .Hi,
You can refer to the tutorial -
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/an%20easy%20reference%20for%20alv%20grid%20control.pdf
Or try using the code below-
CLASS lcl_event_receiver DEFINITION
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
Hot Spot Click
handle_hotspot
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id
e_column_id
es_row_no,
ENDCLASS.
Implementation
*& Method handle_hotspot
This method is called when the user clicks on a hotspot to drill down.
The following types are exported from the ALV
LVC_S_ROW
LVC_S_COL
LVC_S_ROID
METHOD handle_hotspot.
The hotspot processing coded in the form below.
PERFORM f9802_handle_hotspot USING e_row_id
e_column_id
es_row_no.
ENDMETHOD.
*& Form f9802_handle_hotspot
This form is called when the user clicks on a hotspot on the ALV grid
The parameters are of type
-->P_E_ROW text
-->P_E_COL text
-->P_E_ROID text
FORM f9802_handle_hotspot USING p_row
p_col
p_roid.
DATA: lw_output LIKE LINE OF i_output.
READ TABLE i_output INDEX p_row INTO lw_output.
SET PARAMETER ID 'MAT' FIELD lw_output-matnr.
CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.
ENDFORM. " f9802_handle_hotspot
FORM f9300_modify_field_cat TABLES p_fieldcat STRUCTURE lvc_s_fcat.
Field-symbols: <lfs_fieldcat> TYPE lvc_s_fcat.
LOOP AT p_fieldcat ASSIGNING <lfs_fieldcat>.
CASE <lfs_fieldcat>-fieldname.
WHEN 'MATNR'.
<lfs_fieldcat>-hotspot = c_x.
<lfs_fieldcat>-key = c_x.
WHEN OTHERS.
ENDCASE.
ENDLOOP.
ENDFORM.
In PBO,
module STATUS_9001 output.
Set handlers for events
SET HANDLER o_eventreceiver->handle_hotspot FOR o_Alvgrid.
ENDMODULE.
Hope this helps -
Sub total in ALV GRID using oops concept
Hi,
If Plant (VBAP-WERKS) is not the same for all items on a Sales Order (VBAK-VBELN is the same for al items) then create a separate line on the report for each different plant specified in the line items. Copy all fields from the original order line except for plant and Net Value. Net Value should be the total of item Net Values for all items with the same plant in the order.
Example:
Data:
Order---- Item- Plant- Net Value---
123---- 010- 3467- 100.00---
123---- 020- 7865- 50.00---
123---- 030- 3467- 80.50---
Report:
Order- Plant- Net Value---
123- 3467- 180.50---
123- 7865- 50.00----
I need to dispaly the Report format in ALV Grid using oops concept...
no need of calling any function modules.
Regards,
NithyaHi
Here is example code
This is the method to be called:
get_subtotals
Use
Returns the current subtotals of the ALV Grid Control. Having created totals for at least one column, users can calculate at most nine subtotals. The list is sorted by the values of one or several columns (called the subtotals column). If a value is changed in the subtotals column, the subtotal is displayed (this is also referred to as control level change).
Integration
Before you access the subtotals value, you use the method get_sort_criteria to get the sort table . One row of this table describes properties of a column in the output table.
If the field SUBTOT is set for a column in this table, the column is a subtotals column.
The field SPOS then indicates at which level (see below) the subtotal has been calculated.
The field FIELDNAME contains the name of the subtotals column in the output table.
Based on this information, you specifically access the values of the tables passed (using reference variables COLLECT01 to COLLECT09).
Features
CALL METHOD <ref. var. to CL_GUI_ALV_GRID>->get_subtotals
IMPORTING
EP_COLLECT00 = <reference variable of type REF TO DATA>
EP_COLLECT01 = <reference variable of type REF TO DATA>
EP_COLLECT02 = <reference variable of type REF TO DATA>
EP_COLLECT03 = <reference variable of type REF TO DATA>
EP_COLLECT04 = <reference variable of type REF TO DATA>
EP_COLLECT05 = <reference variable of type REF TO DATA>
EP_COLLECT06 = <reference variable of type REF TO DATA>
EP_COLLECT07 = <reference variable of type REF TO DATA>
EP_COLLECT08 = <reference variable of type REF TO DATA>
EP_COLLECT09 = <reference variable of type REF TO DATA>
ET_GROUPLEVELS = <ínternal table of type LVC_T_GRPL>.
In order to access the values of EP_COLLECT00 to EP_COLLECT09, you use ASSIGN to dereference the relevant reference variable in a field symbol of your output table type (see below).
Parameters
Meaning
EP_COLLECT00
Points to the totals line. Since there is only one totals line which, in addition, has a unique totalling area, no further information is available for this table in table ET_GROUPLEVELS.
get_subtotals
EP_COLLECT01 to EP_COLLECT09
Point to the subtotals line. For each subtotals level, there is one reference variable. Each of these variables points to an internal table that has the type of the output table. EP_COLLECT01 points to the subtotal at the hightest level, while EP_COLLECT02 points to the subtotal at the second highest level, and so on. The levels are derived from the sort priority (field SPOS in the sort table ). The column by which the data was sorted first, is the highest subtotals level.
ET_GROUPLEVELS
Manages all indexes for the individual control levels. The fields of the table have the following meaning:
INDEX_FROM, INDEX_TO: Rows of the output table for which the subtotal was created
LEVEL: Subtotals level (see above)
COUNTER: Number of rows for which the subtotal was created
COMPRESS: For this subtotals line, the user has hidden the associated rows.
COLLECT: Indicates the subtotals table (01-09) in which the values are stored
For an overview, see Methods of Class CL_GUI_ALV_GRID
Activities -
Disbable button on alv report using oops
Hi all,
I have a button to toll bar of alv grid using oops
based on that when the user clicks on that some action is performed and list is displayed again
now when the list is diaplyed i need the button that i added to be disabled so that the user cannot click it agin
i have everything i don't know how to disable the button.
USING THIS STATMENT move 'X' to ls_toolbar-disabled WE CAN DISABLE BUT I DON'T WHERE TO PASS IT..
LOCAL CLASSES: Definition
*===============================================================
class lcl_event_receiver: local class to
define and handle own functions.
Definition:
~~~~~~~~~~~
class lcl_event_receiver 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.
private section.
endclass.
lcl_event_receiver (Definition)
*===============================================================
LOCAL CLASSES: Implementation
*===============================================================
class lcl_event_receiver (Implementation)
class lcl_event_receiver implementation.
method handle_toolbar.
append a separator to normal toolbar
clear ls_toolbar.
move 3 to ls_toolbar-butn_type.
append ls_toolbar to e_object->mt_toolbar.
append an icon to show booking table
clear ls_toolbar.
move 'ADD' to ls_toolbar-function.
move icon_employee to ls_toolbar-icon.
move 'Show Bookings'(111) to ls_toolbar-quickinfo.
move 'Add Material'(112) to ls_toolbar-text.
move '' to ls_toolbar-disabled.
append ls_toolbar to e_object->mt_toolbar.
endmethod.
method handle_user_command.
case e_ucomm.
when 'ADD'.
call method g_grid->get_selected_rows
importing et_index_rows = lt_rows.
call method cl_gui_cfw=>flush.
if sy-subrc ne 0.
add your handling, for example
call function 'POPUP_TO_INFORM'
exporting
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error in Flush'(500).
else.
*tHIS IS THE PART IAM HAVING PROBLEM WITH
*class lcl_event_receiver implementation.
method handle_toolbar.
*clear : ls_toolbar.
loop at e_object->mt_toolbar into ls_toolbar WHERE FUNCTION = 'ADD'.
DELETE e_object->mt_toolbar FROM ls_toolbar.
move ' ' to ls_toolbar-disabled.
append ls_toolbar to e_object->mt_toolbar.
endloop.
*ENDMETHOD.
*ENDCLASS.
***tHIS IS THE PART
call method g_grid->refresh_table_display.
endif.
endcase.
endmethod.
Thanks in advanceHi
hI ALL,
MY QUESTION IS WHEN method handle_toolbaR WOULD BE TRIGERRED
first time i have the button enabled and when i press the button its get disabled.This is what i need
But iam trying to understand how this is working
Let me know whether iam right or not
when this piece of code would be triggered
method handle_toolbar.
clear ls_toolbar.
move 3 to ls_toolbar-butn_type.
append ls_toolbar to e_object->mt_toolbar.
clear ls_toolbar.
move 'ADD' to ls_toolbar-function.
move icon_employee to ls_toolbar-icon.
move 'Show Bookings'(111) to ls_toolbar-quickinfo.
move 'Add Material'(112) to ls_toolbar-text.
move ' ' to ls_toolbar-disabled.
append ls_toolbar to e_object->mt_toolbar.
IF FLAG = 'X'.
LOOP AT e_object->mt_toolbar INTO ls_toolbar.
if ls_toolbar-function = 'ADD'.
ls_toolbar-disabled = 'X'.
MODIFY e_object->mt_toolbar FROM ls_toolbar.
endif.
ENDLOOP.
ENDIF.
1 ) would this be triggered
when i call this call method g_grid->refresh_table_display.
2)or
call method g_grid->set_toolbar_interactive
This is my piece of code
class lcl_event_receiver 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.
private section.
endclass.
class lcl_event_receiver implementation.
method handle_toolbar.
clear ls_toolbar.
move 3 to ls_toolbar-butn_type.
append ls_toolbar to e_object->mt_toolbar.
clear ls_toolbar.
move 'ADD' to ls_toolbar-function.
move icon_employee to ls_toolbar-icon.
move 'Show Bookings'(111) to ls_toolbar-quickinfo.
move 'Add Material'(112) to ls_toolbar-text.
move ' ' to ls_toolbar-disabled.
append ls_toolbar to e_object->mt_toolbar.
IF FLAG = 'X'.
LOOP AT e_object->mt_toolbar INTO ls_toolbar.
if ls_toolbar-function = 'ADD'.
ls_toolbar-disabled = 'X'.
MODIFY e_object->mt_toolbar FROM ls_toolbar.
endif.
ENDLOOP.
ENDIF.
endmethod.
method handle_user_command.
case e_ucomm.
when 'ADD'.
call method g_grid->get_selected_rows
importing et_index_rows = lt_rows.
call method cl_gui_cfw=>flush.
if sy-subrc ne 0.
else.
perform test.
call method g_grid->refresh_table_display.
endif.
endcase.
endmethod. "handle_user_command
odule status_0100 output.
SET PF-STATUS 'STATUS'.
set pf-status 'MAIN100'.
set titlebar 'HEADER_CHECK'.
if g_custom_container is initial.
create object g_custom_container
exporting container_name = g_container.
create object g_grid
exporting i_parent = g_custom_container.
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = 'ZTEST'
changing
ct_fieldcat = fieldcat
exceptions
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.
endif.
g_layout-sel_mode = 'A'. " TO GET SELECTION BOX
call method g_grid->set_table_for_first_display
exporting
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
is_layout = g_layout
IS_PRINT =
IT_SPECIAL_GROUPS =
it_toolbar_excluding = pt_exclude
IT_HYPERLINK =
IT_ALV_GRAPHICS =
changing
it_outtab = i_zTEST
it_fieldcatalog = fieldcat
IT_SORT =
IT_FILTER =
exceptions
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
create object event_receiver.
set handler event_receiver->handle_user_command for g_grid.
set handler event_receiver->handle_toolbar for g_grid.
call method g_grid->set_toolbar_interactive.
endif. "IF grid1 IS INITIAL
call method cl_gui_control=>set_focus exporting control = g_grid.
endmodule. " STATUS_0100 OUTPUT
Thanks
Suchitra -
hi friendz,
can any one of u give an example, how to build alv report using oops abap ?
thanks in advance.
points for sure
regards,
VijayaHi Vijaya,
I hope the following code upto your requirement.
*& Report ZMAT_ALV_GRID *
REPORT ZCL_CLASS1.
TYPES: BEGIN OF T_MARA,
MATNR TYPE MARA-MATNR,
MAKTX TYPE MAKT-MAKTX,
WERKS TYPE MARD-WERKS,
LGORT TYPE MARD-LGORT,
LABST TYPE MARD-LABST,
END OF T_MARA.
*DATA: IT_MARA TYPE STANDARD TABLE OF T_MARA.
DATA: IT_MARA TYPE T_MARA OCCURS 0.
DATA: O_CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
O_GRID TYPE REF TO CL_GUI_ALV_GRID.
DATA: X_FLDCAT TYPE LVC_S_FCAT.
DATA: IT_FLDCAT TYPE LVC_T_FCAT.
DATA: I_LAYOUT TYPE LVC_S_LAYO.
DATA: X_SORT TYPE LVC_S_SORT.
DATA: I_SORT TYPE LVC_T_SORT.
TABLES: MARA.
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.
PARAMETERS: P_CHK AS CHECKBOX.
START-OF-SELECTION.
PERFORM GET_DATA.
PERFORM GENERATE_FLDCAT.
PERFORM GENERATE_LAYOUT.
PERFORM DO_SORT.
SET SCREEN 100.
*& Module STATUS_0100 OUTPUT
text
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'MAIN'.
SET TITLEBAR 'xxx'.
PERFORM BUILD_ALV.
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
*& Form BUILD_ALV
text
FORM BUILD_ALV .
CREATE OBJECT O_CONT
EXPORTING
CONTAINER_NAME = 'MAT_CONTAINER'
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
others = 6.
CREATE OBJECT O_GRID
EXPORTING
I_PARENT = O_CONT
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
others = 5.
CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT = ' '
IS_LAYOUT = I_LAYOUT
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
CHANGING
IT_OUTTAB = IT_MARA
IT_FIELDCATALOG = IT_FLDCAT[]
IT_SORT = I_SORT
IT_FILTER =
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
others = 4.
ENDFORM. " BUILD_ALV
*& Form GET_DATA
text
FORM GET_DATA .
SELECT A~MATNR
B~MAKTX
C~WERKS
C~LGORT
C~LABST
INTO TABLE IT_MARA
FROM MARA AS A
INNER JOIN MAKT AS B
ON BMATNR = AMATNR
INNER JOIN MARD AS C
ON CMATNR = AMATNR
WHERE A~MATNR IN S_MATNR
AND B~SPRAS = SY-LANGU.
ENDFORM. " GET_DATA
*& Form GENERATE_FLDCAT
text
FORM GENERATE_FLDCAT .
*CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_BUFFER_ACTIVE =
I_STRUCTURE_NAME = 'ZSMARA'
I_CLIENT_NEVER_DISPLAY = 'X'
I_BYPASSING_BUFFER =
I_INTERNAL_TABNAME = ' '
CHANGING
CT_FIELDCAT = IT_FLDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
X_FLDCAT-COL_POS = 1.
X_FLDCAT-FIELDNAME = 'MATNR'.
X_FLDCAT-OUTPUTLEN = '18'.
X_FLDCAT-REPTEXT = 'Material No'.
APPEND X_FLDCAT TO IT_FLDCAT.
X_FLDCAT-COL_POS = 2.
X_FLDCAT-FIELDNAME = 'MAKTX'.
X_FLDCAT-OUTPUTLEN = '48'.
X_FLDCAT-REPTEXT = 'Material Desc'.
X_FLDCAT-TOOLTIP = 'Material Desc'.
APPEND X_FLDCAT TO IT_FLDCAT.
X_FLDCAT-COL_POS = 3.
X_FLDCAT-FIELDNAME = 'WERKS'.
X_FLDCAT-OUTPUTLEN = '5'.
X_FLDCAT-REPTEXT = 'Plant'.
X_FLDCAT-TOOLTIP = 'Plant'.
APPEND X_FLDCAT TO IT_FLDCAT.
X_FLDCAT-COL_POS = 4.
X_FLDCAT-FIELDNAME = 'LGORT'.
X_FLDCAT-OUTPUTLEN = '5'.
X_FLDCAT-REPTEXT = 'S.Loc'.
X_FLDCAT-TOOLTIP = 'S.Loc'.
APPEND X_FLDCAT TO IT_FLDCAT.
X_FLDCAT-COL_POS = 5.
X_FLDCAT-FIELDNAME = 'LABST'.
X_FLDCAT-OUTPUTLEN = '20'.
X_FLDCAT-REPTEXT = 'Quantity'.
X_FLDCAT-TOOLTIP = 'Quantity'.
X_FLDCAT-DO_SUM = 'X'.
APPEND X_FLDCAT TO IT_FLDCAT.
ENDFORM. " GENERATE_FLDCAT
*& Form GENERATE_LAYOUT
text
FORM GENERATE_LAYOUT .
I_LAYOUT-ZEBRA = 'X'.
I_LAYOUT-FRONTEND = 'X'.
I_LAYOUT-GRID_TITLE = 'ALV GRID USING OOPS'.
I_LAYOUT-NUMC_TOTAL = 'X'.
ENDFORM. " GENERATE_LAYOUT
*& Form DO_SORT
text
FORM DO_SORT .
X_SORT-FIELDNAME = 'MATNR'.
X_SORT-UP = 'X'.
X_SORT-SUBTOT = 'X'.
IF P_CHK = 'X'.
X_SORT-EXPA = SPACE.
ELSE.
X_SORT-EXPA = 'X'.
ENDIF.
APPEND X_SORT TO I_SORT.
ENDFORM. " DO_SORT
inorder to execute this code perfectly, do the following things.
1. Create a Graphical Screen 100.
2. Place a Custom Control on that screen and give name as MAT_CONTAINER.
3. activate the screen.
and execute the program.
if this suits requirement award points.
satish -
End of page in ALV display using OOPS
Hi all,
How can i display end of page or footer in ALV display using OOPS concept.
Thanks,
vinitHi ,
Try using this code.
First add a handler method in your handler class definition as:
e.g. METHOD handle__end_of_page
FOR EVENT print_end_of_page OF cl_gui_alv_grid .
Then implement the method in the implementation part of your local class.
e.g. METHOD handle_print_end_of_page .
WRITE:/ 'Flights Made on ', sy-datum .
ENDMETHOD .
And register this method as the handler.
SET HANDLER gr_event_handler->handle_print_end_of_page FOR gr_alvgrid .
Hope this helps.
Regards,
Janaki. -
Freeze toolbar while scrolling down in ALV grid using OOPS
Hi,
My program is showing few products in ALV grid using OOPS. But If I scroll down to select a product, then I cant see the toolbar on which I have to press a button using selected product. Is there any way to freeze toolbar while scrolling down also.
As of now I have to scroll up after selecting product and then press the button on toolbar.
Regards,
Seema
Edited by: Seema Naharia on Feb 23, 2012 9:17 AMHi ,
You may have to set handler for the toolbars. Check class cl_gui_alv_grid for the events toolbar.
Or just for a try, since your problem is only when scrolling,you can use set_visible_row_count to -1 , so that data will appear in same view without the need to scroll.
Regards,
Ramya -
Disable most recently used items for this field in CRM 2013
Hi,
I have checked "Disable most recently used items for this field " property option for lookup filed in CRM 2013. But it still displaying MRU items on the lookup filed. Can someone please help to fix this ?
Regards,
Thangadid you try to clean your browser cache? use a different browser?
My blog: www.crmanswers.net -
Rockstar 365 Profile -
Disable editable field in ALV grid using OOPS
I have following requirements,
Displaying ALV grid output with most of the fields editable.
Validations on data entered for each fields,for error messages
Query :
I want to make all the fields except the field in ERROR in display only mode
similar to case when we do validation of fields in table controls.HI
check the below links lot of info and examples r there for OOPS
http://www.sapgenie.com/abap/OO/index.htm
http://www.geocities.com/victorav15/sapr3/abap_ood.html
http://www.brabandt.de/html/abap_oo.html
Check this cool weblog:
/people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
/people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b6254f411d194a60000e8353423/frameset.htm
http://www.sapgenie.com/abap/OO/
http://www.sapgenie.com/abap/OO/index.htm
http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt
http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
http://www.allsaplinks.com/
http://www.sap-img.com/
http://www.sapgenie.com/
http://help.sap.com
http://www.sapgenie.com/abap/OO/
http://www.sapgenie.com/abap/OO/index.htm
http://www.sapgenie.com/abap/controls/index.htm
http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
http://www.esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
http://www.sapgenie.com/abap/OO/index.htm
http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
http://www.sapgenie.com/abap/OO/
these links
http://help.sap.com/saphelp_47x200/helpdata/en/ce/b518b6513611d194a50000e8353423/content.htm
For funtion module to class
http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5954f411d194a60000e8353423/content.htm
for classes
http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5c54f411d194a60000e8353423/content.htm
for methods
http://help.sap.com/saphelp_47x200/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm
for inheritance
http://help.sap.com/saphelp_47x200/helpdata/en/dd/4049c40f4611d3b9380000e8353423/content.htm
for interfaces
http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b6254f411d194a60000e8353423/content.htm
For Materials:
1) http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf -- Page no: 1291
2) http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
3) http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
4) http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
5) http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
6) http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf
7) http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt
8) http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8
1) http://www.erpgenie.com/sap/abap/OO/index.htm
2) http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
Check these sample code
data : begin of it_mara occurs 0,
mark type flag,
matnr type matnr,
mtart type mtart,
meins type meins,
end of it_mara.
data : begin of it_mara1 occurs 0,
mark type flag,
matnr type matnr,
mtart type mtart,
meins type meins,
end of it_mara1.
data : begin of it_mara2 occurs 0,
mark type flag,
matnr type matnr,
mtart type mtart,
meins type meins,
end of it_mara2.
data : t_fieldcat type lvc_t_fcat,
t_fieldcat1 type lvc_t_fcat,
s_fieldcat like line of t_fieldcat.
data : s_layout type lvc_s_layo.
data : control type ref to cl_gui_custom_container,
grid type ref to cl_gui_alv_grid.
data: begin of wa ,
mark type flag,
matnr type matnr,
mtart type mtart,
meins type meins,
end of wa.
class lcl_events_box definition.
public section.
methods :
*Handler_Data_Changed for event Data_Changed of cl_gui_alv_grid
*imporTing er_data_changed,
Handler_User_Command for event User_Command of cl_gui_alv_grid
imporTing e_ucomm,
Handler_ToolBar for event ToolBar of cl_gui_alv_grid
importing E_object E_interactive.
endclass.
class lcl_events_box implementation.
method Handler_user_command.
PERFORM FORM_USERCOMMAND CHANGING E_UCOMM.
endmethod.
method Handler_ToolBar.
PERFORM FORM_TOOLBAR CHANGING E_OBJECT E_INTERACTIVE
E_OBJECT->MT_TOOLBAR.
endmethod.
ENDCLASS.
start-of-selection.
data : w_events type ref to lcl_events_box.
select matnr mtart meins from mara into corresponding fields of table
it_mara.
call screen 100.
*& Module pbo_module OUTPUT
text
MODULE pbo_module OUTPUT.
if GRID is initial.
CREATE OBJECT CONTROL
EXPORTING
CONTAINER_NAME = 'CUST_CTRL'.
CREATE OBJECT GRID
EXPORTING
I_PARENT = CONTROL.
PERFORM BUILD_CATALOG.
PERFORM BUILD_CATALOG1.
PERFORM BUILD_LAYOUT.
CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = s_layout
CHANGING
IT_OUTTAB = it_mara[]
IT_FIELDCATALOG = t_fieldcat.
CREATE OBJECT W_EVENTS.
SET HANDLER : W_EVENTS->HANDLER_TOOLBAR FOR GRID,
W_EVENTS->HANDLER_USER_COMMAND FOR GRID.
CALL METHOD GRID->SET_TOOLBAR_INTERACTIVE.
ELSE.
call method grid->refresh_table_display.
ENDIF.
ENDMODULE. " pbo_module OUTPUT
*& Form BUILD_CATALOG
FORM BUILD_CATALOG .
S_FIELDCAT-COL_POS = '1'.
S_FIELDCAT-FIELDNAME = 'MARK'.
S_FIELDCAT-CHECKBOX = 'X'.
S_FIELDCAT-eDIT = 'X'.
APPEND S_FIELDCAT TO T_FIELDCAT.
CLEAR S_FIELDCAT.
S_FIELDCAT-COL_POS = '2'.
S_FIELDCAT-FIELDNAME = 'MATNR'.
S_FIELDCAT-SCRTEXT_M = 'MATERIAL'.
APPEND S_FIELDCAT TO T_FIELDCAT.
S_FIELDCAT-COL_POS = '3'.
S_FIELDCAT-FIELDNAME = 'MTART'.
S_FIELDCAT-SCRTEXT_M = 'MATERL TYPE'.
APPEND S_FIELDCAT TO T_FIELDCAT.
S_FIELDCAT-COL_POS = '4'.
S_FIELDCAT-FIELDNAME = 'MEINS'.
S_FIELDCAT-SCRTEXT_M = 'UOM'.
APPEND S_FIELDCAT TO T_FIELDCAT.
ENDFORM. " BUILD_CATALOG
*& Form BUILD_LAYOUT
text
--> p1 text
<-- p2 text
FORM BUILD_LAYOUT .
S_LAYOUT-ZEBRA = 'X'.
S_LAYOUT-CWIDTH_OPT = 'X'.
S_LAYOUT-GRID_TITLE = 'Material Details'.
ENDFORM.
" BUILD_LAYOUT////////////////////////////////////
" USER_COMMAND_0100 INPUT
*& Form FORM_USERCOMMAND
text
<--P_E_UCOMM text
form FORM_USERCOMMAND changing p_e_ucomm.
CASE P_E_UCOMM.
WHEN 'INT1'.
DO.
READ TABLE IT_MARA INDEX SY-INDEX TRANSPORTING MARK MATNR.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
IF IT_MARA-MARK = 'X'.
read table it_mara into wa TRANSPORTING MATNR MTART MEINS .
MOVE-CORRESPONDING WA TO IT_MARA1.
READ TABLE IT_MARA1 TRANSPORTING MATNR MTART MEINS .
MOVE-CORRESPONDING IT_MARA1 TO IT_MARA2.
APPEND IT_MARA2.
CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = s_layout
CHANGING
IT_OUTTAB = it_mara2[]
IT_FIELDCATALOG = t_fieldcat1.
SET PARAMETER ID 'MAT' FIELD IT_MARA-MATNR.
CALL TRANSACTION 'MM02'.
. ENDIF.
ENDIF.
ENDDO.
ENDCASE.
endform. " FORM_USERCOMMAND
*& Form FORM_TOOLBAR
text
<--P_E_OBJECT text
<--P_E_INTERACTIVE text
<--P_E_OBJECT_>MT_TOOLBAR text
FORM FORM_TOOLBAR CHANGING P_E_OBJECT TYPE REF TO
CL_ALV_EVENT_TOOLBAR_SET
P_E_INTERACTIVE
MT_TOOLBAR TYPE TTB_BUTTON.
DATA WAL_BUTTON TYPE STB_BUTTON.
*WAL_BUTTON-ICON = ICON_status_reverse.
WAL_BUTTON-TEXT = 'GO'.
WAL_BUTTON-QUICKINFO = 'PROCEED'.
waL_button-FUNCTION = 'INT1'.
WAL_BUTTON-BUTN_TYPE = 0.
WAL_BUTTON-DISABLED = SPACE.
insert WAL_BUTTON INTO P_E_OBJECT->MT_TOOLBAR index 1.
endform. " FORM_TOOLBAR
*& Module PF-STATUS OUTPUT
text
module PF-STATUS output.
set pf-status 'Z7PSTAT'.
endmodule. " PF-STATUS OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
module USER_COMMAND_0100 input.
CASE SY-UCOMM.
WHEN 'BACK'.
LEAVE PROGRAM.
WHEN 'CANCEL'.
LEAVE PROGRAM.
ENDCASE.
endmodule. " USER_COMMAND_0100 INPUT
*& Form BUILD_CATALOG1
text
--> p1 text
<-- p2 text
form BUILD_CATALOG1 .
S_FIELDCAT-COL_POS = '1'.
S_FIELDCAT-FIELDNAME = 'MATNR'.
S_FIELDCAT-SCRTEXT_M = 'MATERIAL'.
APPEND S_FIELDCAT TO T_FIELDCAT1.
S_FIELDCAT-COL_POS = '2'.
S_FIELDCAT-FIELDNAME = 'MTART'.
S_FIELDCAT-SCRTEXT_M = 'MATERL TYPE'.
APPEND S_FIELDCAT TO T_FIELDCAT1.
S_FIELDCAT-COL_POS = '3'.
S_FIELDCAT-FIELDNAME = 'MEINS'.
S_FIELDCAT-SCRTEXT_M = 'UOM'.
APPEND S_FIELDCAT TO T_FIELDCAT1.
endform. " BUILD_CATALOG1
check the below link may be useful for you
http://www.sapdevelopment.co.uk/reporting/alvhome.htm
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
Simple ALV report
http://www.sapgenie.com/abap/controls/alvgrid.htm
http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox
ALV
1. Please give me general info on ALV.
http://www.sapfans.com/forums/viewtopic.php?t=58286
http://www.sapfans.com/forums/viewtopic.php?t=76490
http://www.sapfans.com/forums/viewtopic.php?t=20591
http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.
2. How do I program double click in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=11601
http://www.sapfans.com/forums/viewtopic.php?t=23010
3. How do I add subtotals (I have problem to add them)...
http://www.sapfans.com/forums/viewtopic.php?t=20386
http://www.sapfans.com/forums/viewtopic.php?t=85191
http://www.sapfans.com/forums/viewtopic.php?t=88401
http://www.sapfans.com/forums/viewtopic.php?t=17335
4. How to add list heading like top-of-page in ABAP lists?
http://www.sapfans.com/forums/viewtopic.php?t=58775
http://www.sapfans.com/forums/viewtopic.php?t=60550
http://www.sapfans.com/forums/viewtopic.php?t=16629
5. How to print page number / total number of pages X/XX in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)
6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.
http://www.sapfans.com/forums/viewtopic.php?t=64320
http://www.sapfans.com/forums/viewtopic.php?t=44477
7. How can I set the cell color in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=52107
8. How do I print a logo/graphics in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=81149
http://www.sapfans.com/forums/viewtopic.php?t=35498
http://www.sapfans.com/forums/viewtopic.php?t=5013
9. How do I create and use input-enabled fields in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=84933
http://www.sapfans.com/forums/viewtopic.php?t=69878
10. How can I use ALV for reports that are going to be run in background?
http://www.sapfans.com/forums/viewtopic.php?t=83243
http://www.sapfans.com/forums/viewtopic.php?t=19224
11. How can I display an icon in ALV? (Common requirement is traffic light icon).
http://www.sapfans.com/forums/viewtopic.php?t=79424
http://www.sapfans.com/forums/viewtopic.php?t=24512
12. How can I display a checkbox in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=88376
http://www.sapfans.com/forums/viewtopic.php?t=40968
http://www.sapfans.com/forums/viewtopic.php?t=6919
Go thru these programs they may help u to try on some hands on
ALV Demo program
BCALV_DEMO_HTML
BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode
BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode
BCALV_GRID_DEMO Simple ALV Control Call Demo Program
BCALV_TREE_DEMO Demo for ALV tree control
BCALV_TREE_SIMPLE_DEMO
BC_ALV_DEMO_HTML_D0100
<b>Reward all helpfull answers</b>
Regards -
Traffic Signals in ALV Without using oops only for normal Grid Display.
Hi Experts ,
I need to add traffic signals into my normal ALV Grid program without using oops concepts.
Please any one send me full code or provide me one program code without using oops concept for normal ALV Grid .
I searched in many forums but i found most of the programs wriiten using oops concept with ALV's but here my requirement without using oops concept and only normal reuse_alv_grid_display.
Thanks in Advance.
Venky.You can check the below sample code.Traffic light is implemented in it.
REPORT ztest NO STANDARD PAGE HEADING
LINE-SIZE 255 MESSAGE-ID zlqm.
TYPE-POOLS : slis,icon.
TABLES :qals,qave.
INCLUDE : zlqmr002_top, "Global Data Declaration
zlqmr002_selection_screen, "Selection Screen Inputs
zlqmr002_subroutine. "Subroutines
INITIALIZATION
INITIALIZATION.
PERFORM variant_init.
AT SELECTION-SCREEN
AT SELECTION-SCREEN.
Check for Variant existance
PERFORM pai_of_selection_screen.
*Validation for Material
AT SELECTION-SCREEN ON s_matnr.
IF NOT s_matnr IS INITIAL.
SELECT SINGLE matnr
INTO g_matnr
FROM mara
WHERE matnr IN s_matnr.
IF sy-subrc <> 0.
SET CURSOR FIELD 'S_MATNR'.
MESSAGE e000 WITH text-003.
ENDIF.
ENDIF.
*Validation for Plant
AT SELECTION-SCREEN ON s_werk.
IF NOT s_werk IS INITIAL.
SELECT SINGLE werks
INTO g_werk
FROM t001w
WHERE werks IN s_werk.
IF sy-subrc <> 0.
SET CURSOR FIELD 'S_WERK'.
MESSAGE e000 WITH text-004.
ENDIF.
ENDIF.
*Validation for Inspection Type
AT SELECTION-SCREEN ON s_art.
IF NOT s_art IS INITIAL.
SELECT SINGLE art
INTO g_art
FROM tq30
WHERE art IN s_art.
IF sy-subrc <> 0.
SET CURSOR FIELD 'S_ART'.
MESSAGE e000 WITH text-005.
ENDIF.
ENDIF.
*Validation for Code group
AT SELECTION-SCREEN ON s_vcdgrp.
IF NOT s_vcdgrp IS INITIAL.
SELECT SINGLE codegruppe
INTO g_vcdgrp
FROM qpgr
WHERE codegruppe IN s_vcdgrp.
IF sy-subrc <> 0.
SET CURSOR FIELD 'S_VCDGRP'.
MESSAGE e000 WITH text-006.
ENDIF.
ENDIF.
*Validation for Code
AT SELECTION-SCREEN ON s_vcode.
IF NOT s_vcode IS INITIAL.
SELECT SINGLE code
INTO g_vcode
FROM qpcd
WHERE code IN s_vcode.
IF sy-subrc <> 0.
SET CURSOR FIELD 'S_VCODE'.
MESSAGE e000 WITH text-007.
ENDIF.
ENDIF.
Process on value request
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
PERFORM f4_for_variant.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_vcdgrp-low.
PERFORM get_codegroup.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_vcdgrp-high.
PERFORM get_codegroup.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_vcode-low.
PERFORM get_code.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_vcode-high.
PERFORM get_code.
START-OF-SELECTION.
START-OF-SELECTION.
**Selecting data form Database tables
PERFORM select_data TABLES i_out i_out1.
END-OF-SELECTION
END-OF-SELECTION.
**Generate ALV
PERFORM generate_alv.
DATA TYPES
TYPES : BEGIN OF t_qals,
matnr TYPE qals-matnr, "Material
werk TYPE qals-werk, "Plant
mengeneinh TYPE qals-mengeneinh, "UOM
lmenge01 TYPE qals-lmenge01, "Unrestricted qty
lmenge02 TYPE qals-lmenge02, "Scrap qty
lmenge03 TYPE qals-lmenge03, "Sample qty
lmenge04 TYPE qals-lmenge04, "Blocked qty
lmenge05 TYPE qals-lmenge05, "Retain qty
lmenge06 TYPE qals-lmenge06, "Othermat qty
lmenge07 TYPE qals-lmenge07, "RTV qty
lmenge08 TYPE qals-lmenge08, "Exp.scrap qty
prueflos TYPE qals-prueflos, "Inspection lot
art TYPE qals-art, "Inspection type
charg TYPE qals-charg, "Batch
vcode TYPE qave-vcode, "Usage decision
vdatum TYPE qave-vdatum, "Date
qmnum TYPE qmel-qmnum, "Notification
END OF t_qals.
TYPES : BEGIN OF t_out,
icon TYPE icon-id, "Status
matnr TYPE qals-matnr, "Material
werk TYPE qals-werk, "Plant
mengeneinh TYPE qals-mengeneinh, "UOM
vcode TYPE qave-vcode, "Usage decision
mncod(30) TYPE c, "Disposition
lmenge01 TYPE qals-lmenge01, "Unrestricted qty
lmenge02 TYPE qals-lmenge02, "Scrap qty
lmenge03 TYPE qals-lmenge03, "Sample qty
lmenge04 TYPE qals-lmenge04, "Blocked qty
lmenge05 TYPE qals-lmenge05, "Retain qty
lmenge06 TYPE qals-lmenge06, "Othermat qty
lmenge07 TYPE qals-lmenge07, "RTV qty
lmenge08 TYPE qals-lmenge08, "Exp.scrap qty
prueflos TYPE qals-prueflos, "Inspection lot
art TYPE qals-art, "Inspection type
qmnum TYPE qmel-qmnum, "Notification
vdatum TYPE qave-vdatum, "Date
charg TYPE qals-charg, "Batch
END OF t_out.
TYPES : BEGIN OF t_qmsm,
qmnum TYPE qmsm-qmnum,
manum TYPE qmsm-manum,
mncod TYPE qmsm-mncod,
END OF t_qmsm.
TYPES: BEGIN OF t_disp,
qmnum TYPE qmsm-qmnum,
mncod(30) TYPE c,
END OF t_disp.
TYPES: BEGIN OF t_codegrp,
katalogart TYPE qpgt-katalogart,
codegruppe TYPE qpgt-codegruppe,
kurztext TYPE qpgt-kurztext,
END OF t_codegrp.
TYPES: BEGIN OF t_code,
katalogart TYPE qpct-katalogart,
codegruppe TYPE qpct-codegruppe,
code TYPE qpct-code,
version TYPE qpct-version,
kurztext TYPE qpct-kurztext,
END OF t_code.
INTERNAL TABLES
DATA: i_qals TYPE TABLE OF t_qals,
wa_qals LIKE LINE OF i_qals,
i_qmsm TYPE TABLE OF t_qmsm,
wa_qmsm TYPE t_qmsm,
i_disp TYPE TABLE OF t_disp,
wa_disp LIKE LINE OF i_disp,
i_out TYPE TABLE OF t_out,
wa_out TYPE t_out,
i_out1 TYPE TABLE OF t_out,
wa_out1 TYPE t_out,
i_codegrp TYPE TABLE OF t_codegrp,
i_code TYPE TABLE OF t_code,
i_qmsm_tmp TYPE TABLE OF t_qmsm.
DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
i_layout TYPE slis_layout_alv,
g_repid TYPE sy-repid,
wa_fieldcat TYPE slis_fieldcat_alv.
Global Variables
DATA : g_matnr TYPE matnr,
g_werk TYPE werks,
g_art TYPE qpart,
g_vcdgrp TYPE qvgruppe,
g_vcode TYPE qvcode,
g_red TYPE c,
g_yellow TYPE c,
g_table(6) TYPE c,
g_save(1) TYPE c,
g_exit(1) TYPE c,
g_report TYPE sy-repid,
g_var TYPE disvariant,
g_variant TYPE disvariant.
Constants
CONSTANTS: c_green TYPE icon-id VALUE '@08@',
c_yellow TYPE icon-id VALUE '@09@',
c_red TYPE icon-id VALUE '@0A@'.
SELECTION SCREEN
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_matnr FOR qals-matnr, "Material Number
s_werk FOR qals-werk, "Plant
s_art FOR qals-art, "Inspection Type
s_vcdgrp FOR qave-vcodegrp, "Usage Decision Code Group
s_vcode FOR qave-vcode, "Usage Decision Code
s_vdatum FOR qave-vdatum. "Usage Decision Code Date
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS: p_all RADIOBUTTON GROUP g1 DEFAULT 'X',
p_excp RADIOBUTTON GROUP g1.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-009.
"Variant Selection
PARAMETERS: p_vari TYPE disvariant-variant.
SELECTION-SCREEN END OF BLOCK b3.
*& Form select_data
Select Inspection Details
FORM select_data TABLES p_out STRUCTURE wa_out
p_out1 STRUCTURE wa_out.
DATA:l_mncod(30) TYPE c.
REFRESH : i_qals,i_qmsm,i_qmsm_tmp,i_disp,p_out.
SELECT qalsmatnr qalswerk qals~mengeneinh
qalslmenge01 qalslmenge02 qals~lmenge03
qalslmenge04 qalslmenge05 qals~lmenge06
qalslmenge07 qalslmenge08 qals~prueflos
qalsart qalscharg qave~vcode
qavevdatum qmelqmnum
INTO CORRESPONDING FIELDS OF TABLE i_qals
FROM qals
INNER JOIN qave
ON qalsprueflos = qaveprueflos
INNER JOIN qmel
ON qalsprueflos = qmelprueflos
WHERE qals~matnr IN s_matnr
AND qals~werk IN s_werk
AND qals~art IN s_art
AND qals~stat34 EQ 'X'
AND qave~vcodegrp IN s_vcdgrp
AND qave~vcode IN s_vcode
AND qave~vdatum IN s_vdatum.
IF sy-subrc NE 0.
MESSAGE i000 WITH text-008.
ENDIF.
IF NOT i_qals IS INITIAL.
SELECT qmnum manum mncod INTO TABLE i_qmsm
FROM qmsm
FOR ALL ENTRIES IN i_qals
WHERE qmnum EQ i_qals-qmnum
AND mngrp LIKE 'Q_D%'
AND kzloesch NE 'X'.
ENDIF.
***Concatenation of Disposition Codes
IF NOT i_qmsm IS INITIAL.
i_qmsm_tmp = i_qmsm.
SORT i_qmsm_tmp BY qmnum mncod.
DELETE ADJACENT DUPLICATES FROM i_qmsm_tmp COMPARING qmnum mncod+0(2).
CLEAR wa_qmsm.
LOOP AT i_qmsm_tmp INTO wa_qmsm.
MOVE wa_qmsm-qmnum TO wa_disp-qmnum.
CONCATENATE l_mncod wa_qmsm-mncod+0(2) INTO l_mncod SEPARATED BY space.
AT END OF qmnum.
SHIFT l_mncod LEFT DELETING LEADING space.
MOVE l_mncod TO wa_disp-mncod.
APPEND wa_disp TO i_disp.
CLEAR:wa_disp,l_mncod.
ENDAT.
ENDLOOP.
ENDIF.
***Transfer of data to the output table
LOOP AT i_qals INTO wa_qals.
MOVE-CORRESPONDING wa_qals TO wa_out.
CLEAR wa_disp.
READ TABLE i_disp INTO wa_disp
WITH KEY qmnum = wa_qals-qmnum.
IF sy-subrc EQ 0.
MOVE wa_disp-mncod TO wa_out-mncod.
ENDIF.
PERFORM check_quantity USING wa_qals.
CLEAR wa_qmsm.
LOOP AT i_qmsm INTO wa_qmsm
WHERE qmnum EQ wa_qals-qmnum.
PERFORM check_group USING wa_qals
wa_qmsm.
CLEAR wa_qmsm.
ENDLOOP.
IF g_red NE 'X'.
CLEAR wa_qmsm.
LOOP AT i_qmsm INTO wa_qmsm WHERE qmnum = wa_qals-qmnum
AND mncod0(2) NE wa_qals-vcode0(2).
g_yellow = 'X'.
ENDLOOP.
ENDIF.
IF g_yellow EQ 'X'.
MOVE c_yellow TO wa_out-icon.
ELSEIF g_red EQ 'X'.
MOVE c_red TO wa_out-icon.
ELSE.
MOVE c_green TO wa_out-icon.
ENDIF.
APPEND wa_out TO p_out.
CLEAR:wa_qals,wa_out,g_red,g_yellow.
ENDLOOP.
***IF only exceptions are need to be displayed
IF p_excp EQ 'X'.
CLEAR wa_out.
LOOP AT p_out INTO wa_out WHERE icon EQ c_red.
APPEND wa_out TO p_out1.
ENDLOOP.
ENDIF.
ENDFORM. " select_data
*& Form populate_fieldcat
Populate the Fieldcat Table
FORM populate_fieldcat USING p_table TYPE c.
**status
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'ICON'.
wa_fieldcat-seltext_l = text-010.
wa_fieldcat-outputlen = 15.
wa_fieldcat-icon = 'X'.
APPEND wa_fieldcat TO i_fieldcat.
**Material
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-seltext_l = text-011.
wa_fieldcat-outputlen = 15.
APPEND wa_fieldcat TO i_fieldcat.
**Plant
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'WERK'.
wa_fieldcat-seltext_l = text-012.
wa_fieldcat-outputlen = 7.
APPEND wa_fieldcat TO i_fieldcat.
**Usage Decision
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'VCODE'.
wa_fieldcat-seltext_l = text-013.
wa_fieldcat-outputlen = 15.
APPEND wa_fieldcat TO i_fieldcat.
**Dispositions
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'MNCOD'.
wa_fieldcat-seltext_l = text-014.
wa_fieldcat-outputlen = 18.
APPEND wa_fieldcat TO i_fieldcat.
**UOM
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'MENGENEINH'.
wa_fieldcat-seltext_l = text-015.
wa_fieldcat-outputlen = 18.
APPEND wa_fieldcat TO i_fieldcat.
**Unrestricted Quantity
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'LMENGE01'.
wa_fieldcat-seltext_l = text-016.
wa_fieldcat-qfieldname = 'MENGENEINH'.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
**Scrap Quantity
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'LMENGE02'.
wa_fieldcat-seltext_l = text-017.
wa_fieldcat-qfieldname = 'MENGENEINH'.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
**Sample Quantity
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'LMENGE03'.
wa_fieldcat-seltext_l = text-018.
wa_fieldcat-qfieldname = 'MENGENEINH'.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
**Blocked Quantity
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'LMENGE04'.
wa_fieldcat-seltext_l = text-019.
wa_fieldcat-qfieldname = 'MENGENEINH'.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
**Retain Quantity
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'LMENGE05'.
wa_fieldcat-seltext_l = text-020.
wa_fieldcat-qfieldname = 'MENGENEINH'.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
**Other Mat Quantity
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'LMENGE06'.
wa_fieldcat-seltext_l = text-021.
wa_fieldcat-qfieldname = 'MENGENEINH'.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
**RTV Quantity
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'LMENGE07'.
wa_fieldcat-seltext_l = text-022.
wa_fieldcat-qfieldname = 'MENGENEINH'.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
**Exp. Scrap Quantity
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'LMENGE08'.
wa_fieldcat-seltext_l = text-023.
wa_fieldcat-qfieldname = 'MENGENEINH'.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
**Inspection Lot
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'PRUEFLOS'.
wa_fieldcat-seltext_l = text-024.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
**Inspection Type
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'ART'.
wa_fieldcat-seltext_l = text-025.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
**Notification
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'QMNUM'.
wa_fieldcat-seltext_l = text-026.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
**Date
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'VDATUM'.
wa_fieldcat-seltext_l = text-027.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
**Batch
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'CHARG'.
wa_fieldcat-seltext_l = text-028.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
ENDFORM. " populate_fieldcat
*& Form check_quantity
To Check the Quantity
FORM check_quantity USING p_qals TYPE t_qals.
IF wa_qals-lmenge01 GT 0.
LOOP AT i_disp TRANSPORTING NO FIELDS
WHERE qmnum EQ wa_qals-qmnum
AND ( mncod CP 'UI'
OR mncod CP 'SR'
OR mncod CP 'ND' ).
ENDLOOP.
IF sy-subrc NE 0.
g_red = 'X'.
ENDIF.
ENDIF.
IF wa_qals-lmenge02 GT 0 AND g_red NE 'X'.
LOOP AT i_disp TRANSPORTING NO FIELDS
WHERE qmnum EQ wa_qals-qmnum
AND ( mncod CP 'SC'
OR mncod CP 'SR' ).
ENDLOOP.
IF sy-subrc NE 0.
g_red = 'X'.
ENDIF.
ENDIF.
IF wa_qals-lmenge04 GT 0 AND g_red NE 'X'.
LOOP AT i_disp TRANSPORTING NO FIELDS
WHERE qmnum EQ wa_qals-qmnum
AND ( mncod CP 'RW'
OR mncod CP 'RD' ).
ENDLOOP.
IF sy-subrc NE 0.
g_red = 'X'.
ENDIF.
ENDIF.
IF wa_qals-lmenge05 GT 0 AND g_red NE 'X'.
LOOP AT i_disp TRANSPORTING NO FIELDS
WHERE qmnum EQ wa_qals-qmnum
AND mncod CP 'R1'.
ENDLOOP.
IF sy-subrc NE 0.
g_red = 'X'.
ENDIF.
ENDIF.
IF wa_qals-lmenge06 GT 0 AND g_red NE 'X'.
LOOP AT i_disp TRANSPORTING NO FIELDS
WHERE qmnum EQ wa_qals-qmnum
AND mncod CP 'RD'.
ENDLOOP.
IF sy-subrc NE 0.
g_red = 'X'.
ENDIF.
ENDIF.
IF wa_qals-lmenge07 GT 0 AND g_red NE 'X'.
LOOP AT i_disp TRANSPORTING NO FIELDS
WHERE qmnum EQ wa_qals-qmnum
AND mncod CP 'RV'.
ENDLOOP.
IF sy-subrc NE 0.
g_red = 'X'.
ENDIF.
ENDIF.
IF wa_qals-lmenge08 GT 0 AND g_red NE 'X'.
LOOP AT i_disp TRANSPORTING NO FIELDS
WHERE qmnum EQ wa_qals-qmnum
AND ( mncod CP 'SC'
OR mncod CP 'SE' ).
ENDLOOP.
IF sy-subrc NE 0.
g_red = 'X'.
ENDIF.
ENDIF.
ENDFORM. " check_quantity
*& Form check_group
To check the Disposition Code
FORM check_group USING p_qals TYPE t_qals
p_qmsm TYPE t_qmsm.
IF p_qmsm-mncod+0(2) EQ 'UI' AND
NOT p_qals-lmenge01 GT 0.
g_red = 'X'.
EXIT.
ENDIF.
IF p_qmsm-mncod+0(2) EQ 'RW' AND
NOT p_qals-lmenge04 GT 0.
g_red = 'X'.
EXIT.
ENDIF.
IF p_qmsm-mncod+0(2) EQ 'SC' AND
NOT p_qals-lmenge02 GT 0 AND
NOT p_qals-lmenge08 GT 0.
g_red = 'X'.
EXIT.
ENDIF.
IF p_qmsm-mncod+0(2) EQ 'SE' AND
NOT p_qals-lmenge08 GT 0.
g_red = 'X'.
EXIT.
ENDIF.
IF p_qmsm-mncod+0(2) EQ 'RV' AND
NOT p_qals-lmenge07 GT 0.
g_red = 'X'.
EXIT.
ENDIF.
IF p_qmsm-mncod+0(2) EQ 'SR' AND
NOT p_qals-lmenge01 GT 0 AND
NOT p_qals-lmenge02 GT 0.
g_red = 'X'.
EXIT.
ENDIF.
IF p_qmsm-mncod+0(2) EQ 'ND' AND
NOT p_qals-lmenge01 GT 0.
g_red = 'X'.
EXIT.
ENDIF.
IF p_qmsm-mncod+0(2) EQ 'R1' AND
NOT p_qals-lmenge05 GT 0.
g_red = 'X'.
EXIT.
ENDIF.
IF p_qmsm-mncod+0(2) EQ 'RD' AND
NOT p_qals-lmenge04 GT 0 AND
NOT p_qals-lmenge06 GT 0.
g_red = 'X'.
EXIT.
ENDIF.
ENDFORM. " check_group
*& Form call_alv
Call ALV Grid Display
FORM call_alv TABLES p_out STRUCTURE wa_out.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
i_callback_pf_status_set = 'PF_STATUS_SET'
i_callback_user_command = 'USER_COMMAND'
is_layout = i_layout
it_fieldcat = i_fieldcat[]
TABLES
t_outtab = p_out
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.
ENDFORM. " call_alv
*& Form generate_alv
Build ALV
FORM generate_alv .
IF NOT i_out IS INITIAL OR
NOT i_out1 IS INITIAL.
g_repid = sy-repid.
IF p_excp EQ 'X'.
MOVE 'I_OUT1' TO g_table.
ELSEIF p_all EQ 'X'.
MOVE 'I_OUT' TO g_table.
ENDIF.
PERFORM populate_fieldcat USING g_table.
i_layout-zebra = 'X'.
i_layout-colwidth_optimize = 'X'.
IF p_excp = 'X'.
PERFORM call_alv TABLES i_out1.
ELSEIF p_all = 'X'.
PERFORM call_alv TABLES i_out.
ENDIF.
ENDIF.
ENDFORM. " generate_alv
*& Form PF_STATUS_SET
Setting PF Status
FORM pf_status_set USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'STATUS1' .
ENDFORM. "PF_STATUS_SET
*& Form USER_COMMAND
User Command Processing
FORM user_command USING r_ucomm TYPE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN 'UDG'.
IF p_all EQ 'X'.
CLEAR wa_out.
READ TABLE i_out INTO wa_out INDEX rs_selfield-tabindex.
SET PARAMETER ID 'QLS' FIELD wa_out-prueflos.
ELSEIF p_excp EQ 'X'.
CLEAR wa_out1.
READ TABLE i_out1 INTO wa_out1 INDEX rs_selfield-tabindex.
SET PARAMETER ID 'QLS' FIELD wa_out1-prueflos.
ENDIF.
CALL TRANSACTION 'QA13' AND SKIP FIRST SCREEN.
WHEN 'QNF'.
IF p_all EQ 'X'.
CLEAR wa_out.
READ TABLE i_out INTO wa_out INDEX rs_selfield-tabindex.
SET PARAMETER ID 'IQM' FIELD wa_out-qmnum.
ELSEIF p_excp EQ 'X'.
CLEAR wa_out1.
READ TABLE i_out1 INTO wa_out1 INDEX rs_selfield-tabindex.
SET PARAMETER ID 'IQM' FIELD wa_out1-qmnum.
ENDIF.
CALL TRANSACTION 'QM03' AND SKIP FIRST SCREEN.
ENDCASE.
ENDFORM. "USER_COMMAND
*& Form variant_init
Initialize variant
FORM variant_init .
Set Options: save variants userspecific or general
g_save = 'A'.
g_report = sy-repid.
g_var-report = g_report.
Get default variant
g_variant = g_var.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = g_save
CHANGING
cs_variant = g_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 0.
p_vari = g_variant-variant.
ENDIF.
ENDFORM. " variant_init
*& Form f4_for_variant
F4 help for variant
FORM f4_for_variant .
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = g_var
i_save = g_save
IMPORTING
e_exit = g_exit
es_variant = g_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 2.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
IF g_exit = space.
p_vari = g_variant-variant.
ENDIF.
ENDIF.
ENDFORM. " f4_for_variant
*& Form pai_of_selection_screen
Check existence of Variant
FORM pai_of_selection_screen .
IF NOT p_vari IS INITIAL.
MOVE g_var TO g_variant.
MOVE p_vari TO g_variant-variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
i_save = g_save
CHANGING
cs_variant = g_variant.
g_var = g_variant.
ELSE.
PERFORM variant_init.
ENDIF.
ENDFORM. " pai_of_selection_screen
*& Form get_codegroup
Get F4 help for Code Group
FORM get_codegroup .
DATA: i_return TYPE TABLE OF ddshretval.
SELECT katalogart codegruppe kurztext FROM qpgt
INTO TABLE i_codegrp
WHERE katalogart EQ '3'
AND sprache EQ sy-langu.
IF sy-subrc EQ 0.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
DDIC_STRUCTURE = ' '
retfield = 'CODEGRUPPE'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'S_VCDGRP'
value_org = 'S'
TABLES
value_tab = i_codegrp[]
return_tab = i_return[]
EXCEPTIONS
parameter_error = 1
no_values_found = 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.
ENDIF.
ENDIF.
ENDFORM. " get_codegroup
*& Form get_code
Get F4 help for Code
FORM get_code .
DATA: l_field TYPE rsscr-name VALUE 'S_VCDGRP',
l_field_kind TYPE rsscr-kind VALUE 'S',
li_par_values TYPE TABLE OF rsparams,
la_par_values TYPE rsparams,
r_cdgrp TYPE RANGE OF qpct-codegruppe,
la_cdgrp LIKE LINE OF r_cdgrp.
**Get the values entered in the selection screen
PERFORM f4_get_related_values IN PROGRAM rsdbspf4
TABLES li_par_values
USING l_field l_field_kind.
IF NOT li_par_values IS INITIAL.
CLEAR:la_cdgrp,la_par_values.
LOOP AT li_par_values INTO la_par_values.
MOVE-CORRESPONDING la_par_values TO la_cdgrp.
IF la_cdgrp-option IS INITIAL.
MOVE 'EQ' TO la_cdgrp-option.
ENDIF.
APPEND la_cdgrp TO r_cdgrp.
CLEAR la_cdgrp.
ENDLOOP.
ENDIF.
SELECT katalogart codegruppe
code version
kurztext FROM qpct
INTO TABLE i_code
WHERE katalogart EQ '3'
AND codegruppe IN r_cdgrp
AND sprache EQ sy-langu.
IF sy-subrc EQ 0.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
DDIC_STRUCTURE = ' '
retfield = 'CODE'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'S_VCODE'
value_org = 'S'
TABLES
value_tab = i_code[]
return_tab =
EXCEPTIONS
parameter_error = 1
no_values_found = 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.
ENDIF.
ENDIF.
ENDFORM. " get_code -
Alv output to Excel with numeric fields as numeric fields only and not char
Hi,
When we download the alv output to excel format in the locat file using the toolbar button provided in the ALV, the numeric fields get converted to character format. Is there any other way or settings in ALV so that the numeric fields will be get saved as numeric fields only and not character?
Rgds,
MAdhuriany idea for above problem is welcome
Maybe you are looking for
-
Customizing Graph View in OBIEE 11G
Hi! I am using OBIEE 11.1.1.6. In line graph data labels in graph view are coming on the line so some values are not readable, we have to show values always How can we move the data labels above the line or below the line. I understand its differnt t
-
Java Update Release 1-Install Process Freeze
On downloading Java Release 1 for Mac OSX 10.5, after downloading, I was prompted to enter my user password for a second time. As of now 'CONFIGURING INSTALLATION' has been frozen for over an hour with no movement on the progress bar. Contemplating a
-
I am trying to change variations in eBay with Firefox 9 and when I click the link nothing happens. When I open in new tab that same page opens. I have cleared cache and cookies and restarted browser. This didn't work so I reinstalled firefox. Anyone
-
I have an iphone 3 that was synced awhile back.All was fine,now I need space on the phone & cannot get a picture file with 344 photos off the phone. I've tried not checking any folders to sync
-
When trying to 'Buy Book' in iPhoto '09, I keep getting the error: *Incomplete Book* Your book seems to have frames on one or more pages that do not contain photos. You must either change the layout of those pages or place photos in those frames befo