Subrutinas
Subrutinas
Subrutinas
*&---------------------------------------------------------------------*
*& Form GET_DATES
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_dates .
REFRESH: gt_periodos.
CLEAR: gt_periodos.
REFRESH p0000.
IF rb_wrd = 'X'.
DATA: COUNT_PERIOD TYPE i.
PERFORM import_rgdir.
SORT rgdir BY fpper DESCENDING.
IF rp-imp-cd-subrc = 0.
CLEAR: gt_periodos, COUNT_PERIOD.
LOOP AT rgdir WHERE srtza EQ 'A'.
COUNT_PERIOD = 1 + COUNT_PERIOD.
gt_periodos-fpper = rgdir-fpper.
gt_periodos-begda = rgdir-FPBEG.
gt_periodos-endda = rgdir-FPEND.
IF COUNT_PERIOD <= 6.
APPEND gt_periodos.
ELSE.
CLEAR gt_periodos.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
ELSE.
* Si no informan nada, por defecto todo.
IF so_datum-high IS INITIAL.
so_datum-high = sy-datum."gc_endda.
ENDIF.
ENDIF.
gt_periodos-fpper = so_datum-high(6).
gt_periodos-begda = so_datum-high.
gt_periodos-endda = so_datum-high.
gt_periodos-begda+6(2) = '01'.
APPEND gt_periodos.
lv_fin_aux = gt_periodos-begda.
* ENDIF.
IF sy-subrc EQ 0.
gt_periodos-begda = lv_fin_aux.
gt_periodos-fpper = gt_periodos-begda(6).
APPEND gt_periodos.
* CLEAR: gt_periodos.
ELSE.
lv_fin_aux = lv_fin.
ENDIF.
ENDWHILE.
CLEAR: gt_periodos.
SORT gt_periodos BY fpper.
ENDIF.
CLEAR: gt_data_es.
gt_data_es-pernr = PNPPERNR-LOW.
PERFORM get_datos_empresa.
PERFORM get_representante.
PERFORM get_datos_empleado.
PERFORM get_bases_15_anyos.
datos_word = 'X'.
APPEND gt_data_es.
ENDIF.
IF pnp-sw-found EQ 1.
CLEAR: gv_mocat.
gt_data_es-bukrs = p0001-bukrs.
* gt_data_es-codpos = l_nisse_data-s_niss1-codpos.
* gt_data_es-provincia = l_nisse_data-s_niss1-textprovn.
* gt_data_es-domicil = l_nisse_data-s_niss1-domicil.
* gt_data_es-ort01 = l_nisse_data-s_niss1-localidad.
gt_data_es-aeptx = l_juper_data-activ_econom_text.
DATA: WA_T536A TYPE TABLE OF T536A WITH HEADER LINE,
COD_PROV TYPE T005U-BLAND.
SELECT * FROM T536A INTO TABLE WA_T536A WHERE ANART = '/E' AND VARGU =
p0001-juper.
LOOP AT WA_T536A.
CASE WA_T536A-SEQNU.
WHEN '1'.
gt_data_es-butxt = WA_T536A-ANTXT.
WHEN '2'.
gt_data_es-domicil = WA_T536A-ANTXT.
WHEN '3'.
CONCATENATE gt_data_es-domicil '.' WA_T536A-ANTXT INTO gt_data_es-
domicil SEPARATED BY SPACE.
WHEN '4'.
CONCATENATE gt_data_es-domicil WA_T536A-ANTXT INTO gt_data_es-
domicil SEPARATED BY SPACE.
WHEN '9'.
gt_data_es-codpos = WA_T536A-ANTXT.
ENDCASE.
endloop.
SELECT SINGLE LOCALID FROM T5E35 INTO gt_data_es-ort01 WHERE COD_POS =
gt_data_es-codpos.
COD_PROV = gt_data_es-codpos(2).
SELECT SINGLE BEZEI FROM T005U INTO gt_data_es-provincia WHERE SPRAS = sy-
langu
AND LAND1 =
'ES'
AND BLAND =
COD_PROV.
ENDIF.
ENDFORM. " GET_DATOS_EMPRESA
*&---------------------------------------------------------------------*
*& Form GET_DATOS_EMPLEADO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_datos_empleado .
LOCAL p0000.
REFRESH p0000.
IF pnp-sw-found EQ 1.
IF p0000-stat2 EQ gc_activo.
gt_data_es-acti_si = 'X'.
gt_data_es-acti_no = ''.
ELSE.
gt_data_es-acti_no = 'X'.
gt_data_es-acti_si = ''.
IF p0000-massn EQ gc_massn_s5 OR
p0000-massn EQ gc_massn_09.
ENDIF.
ENDIF.
ENDIF.
IF pnp-sw-found EQ 1.
gt_data_es-ename = p0001-ename.
gt_data_es-gbdat = p0002-gbdat.
gt_data_es-gbort = p0002-gbort.
gt_data_es-gbdep = p0002-gbdep.
ENDIF.
* ini mmg
* rp_provide_from_last p0006 '0001' pn-begda pn-endda.
rp_provide_from_last p0006 '1' pn-begda pn-endda.
* fin mmg
IF pnp-sw-found EQ 1.
* gt_data_es-stras = p0006-stras.
gt_data_es-pstlz = p0006-pstlz.
gt_data_es-pobla = p0006-ort01.
PERFORM get_text_provincia USING p0006-land1
p0006-state
CHANGING gt_data_es-provi.
ENDIF.
IF pnp-sw-found EQ 1.
gt_data_es-natss = p0061-natss.
gt_data_es-berkt = p0061-berkt.
gt_data_es-grcot = p0061-grcot.
ENDIF.
IF pnp-sw-found EQ 1.
* NgA 02.04.2012 En el campo CTEXT debe informarse el Grupo Prof. del Inf08
gt_data_es-ctext = p0008-trfgr.
ENDIF.
IF pnp-sw-found EQ 1.
* IF p2001-awart IN r_awart.
IF p2001-awart(1) EQ '1'
OR p2001-awart(1) EQ '2'
OR p2001-awart(1) EQ '3'.
gt_data_es-ilt_si = 'X'.
gt_data_es-ilt_no = ''.
gt_data_es-bajamedica = p2001-begda.
ENDIF.
ENDIF.
PERFORM get_periodos_activos.
CLEAR r_lgart.
r_lgart-sign = 'I'.
r_lgart-option = 'EQ'.
r_lgart-low = '/302'.
APPEND r_lgart.
r_lgart-low = '/342'.
APPEND r_lgart.
r_lgart-low = '/3AC'.
APPEND r_lgart.
r_lgart-low = '/3AH'.
APPEND r_lgart.
r_lgart-low = '/3VG'.
APPEND r_lgart.
r_lgart-low = '/3VH'.
APPEND r_lgart.
r_lgart-low = '/3VM'.
APPEND r_lgart.
r_lgart-low = '/3VA'.
APPEND r_lgart.
* break smeri15.
* ini mmg
IF gv_begda_ini LT gc_date_sap.
PERFORM get_bases_m4 USING gv_begda_ini.
ENDIF.
* fin mmg
LOOP AT gt_periodos.
REFRESH: lt_rt.
CLEAR: lt_rt.
CLEAR: lt_bases.
IF gt_periodos-begda LT gc_date_sap.
* break smeri15.
" Recoger datos de la tabla ZHRPY_CONV_0001
LOOP AT gt_bases_m4 WHERE pernr EQ gt_data_es-pernr
AND anyo EQ gt_periodos-fpper(4)
AND mes EQ gt_periodos-fpper+4(2).
lt_bases-fpper = gt_periodos-fpper.
lt_bases-dias = lt_bases-dias + gt_bases_m4-dias_cot.
lt_bases-base = lt_bases-base + gt_bases_m4-base_cot.
lt_bases-waers = gt_bases_m4-waers.
ENDLOOP.
ELSE.
PERFORM import_rgdir.
IF rp-imp-cd-subrc = 0.
CLEAR: lv_dss_vnd.
PERFORM import_cluster_re.
IF rp-imp-re-subrc = 0.
lt_bases-fpper = gt_periodos-fpper.
lt_bases-waers = versc-waers.
CASE rt-lgart.
WHEN '/302' OR '/342'.
lt_bases-base = lt_bases-base + rt-betrg.
WHEN '/3AC'.
lt_bases-dias = lt_bases-dias + rt-anzhl.
WHEN '/3AH'.
lt_bases-dias = lt_bases-dias - rt-anzhl.
WHEN '/3VM'.
lv_dss_vnd = rt-anzhl.
WHEN '/3VG'.
PERFORM fill_future_vnd TABLES lt_bases USING gt_periodos-
fpper rt.
WHEN '/3VA'.
gt_data_es-base_vac = gt_data_es-base_vac + rt-betrg.
gt_data_es-dias_vac = gt_data_es-dias_vac + rt-
anzhl."lv_dss_vnd = rt-anzhl.
ENDCASE.
ENDLOOP.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
COLLECT lt_bases.
* Chequeamos si ha habido VND del mes anterior, para modificar los días.
IF lv_dss_vnd IS NOT INITIAL.
lt_bases-dias = lv_dss_vnd.
MODIFY lt_bases INDEX sy-tabix TRANSPORTING dias.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
REFRESH: gt_bases_m4.
CLEAR: gt_bases_m4.
* data lv_pernr(8).
*
* lv_pernr = pernr-pernr.
*
* while lv_pernr(1) = 0.
* lv_pernr = lv_pernr+1.
* endwhile.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*--
CLEAR: i_components, i_signature, i_connections, i_uris.
REFRESH: i_components, i_signature, i_connections, i_uris.
*-- Recuperamos la clave del objeto word
IF p_object_key IS INITIAL.
CALL FUNCTION 'BDS_BUSINESSDOCUMENT_GET_INFO'
EXPORTING
classname = p_classname
classtype = p_classtype
client = sy-mandt
* object_key = v_object_key
all = ' '
check_state = ' '
TABLES
components = i_components
signature = i_signature
connections = i_connections
EXCEPTIONS
nothing_found = 1
parameter_error = 2
not_allowed = 3
error_kpro = 4
internal_error = 5
not_authorized = 6
OTHERS = 7.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CLEAR lv_plantilla.
lv_plantilla = p_plantilla.
LOOP AT i_components.
TRANSLATE: i_components-comp_id TO UPPER CASE,
lv_plantilla TO UPPER CASE.
CHECK i_components-comp_id = lv_plantilla.
READ TABLE i_signature WITH KEY doc_count = i_components-doc_count.
READ TABLE i_connections WITH KEY doc_id = i_signature-doc_id.
gv_object_key = i_connections-object_key.
EXIT.
ENDLOOP.
ELSE.
gv_object_key = p_object_key.
ENDIF.
IF sy-subrc <> 0.
RAISE nothing_found.
ENDIF.
gv_doc_id = i_signature-doc_id.
gv_doc_ver_no = i_signature-doc_ver_no.
gv_doc_var_id = i_signature-doc_var_id.
CASE sy-subrc.
WHEN '1'.
RAISE nothing_found.
WHEN '2'.
RAISE parameter_error.
WHEN '3'.
RAISE not_allowed.
WHEN '4'.
RAISE error_kpro.
WHEN '5'.
RAISE internal_error.
WHEN '6'.
RAISE not_authorized.
WHEN '7'.
*-- Se asterisca esta opción debido a que en ocasiones se queda
*-- bloqueada la plantilla
* RAISE foreign_lock.
WHEN '8'.
RAISE others.
ENDCASE.
gv_uri = i_uris-uri.
CONCATENATE: gv_sapworkdir
*&---------------------------------------------------------------------*
*& Include ZESPY_PRO_IN_CONV_0008_F02
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form DISPLAY_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM display_data .
PERFORM find_planti.
PERFORM word_open.
PERFORM datos_contrato USING 'BASE_COTI'.
clear_carta.
PERFORM cabecera_contratos.
PERFORM descarga_carta.
* PERFORM extrar_nombre_word.
PERFORM abrir_word.
PERFORM word_open.
ENDIF.
ELSE.
PERFORM fill_alv.
PERFORM display_alv.
ENDIF.
DATA: lv_per(25),
lv_data_per(25),
lv_dia(25),
lv_data_dia(25),
lv_bas(25),
lv_data_bas(25),
lv_index(3) TYPE n.
FIELD-SYMBOLS: <fs_per>,
<fs_dia>,
<fs_bas>.
lv_index = 1.
DO 288 TIMES.
UNASSIGN <fs_per>.
ASSIGN (lv_data_per) TO <fs_per>.
IF sy-subrc EQ 0.
MOVE lv_per TO <fs_per>.
ENDIF.
UNASSIGN <fs_dia>.
ASSIGN (lv_data_dia) TO <fs_dia>.
IF sy-subrc EQ 0.
MOVE lv_dia TO <fs_dia>.
ENDIF.
UNASSIGN <fs_bas>.
ASSIGN (lv_data_bas) TO <fs_bas>.
IF sy-subrc EQ 0.
MOVE lv_bas TO <fs_bas>.
ENDIF.
lv_index = lv_index + 1.
ENDDO.
DATA: lv_per(25),
lv_data_per(25),
lv_dia(25),
lv_data_dia(25),
lv_bas(25),
lv_data_bas(25),
lv_index(3) TYPE n,
lv_initial(10).
clear_carta.
REFRESH: lt_bases.
CLEAR: lt_bases.
lt_bases[] = gt_data_es-base_coti[].
lv_index = 1.
LOOP AT lt_bases.
UNASSIGN <fs_per>.
ASSIGN (lv_data_per) TO <fs_per>.
IF sy-subrc EQ 0.
CONCATENATE lt_bases-fpper+4(2) '/' lt_bases-fpper(4) INTO <fs_per>.
ENDIF.
UNASSIGN <fs_dia>.
ASSIGN (lv_data_dia) TO <fs_dia>.
IF sy-subrc EQ 0.
WRITE lt_bases-dias TO <fs_dia> DECIMALS 0.
ENDIF.
UNASSIGN <fs_bas>.
ASSIGN (lv_data_bas) TO <fs_bas>.
IF sy-subrc EQ 0.
WRITE lt_bases-base TO <fs_bas>.
ENDIF.
lv_index = lv_index + 1.
ENDLOOP.
* CONDENSE gt_carta.
APPEND gt_carta.
IF sy-subrc EQ 2.