Sunteți pe pagina 1din 7

GettingStarted Newsletters

Welcome,Guest

Login

Register

SearchtheCommunity

Products

Services&Support

AboutSCN

Downloads

Industries

Training&Education

Partnership

DeveloperCenter

LinesofBusiness

UniversityAlliances

Events&Webinars

Innovation

Weareimproving!TheSCNwikiwillnotbeavailablefornewcontentsubmissionstartingAugust7th6PMCETuntilAugust10th6PMCET.
PleaseplanyourSCNwikitasksaccordingly.

CodeGallery

ABAPOOPSInteractivereportwithDoubleclick&Hotspot
AddedbyKaleemullah,lasteditedbyManishKumaronJun26,2013
Author:Kaleemullah
Submitted:16/11/2007
ALVInteractiveReportforNewbeeswithHotSpotandDoubleclicktosecondaryreport.

REPORTzcls_alv_oopsMESSAGEIDz1.
TABLES:mara.
*
*TypesDeclaration..
*
TYPES:
BEGINOFt_mara,
matnrTYPEmatnr,
mtartTYPEmtart,
maktxTYPEmaktx,
ENDOFt_mara,

BEGINOFt_marc,
matnrTYPEmatnr,
werksTYPEwerks_d,
mtartTYPEmtart,
maktxTYPEmaktx,
ENDOFt_marc.
*
*InternalTablesDeclaration..
*
DATA:
i_maraTYPETABLEOFt_mara,
i_marcTYPETABLEOFt_marc,
i_fcat1TYPElvc_t_fcat,
i_fcat2TYPElvc_t_fcat.
*
*ConstantsDeclaration..
*
CONSTANTS:
c_cont1TYPEscrfnameVALUE'CONT1',
c_cont2TYPEscrfnameVALUE'CONT2'.
SELECTIONSCREENBEGINOFBLOCKb1WITHFRAME.
SELECTOPTIONS:
s_matnrFORmaramatnrNOINTERVALS.
SELECTIONSCREENSKIP1.
PARAMETERS:
p_hotsptRADIOBUTTONGROUPr1DEFAULT'X',
p_bttnRADIOBUTTONGROUPr1.
SELECTIONSCREENENDOFBLOCKb1.

*Classforwardreferncing.
CLASSlcl_rcvr_classDEFINITIONDEFERRED.
*

Store

*PointersDeclaration..
*
DATA:
lp_rcvrTYPEREFTOlcl_rcvr_class,
lp_cont1TYPEREFTOcl_gui_custom_container,
lp_cont2TYPEREFTOcl_gui_custom_container,
lp_grid1TYPEREFTOcl_gui_alv_grid,
lp_grid2TYPEREFTOcl_gui_alv_grid.
*
*LocalClassDefiniton.
*
CLASSlcl_rcvr_classDEFINITION.
PUBLICSECTION.
METHODS:
hotspot_clickFOREVENThotspot_clickOFcl_gui_alv_grid
IMPORTINGe_row_ide_column_ides_row_no,

handle_double_clickFOREVENTdouble_clickOFcl_gui_alv_grid
IMPORTINGe_rowe_column.
ENDCLASS."lcl_rcvr_classDEFINITION
*
*LocalClassImplementation.
*
CLASSlcl_rcvr_classIMPLEMENTATION.
METHODhotspot_click.
DATA:
wa_maraTYPEt_mara,
wa_marcTYPEt_marc.

DATA:
l_indexTYPEsytabix.

READTABLEi_maraINTOwa_maraINDEXe_row_idindex.
IFsysubrcEQ0.
REFRESHi_marc.
SELECTmatnr
werks
INTOTABLEi_marc
FROMmarc
WHEREmatnrEQwa_maramatnr.

IFsysubrcEQ0.
LOOPATi_marcINTOwa_marc.
l_index=sytabix.
wa_marcmtart=wa_maramtart.
wa_marcmaktx=wa_maramaktx.
MODIFYi_marcFROMwa_marcINDEXl_index
TRANSPORTINGmtartmaktx.
ENDLOOP.
CALLSCREEN200.
ELSE.
MESSAGEe121WITHtext005wa_maramatnr.
ENDIF.
ENDIF.

ENDMETHOD."hotspot_click

METHODhandle_double_click.
DATA:
wa_maraTYPEt_mara,
wa_marcTYPEt_marc.

DATA:
l_indexTYPEsytabix.

READTABLEi_maraINTOwa_maraINDEXe_rowindex.
IFsysubrcEQ0.
REFRESHi_marc.
SELECTmatnr
werks
INTOTABLEi_marc
FROMmarc
WHEREmatnrEQwa_maramatnr.

IFsysubrcEQ0.
LOOPATi_marcINTOwa_marc.
l_index=sytabix.
wa_marcmtart=wa_maramtart.
wa_marcmaktx=wa_maramaktx.
MODIFYi_marcFROMwa_marcINDEXl_index
TRANSPORTINGmtartmaktx.
ENDLOOP.
CALLSCREEN200.
ELSE.
MESSAGEe121WITHtext005wa_maramatnr.
ENDIF.
ENDIF.

ENDMETHOD."handle_double_click
ENDCLASS."lcl_rcvr_classIMPLEMENTATION
*
*StartofSelection
*
STARTOFSELECTION.
*ExtracttheMaterialMasterdatafortheInputMaterial.
SELECTa~matnr
a~mtart
b~maktx
INTOTABLEi_mara
FROMmaraASa
INNERJOINmaktASb
ONa~matnrEQb~matnr
WHEREa~matnrINs_matnr
ANDb~sprasEQsylangu.

ENDOFSELECTION.
IFNOTi_mara[]ISINITIAL.
*CallScreentodisplaytheMaterialMasterdata.
CALLSCREEN100.
ELSE.
MESSAGEs121WITHtext006.
ENDIF.
*&*
*&ModuleDISP_GRIDOUTPUT
*&*
MODULEdisp_gridOUTPUT.
*BuildtheFieldcatelogforMaterialMasterdata.
PERFORMbuild_fcat.
*DisplaytheMaterialMasterdatausingALV.
PERFORMdisp_alv.

ENDMODULE."DISP_GRIDOUTPUT
*&*
*&ModuleUSER_COMMAND_0100INPUT
*&*
MODULEuser_command_0100INPUT.

*whenexitorcancelisclickedprogramhastocomeout
CASEsyucomm.
WHEN'EXIT'OR'CANC'.

LEAVEPROGRAM.
WHEN'BACK'.
LEAVETOSCREEN0.
ENDCASE.

ENDMODULE."USER_COMMAND_0100INPUT
*&*
*&Formbuild_fcat
*&*
FORMbuild_fcat.

DATA:ws_fcatTYPElvc_s_fcat.

ws_fcatfieldname='MATNR'.
ws_fcatscrtext_m=text001.
ws_fcattabname='I_MARA'.
IFp_hotsptEQ'X'.
ws_fcathotspot='X'.
ENDIF.
APPENDws_fcatTOi_fcat1.
CLEARws_fcat.

ws_fcatfieldname='MTART'.
ws_fcatscrtext_m=text002.
ws_fcattabname='I_MARA'.
APPENDws_fcatTOi_fcat1.
CLEARws_fcat.

ws_fcatfieldname='MAKTX'.
ws_fcatscrtext_m=text003.
ws_fcattabname='I_MARA'.
APPENDws_fcatTOi_fcat1.
CLEARws_fcat.

ENDFORM."build_fcat
*&*
*&Formdisp_alv
*&*
FORMdisp_alv.

IFlp_cont1ISINITIAL.
*CreatetheContainerObjectofMaterialMaster.
CREATEOBJECTlp_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.
IFsysubrcNE0.
MESSAGEIDsymsgidTYPEsymsgtyNUMBERsymsgno
WITHsymsgv1symsgv2symsgv3symsgv4.
ELSE.
*CreatetheObjectforGridofMaterialMaster.
CREATEOBJECTlp_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.
IFsysubrcNE0.
MESSAGEIDsymsgidTYPEsymsgtyNUMBERsymsgno
WITHsymsgv1symsgv2symsgv3symsgv4.
ELSE.
*DipslayMaterialMasterdatabycallingmethod.
CALLMETHODlp_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.
IFsysubrcNE0.
MESSAGEIDsymsgidTYPEsymsgtyNUMBERsymsgno
WITHsymsgv1symsgv2symsgv3symsgv4.
ELSE.
*SetHandlerfortheHotSpotEvent.
CREATEOBJECTlp_rcvr.
IFp_hotsptEQ'X'.
SETHANDLERlp_rcvr>hotspot_clickFORlp_grid1.
ELSE.
SETHANDLERlp_rcvr>handle_double_clickFORlp_grid1.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.

ENDFORM."disp_alv
*&*
*&ModuleSTATUS_0100OUTPUT
*&*
MODULEstatus_0100OUTPUT.
SETPFSTATUS'MAIN_STAT'.
SETTITLEBAR'T_100'.
ENDMODULE."STATUS_0100OUTPUT
*&*
*&ModuleSTATUS_0200OUTPUT
*&*
MODULEstatus_0200OUTPUT.
SETPFSTATUS'PLANT_STAT'.
SETTITLEBAR'T_200'.
ENDMODULE."STATUS_0200OUTPUT
*&*
*&ModuleDISP_GRID_plantOUTPUT
*&*
MODULEdisp_grid_plantOUTPUT.
*BuildtheFieldcatelogforMaterialPlantdata.
PERFORMbuild_fcat_plant.
*DisplaytheMaterialMasterPlantdatausingALV.
PERFORMdisp_alv_plant.
ENDMODULE."DISP_GRID_plantOUTPUT
*&*
*&ModuleUSER_COMMAND_0200INPUT
*&*
MODULEuser_command_0200INPUT.

*whenexitorcancelisclickedprogramhastocomeout
CASEsyucomm.
WHEN'EXIT'OR'CANC'.
LEAVEPROGRAM.
WHEN'BACK'.

LEAVETOSCREEN0.
ENDCASE.

ENDMODULE."USER_COMMAND_0200INPUT
*&*
*&Formbuild_fcat_plant
*&*
FORMbuild_fcat_plant.
DATA:ws_fcatTYPElvc_s_fcat.

ws_fcatfieldname='MATNR'.
ws_fcatscrtext_m=text001.
ws_fcattabname='I_MARC'.
APPENDws_fcatTOi_fcat2.
CLEARws_fcat.

ws_fcatfieldname='WERKS'.
ws_fcatscrtext_m=text004.
ws_fcattabname='I_MARC'.
APPENDws_fcatTOi_fcat2.
CLEARws_fcat.

ws_fcatfieldname='MTART'.
ws_fcatscrtext_m=text002.
ws_fcattabname='I_MARC'.
APPENDws_fcatTOi_fcat2.
CLEARws_fcat.

ws_fcatfieldname='MAKTX'.
ws_fcatscrtext_m=text003.
ws_fcattabname='I_MARC'.
APPENDws_fcatTOi_fcat2.
CLEARws_fcat.

ENDFORM."build_fcat_plant
*&*
*&Formdisp_alv_plant
*&*
FORMdisp_alv_plant.
IFlp_cont2ISINITIAL.
*CreatetheContainerObjectofMaterialPlantdata.
CREATEOBJECTlp_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.
IFsysubrcNE0.
MESSAGEIDsymsgidTYPEsymsgtyNUMBERsymsgno
WITHsymsgv1symsgv2symsgv3symsgv4.
ELSE.
*CreatetheObjectforGridofMaterialPlantdata.
CREATEOBJECTlp_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.

IFsysubrcNE0.
MESSAGEIDsymsgidTYPEsymsgtyNUMBERsymsgno
WITHsymsgv1symsgv2symsgv3symsgv4.
ELSE.
*DisplayMaterialPlantdatabycallingmethod.
CALLMETHODlp_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.
IFsysubrcNE0.
MESSAGEIDsymsgidTYPEsymsgtyNUMBERsymsgno
WITHsymsgv1symsgv2symsgv3symsgv4.
ENDIF.
ENDIF.
ENDIF.
ELSE.
*Callmethod'REFRESH_TABLE_DISPLAY'torefreshthegriddata.
CALLMETHODlp_grid2>refresh_table_display.
ENDIF.

ENDFORM."disp_alv_plant
add
ContactUs
Privacy

SAPHelpPortal
TermsofUse

LegalDisclosure

Copyright

call

screen

snap

shot

program

abap

FollowSCN

S-ar putea să vă placă și