Professional Documents
Culture Documents
EXIT_SAPLV01Z_002
INCLUDE ZXVBZU02
*&---------------------------------------------------------------------*
*& Include ZXVBZU02
*&---------------------------------------------------------------------*
*BREAK osvstarke.
*&---------------------------------------------------------------------*
*& Subroutinenpool ZOSPP_AMP_GENERACION_LOTE
*&---------------------------------------------------------------------*
* INFORMACION GENERAL
*----------------------------------------------------------------------*
* Módulo : PP
* Descripción : Generación de Lote
* Proyecto : Life - Omnia Solution SAC
* Autor : John W. Ascona Briceño
* Fecha : 03-10-22
*----------------------------------------------------------------------*
* Módulo : PP
* Descripción : Generación de Lote
* Proyecto : Corp. Life - Omnia Solution SAC
* Autor : Vïctor A. Starke
* Fecha : 11.01.2023
* Marca : @001
*----------------------------------------------------------------------*
PROGRAM zospp_amp_generacion_lote.
*&---------------------------------------------------------------------*
*& Definición de tipos de datos
*&---------------------------------------------------------------------*
TYPES: BEGIN OF gty_const.
INCLUDE STRUCTURE zostb_constantes.
TYPES: END OF gty_const.
* ampliación activa?
PERFORM validar_ampliacion CHANGING lv_activo.
CLEAR: gs_lote_x,
gr_mtart.
ls_order_objects-header = 'X'.
ls_order_objects-components = 'X'.
DATA(ldt_const_mtart) = gdt_const[].
DELETE ldt_const_mtart WHERE campo NE gc_const2 OR valor1 NE
'MTART'.
CLEAR gr_mtart.
LOOP AT ldt_const_mtart INTO DATA(lwa_mtart).
APPEND VALUE #( sign = 'I' option = 'EQ' low = lwa_mtart-
valor2 ) TO gr_mtart.
ENDLOOP.
IF x_bncom-auart EQ 'ZCP3'.
DATA(ldt_const_mvgr5) = gdt_const[].
DELETE ldt_const_mvgr5 WHERE campo NE 'MVGR5'.
LOOP AT ldt_const_mvgr5 ASSIGNING FIELD-SYMBOL(<fs_mvgr5>).
APPEND VALUE #( sign = 'I' option = 'EQ' low = <fs_mvgr5>
-valor1 ) TO gr_mvgr5.
ENDLOOP.
valor2 = x_bncom-lifnr.
IF sy-subrc EQ 0.
gs_lote_x = <fs_const>-comentario.
ENDIF.
ELSE.
CASE lv_mtart.
WHEN 'ZROH'.
gs_lote_x = 'M'.
WHEN 'ZLEE'.
gs_lote_x = 'E'.
WHEN 'ZVER'.
gs_lote_x = 'P'.
WHEN 'ZSUM'.
gs_lote_x = 'U'.
WHEN 'ZHAW'.
gs_lote_x = 'W'.
ENDCASE.
ENDIF.
ENDIF.
ENDIF.
IF new_charg IS INITIAL.
IF sy-tcode IN gr_tcode AND gr_tcode[] IS NOT INITIAL. "EQ 'COR2' OR
sy-tcode EQ 'COR1' OR sy-tcode EQ 'COHVPI'.
DATA(lv_gstrs) = '(SAPLCOKO)CAUFVD-GSTRS'.
ASSIGN (lv_gstrs) TO FIELD-SYMBOL(<fs_gstrs>).
if <fs_gstrs> is NOT INITIAL and <fs_gstrs> NE '00000000'. "I JBO26
052023 3000021927
gs_lote_mm = <fs_gstrs>+4(2).
gs_lote_yy = <fs_gstrs>+2(2).
ELSE. "I JBO26052023 3000021927
gs_lote_mm = sy-datum+4(2). "I JBO26052023 3000021927
gs_lote_yy = sy-datum+2(2). "I JBO26052023 3000021927
ENDIF. "I JBO26052023 3000021927
ELSE.
gs_lote_mm = sy-datum+4(2).
gs_lote_yy = sy-datum+2(2).
ENDIF.
CONCATENATE gs_lote_x gs_lote_rango+15(5) gs_lote_mm gs_lote_yy INTO
new_charg.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form validar_ampliacion
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& <-- LV_ACTIVO
*&---------------------------------------------------------------------*
FORM validar_ampliacion CHANGING po_activo.
zosge_utilities=>validar_ampliacion(
EXPORTING
i_modulo = 'PP'
i_repid = 'ZOSPP_AMP_GEN_LOTE_AUTO'
CHANGING
c_activo = po_activo ).
ENDFORM.
*&---------------------------------------------------------------------*
*& Form get_constantes
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM get_constantes .
REFRESH: gr_tcode,
gr_vkorg,
gr_vtweg.
gdt_const = zosge_utilities=>get_constants(
i_modul = 'PP'
i_aplic = 'GEN_LOTE'
i_cprog = 'EXIT_SAPLV01Z_002' ).
CLEAR gdt_sede.
DATA(ldt_const_sede) = gdt_const[].
DELETE ldt_const_sede WHERE campo NE 'NATURALEZA'.
CASE <fs_const>-campo.
WHEN 'TCODE'.
gr_tcode = VALUE #( BASE gr_tcode ( sign = <fs_const>-signo optio
n = <fs_const>-opcion low = <fs_const>-valor1 ) ).
WHEN 'VKORG'.
gr_vkorg = VALUE #( BASE gr_vkorg ( sign = <fs_const>-signo optio
n = <fs_const>-opcion low = <fs_const>-valor1 ) ).
WHEN 'VTWEG'.
gr_vtweg = VALUE #( BASE gr_vtweg ( sign = <fs_const>-signo optio
n = <fs_const>-opcion low = <fs_const>-valor1 ) ).
ENDCASE.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form get_ranges
*&---------------------------------------------------------------------*
*& I-@001
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM get_ranges USING i_type TYPE c
i_nrnr TYPE nrnr
i_mtart TYPE mtart
CHANGING o_range TYPE nrlevel.
CASE i_type.
WHEN 'P'.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = i_nrnr
object = 'ZNUM_LOTE'
toyear = sy-datum+0(4)
IMPORTING
number = o_range.
WHEN 'M'.
* Obtener rango por tipo de material
SELECT SINGLE * INTO @DATA(ls_ran_lote)
FROM zostb_ran_lote
WHERE mtart = @i_mtart
AND gjahr = @sy-datum+0(4).
IF sy-subrc NE 0.
ls_ran_lote-correl = 1.
ELSE.
ADD 1 TO ls_ran_lote-correl.
ENDIF.
ENDFORM.