Hierarchy ALV in ABAP OOPS
Hi FOlks,
Have a requirement to develop Hierarchy ALV with two levels. As we need to make the columns as editable we are going for ALV OOPS. Is there any way of doing Hierarchy ALV in OOPS...if so, could you please suggest me which Class and method to be used.....
Thanks in advance,
Shyam.
Look at sample programs in R3
SALV_DEMO_TREE_DATA_UPDATE Demonstration Program for ALV OM Tree: Changed Data
SALV_DEMO_TREE_EVENTS Demonstration Program for ALV OM Tree: Events
SALV_DEMO_TREE_FUNCTIONS Demonstration Program for ALV OM Tree: Functions
SALV_DEMO_TREE_METADATA Demonstration Program for ALV OM Tree: Metadata
SALV_DEMO_TREE_SELECTIONS Demonstration Program for ALV OM Tree: Selections
SALV_DEMO_TREE_SETTINGS Demonstration Program for ALV OM Tree: Settings
SALV_DEMO_TREE_SIMPLE Demonstration Program for ALV OM Tree
Regards,
Similar Messages
-
Hi Friends,
I have created a Hierarchial ALV report using OOP concept (Class Builder). The output is OK but it is displaying the unwanted columns in the header part.
The code written is as follows.
=====================================================
data: gt_zsd_abcd type zsd_abcd occurs 0, "Output-Table
data l_hierarchy_header type treev_hhdr.
perform build_hierarchy_header changing l_hierarchy_header.
call method g_alv_tree->set_table_for_first_display
exporting
i_structure_name = 'zsd_abcd'
is_hierarchy_header = l_hierarchy_header
changing
it_outtab = gt_zsd_abcd. "table must be empty !
perform create_hierarchy.
call method g_alv_tree->frontend_update.
=====================================================
I would like know as to how to display only the required columns in the header part.
Pls guide me.
TIA.
Regards,
Mark KHi Mark,
i got it, in your case you will get all the fields present in the structure you mentioned in the method.
so if you want only Purchase Order then you need to Build the fieldcat only for that field and then pass that fieldcat to the method. and don't pass the structure in this case.
call method alv_tree_control->set_table_for_first_display
exporting
is_variant = l_variant
i_save = 'A'
i_default = 'X'
is_hierarchy_header = l_hierarchy_header
it_special_groups = l_special_groups
it_toolbar_excluding = l_toolbar_excluding
changing
<b>it_fieldcatalog = l_field_catalog</b>
it_outtab = l_output_tbl.
Regards
vijay -
Hi Friends,
I have created a Hierarchial ALV report using OOP concept (Class Builder). The output is OK but it is displaying the unwanted columns in the header part.
The code written is as follows.
=====================================================
REPORT ZMMSTKH.
DATA: G_ALV_TREE TYPE REF TO CL_GUI_ALV_TREE,
G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA: GT_ZSD_BILLINFO TYPE ZSD_BILLINFO OCCURS 0, "Output-Table
OK_CODE LIKE SY-UCOMM,
SAVE_OK LIKE SY-UCOMM, "OK-Code
G_MAX TYPE I VALUE 255.
DATA CCONTAINER1.
DATA LS_FIELDCAT TYPE LVC_S_FCAT.
DATA GT_FIELDCAT_LVC TYPE LVC_S_FCAT OCCURS 0.
DATA IT_FIELDCATALOG TYPE LVC_S_FCAT OCCURS 0.
END-OF-SELECTION.
CALL SCREEN 100.
*& Module PBO OUTPUT
process before output
MODULE PBO OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAINTITLE'.
IF G_ALV_TREE IS INITIAL.
PERFORM INIT_TREE.
CALL METHOD CL_GUI_CFW=>FLUSH
EXCEPTIONS
CNTL_SYSTEM_ERROR = 1
CNTL_ERROR = 2.
IF SY-SUBRC NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
TITEL = 'Automation Queue failure'(801)
TXT1 = 'Internal error:'(802)
TXT2 = 'A method in the automation queue'(803)
TXT3 = 'caused a failure.'(804).
ENDIF.
ENDIF.
ENDMODULE. " PBO OUTPUT
*& Module PAI INPUT
process after input
MODULE PAI INPUT.
SAVE_OK = OK_CODE.
CLEAR OK_CODE.
CASE SAVE_OK.
WHEN 'EXIT' OR 'BACK' OR 'CANC'.
PERFORM EXIT_PROGRAM.
WHEN OTHERS.
CALL METHOD CL_GUI_CFW=>DISPATCH.
ENDCASE.
CALL METHOD CL_GUI_CFW=>FLUSH.
ENDMODULE. " PAI INPUT
*& Form init_tree
text
--> p1 text
<-- p2 text
FORM INIT_TREE.
DATA: L_TREE_CONTAINER_NAME(30) TYPE C.
L_TREE_CONTAINER_NAME = 'CCONTAINER1'(001).
CREATE OBJECT G_CUSTOM_CONTAINER
EXPORTING
CONTAINER_NAME = L_TREE_CONTAINER_NAME
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5.
IF SY-SUBRC <> 0.
MESSAGE X208(00) WITH 'ERROR'(100).
ENDIF.
CREATE OBJECT G_ALV_TREE
EXPORTING
PARENT = G_CUSTOM_CONTAINER
NODE_SELECTION_MODE = CL_GUI_COLUMN_TREE=>NODE_SEL_MODE_SINGLE
ITEM_SELECTION = 'X'
NO_HTML_HEADER = 'X'
NO_TOOLBAR = ''
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
ILLEGAL_NODE_SELECTION_MODE = 5
FAILED = 6
ILLEGAL_COLUMN_NAME = 7.
IF SY-SUBRC <> 0.
MESSAGE X208(00) WITH 'ERROR'. "#EC NOTEXT
ENDIF.
DATA L_HIERARCHY_HEADER TYPE TREEV_HHDR.
PERFORM BUILD_HIERARCHY_HEADER CHANGING L_HIERARCHY_HEADER.
PERFORM ZF_CREATE_FIELDCAT.
CALL METHOD G_ALV_TREE->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'zsd_billinfo'
IS_HIERARCHY_HEADER = L_HIERARCHY_HEADER
CHANGING
IT_OUTTAB = GT_ZSD_BILLINFO. "table must be empty !
IT_FIELDCATALOG = GT_FIELDCAT_LVC[].
PERFORM CREATE_HIERARCHY.
CALL METHOD G_ALV_TREE->FRONTEND_UPDATE.
ENDFORM. " init_tree
*& Form build_hierarchy_header
FORM BUILD_HIERARCHY_HEADER CHANGING
P_HIERARCHY_HEADER TYPE TREEV_HHDR.
P_HIERARCHY_HEADER-HEADING = 'Region / Material'(300).
p_hierarchy_header-tooltip = 'PO No'(400).
P_HIERARCHY_HEADER-WIDTH = 30.
P_HIERARCHY_HEADER-WIDTH_PIX = ' '.
ENDFORM. " build_hierarchy_header
*& Form exit_program
free object and leave program
FORM EXIT_PROGRAM.
CALL METHOD G_CUSTOM_CONTAINER->FREE.
LEAVE PROGRAM.
ENDFORM. " exit_program
*& Form create_hierarchy
text
--> p1 text
<-- p2 text
FORM CREATE_HIERARCHY.
DATA: LS_ZSD_BILLINFO TYPE ZSD_BILLINFO,
LT_ZSD_BILLINFO TYPE ZSD_BILLINFO OCCURS 0,
l_bukrs like zsd_billinfo-bukrs,
l_vbeln like zsd_billinfo-vbeln,
l_fkdat like zsd_billinfo-fkdat,
l_fkart like zsd_billinfo-fkart,
l_vkorg like zsd_billinfo-vkorg,
l_spart like zsd_billinfo-spart,
L_BZIRK LIKE ZSD_BILLINFO-BZIRK,
L_BZIRK_LAST LIKE ZSD_BILLINFO-BZIRK,
l_vkbur like zsd_billinfo-vkbur,
L_WERKS LIKE ZSD_BILLINFO-WERKS,
L_WERKS_LAST LIKE ZSD_BILLINFO-WERKS,
L_MATNR LIKE ZSD_BILLINFO-MATNR,
L_MATNR_LAST LIKE ZSD_BILLINFO-MATNR,
L_FKIMG LIKE ZSD_BILLINFO-FKIMG,
L_NETWR LIKE ZSD_BILLINFO-NETWR.
DATA: L_BUKRS_KEY TYPE LVC_NKEY,
L_BZIRK_KEY TYPE LVC_NKEY,
L_WERKS_KEY TYPE LVC_NKEY,
L_MATNR_KEY TYPE LVC_NKEY,
l_vbeln_key type lvc_nkey,
L_LAST_KEY TYPE LVC_NKEY.
SELECT BUKRS BZIRK WERKS MATNR FKIMG FROM ZSD_BILLINFO
INTO CORRESPONDING FIELDS OF
TABLE LT_ZSD_BILLINFO
WHERE SPART = 'CT' AND
FKART = 'ZVAT'.
select * from zsd_billinfo into table lt_zsd_billinfo
where spart = 'CT' and
fkart = 'ZVAT'.
SORT LT_ZSD_BILLINFO BY BZIRK WERKS MATNR.
LOOP AT LT_ZSD_BILLINFO INTO LS_ZSD_BILLINFO.
L_BZIRK = LS_ZSD_BILLINFO-BZIRK.
L_WERKS = LS_ZSD_BILLINFO-WERKS.
L_MATNR = LS_ZSD_BILLINFO-MATNR.
IF L_BZIRK <> L_BZIRK_LAST.
L_BZIRK_LAST = L_BZIRK.
PERFORM ADD_BZIRK USING L_BZIRK
CHANGING L_BZIRK_KEY.
CLEAR L_WERKS_LAST.
ENDIF.
IF L_WERKS <> L_WERKS_LAST.
L_WERKS_LAST = L_WERKS.
PERFORM ADD_WERKS_LINE USING LS_ZSD_BILLINFO
L_WERKS_KEY
CHANGING L_WERKS_KEY.
IF L_MATNR <> L_MATNR_LAST.
L_MATNR_LAST = L_MATNR.
PERFORM ADD_MATNR_LINE USING LS_ZSD_BILLINFO
L_MATNR_KEY
CHANGING L_MATNR_KEY.
ENDIF.
PERFORM ADD_COMPLETE_LINE USING LS_ZSD_BILLINFO
L_MATNR_KEY
CHANGING L_LAST_KEY.
ENDIF.
*if l_matnr <> l_matnr_last.
l_matnr_last = l_matnr.
perform add_matnr_line using ls_zsd_billinfo
l_matnr_key
changing l_matnr_key.
endif.
perform add_complete_line using ls_zsd_billinfo
l_matnr_key
changing l_last_key.
ENDLOOP.
ENDFORM. " create_hierarchy
*& Form add_month
*& Form add_ebeln
FORM ADD_BZIRK USING P_BZIRK TYPE C
P_RELAT_KEY TYPE LVC_NKEY
CHANGING P_NODE_KEY TYPE LVC_NKEY.
DATA: L_NODE_TEXT TYPE LVC_VALUE,
LS_ZSD_BILLINFO TYPE ZSD_BILLINFO,
L_BZIRK(12) TYPE C. "output string for month
CALL METHOD G_ALV_TREE->ADD_NODE
EXPORTING
I_RELAT_NODE_KEY = P_RELAT_KEY
I_RELATIONSHIP = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD
I_NODE_TEXT = L_NODE_TEXT
IS_OUTTAB_LINE = LS_ZSD_BILLINFO
IMPORTING
E_NEW_NODE_KEY = P_NODE_KEY.
ENDFORM. " add_month
FORM ADD_WERKS_LINE USING PS_ZSD_BILLINFO TYPE ZSD_BILLINFO
P_RELAT_KEY TYPE LVC_NKEY
CHANGING P_NODE_KEY TYPE LVC_NKEY.
DATA: L_NODE_TEXT TYPE LVC_VALUE,
LS_ZSD_BILLINFO TYPE ZSD_BILLINFO.
L_NODE_TEXT = PS_ZSD_BILLINFO-WERKS.
CALL METHOD G_ALV_TREE->ADD_NODE
EXPORTING
I_RELAT_NODE_KEY = P_RELAT_KEY
I_RELATIONSHIP = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD
I_NODE_TEXT = L_NODE_TEXT
IS_OUTTAB_LINE = LS_ZSD_BILLINFO
IMPORTING
E_NEW_NODE_KEY = P_NODE_KEY.
ENDFORM. " add_carrid_line
FORM ADD_MATNR_LINE USING PS_ZSD_BILLINFO TYPE ZSD_BILLINFO
P_RELAT_KEY TYPE LVC_NKEY
CHANGING P_NODE_KEY TYPE LVC_NKEY.
DATA: L_NODE_TEXT TYPE LVC_VALUE,
LS_ZSD_BILLINFO TYPE ZSD_BILLINFO.
L_NODE_TEXT = PS_ZSD_BILLINFO-MATNR.
CALL METHOD G_ALV_TREE->ADD_NODE
EXPORTING
I_RELAT_NODE_KEY = P_RELAT_KEY
I_RELATIONSHIP = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD
I_NODE_TEXT = L_NODE_TEXT
IS_OUTTAB_LINE = LS_ZSD_BILLINFO
IMPORTING
E_NEW_NODE_KEY = P_NODE_KEY.
ENDFORM. " add_carrid_line
**& Form add_complete_line
FORM ADD_COMPLETE_LINE USING PS_ZSD_BILLINFO TYPE ZSD_BILLINFO
P_RELAT_KEY TYPE LVC_NKEY
CHANGING P_NODE_KEY TYPE LVC_NKEY.
DATA: L_NODE_TEXT TYPE LVC_VALUE.
WRITE PS_ZSD_BILLINFO-BZIRK TO L_NODE_TEXT.
CALL METHOD G_ALV_TREE->ADD_NODE
EXPORTING
I_RELAT_NODE_KEY = P_RELAT_KEY
I_RELATIONSHIP = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD
IS_OUTTAB_LINE = PS_ZSD_BILLINFO
I_NODE_TEXT = L_NODE_TEXT
IMPORTING
E_NEW_NODE_KEY = P_NODE_KEY.
ENDFORM. " add_complete_line
*& Form zf_create_fieldcat
text
FORM ZF_CREATE_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'FKIMG'.
LS_FIELDCAT-REF_TABLE = 'zsd_billinfo'.
LS_FIELDCAT-NO_OUT = 'X'.
LS_FIELDCAT-KEY = ''.
APPEND LS_FIELDCAT TO GT_FIELDCAT_LVC.
ENDFORM. " ZF_CREATE_FIELDCAT
=================================================
Kindly look into the code and guide me the solution.
TIA.
Regards,
Mark Khi
good
i tried your ALV report but it is giving some error due to some ztable you have used in your progam,
you can go to se38 and give there BCALV* and press f4, you ll find lots of ALV example related to OOP concept, you can test them and use them as per your requirement.
thnaks
mrutyun^ -
Hi Friends,
I have created a Hierarchial ALV report using OOP concept (Class Builder). The output is OK but it is displaying the unwanted columns in the header part.
The code written is as follows.
=====================================================
data: gt_zsd_abcd type zsd_abcd occurs 0, "Output-Table
data l_hierarchy_header type treev_hhdr.
perform build_hierarchy_header changing l_hierarchy_header.
call method g_alv_tree->set_table_for_first_display
exporting
i_structure_name = 'zsd_abcd'
is_hierarchy_header = l_hierarchy_header
changing
it_outtab = gt_zsd_abcd. "table must be empty !
perform create_hierarchy.
call method g_alv_tree->frontend_update.
=====================================================
I would like know as to how to display only the required columns in the header part.
Pls guide me.
TIA.
Regards,
Mark Kin the changing parameter you have to pass a fieldcatalog conaining only those columns you want to display .
call method g_alv_tree->set_table_for_first_display
exporting
i_structure_name = 'zsd_abcd'
is_hierarchy_header = l_hierarchy_header
changing
it_outtab = gt_zsd_abcd. "table must be empty !
it_fieldcatalog = gt_fieldcat_lvc[].
you can fill the catalog like this :
FORM zf_create_fieldcat.
DATA ls_fieldcat TYPE lvc_s_fcat.
Main Asset Number
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'ANLN1'.
ls_fieldcat-ref_table = 'ANLA'.
ls_fieldcat-no_out = 'X'.
ls_fieldcat-key = ''.
APPEND ls_fieldcat TO gt_fieldcat_lvc.
Asset Subnumber
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'ANLN2'.
ls_fieldcat-ref_table = 'ANLA'.
ls_fieldcat-no_out = 'X'.
ls_fieldcat-key = ''.
APPEND ls_fieldcat TO gt_fieldcat_lvc.
Assigned to WBS
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'XLOEV'.
ls_fieldcat-ref_table = 'ANLA'.
ls_fieldcat-coltext = 'Assigned to WBS'(003).
ls_fieldcat-tooltip = ls_fieldcat-coltext.
ls_fieldcat-seltext = ls_fieldcat-coltext.
ls_fieldcat-outputlen = '3'.
APPEND ls_fieldcat TO gt_fieldcat_lvc.
Value
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'URWRT'.
ls_fieldcat-ref_table = 'ANLA'.
ls_fieldcat-coltext = 'Value'(004).
ls_fieldcat-tooltip = ls_fieldcat-coltext.
ls_fieldcat-seltext = ls_fieldcat-coltext.
APPEND ls_fieldcat TO gt_fieldcat_lvc.
Asset description
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'TXT50'.
ls_fieldcat-ref_table = 'ANLA'.
APPEND ls_fieldcat TO gt_fieldcat_lvc.
ENDFORM. " ZF_CREATE_FIELDCAT -
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 -
Scrolling Issue - ALV- ABAP OOPS!
Hello All,
I have a strange issue with regards to ALV developed using ABAP OOPS. I have more than 25 fields on the output screen.
For each field on output screen, F4 help is possible. So when I scroll to the right most fields on the screen, do a f4 help and fill the value, the alv output screen automatically moves to the left side.
I tried to resolve using SET_SCROLL_INFO_VIA_ID method of the class CL_GUI_ALV_GRID.
CALL METHOD g_alvgrid->set_scroll_info_via_id
EXPORTING
is_row_info = v_scrl_row_info
is_col_info = v_scrl_col_info.
* Set Scroll Position
CALL METHOD g_alvgrid->set_current_cell_via_id
EXPORTING
is_row_id = v_scrl_row_set
is_column_id = v_scrl_col_set.
But still moves to the left side.
If you have some ideas on this, pls share the same. Thanks in advance.
Best Regards
Himayat.
Edited by: Himayatullah Md on Nov 25, 2011 4:42 PM
Please use code tags
Edited by: Rob Burbank on Nov 25, 2011 10:49 AMIf you use [refresh_table_display|http://help.sap.com/saphelp_erp2004/helpdata/en/0a/b5531ed30911d2b467006094192fe3/frameset.htm] set paramter is_stable to keep scrollbar on desired position.
Regards
Marcin -
what do u mean by Hierarchial alv's and what is the exact purpose of them according to ooabap functionality and can anybody explain various issues regarding it,If possible with an example.
FOLLOW THE LINKS
alv with oops
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
www.saptechies.com/alv-faq--general-information/
The specified item was not found.
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
http://www.geocities.com/mpioud/Abap_programs.html
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/an%20easy%20reference%20for%20alv%20grid%20control.pdf
http://www.sapgenie.com/abap/controls/alvgrid.htm
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCIDOCK/BCCIDOCK.pdf
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCIGOF/BCCIGOF.pdf
http://www.sapdevelopment.co.uk/reporting/alv/alvscr.htm
http://esnips.com/doc/b708766f-a934-42a1-8064-c4de75b48fc4/Sample-Program-of-alv-using-oops.ppt
http://esnips.com/doc/a2e42503-cf0f-4418-94ee-580f5900a81f/alv-with-oop.doc
http://esnips.com/doc/2d953590-e8c5-490c-a607-d1ab7cf517d7/ALV.pdf
codes for alv with oops
codeBCALV_EDIT_01.
BCALV_EDIT_02.
BCALV_EDIT_03.
BCALV_EDIT_04.
BCALV_EDIT_05.
BCALV_EDIT_06.
BCALV_EDIT_07.
BCALV_EDIT_08.[/code]
HIERARCHIAL ALV
REUSE_ALV_HIERSEQ_LIST_DISPLAY
Text
Hierarchical sequential list output
Functionality
This module outputs two internal tables as a formated hierarchical-sequential list.
Principle:
Pass an internal table containing the set of header information to be output.
Pass an internal table containing the set of item information to be output.
Pass a structure containing the general list layout details
Pass a field catalog in the form of an internal table. The field catalog describes the fields to be output in the list.
Notes
All interactions which are performed on the list refer directly to the internal output tables, e.g. sorting the list also sorts the passed internal output tables (passed by reference).
The expected output data quantity is an important consideration for the use of the tool or various generic functions (totals, subtotals).
The application must take account of this.
Further Information
Parameters
ES_EXIT_CAUSED_BY_USER
Meaning
See the documentation of parameter .
REUSE_ALV_LIST_DISPLAY ES_EXIT_CAUSED_BY_USER> ES_EXIT_CAUSED_BY_USER .
Range
Default
E_EXIT_CAUSED_BY_CALLER
Meaning
<DS:FU.REUSE_ALV_LIST_DISPLAY E_EXIT_CAUSED_BY_CALLER> link to REUSE_ALV_LIST_DISPLAY E_EXIT_CAUSED_BY_CALLER
Range
Default
IS_KEYINFO
Meaning
This structure contains the header and item table field names which link the two tables (shared key).
Enter the foreign key field names in the fields KEYINFO-HEADERxx and KEYINFO-ITEMxx. The foreign key field names of the header and item tables are usually identical.
The item table has other key fields as well as the header table foreign key. These other key fields should also be named in this structure. The corresponding header table field (HEADERxx) must be SPACE.
Naming the other key fields guarantees a stable item table sort sequence.
Range
Default
IS_LAYOUT
Meaning
<DS:FU.REUSE_ALV_LIST_DISPLAY IS_LAYOUT> link to REUSE_ALV_LIST_DISPLAY IS_LAYOUT
IS_PRINT
Meaning
<DS:FU.REUSE_ALV_LIST_DISPLAY IS_PRINT> link to REUSE_ALV_LIST_DISPLAY IS_PRINT
Range
Default
IS_REPREP_ID
IS_SEL_HIDE
Meaning
<DS:FU.REUSE_ALV_LIST_DISPLAY IS_SEL_HIDE> link to REUSE_ALV_LIST_DISPLAY IS_SEL_HIDE
Range
Default
IS_VARIANT
Meaning
<DS:FU.REUSE_ALV_LIST_DISPLAY IS_VARIANT> link to REUSE_ALV_LIST_DISPLAY IS_VARIANT
Range
Default
IT_EVENTS
Meaning
<DS:FU.REUSE_ALV_LIST_DISPLAY IT_EVENTS> link to REUSE_ALV_LIST_DISPLAY IT_EVENTS
Range
Default
IT_EVENT_EXIT
Meaning
<DS:FU.REUSE_ALV_LIST_DISPLAY IT_EVENT_EXIT> link to REUSE_ALV_LIST_DISPLAY IT_EVENT_EXIT
Range
Default
IT_EXCLUDING
Meaning
<DS:FU.REUSE_ALV_LIST_DISPLAY IT_EXCLUDING> link to REUSE_ALV_LIST_DISPLAY IT_EXCLUDING
Range
Default
IT_FIELDCAT
Meaning
<DS:FU.REUSE_ALV_LIST_DISPLAY IT_FIELDCAT> link to REUSE_ALV_LIST_DISPLAY IT_FIELDCAT
Range
Default
IT_FILTER
Meaning
<DS:FU.REUSE_ALV_LIST_DISPLAY IT_FILTER> link to REUSE_ALV_LIST_DISPLAY IT_FILTER
Range
Default
IT_SORT
Meaning
<DS:FU.REUSE_ALV_LIST_DISPLAY IT_SORT> link to REUSE_ALV_LIST_DISPLAY IT_SORT
Range
Default
IT_SPECIAL_GROUPS
Meaning
<DS:FU.REUSE_ALV_LIST_DISPLAY IT_SPECIAL_GROUPS> link to REUSE_ALV_LIST_DISPLAY IT_SPECIAL_GROUPS
Range
Default
I_BUFFER_ACTIVE
I_BYPASSING_BUFFER
I_CALLBACK_PF_STATUS_SET
<DS:FU.REUSE_ALV_LIST_DISPLAY I_CALLBACK_PF_STATUS_SET> link to REUSE_ALV_LIST_DISPLAY I_CALLBACK_PF_STATUS_SET
I_CALLBACK_PROGRAM
Meaning
<DS:FU.REUSE_ALV_LIST_DISPLAY I_CALLBACK_PROGRAM> link to REUSE_ALV_LIST_DISPLAY I_CALLBACK_PROGRAM
Range
Default
I_CALLBACK_USER_COMMAND
<DS:FU.REUSE_ALV_LIST_DISPLAY I_CALLBACK_USER_COMMAND> link to REUSE_ALV_LIST_DISPLAY I_CALLBACK_USER_COMMAND
I_DEFAULT
Meaning
<DS:FU.REUSE_ALV_LIST_DISPLAY I_DEFAULT> link to REUSE_ALV_LIST_DISPLAY I_DEFAULT
Range
Default
I_INTERFACE_CHECK
Meaning
<DS:FU.REUSE_ALV_LIST_DISPLAY I_INTERFACE_CHECK> link to REUSE_ALV_LIST_DISPLAY I_INTERFACE_CHECK
Range
Default
I_SAVE
Meaning
<DS:FU.REUSE_ALV_LIST_DISPLAY I_SAVE> link to REUSE_ALV_LIST_DISPLAY I_SAVE
Range
Default
I_SCREEN_END_COLUMN
Meaning
<DS:FU.REUSE_ALV_LIST_DISPLAY I_SCREEN_END_COLUMN> link to REUSE_ALV_LIST_DISPLAY I_SCREEN_END_COLUMN
Range
Default
I_SCREEN_END_LINE
Meaning
<DS:FU.REUSE_ALV_LIST_DISPLAY I_SCREEN_END_LINE> link to REUSE_ALV_LIST_DISPLAY I_SCREEN_END_LINE
Range
Default
I_SCREEN_START_COLUMN
Meaning
<DS:FU.REUSE_ALV_LIST_DISPLAY I_SCREEN_START_COLUMN> link to REUSE_ALV_LIST_DISPLAY I_SCREEN_START_COLUMN
Range
Default
I_SCREEN_START_LINE
Meaning
<DS:FU.REUSE_ALV_LIST_DISPLAY I_SCREEN_START_LINE> link to REUSE_ALV_LIST_DISPLAY I_SCREEN_START_LINE
Range
Default
I_STRUCTURE_NAME_HEADER
Meaning
<DS:FU.REUSE_ALV_LIST_DISPLAY I_STRUCTURE_NAME> link to REUSE_ALV_LIST_DISPLAY I_STRUCTURE_NAME
Range
Default
I_STRUCTURE_NAME_ITEM
Meaning
<DS:FU.REUSE_ALV_LIST_DISPLAY I_STRUCTURE_NAME> link to REUSE_ALV_LIST_DISPLAY I_STRUCTURE_NAME
Range
Default
I_TABNAME_HEADER
Meaning
Name of the internal table in the program containing the output data of the highest hierarchy level.
Range
Default
I_TABNAME_ITEM
Meaning
Name of the internal table in the program containing the output data of the lowest hierarchy level.
Range
Default
T_OUTTAB_HEADER
Meaning
Header table with data to be output
<DS:FU.REUSE_ALV_LIST_DISPLAY T_OUTTAB> link to REUSE_ALV_LIST_DISPLAY T_OUTTAB
Range
Default
T_OUTTAB_ITEM
Meaning
Item table with data to be output
<DS:FU.REUSE_ALV_LIST_DISPLAY T_OUTTAB> link to REUSE_ALV_LIST_DISPLAY T_OUTTAB
Default
Exceptions
PROGRAM_ERROR
Meaning
<DS:FX.REUSE_ALV_LIST_DISPLAY PROGRAM_ERROR> link to REUSE_ALV_LIST_DISPLAY PROGRAM_ERROR
EXAMPLE
go through this alv grid display example
wa_listheader-key = ''.
wa_listheader-typ = 'S'.
wa_listheader-info = 'Date'.
append wa_listheader to it_end_listheader.
clear: wa_listheader.
concatenate 'Time' sy-uzeit into w_date separated by space.
wa_listheader-key = ''.
wa_listheader-typ = 'S'.
wa_listheader-info = 'Time'.
append wa_listheader to it_end_listheader.
clear: wa_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = it_end_listheader[]
I_LOGO =
I_END_OF_LIST_GRID =
ENDFORM. " f100-end_of_page
In grid display there will be no end_of_page and no end_of_list.
You have show in top_of_page itself.
Otherwise use list display instead of grid.
Suresh Avutu
These steps have to be carried out...
DATA: gc_formname_top_of_page TYPE slis_formname
VALUE 'TOP_OF_PAGE'.
DATA: gc_formname_end_of_page TYPE slis_formname
VALUE 'END_OF_PAGE'.
DATA: gt_list_top_of_page TYPE slis_t_listheader.
DATA: gt_list_end_of_page TYPE slis_t_listheader.
PERFORM e03_eventtab_build USING gt_event[].
PERFORM e04_comment_build USING
gt_list_top_of_page[].
PERFORM e06_comment_build USING
gt_list_end_of_page[].
PERFORM list_alv_display.
FORM list_alv_display .
gt_event-name = slis_ev_top_of_list.
gt_event-form = 'TOP_OF_PAGE'.
APPEND gt_event.
gt_event-name = slis_ev_end_of_list.
gt_event-form = 'END_OF_PAGE'.
APPEND gt_event.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
i_bypassing_buffer = 'X'
i_buffer_active = ' '
i_callback_program = ....
FORM end_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = ''
it_list_commentary = gt_list_end_of_page
I_END_OF_LIST_GRID = 1.
ENDFORM. "END_OF_PAGE
FORM e06_comment_build
USING e06_lt_end_of_page TYPE slis_t_listheader.
DATA: ls_line TYPE slis_listheader.
DATA: yl_uname(60).
< here u can concatenate system date and time to
yl_uname>
CLEAR ls_line.
ls_line-typ = 'S'.
ls_line-info = yl_uname.
APPEND ls_line TO e06_lt_end_of_page.
endform. "e06_comment_build
Suman Tyagi
An Example:
REPORT ZALV_GRID.
TABLES :vbap.
type-pools : slis.
data i_events TYPE slis_t_event.
DATA : my_alv TYPE REF TO cl_gui_alv_grid.
TYPES : BEGIN OF itab,
vbeln LIKE vbap-vbeln,
arktx LIKE vbap-arktx,
END OF itab.
TYPES : itab1 TYPE TABLE OF itab.
DATA : display TYPE itab1.
DATA : fcat TYPE SLIS_T_FIELDCAT_ALV.
DATA : wa LIKE LINE OF FCAT.
DATA WA1 LIKE VBAP.
DATA: container TYPE REF TO cl_gui_custom_container.
data report_id like sy-repid.
SELECT-OPTIONS s_vbeln FOR vbap-vbeln.
report_id = sy-repid.
SELECT * FROM vbap INTO CORRESPONDING FIELDS OF TABLE display WHERE
vbeln IN s_vbeln.
wa-fieldname = 'VBELN'.
wa-tabname = 'VBAP'.
wa-key = 'X'.
WA-HOTSPOT = 'X'.
wa-text_fieldname = 'Doc no.'.
APPEND wa TO fcat.
CLEAR wa.
wa-fieldname = 'ARKTX'.
wa-tabname = 'VBAP'.
wa-text_fieldname = 'Item Text'.
APPEND wa TO fcat.
PERFORM f0650_build_event USING 'USER_COMMAND'
'F0750_USER_COMMAND'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY '
EXPORTING
I_CALLBACK_PROGRAM = report_id
IT_FIELDCAT = FCAT
IT_EVENTS = i_events
TABLES
t_outtab = DISPLAY
FORM f0650_build_event USING value(w_c_event_name)
value(w_c_event_form).
DATA: f0650_wa_event TYPE slis_alv_event.
CLEAR f0650_wa_event.
f0650_wa_event-name = w_c_event_name.
f0650_wa_event-form = w_c_event_form.
APPEND f0650_wa_event TO i_events.
ENDFORM.
FORM f0750_user_command USING w_ucomm TYPE sy-ucomm
w_selfield TYPE slis_selfield.
CASE w_ucomm.
WHEN '&IC1'.
READ TABLE DISPLAY INTO WA1 INDEX w_selfield-tabindex.
MESSAGE E000 WITH
' You have no authorization to view the report'.
call transaction 'SE11'.
ENDCASE.
ENDFORM.
cheers,
sharad
Edited by: sharad narayan on Apr 18, 2008 9:26 AM
Edited by: sharad narayan on Apr 18, 2008 9:32 AM -
ABAP OOP example and invitation
For quite a while, I've been trying to learn more about ABAP OOP. But, I've
found many of the examples on the web, and in SAP provided articles, either
difficult to understand or outright lame. They never seemed to illustrate
much of what a staff ABAP programmer is called upon to do.
So, last week I decided to take the problem head on and see if I could come
up with something we all could use as a starting point to learn more about
ABAP objects.
Here's a chunk of code that I want everybody to pick apart, critique,
modify, append or whatever. The only stipulation is that you post your
suggestions back to this forum. Maybe after we get some nice ABAP objects
together, the forum manager can put them into an OOP area of this website.
================================================================
The first object I created uses the MARC (Plant Data for Material) table.
I wanted to use it to learn more about how "Selection Sets" can be used with
ABAP OOP.
The class has five methods:
-o- constructor
-o- return_marc_table
-o- return_subset_marc_table
-o- length
-o- write_marc_table
This class isn't, really, very useful. But, it does show how selection-sets
can be used with ABAP oop. The code is studded with commented BREAK-POINTS
that you can turn on and off to examine things.
Split the code into two files: Main program and Top include. Look at the
initialization section and you should be able to see how you can tweak
the materials selected for your environment.
enjoy
[email protected]
REPORT zejb_oop_sel_set2 .
This program is designed to demonstrate passing selection sets
to an ABAP object
The program has some educational value. But, other than that
probably isn't of much use.
=========================================== Main Program - BEGIN
INCLUDE zejb_oop_sel_set2_top. "data and class definitions
SELECT-OPTIONS:
s_matnr FOR marc-matnr,
s_werks FOR marc-werks.
DATA: my_marc TYPE REF TO marc_object .
============================================= START-OF-SELECTION
START-OF-SELECTION.
matnr_selector[] = s_matnr[] .
werks_selector[] = s_werks[].
call the constructor table and create the CLASS-DATA
CREATE OBJECT my_marc
EXPORTING
s_matnr = matnr_selector
s_werks = werks_selector .
================================================ END-OF-SELECTION
END-OF-SELECTION.
CALL METHOD my_marc->return_marc_table
IMPORTING
return_marc = tb_marc.
BREAK-POINT. " inspect tb_marc
CALL METHOD my_marc->length
IMPORTING
table_size = zzlines.
WRITE:/ 'Class-Data table in object my_marc has '
, zzlines , ' lines'.
ULINE.
WRITE:/ 'printing internal table tb_marc'.
CALL METHOD my_marc->write_marc_table
EXPORTING
print_table = tb_marc.
SKIP.
BREAK-POINT.
examine matnr_subset_selector
examine werks_subset_selector
CALL METHOD my_marc->return_subset_marc_table
EXPORTING
s_matnr = matnr_subset_selector
s_werks = werks_subset_selector
IMPORTING
return_marc = tb_subset_marc.
BREAK-POINT.
examine tb_subset_marc
ULINE.
WRITE:/ 'printing internal table tb_subset_marc'.
CALL METHOD my_marc->write_marc_table
EXPORTING
print_table = tb_subset_marc.
ULINE.
================================================== INITIALIZATION
INITIALIZATION.
DEFINE range_append. "#EC *
1 == range_name
clear &1. "#EC *
&1-sign = &2. "#EC *
&1-option = &3. "#EC *
&1-low = &4. "#EC *
&1-high = &5. "#EC *
append &1. clear &1. "#EC *
END-OF-DEFINITION. "#EC *
DEFINE fill_range. "#EC *
1 == range_name
clear &1. "#EC *
&1-sign = &2. "#EC *
&1-option = &3. "#EC *
&1-low = &4. "#EC *
&1-high = &5. "#EC *
END-OF-DEFINITION. "#EC *
modify these materials and plants to suit your environment
or create a selection variant
range_append s_matnr 'I' 'EQ' 'HAP100' space.
range_append s_matnr 'I' 'EQ' 'HAP205' space.
range_append s_matnr 'I' 'EQ' 'HAP221' space.
range_append s_matnr 'I' 'EQ' 'HAP240' space.
range_append s_matnr 'I' 'EQ' 'HAP245' space.
range_append s_matnr 'I' 'EQ' 'HAP250' space.
range_append s_matnr 'I' 'EQ' 'HAP260' space.
range_append s_werks 'I' 'EQ' '1000' space.
range_append s_werks 'I' 'EQ' '1020' space.
fill subset selector
fill_range st_matnr_selector 'I' 'EQ' 'HAP205' space.
APPEND st_matnr_selector TO matnr_subset_selector.
fill_range st_matnr_selector 'I' 'EQ' 'HAP250' space.
APPEND st_matnr_selector TO matnr_subset_selector.
fill_range st_werks_selector 'I' 'EQ' '1000' space.
APPEND st_werks_selector TO werks_subset_selector.
============================================ Main Program - End
*& Include ZEJB_OOP_SEL_SET2_TOP *
============================================ Top include - BEGIN
TABLES : marc.
DATA: tb_marc TYPE TABLE OF marc,
tb_subset_marc TYPE TABLE OF marc,
st_marc TYPE marc. "#EC *
"^^^^^^^ to/from structure. use as needed
DATA: st_matnr_selector TYPE range_s_matnr,
st_werks_selector TYPE range_werks,
matnr_selector TYPE TABLE OF range_s_matnr,
werks_selector TYPE TABLE OF range_werks,
matnr_subset_selector TYPE TABLE OF range_s_matnr,
werks_subset_selector TYPE TABLE OF range_werks.
DATA: zzlines TYPE i. " size of class_data table.
CLASS marc_object DEFINITION
NOTE: for those new to abap objects, EVERYTHING in abap OOP
must be explicitly "TYPED". more on this as I go along
CLASS marc_object DEFINITION.
PUBLIC SECTION.
TYPES:
typ_marc TYPE TABLE OF marc,
typ_matnr_selector TYPE TABLE OF range_s_matnr,
typ_werks_selector TYPE TABLE OF range_werks.
DATA: return_marc TYPE typ_marc,
print_table TYPE typ_marc.
CLASS-DATA:
class_marc
TYPE typ_marc. " <== inside public area
^^^^^^^ this table will be available to all methods
^^^^^^^ in the class
METHODS:
constructor
IMPORTING
s_matnr TYPE typ_matnr_selector
s_werks TYPE typ_werks_selector OPTIONAL ,
return_marc_table
EXPORTING return_marc TYPE typ_marc ,
return_subset_marc_table
IMPORTING
s_matnr TYPE typ_matnr_selector
s_werks TYPE typ_werks_selector OPTIONAL
EXPORTING
return_marc TYPE typ_marc,
length EXPORTING table_size TYPE i,
write_marc_table
IMPORTING print_table TYPE typ_marc.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS. "marc_object DEFINITION
*EJECT
CLASS zget_sales_order_change IMPLEMENTATION
CLASS marc_object IMPLEMENTATION.
METHOD constructor .
DATA:
s_lcl_matnr TYPE TABLE OF range_s_matnr ,
s_lcl_werks TYPE TABLE OF range_werks .
s_lcl_matnr[] = s_matnr[] .
s_lcl_werks[] = s_werks[] .
SELECT * FROM marc
APPENDING TABLE class_marc
WHERE matnr IN s_lcl_matnr
AND werks IN s_lcl_werks.
SORT class_marc BY matnr werks.
BREAK-POINT.
ENDMETHOD. "xxx
METHOD return_marc_table.
return_marc[] = class_marc[] .
BREAK-POINT. " examine class_marc
ENDMETHOD. "return_marc table
METHOD return_subset_marc_table.
DATA: st_marc TYPE marc.
REFRESH return_marc.
LOOP AT class_marc INTO st_marc
WHERE matnr IN s_matnr
AND werks IN s_werks .
APPEND st_marc TO return_marc.
ENDLOOP.
BREAK-POINT. " examine return_marc
ENDMETHOD. "return_subset_marc_table
METHOD length.
DESCRIBE TABLE class_marc LINES table_size.
ENDMETHOD. "length
METHOD write_marc_table.
DATA: st_marc TYPE marc.
LOOP AT print_table INTO st_marc.
WRITE:/ 'Material ' , st_marc-matnr,
'Plant ' , st_marc-werks.
ENDLOOP.
ENDMETHOD. "write_marc_table
ENDCLASS. "marc_object IMPLEMENTATION
============================================== Top include - ENDSearch using " ALV Factory methods" u'll get lots of material.
for instance u can a look at this wiki
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/abap%2b-%2bdeveloping%2binteractive%2balv%2breport%2busing%2booabap
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/community/object%2bmodel%2balv%2b-%2binteractive
[ALVOO PDF|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/cda3992d-0e01-0010-90b2-c4e1f899ac01] -
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 -
Multilevel hierarchy ALV report of Mother WBS
Hi ABAP Guru,
I have created a Mother WBS sturcture which has been created in CJ91 tcode. I need a same hierarchy alv report same structure as shown in cj91 t code. Please help me out.
I have created a alv reort on that but when I make change in mother WBS, the new added wbs is comming in my report at last. PLease help me out.Hi Manish,
I am able to see WBS Elements in MB51 Report after going to detailed list from the initial output page. In this detailed output the sender and receiver WBS Elements are getting displayed incorrectly.From that screen only,if I go to Material document list,sender and receiver WBS Elements are getting displayed correctly.
Regards,
B P Singh -
How to trigger New page while using ALV with classes/oops?
Hi All
I am trying to print a report which has to show the data in two pages.
I am using ALV with classes/oops.
Though I am able to print the report but a new page is not coming. Whole of the data is coming in one single page.
Please tell me as to how to trigger a NEW PAGE while using ALV with classes/oops.
Please send some code samples also if available.
Thanks in advance.
Jerryusing sort option you can do it. in case of grid/oo alv class ALV you can view that only in print mode/preview mode.
in case of list you can view that directly.
sort-fieldname = 'FIELDNAME'.
sort-group = '*' "triggers new page
sort-up = 'X'.
append sort to it_sort. -
Runtime error while i add a node in ALV Tree in oops
i am adding a node to alv tree using oop am passing a work area and when i execute it is going for a dump and it says UC_OBJECTS_NOT_CONVERTIBLE
and the below where it is bold and italic it is where the dump is occuring
METHOD ADD_NODE.
FIELD-SYMBOLS: <TAB1> TYPE standard TABLE,
<wa> type any.
assign mt_outtab->* to <tab1>.
insert line in outtab
DATA: L_INDEX TYPE SY-TABIX.
if is_outtab_line is initial.
create initial line
data l_dref_wa type ref to data.
create data l_dref_wa like line of <tab1>.
assign l_dref_wa->* to <wa>.
l_index = 0.
append <wa> to <Tab1>.
else.
APPEND IS_OUTTAB_LINE TO <TAB1>. endif.
L_INDEX = SY-TABIX.
add node to model
CALL METHOD ME->ADD_MODEL_NODE
EXPORTING
I_RELAT_NODE_KEY = I_RELAT_NODE_KEY
I_RELATIONSHIP = I_RELATIONSHIP
IS_NODE_LAYOUT = IS_NODE_LAYOUT
IT_ITEM_LAYOUT = IT_ITEM_LAYOUT
I_NODE_TEXT = I_NODE_TEXT
I_INDEX_OUTTAB = L_INDEX
IMPORTING
E_NEW_NODE_KEY = E_NEW_NODE_KEY.
ENDMETHOD.HI Mohsin,
please refer to the below ....
might be helpful for u .....
https://scn.sap.com/thread/2050188
http://scn.sap.com/message/6407195
http://r0005001.benxbrain.com/de%28bD1lbiZjPTAwMQ==%29/index.do?onInputProcessing=brai_thread&001_thread_id=1759814%20&001_temp=R3TR|PROG|RCSBI010||P01|
Hope thiw will help ....
Regards,
AKS -
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 -
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 -
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.
Maybe you are looking for
-
I rented 4 movies yesterday but only 1 is now showing on my rental list, i went to re-download but it is not showing them under purchased. It does show that i paid for them all...any suggestions??
-
Hi, I am getting the following error in moni when i try to consume a webservice. Even SOAP scenarios that were working fine before also are throwing the same error.I have checked some threads regarding the same error and did as mentioned in the same,
-
can someone help me the green button in itunes does not make screen larger just goes to a square also i cannot us the arrow to make screen larger or smaller anymore
-
Parameter transaction for view maintenance
Hi there, please help I've created a parameter transaction(ZTRN) for a view maintenance(ZVIEW) with the ff Skip initial screen = X VIEWNAME = 'ZVIEW' UPDATE = X. How can i change this transaction/view so that only 1 record can be maintained, i.e how/
-
Collected my new MacPro yesterday from an Apple Store in the West of England. All is fine except for the installation of the CS4 Suite. The installation begins and after a short while the machine completely crashes. (Screen dims from the top slowly a