*----------------------------------------------------------------------*
* DECLARATIONS *
*----------------------------------------------------------------------*
TABLES: fsh_seasons, kna1, vbak, ztsdo_pr_ven_web.
TYPES: BEGIN OF ty_out,
chkbx TYPE c,
kunnr TYPE ztsdo_pr_ven_web-kunnr,
name1 TYPE kna1-name1,
zreserve_no TYPE ztsdo_pr_ven_web-zreserve_no,
vbeln TYPE ztsdo_res_sch-vbeln,
posnr TYPE ztsdo_res_sch-posnr,
etenr TYPE ztsdo_res_sch-etenr,
text TYPE ztsdo_res_sch-text,
zzseason TYPE ztsdo_res_sch-zzseason,
fsh_season TYPE vbap-fsh_season,
land1 TYPE kna1-land1,
zzsubbrand TYPE vbak-zzsubbrand,
qty TYPE kwmeng,
zvaltot TYPE bp_wgt,
zkschl TYPE ztsdo_res_sch-zkschl,
zprcsc TYPE ztsdo_res_sch-zprcsc,
zschl_02 TYPE kscha,
zprcsc_02 TYPE kbetr,
zvalnet TYPE vbak-netwr,
zwaerk TYPE waerk,
zaugru TYPE ztsdo_res_sch-zaugru,
zdtaord TYPE ztsdo_pr_ven_web-zdtaord,
zstato TYPE ztsdo_pr_ven_web-zstato,
zdescr TYPE ztsdo_statven_pt-zdescr,
zupddat TYPE ztsdo_pr_ven_web-zupddat,
style TYPE lvc_t_styl,
END OF ty_out,
ty_outtab TYPE STANDARD TABLE OF ty_out.
DATA: gt_out TYPE ty_outtab.
CLASS lcl_event_receiver DEFINITION DEFERRED.
DATA: go_custom_c TYPE REF TO cl_gui_custom_container,
go_grid TYPE REF TO cl_gui_alv_grid,
go_event_receiver TYPE REF TO lcl_event_receiver,
gs_stable TYPE lvc_s_stbl,
gt_excl_func TYPE ui_functions,
gv_ts TYPE timestamp,
gv_ora TYPE syst_uzeit.
*----------------------------------------------------------------------*
* CLASS LCL_EVENT_RECEIVER DEFINITION *
*----------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_onf4 FOR EVENT onf4 OF cl_gui_alv_grid
IMPORTING
e_fieldname
e_fieldvalue
es_row_no
er_event_data
et_bad_cells
e_display.
ENDCLASS. "lcl_event_receiver DEFINITION
*----------------------------------------------------------------------*
* CLASS LCL_EVENT_RECEIVER IMPLEMENTATION *
*----------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_onf4.
FIELD-SYMBOLS: TYPE STANDARD TABLE,
TYPE lvc_t_modi.
DATA: lv_retfield TYPE dfies-fieldname,
lt_return TYPE TABLE OF ddshretval.
CASE e_fieldname.
WHEN 'ZAUGRU'.
SELECT augru, bezei
FROM tvaut
INTO TABLE @DATA(lt_tvaut)
WHERE spras = @sy-langu.
lv_retfield = 'AUGRU'.
ASSIGN lt_tvaut TO .
WHEN 'ZKSCHL' OR 'ZSCHL_02'.
SELECT kschl, vtext
FROM t685t
INTO TABLE @DATA(lt_t685t)
WHERE kvewe = 'A'
AND kappl = 'V'
AND spras = @sy-langu.
lv_retfield = 'KSCHL'.
ASSIGN lt_t685t TO .
ENDCASE.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = lv_retfield
value_org = 'S'
TABLES
value_tab =
return_tab = lt_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc = 0 AND lt_return[] IS NOT INITIAL.
ASSIGN er_event_data->m_data->* TO .
APPEND VALUE #( row_id = es_row_no-row_id
fieldname = e_fieldname
value = lt_return[ 1 ]-fieldval ) TO .
ENDIF.
er_event_data->m_event_handled = 'X'.
ENDMETHOD. "handle_onf4
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
*----------------------------------------------------------------------*
* LAYOUT *
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: so_kunnr FOR kna1-kunnr,
so_seasn FOR fsh_seasons-fsh_season,
so_land1 FOR kna1-land1,
so_subbr FOR vbak-zzsubbrand,
so_stato FOR ztsdo_pr_ven_web-zstato DEFAULT '01'.
PARAMETERS: cb_bkg AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK b1.
*----------------------------------------------------------------------*
* INIT *
*----------------------------------------------------------------------*
INITIALIZATION.
gs_stable-row = 'X'.
gs_stable-col = 'X'.
gv_ora = sy-uzeit.
gv_ts = sy-datum && sy-uzeit.
*----------------------------------------------------------------------*
* PROGRAM BODY *
*----------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM get_data.
IF cb_bkg IS INITIAL.
CALL SCREEN 100.
ELSE.
PERFORM sale_approval USING gt_out.
ENDIF.
END-OF-SELECTION.
EXIT.
*----------------------------------------------------------------------*
* *
* ██████╗ ██████╗ ██████╗ *
* ██╔══██╗ ██╔══██╗ ██╔═══██╗ *
* ██████╔╝ ██████╔╝ ██║ ██║ *
* ██╔═══╝ ██╔══██╗ ██║ ██║ *
* ██║ ██████╔╝ ╚██████╔╝ *
* ╚═╝ ╚═════╝ ╚═════╝ *
* *
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* MODULE STATUS_0100 OUTPUT *
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
DATA: ls_layout TYPE lvc_s_layo,
lt_fieldcat TYPE lvc_t_fcat,
lt_f4 TYPE lvc_t_f4.
SET PF-STATUS 'ZPF01'.
SET TITLEBAR 'ZTITLE01'.
IF go_custom_c IS INITIAL.
* Creo il container
CREATE OBJECT go_custom_c
EXPORTING
container_name = 'CONTAINER'.
PERFORM exclude_tb_func.
PERFORM build_fielcat CHANGING lt_fieldcat.
CREATE OBJECT go_grid
EXPORTING
i_parent = go_custom_c.
APPEND VALUE lvc_s_f4( fieldname = 'ZAUGRU'
register = 'X' ) TO lt_f4.
APPEND VALUE lvc_s_f4( fieldname = 'ZKSCHL'
register = 'X' ) TO lt_f4.
APPEND VALUE lvc_s_f4( fieldname = 'ZSCHL_02'
register = 'X' ) TO lt_f4.
CALL METHOD go_grid->register_f4_for_fields
EXPORTING
it_f4 = lt_f4.
ls_layout-stylefname = 'STYLE'.
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
is_layout = ls_layout
it_toolbar_excluding = gt_excl_func
CHANGING
it_fieldcatalog = lt_fieldcat
it_outtab = gt_out.
CREATE OBJECT go_event_receiver.
SET HANDLER go_event_receiver->handle_onf4
FOR go_grid.
ENDIF.
ENDMODULE.
*----------------------------------------------------------------------*
* *
* ██████╗ █████╗ ██╗ *
* ██╔══██╗ ██╔══██╗ ██║ *
* ██████╔╝ ███████║ ██║ *
* ██╔═══╝ ██╔══██║ ██║ *
* ██║ ██║ ██║ ██║ *
* ╚═╝ ╚═╝ ╚═╝ ╚═╝ *
* *
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* MODULE USER_COMMAND_0100 INPUT *
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'UP'.
FREE: go_custom_c,
go_grid,
go_event_receiver.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
FREE: go_custom_c,
go_grid,
go_event_receiver.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.
*----------------------------------------------------------------------*
* *
* ███████╗ ██████╗ ██████╗ ███╗ ███╗ ███████╗ *
* ██╔════╝ ██╔═══██╗ ██╔══██╗ ████╗ ████║ ██╔════╝ *
* █████╗ ██║ ██║ ██████╔╝ ██╔████╔██║ ███████╗ *
* ██╔══╝ ██║ ██║ ██╔══██╗ ██║╚██╔╝██║ ╚════██║ *
* ██║ ╚██████╔╝ ██║ ██║ ██║ ╚═╝ ██║ ███████║ *
* ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝ *
* *
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* FORM GET_DATA *
*----------------------------------------------------------------------*
FORM get_data.
[...]
ENDFORM.
*----------------------------------------------------------------------*
* FORM EXCLUDE_TB_FUNC *
*----------------------------------------------------------------------*
FORM exclude_tb_func.
[...]
ENDFORM.
*----------------------------------------------------------------------*
* FORM BUILD_FIELCAT *
*----------------------------------------------------------------------*
FORM build_fielcat CHANGING pt_fieldcat TYPE lvc_t_fcat.
DATA ls_fieldcat TYPE lvc_s_fcat.
DEFINE fill_fieldcat.
ADD 1 TO ls_fieldcat-col_pos.
ls_fieldcat-fieldname = &1.
ls_fieldcat-reptext = &2.
ls_fieldcat-f4availabl = &3.
ls_fieldcat-outputlen = &4.
APPEND ls_fieldcat TO pt_fieldcat.
END-OF-DEFINITION.
ls_fieldcat-key = space.
ls_fieldcat-tabname = 'GT_OUT'.
ls_fieldcat-edit = ls_fieldcat-no_out = 'X'.
fill_fieldcat 'CHKBX' 'X' '' '2'.
ls_fieldcat-edit = ls_fieldcat-no_out = ''.
fill_fieldcat 'KUNNR' 'Negozio' '' '10'.
fill_fieldcat 'NAME1' 'Descrizione' '' '35'.
fill_fieldcat 'ZRESERVE_NO' 'Numero prenotazione' '' '10'.
fill_fieldcat 'TEXT' 'Descr. prenotazione' '' '40'.
fill_fieldcat 'ZZSEASON' 'Stag.Vendita' '' '4'.
fill_fieldcat 'FSH_SEASON' 'Stag.Giacenza' '' '4'.
fill_fieldcat 'LAND1' 'Paese' '' '2'.
fill_fieldcat 'ZZSUBBRAND' 'Marchio' '' '2'.
fill_fieldcat 'QTY' 'Capi' '' '19'.
fill_fieldcat 'ZVALTOT' 'Valore totale' '' '21'.
fill_fieldcat 'ZKSCHL' 'Cond.Sconto' 'X' '4'.
fill_fieldcat 'ZPRCSC' 'Percent.Sconto' '' '16'.
fill_fieldcat 'ZSCHL_02' '2ª Cond.Sconto' 'X' '4'.
fill_fieldcat 'ZPRCSC_02' '2ª Percent.Sconto' '' '16'.
fill_fieldcat 'ZVALNET' 'Valore netto' '' '21'.
fill_fieldcat 'ZWAERK' 'Divisa' '' '5'.
fill_fieldcat 'ZAUGRU' 'Mot.Ordine' 'X' '3'.
fill_fieldcat 'ZDTAORD' 'Data ordine' '' '10'.
fill_fieldcat 'ZSTATO' 'Stato' '' '2'.
fill_fieldcat 'ZDESCR' 'Descr.stato' '' '30'.
fill_fieldcat 'ZUPDDAT' 'Data evasione' '' '10'.
ENDFORM.
*----------------------------------------------------------------------*
* FORM SALE_APPROVAL *
*----------------------------------------------------------------------*
FORM sale_approval USING pt_out TYPE ty_outtab.
[...]
ENDFORM.
*----------------------------------------------------------------------*