Isso aqui é mais pessoal do que para ajudar. O velho problema de validar itens na SM30 e nesse casos inclui um contador de item que alimenta automático.
***INCLUDE LZTMM_0019F01 .
*----------------------------------------------------------------------*
FORM adiciona_item.
"Vinculado ao evento '05'
PERFORM check_dados USING 'I'.
ENDFORM. "adiciona_item
*&---------------------------------------------------------------------*
*& Form VALIDA_INTERVALO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM valida_intervalo.
"Adicionado dentro do módulo de tela
PERFORM check_dados USING 'U'.
ENDFORM. "VALIDA_INTERVALO
*&---------------------------------------------------------------------*
*& Module VALIDA_INTERVALO INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE valida_intervalo INPUT.
PERFORM valida_intervalo.
ENDMODULE. " VALIDA_INTERVALO INPUT
*&---------------------------------------------------------------------*
*& Form CHECK_DADOS
*&---------------------------------------------------------------------*
FORM check_dados USING f_tipo TYPE char1.
FIELD-SYMBOLS: <lfs_valor> TYPE any,
<lfs_posnr> TYPE any.
DATA: l_werks TYPE werks_d,
l_matnr TYPE matnr,
l_kunnr TYPE kunnr,
l_carac TYPE zze_carac_cl,
l_count TYPE i,
l_intde TYPE ztmm_0019-intde,
l_intat TYPE ztmm_0019-intat,
l_begda TYPE ztmm_0019-begda,
l_endda TYPE ztmm_0019-endda,
l_intde_x TYPE ztmm_0019-intde,
l_intat_x TYPE ztmm_0019-intat,
l_begda_x TYPE ztmm_0019-begda,
l_endda_x TYPE ztmm_0019-endda.
* BREAK-POINT.
ASSIGN COMPONENT 'WERKS' OF STRUCTURE <table1> TO <lfs_valor>.
IF sy-subrc = 0.
l_werks = <lfs_valor>.
ENDIF.
ASSIGN COMPONENT 'MATNR' OF STRUCTURE <table1> TO <lfs_valor>.
IF sy-subrc = 0.
l_matnr = <lfs_valor>.
ENDIF.
ASSIGN COMPONENT 'KUNNR' OF STRUCTURE <table1> TO <lfs_valor>.
IF sy-subrc = 0.
l_kunnr = <lfs_valor>.
ENDIF.
ASSIGN COMPONENT 'CARAC' OF STRUCTURE <table1> TO <lfs_valor>.
IF sy-subrc = 0.
l_carac = <lfs_valor>.
ENDIF.
ASSIGN COMPONENT 'INTDE' OF STRUCTURE <table1> TO <lfs_valor>.
IF sy-subrc = 0.
l_intde = <lfs_valor>.
ENDIF.
ASSIGN COMPONENT 'INTAT' OF STRUCTURE <table1> TO <lfs_valor>.
IF sy-subrc = 0.
l_intat = <lfs_valor>.
ENDIF.
ASSIGN COMPONENT 'BEGDA' OF STRUCTURE <table1> TO <lfs_valor>.
IF sy-subrc = 0.
l_begda = <lfs_valor>.
ENDIF.
ASSIGN COMPONENT 'ENDDA' OF STRUCTURE <table1> TO <lfs_valor>.
IF sy-subrc = 0.
l_endda = <lfs_valor>.
ENDIF.
IF l_begda IS NOT INITIAL AND
l_endda IS NOT INITIAL AND
l_begda > l_endda.
MESSAGE e000(zmm001)
WITH 'Data de validade inicial não pode ser maior que final'.
ENDIF.
IF l_intde > l_intat.
MESSAGE e000(zmm001)
WITH 'Intervalo (De) não pode ser maior que (Até).'.
ENDIF.
ASSIGN COMPONENT 'POSNR' OF STRUCTURE <table1> TO <lfs_posnr>.
IF total[] IS NOT INITIAL.
* BREAK-POINT.
LOOP AT total.
CHECK <action> <> 'D'.
ASSIGN COMPONENT 'WERKS' OF STRUCTURE <vim_total_struc>
TO <lfs_valor>.
IF sy-subrc = 0.
CHECK <lfs_valor> = l_werks.
ENDIF.
ASSIGN COMPONENT 'MATNR' OF STRUCTURE <vim_total_struc>
TO <lfs_valor>.
IF sy-subrc = 0.
CHECK <lfs_valor> = l_matnr.
ENDIF.
ASSIGN COMPONENT 'KUNNR' OF STRUCTURE <vim_total_struc>
TO <lfs_valor>.
IF sy-subrc = 0.
CHECK <lfs_valor> = l_kunnr.
ENDIF.
ASSIGN COMPONENT 'CARAC' OF STRUCTURE <vim_total_struc>
TO <lfs_valor>.
IF sy-subrc = 0.
CHECK <lfs_valor> = l_carac.
ENDIF.
ASSIGN COMPONENT 'INTDE' OF STRUCTURE <vim_total_struc>
TO <lfs_valor>.
IF sy-subrc = 0.
l_intde_x = <lfs_valor>.
ENDIF.
ASSIGN COMPONENT 'INTAT' OF STRUCTURE <vim_total_struc>
TO <lfs_valor>.
IF sy-subrc = 0.
l_intat_x = <lfs_valor>.
ENDIF.
ASSIGN COMPONENT 'BEGDA' OF STRUCTURE <vim_total_struc>
TO <lfs_valor>.
IF sy-subrc = 0.
l_begda_x = <lfs_valor>.
ENDIF.
ASSIGN COMPONENT 'ENDDA' OF STRUCTURE <vim_total_struc>
TO <lfs_valor>.
IF sy-subrc = 0.
l_endda_x = <lfs_valor>.
ENDIF.
IF f_tipo = 'U'.
ASSIGN COMPONENT 'POSNR' OF STRUCTURE <vim_total_struc>
TO <lfs_valor>.
IF sy-subrc = 0.
CHECK <lfs_valor> <> <lfs_posnr>.
ENDIF.
ENDIF.
IF ( ( l_intde >= l_intde_x AND l_intde <= l_intat_x ) OR
( l_intat >= l_intde_x AND l_intat <= l_intat_x ) ) AND
l_begda = l_begda_x AND l_endda = l_endda_x.
MESSAGE e000(zmm001) WITH 'Intervalo Incorreto'.
ENDIF.
ADD 1 TO l_count.
ENDLOOP.
ENDIF.
IF f_tipo = 'I'.
IF <lfs_posnr> IS ASSIGNED.
<lfs_posnr> = l_count + 1.
ENDIF.
ENDIF.
ENDFORM. " CHECK_DADOS
Nenhum comentário:
Postar um comentário