Hello guys
I like to ask you one question i found and get your ideas.
If you look at the codes for creating an ALV
it always recommends you to seperate logic and business layer etc..
this is the new way of creating an ALV
So you have a model view and a controller
I implemented that following useful resources.
So that there s class called view
and the selection screen gets called from there inside the method
like
call SELECTION-SCREEN 100.
IF sy-subrc EQ 0.
ENDIF.
But one issue when you execute the report and press GO BACK standard button it doesnot come back to your selection screen but way to your code.
Is there a get around to that?
here is the code below:
Header 1 |
---|
*&---------------------------------------------------------------------* *& Report ZZ_SOLEN_FIRST *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------*
REPORT ZZ_SOLEN_FIRST.
DATA: gv_vbeln type vbap-Vbeln.
***Screen SELECTION-SCREEN: BEGIN OF SCREEN 100 TITLE t-004. SELECTION-SCREEN: BEGIN OF block aa WITH FRAME TITLE t-001. SELECT-OPTIONS: s_vbeln FOR gv_vbeln. SELECTion-SCREEN: END OF block aa. SELECTion-SCREEN: END OF SCREEN 100.
*****DATA Layer class lcl_data DEFINITION. PUBLIC SECTION. TYPES: BEGIN OF ty_out, vbeln type vbap-vbeln, posnr type vbap-posnr, matnr type vbap-matnr, vkorg type vbak-vkorg, END OF ty_out . TYPES: tt_out TYPE STANDARD TABLE OF ty_out. TYPES: gr_vbeln TYPE RANGE OF vbap-vbeln. DATA: gt_output TYPE tt_out.
methods: constructor, select_data IMPORTING VALUE(rs_vbeln) TYPE gr_vbeln. .
ENDclass.
class lcl_data IMPLEMENTATION. method constructor. clear GT_OUTPUT.
ENDMETHOD.
method select_data. DATA: lt_vbak type SORTED TABLE OF vbak WITH UNIQUE KEY vbeln. FIELD-SYMBOLS: <lfs_output> like LINE OF gt_output, <lfs_vbak> like LINE OF lt_vbak . select vbeln posnr matnr from vbap INto TABLE GT_OUTPUT where vbeln in S_VBELN
.
IF sy-SUBRC EQ 0. select * from vbak INTO TABLE lt_vbak FOR ALL ENTRIES IN GT_OUTPUT where vbeln = GT_OUTPUT-vbeln .
LOOP AT gt_output ASSIGNING <lfs_output>. READ TABLE lt_vbak ASSIGNING <lfs_vbak> with TABLE KEY vbeln = <lfs_output>-vbeln.
IF sy-Subrc eq 0. <lfs_output>-vkorg = <lfs_vbak>-VKORG. ENDIF.
ENDLOOP.
ENDIF.
ENDMETHOD.
ENDCLASS.
****Display class lcl_view DEFINITION. PUBLIC SECTION. methods: start RETURNING VALUE(rv_true) type abap_bool. METHODS: display CHANGING it_data TYPE STANDARD TABLE. ENDCLASS.
class lcl_view IMPLEMENTATION. METHOD start. call SELECTION-SCREEN 100.
IF sy-subrc EQ 0. rv_true = abap_true. ENDIF. endmethod.
method display. DATA: lo_salv_table type REF TO CL_SALV_TABLE, lt_columns TYPE SALV_T_COLUMN_REF.
FIELD-SYMBOLS: <lfs_columns> like LINE OF lt_columns. CL_SALV_TABLE=>FACTORY( * exporting * LIST_DISPLAY = IF_SALV_C_BOOL_SAP=>FALSE " ALV Displayed in List Mode * R_CONTAINER = " Abstract Container for GUI Controls * CONTAINER_NAME = importing R_SALV_TABLE = lo_salv_table " Basis Class Simple ALV Tables changing T_TABLE = it_data ). * catch CX_SALV_MSG. " ALV: General Error Class with Message
*** lt_columns = lo_salv_table->GET_COLUMNS( )->GET( ).
* * LOOP AT lt_columns ASSIGNING <lfs_columns>. * * break developer. * * ENDLOOP.
lo_salv_table->DISPLAY( ). ENDMETHOD.
ENDCLASS.
class lcl_controller DEFINITION. PUBLIC SECTION. methods: main. ENDCLASS.
class lcl_controller IMPLEMENTATION. method main. DATA: lo_view type REF TO lcl_view, lo_data TYPE REF TO LCL_DATA .
CREATE OBJECT: lo_data, lo_view.
break developer.
IF lo_view->START( ) Eq abap_true.
**get the data lo_data->SELECT_DATA( s_vbeln[] ).
lo_view->DISPLAY( changing IT_DATA = lo_data->GT_OUTPUT ). ENDIF.
ENDMETHOD.
ENDCLASS.
INITIALIZATION.
START-OF-SELECTION. break developer. DATA: lo_controller type REF TO lcl_controller.
CREATE OBJECT lo_controller. lo_controller->MAIN( ). |