Вы находитесь на странице: 1из 4

*&---------------------------------------------------------------------*

*& Include
ZFIPE_021_IM_V2
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Include
ZFIPE_LETADM_V1_IM_V2
*&---------------------------------------------------------------------*
*---------------------------------------------------------------------*
*
Form REPORTE_MASIVO
*---------------------------------------------------------------------*
FORM reporte_masivo.
PERFORM rescatar_datos7.
PERFORM alv_columnas.
PERFORM alv_fill_layout.
PERFORM alv_lineas_de_titulo USING g_list_top_of_page[].
PERFORM alv_carga_evento
USING t_events[].
PERFORM alv_desplegar.
ENDFORM.
"reporte_masivo
*---------------------------------------------------------------------*
*
Form RESCATAR_DATOS7
*---------------------------------------------------------------------*
FORM rescatar_datos7.
SELECT SINGLE umskz
"CME
INTO w_umskz2
FROM t030b
WHERE ktosl = 'WAN'.
CLEAR : t_detalle, t_bsid, t_bsed.
REFRESH: t_detalle, t_bsid, t_bsed.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE t_detalle
FROM bsid AS s
INNER JOIN bkpf AS k
ON ( s~bukrs = k~bukrs AND s~belnr = k~belnr AND s~gjahr = k~gjahr )
WHERE k~xreversal = space
AND k~bstat = 'S'
AND s~bukrs = p_bukrs
AND s~umskz = w_umskz2
AND s~blart IN s_blar27
AND s~belnr IN s_beln27
AND s~gjahr IN s_gjah27
AND s~kunnr IN s_kunn27
AND s~bldat IN s_blda27
AND s~budat IN s_blda37
AND s~zlsch IN s_zlsc27
AND s~zterm IN s_zter27
AND s~zuonr IN s_zuon27
AND s~xref1 IN s_nplan7
AND s~xref2 IN s_plaba7
AND s~sgtxt IN s_nlot27.
IF NOT t_detalle[] IS INITIAL.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE t_bsed
FROM bsed
FOR ALL ENTRIES IN t_detalle

WHERE
AND
AND
AND
AND
AND

bukrs
gjahr
belnr
wstat
wevwv
regio

= p_bukrs
= t_detalle-gjahr
= t_detalle-belnr
IN s_wstat7
IN s_wevwv7
IN s_regio7.

ENDIF.
LOOP AT t_detalle.
READ TABLE t_bsed WITH KEY gjahr = t_detalle-gjahr belnr = t_detalle-belnr.
IF sy-subrc = 0.
w_kunnr = t_detalle-kunnr.
PERFORM nombres USING w_kunnr w_name1.
t_detalle-name1 = w_name1.
CLEAR w_kunnr.
w_kunnr = t_bsed-wbzog.
PERFORM nombres USING w_kunnr w_name1.
t_detalle-name2 = w_name1.
CLEAR w_kunnr.
w_kunnr = t_bsed-wort2.
PERFORM nombres USING w_kunnr w_name1.
t_detalle-name3 = w_name1.
t_detalle-wstat = t_bsed-wstat.
t_detalle-wevwv = t_bsed-wevwv.
t_detalle-regio = t_bsed-regio.
t_detalle-wbank = t_bsed-wbank.
t_bsed-wlzbp = t_bsed-wlzbp+1(59).
SPLIT t_bsed-wlzbp AT '>' INTO t_detalle-banks t_detalle-bankl t_detalle-b
ankn t_detalle-bkont borr.
IF t_detalle-zfbdt LT sy-datum.
t_detalle-staven = '@AG@'.
ELSEIF t_detalle-zfbdt EQ sy-datum.
t_detalle-staven = '@1V@'.
ELSE.
t_detalle-staven = '@1U@'.
ENDIF.
CONCATENATE t_detalle-zfbdt+6(2) t_detalle-zfbdt+4(2) t_detalle-zfbdt(4) I
NTO t_detalle-feven SEPARATED BY '.'.
t_detalle-vencim = t_detalle-zfbdt.
IF t_detalle-shkzg = 'H'.
t_detalle-dmbtr = t_detalle-dmbtr * -1.
t_detalle-wrbtr = t_detalle-wrbtr * -1.
ENDIF.
PERFORM descripcion_estados.
MODIFY t_detalle.
ELSE.
DELETE t_detalle.
ENDIF.
ENDLOOP.
SORT t_detalle ASCENDING BY belnr.

ENDFORM.
"rescatar_datos7*&--------------------------------------------------------------------*
*& Include
ZFIPE_LET01_IM
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&
Form GENERAR_TXT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM generar_txt .
*{INSERT @009
DATA: lv_planilla TYPE char12.
CLEAR: t_txt.
REFRESH: t_txt.
*}INSERT @009
SELECT kunnr name1 name2 stcdt stcd1
INTO CORRESPONDING FIELDS OF TABLE t_kna1
FROM kna1
FOR ALL ENTRIES IN t_detalle
WHERE kunnr = t_detalle-kunnr.
LOOP AT t_detalle.
READ TABLE t_kna1 WITH KEY kunnr = t_detalle-kunnr.
IF sy-subrc = 0.
t_txt-razo_soc = t_kna1-name1.
*
t_txt-apel_pat = t_kna1-name2.
*
t_txt-apel_mat = t_kna1-name2.
*
SPLIT t_kna1-name2 AT ' ' INTO t_txt-apel_pat t_txt-apel_mat. "DELETE
t_txt-tipo_doc = t_kna1-stcdt+1(1).
*{INSERT @009
IF t_txt-tipo_doc NE '6'. " Validacin RUC
SPLIT t_kna1-name2 AT ' ' INTO t_txt-apel_pat t_txt-apel_mat.
ENDIF.
*}INSERT @009
t_txt-nume_ind = t_kna1-stcd1.

ENDIF.
t_txt-nume_let = t_detalle-zuonr+6(6).
t_txt-fech_ven = t_detalle-zfbdt+2.
CONCATENATE t_detalle-zfbdt+6(2)
t_detalle-zfbdt+4(2)
t_detalle-zfbdt+2(2) INTO t_txt-fech_ven.

*
t_txt-importe = t_detalle-dmbtr. "DELETE @009
*{INSERT @009
MOVE t_detalle-wrbtr TO t_txt-importe. "INSERT @009
CONDENSE t_txt-importe NO-GAPS .
SHIFT t_txt-importe RIGHT DELETING TRAILING space.
*}INSERT @009
APPEND t_txt.

ENDLOOP.
DATA: ls_filename TYPE string,
lv_titulo(30) TYPE c,
lv_cadena(100) TYPE c.
lv_titulo = 'Bcp_'.
*{INSERT @009
lv_planilla = t_detalle-xref1.
CONDENSE lv_planilla NO-GAPS .
CONCATENATE p_ruta1 lv_titulo lv_planilla '_' sy-datum '.txt' INTO ls_filena
me.
*}INSERT @009
*
9

CONCATENATE p_ruta1 lv_titulo sy-datum '.txt' INTO ls_filename. "DELETE @00


CONDENSE ls_filename.

CALL FUNCTION 'GUI_DOWNLOAD'


EXPORTING
*
BIN_FILESIZE
=
filename
= ls_filename
filetype
= 'ASC'
append
= ' '
write_field_separator = ' '
TABLES
data_tab
= t_txt
EXCEPTIONS
file_write_error
= 1
no_batch
= 2
gui_refuse_filetransfer = 3
invalid_type
= 4
no_authority
= 5
unknown_error
= 6
header_not_allowed
= 7
separator_not_allowed = 8
filesize_not_allowed
= 9
header_too_long
= 10
dp_error_create
= 11
dp_error_send
= 12
dp_error_write
= 13
unknown_dp_error
= 14
access_denied
= 15
dp_out_of_memory
= 16
disk_full
= 17
dp_timeout
= 18
file_not_found
= 19
dataprovider_exception = 20
control_flush_error
= 21
OTHERS
= 22.
IF sy-subrc EQ 0.
CONCATENATE 'Log creado correctamente en' ls_filename '.' INTO lv_cadena SEP
ARATED BY space.
MESSAGE lv_cadena TYPE 'S'.
ENDIF.
ENDFORM.

" GENERAR_TXT