Code: Alles auswählen.
TABLES: mard.
DATA: zeile_itab01 TYPE i.
TYPES: BEGIN OF zeile01_typ,
matnr LIKE mara-matnr, "Materialnummer
maktx LIKE makt-maktx, "Materialtext
END OF zeile01_typ.
DATA: w_labst TYPE p LENGTH 13.
DATA: e_labst TYPE p LENGTH 13.
DATA: s_labst TYPE p LENGTH 13.
DATA: c_labst TYPE p LENGTH 13.
DATA: b_labst TYPE p LENGTH 13.
TYPES itab01_typ TYPE STANDARD TABLE OF zeile01_typ.
DATA: ok_code LIKE sy-ucomm.
DATA: go_custom_container TYPE REF TO cl_gui_custom_container,
gcl_alv TYPE REF TO cl_salv_table. "ALV
DATA itab01 TYPE itab01_typ.
DATA wa_itab01 TYPE zeile01_typ.
SELECT-OPTIONS: s_matnr FOR wa_mara-matnr.
PARAMETERS s_spras TYPE makt-spras OBLIGATORY.
"Programm starten
START-OF-SELECTION.
CALL SCREEN '100'.
*--------------------------------------------------------------------*
*Module Status 0100 ausgeben*
*--------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
* set titlebar 'xxx'.
"Daten auslesen
PERFORM bestand.
PERFORM read_data.
IF go_custom_container IS INITIAL.
CREATE OBJECT go_custom_container
EXPORTING
container_name = 'ALV_CONTAINER'.
TRY.
cl_salv_table=>factory( EXPORTING list_display = abap_false
r_container =
go_custom_container
IMPORTING r_salv_table = gcl_alv
CHANGING t_table = itab01[] ).
CATCH cx_salv_msg.
EXIT.
ENDTRY.
DATA: ls_lay_key TYPE salv_s_layout_key,
lt_cols TYPE salv_t_column_ref,
ls_cols TYPE salv_s_column_ref,
lcl_col TYPE REF TO cl_salv_columns_table,
lcl_disp TYPE REF TO cl_salv_display_settings,
lcl_func TYPE REF TO cl_salv_functions,
lcl_sel TYPE REF TO cl_salv_selections,
lcl_lay TYPE REF TO cl_salv_layout.
*SALV aufrufen (Varianten)
DATA: ls_layout TYPE salv_s_layout_info,
ls_key TYPE salv_s_layout_key.
ls_key-handle = 'GRID'.
ls_key-report = sy-repid.
ls_layout = cl_salv_layout_service=>f4_layouts( s_key = ls_key
restrict = if_salv_c_layout=>restrict_none ).
vari = ls_layout-layout.
* Layouteinstellungen Varainten
lcl_lay = gcl_alv->get_layout( ).
ls_key-report = sy-repid.
ls_key-handle = 'GRID'.
lcl_lay->set_key( ls_key ).
lcl_lay->set_save_restriction( cl_salv_layout=>restrict_none ).
lcl_lay->set_default( abap_true ).
* Layouteinstellungen
lcl_lay = gcl_alv->get_layout( ).
ls_lay_key-report = sy-cprog.
*lr_salv->get_functions_base( )->set_all( value =
*if_salv_c_bool_sap=>true ).
** * bzw.
** lcl_lay = gcl_alv->get_functions_base( ).
** lcl_lay->set_all( value = if_salv_c_bool_sap=>true ).
* Spalten holen (für Spalteneigenschaften )
lcl_col = gcl_alv->get_columns( ).
lt_cols = lcl_col->get( ).
* Spaltenoptimierung
lcl_col->set_optimize( value = cl_salv_functions=>true ).
* Eigenschaften der ALV (für gesamte Liste)
lcl_disp = gcl_alv->get_display_settings( ).
lcl_disp->set_striped_pattern( cl_salv_display_settings=>true ).
gcl_alv->display( ).
ENDIF.
ENDMODULE. "status_0100 OUTPUT
*--------------------------------------------------------------------*
*Exit-Code*
*--------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
ENDCASE.
CLEAR ok_code.
ENDMODULE. " USER_COMMAND_0100 INPUT
*--------------------------------------------------------------------*
*Unterprogramm read_data*
*--------------------------------------------------------------------*
FORM read_data.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE itab01
FROM mara
JOIN makt
ON makt~matnr = mara~matnr
AND makt~spras = s_spras
WHERE mara~matnr IN s_matnr.
ENDFORM. "read_data
FORM bestand.
CLEAR: w_labst.
CLEAR: e_labst.
CLEAR: b_labst.
CLEAR: s_labst.
CLEAR: c_labst.
SELECT * FROM MARD CLIENT SPECIFIED
WHERE MATNR in s_matnr
AND WERKS = s_werks
AND LGORT = '1000'.
ENDSELECT.
MOVE mard-labst to e_labst.
SELECT * FROM MARD CLIENT SPECIFIED
WHERE MATNR in s_matnr
AND WERKS = s_werks
AND LGORT = '1010'.
ENDSELECT.
MOVE mard-labst to s_labst.
SELECT * FROM MARD CLIENT SPECIFIED
WHERE MATNR in s_matnr
AND WERKS = s_werks
AND LGORT = '1020'.
ENDSELECT.
MOVE mard-labst to b_labst.
SELECT * FROM MARD CLIENT SPECIFIED
WHERE MATNR in s_matnr
AND WERKS = s_werks
AND LGORT = '1030'.
ENDSELECT.
MOVE mard-labst to c_labst.
w_labst = e_labst + s_labst + b_labst + c_labst.
ENDFORM.
Code: Alles auswählen.
SELECT SUM(labst)
FROM MARD
CLIENT SPECIFIED
WHERE MATNR IN s_matnr
AND WERKS = s_werks
AND LGORT BETWEEN '1000' AND '1030'.