The combination of ABAP Oo and ALV Exploration (1)

Source: Internet
Author: User

Use OO to develop, especially in the development of complex business

From a programming standpoint, it should be a little simpler.

And ALV is a very high-level control in the two-time development.

Recently made some attempts to explore the use of OO code and the combination of ALV

Using the ALV of the control type

ALV is written directly in the Bo object.

Essentially, just using OO syntax to rewrite the form's invocation

The use of OO and ALV was preliminarily realized.

TYPES:  BEGIN  ofTs_bo, DatumTYPEsy-Datum, UzeitTYPEsy-Uzeit, ValueTYPE string,  END  ofTs_bo, Tt_boTYPETs_booccurs 0.CLASSLcl_boDEFINITION.  Public  Section. METHODS: Mock,"Simulating business operationsAlv_config,"ALV Display parametersAlv_display."ALV  PRIVATE  Section. DATA: Gt_boTYPETt_bo, Gt_fieldcatTYPELvc_t_fcat,"Show Field ListGs_layoutTYPELvc_s_layo,"Page LayoutG_containerTYPE REF  toCl_gui_custom_container,"ContainerG_gridTYPE REF  toCl_gui_alv_grid."Show GridEndclass.CLASSLcl_boImplementation. METHODMock. DATA: Ls_boTYPETs_bo.  Do Ten  Times. Ls_bo-datum = sy-datum + sy-index. Ls_bo-uzeit = sy-Uzeit. Ls_bo-value ='Times :'&& sy-index. APPENDLs_bo toGt_bo.    CLEAR Ls_bo. Enddo. EndMethod. METHODAlv_config. DATA: Ls_fieldcatTYPELvc_s_fcat. Ls_fieldcat-fieldname ='DATUM'. Ls_fieldcat-coltext ='Date'.APPENDLs_fieldcat toGt_fieldcat.    CLEAR Ls_fieldcat. Ls_fieldcat-fieldname ='Uzeit'. Ls_fieldcat-coltext ='Time'.APPENDLs_fieldcat toGt_fieldcat.    CLEAR Ls_fieldcat. Ls_fieldcat-fieldname ='VALUE'. Ls_fieldcat-coltext ='content'.APPENDLs_fieldcat toGt_fieldcat.    CLEAR Ls_fieldcat. Gs_layout-sel_mode ='A'. Gs_layout-zebra ='X' . Gs_layout-cwidth_opt ='X'. EndMethod. METHODAlv_display. IFG_grid is INITIAL. CREATE OBJECTG_containerExportingContainer_name='C0100'. CREATE OBJECTG_gridExportingi_parent=G_container. Pager METHODG_grid->Set_table_for_first_displayExporting*i_buffer_active =*I_consistency_check =*I_structure_name =*is_variant = gs_variantI_save ='A'I_default='X'*is_layout = Gs_layout*Is_print =*it_special_groups =*it_toolbar_excluding = Gt_exclude*It_hyperlink =        changingIt_outtab=Gt_bo It_fieldcatalog=Gt_fieldcat*It_sort = Gt_sort*It_filter =        EXCEPTIONSinvalid_parameter_combination=1Program_error=2Too_many_lines=3OTHERS=4. ELSE. Pager METHODG_grid->Refresh_table_display. ENDIF. EndMethod."DisplayEndclass.DATA: Ok_codeTYPEsy-Ucomm, Go_boTYPE REF  toLcl_bo.start-of-selection. CREATE OBJECTGo_bo. Go_bo-Mock (). Go_bo-Alv_config (). Pager  Screen  -.MODULEstatus_0100OUTPUT. SET Pf-status 'PS100'. Go_bo-Alv_display ().Endmodule."status_0100 OUTPUTMODULEuser_command_0100 INPUT.  CaseOk_code. when' Back'. SET  Screen 0. Endcase.Endmodule."user_command_0100 INPUT

The effect is as follows:

It can also be seen from the code.

Method simply replaces the role of form

Does not reflect the nature of OO

If there are multiple ALV multiple complex objects in a program

The only benefit is that the data for each object is independent.

A little better than a brain's global data.

A Bo object should focus on the logic of fetching numbers

Also focus on the display function

From the perspective of the class in design mode

Inability to meet the requirements of a single duty

Obviously the way this code is organized can also improve

Not to be continued ...

Separation of the next data and display

The combination of ABAP Oo and ALV Exploration (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.