Zpruebas Condiciones1
Zpruebas Condiciones1
Zpruebas Condiciones1
DATA texto(100).
PARAMETERS:
NOM_FIC LIKE RLGRAP-FILENAME OBLIGATORY,
p_vari LIKE disvariant-variant. " ALV Variant
INITIALIZATION.
g_repid = sy-repid.
g_save = 'A'.
PERFORM variant_init.
* Get default variant
gx_variant = g_variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = g_save
CHANGING
cs_variant = gx_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 0.
p_vari = gx_variant-variant.
ENDIF.
* Process on value request
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
PERFORM f4_for_variant.
* PAI
AT SELECTION-SCREEN.
PERFORM pai_of_selection_screen.
start-of-SELECTION.
end-of-selection.
* Generar el catalogo del ALV
PERFORM fill_fieldcat USING mi_fieldcat.
PERFORM fill_layout using mi_layout.
*&---------------------------------------------------------------------*
*& Form funcion_alv
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->R_UCOMM text
* -->RS_SELFIELD text
*----------------------------------------------------------------------*
FORM funcion_alv USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
case r_ucomm.
when 'PRUEBA' or 'DATA_SAVE'. break-point. perform crear_condicion.
when OTHERS. break-point.
endcase.
ENDFORM. "funcion_alv
*&---------------------------------------------------------------------*
*& Form set_pf_status
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->RT_EXTAB text
*----------------------------------------------------------------------*
FORM set_pf_status using rt_extab type slis_t_extab.
set pf-status 'MAIN'.
ENDFORM. "set_pf_status
*&---------------------------------------------------------------------*
*& Form fill_fieldcat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->E01_LT_FIELDCAT text
*----------------------------------------------------------------------*
FORM fill_fieldcat USING e01_lt_fieldcat TYPE slis_t_fieldcat_alv.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.
* EXCEPTIONS
* INCONSISTENT_INTERFACE = 1
* PROGRAM_ERROR = 2
* OTHERS = 3
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "FILL_FIELDCAT
*---------------------------------------------------------------------*
* FORM F4_FOR_VARIANT *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM f4_for_variant.
*
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = g_variant
i_save = g_save
* it_default_fieldcat =
IMPORTING
e_exit = g_exit
es_variant = gx_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 2.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
IF g_exit = space.
p_vari = gx_variant-variant.
ENDIF.
ENDIF.
ENDFORM. "F4_FOR_VARIANT
*&---------------------------------------------------------------------*
*& Form PAI_OF_SELECTION_SCREEN
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM pai_of_selection_screen.
*
IF NOT p_vari IS INITIAL.
MOVE g_variant TO gx_variant.
MOVE p_vari TO gx_variant-variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
i_save = g_save
CHANGING
cs_variant = gx_variant.
g_variant = gx_variant.
ELSE.
PERFORM variant_init.
ENDIF.
ENDFORM. " PAI_OF_SELECTION_SCREEN
*&---------------------------------------------------------------------*
*& Form VARIANT_INIT
*&---------------------------------------------------------------------*
FORM variant_init.
CLEAR g_variant.
g_variant-report = g_repid.
ENDFORM. " VARIANT_INIT
*&---------------------------------------------------------------------*
*& Form FILL_LAYOUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_MI_LAYOUT text
*----------------------------------------------------------------------*
FORM FILL_LAYOUT USING P_MI_LAYOUT TYPE slis_layout_alv.
* p_mi_layout-edit = ' '.
* p_mi_layout-no_input = 'X'.
ENDFORM. " FILL_LAYOUT
*&---------------------------------------------------------------------*
*& Form CREAR_CONDICION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM CREAR_CONDICION.
loop at GT_TARIF.
* clear ls_komg.
* ls_komg-VKORG = '1003'.
* ls_komg-VTWEG = '00'.
* ls_komg-MATNR = '000000000000000631'.
clear ls_komg.
ls_komg-VKORG = GT_TARIF-VKORG.
ls_komg-VTWEG = GT_TARIF-VTWEG.
* ls_komg-MATNR = GT_TARIF-MATNR.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
INPUT = GT_TARIF-MATNR
IMPORTING
OUTPUT = ls_komg-MATNR
EXCEPTIONS
LENGTH_ERROR = 1
OTHERS = 2
.
* clear ls_komv.
* ls_komv-kappl = 'V '. " Application V = Sales
* ls_komv-kschl = 'PR00'. " Condition type
* ls_komv-waers = 'EUR'. " Currency
* ls_komv-kmein = 'CJ'. " Unit of measurement
* ls_komv-kpein = '1'.
* ls_komv-krech = 'M'. " calculation type;
* "M = Quantity - monthy price
* ls_komv-kbetr = '97.22'. " new condition value
* append ls_komv to lt_komv.
refresh lt_komv.
clear ls_komv.
ls_komv-kappl = 'V '. " Application V = Sales
ls_komv-kschl = GT_TARIF-KSCHL.
ls_komv-waers = GT_TARIF-WAERS.
ls_komv-kmein = GT_TARIF-KMEIN.
ls_komv-kpein = GT_TARIF-KPEIN.
ls_komv-krech = 'C'. " calculation type;
"Segun la clase de condicion
ls_komv-kbetr = GT_TARIF-KBETR.
append ls_komv to lt_komv.