Tomar la liquidación obtenida desde el resultado de nómina y pasarlo a PDF.
FORM liquida_pdf TABLES sali USING pernr fec1 fec2 CHANGING msg.
DATA : date TYPE DATUM,
date3 TYPE DATUM,
t_abkrs LIKE pa0001-abkrs,
t_t569v LIKE t569v.
FIELD-SYMBOLS <p>.
DATA spoolpds TYPE pri_params-prdsn.
DATA spoolids TYPE TABLE OF rsporq WITH HEADER LINE.
DATA spoolnam TYPE rspotype-rq0name.
DATA spooldsn TYPE rspotype-rq2name.
DATA spoolid TYPE tsp01-rqident.
DATA listname TYPE pri_params-plist.
DATA pdfsize TYPE i.
DATA pdftable TYPE TABLE OF tline WITH HEADER LINE.
DATA pdfxstr TYPE xstring.
DATA pdfstr TYPE string.
DATA pdflsize TYPE i.
DATA pdfcsize TYPE i.
DATA l_dstix TYPE i.
DATA l_dstln TYPE i.
DATA l_catln TYPE i.
DATA l_bas64_table TYPE TABLE OF zsalida WITH HEADER LINE.
spoolpds = 'AUTSER'.
CONCATENATE spoolpds sy-uzeit INTO listname.
spooldsn = listname.
spoolnam = spoolpds.
DATE+0(4) = FEC2.
DATE+4(2) = FEC1.
DATE+6(2) = '01'.
IF date < '20060101'.
msg = text-005.
EXIT.
ENDIF.
SELECT SINGLE abkrs FROM pa0001 INTO t_abkrs WHERE pernr EQ pernr.
SELECT SINGLE * INTO t_t569v FROM t569v WHERE abkrs EQ t_abkrs
AND vwsaz EQ '01'.
IF sy-subrc EQ 0.
DATE3+0(4) = t_t569v-pabrj.
DATE3+4(2) = t_t569v-pabrp.
DATE3+6(2) = '01'.
date3 = date3 - 1.
IF t_t569v-state NE '0' OR date > date3.
msg = text-006.
EXIT.
ENDIF.
ELSE.
msg = text-007.
EXIT.
ENDIF.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
archive_mode = '1'
destination = 'LP00'
immediately = ' '
new_list_id = 'X'
line_size = '118'
line_count = '90'
layout = 'X_90_120'
data_set = spoolpds
expiration = '1'
list_name = listname
no_dialog = 'X'
IMPORTING
out_parameters = pripar
valid = valid.
IF date+0(6) EQ sy-datum+0(6).
* SUBMIT ZRPCEDT39 TO SAP-SPOOL WITHOUT SPOOL DYNPRO
* SPOOL PARAMETERS pripar
** ARCHIVE PARAMETERS arcpar
SUBMIT zrpcedt39 ""EXPORTING LIST TO MEMORY
TO SAP-SPOOL WITHOUT SPOOL DYNPRO
SPOOL PARAMETERS pripar
WITH pnpxabkr eq 'RG'
WITH pnptimr9 eq 'X'
* with PNPTIMRA eq 'X'
* with PNPPABRP eq fec1
* with PNPPABRJ eq fec2
WITH pnppernr eq pernr
WITH formular eq 'HIST'
WITH andruck eq 'A'
WITH rueckd eq 'X'
WITH rueckr eq 'J'
WITH sort_rr eq '1'
WITH sprache eq 'B'
WITH cur_fp eq 'X'
WITH prt_prot eq ' '
AND RETURN.
msg = text-010.
ELSE.
* SUBMIT ZRPCEDT39 TO SAP-SPOOL WITHOUT SPOOL DYNPRO
* SPOOL PARAMETERS pripar
** ARCHIVE PARAMETERS arcpar
SUBMIT zrpcedt39 ""EXPORTING LIST TO MEMORY
TO SAP-SPOOL WITHOUT SPOOL DYNPRO
SPOOL PARAMETERS pripar
WITH pnpxabkr eq 'RG'
* with PNPTIMR9 eq 'X'
WITH pnptimra eq 'X'
WITH pnppabrp eq fec1
WITH pnppabrj eq fec2
WITH pnppernr eq pernr
WITH formular eq 'HIST'
WITH andruck eq 'A'
WITH rueckd eq 'X'
WITH rueckr eq 'J'
WITH sort_rr eq '1'
WITH sprache eq 'B'
WITH cur_fp eq 'X'
WITH prt_prot eq ' '
AND RETURN.
msg = text-010.
ENDIF.
CALL FUNCTION 'RSPO_FIND_SPOOL_REQUESTS'
EXPORTING
rq0name = spoolnam
rq2name = spooldsn
TABLES
spoolrequests = spoolids
EXCEPTIONS
OTHERS = 0.
LOOP AT spoolids.
spoolid = spoolids-rqident.
CALL FUNCTION 'ZHR_RFC_SPOOL2PDF'
EXPORTING
iv_spoid = spoolid
IMPORTING
ev_pdfsz = pdfsize
TABLES
et_pdftx = pdftable.
CHECK NOT pdftable[] IS INITIAL.
pdfcsize = pdfsize.
LOOP AT pdftable.
IF pdfcsize > 134.
pdflsize = 134.
ELSE.
pdflsize = pdfcsize.
ENDIF.
ASSIGN pdftable TO <p> TYPE 'X'.
CONCATENATE pdfxstr <p>(pdflsize)
INTO pdfxstr IN BYTE MODE.
pdfcsize = pdfcsize - 134.
ENDLOOP.
CLEAR pdfstr.
CALL FUNCTION 'SSFC_BASE64_ENCODE'
EXPORTING
bindata = pdfxstr
binleng = pdfsize
IMPORTING
b64data = pdfstr.
l_dstix = 0.
l_dstln = STRLEN( pdfstr ).
WHILE l_dstix < l_dstln.
l_catln = l_dstln - l_dstix.
IF l_catln > c_maxlinsize.
l_catln = c_maxlinsize.
ENDIF.
APPEND pdfstr+l_dstix(l_catln) TO l_bas64_table.
l_dstix = l_dstix + l_catln.
ENDWHILE.
sali[] = l_bas64_table[].
ENDLOOP.
ENDFORM. " Liquida_pdf
DATA : date TYPE DATUM,
date3 TYPE DATUM,
t_abkrs LIKE pa0001-abkrs,
t_t569v LIKE t569v.
FIELD-SYMBOLS <p>.
DATA spoolpds TYPE pri_params-prdsn.
DATA spoolids TYPE TABLE OF rsporq WITH HEADER LINE.
DATA spoolnam TYPE rspotype-rq0name.
DATA spooldsn TYPE rspotype-rq2name.
DATA spoolid TYPE tsp01-rqident.
DATA listname TYPE pri_params-plist.
DATA pdfsize TYPE i.
DATA pdftable TYPE TABLE OF tline WITH HEADER LINE.
DATA pdfxstr TYPE xstring.
DATA pdfstr TYPE string.
DATA pdflsize TYPE i.
DATA pdfcsize TYPE i.
DATA l_dstix TYPE i.
DATA l_dstln TYPE i.
DATA l_catln TYPE i.
DATA l_bas64_table TYPE TABLE OF zsalida WITH HEADER LINE.
spoolpds = 'AUTSER'.
CONCATENATE spoolpds sy-uzeit INTO listname.
spooldsn = listname.
spoolnam = spoolpds.
DATE+0(4) = FEC2.
DATE+4(2) = FEC1.
DATE+6(2) = '01'.
IF date < '20060101'.
msg = text-005.
EXIT.
ENDIF.
SELECT SINGLE abkrs FROM pa0001 INTO t_abkrs WHERE pernr EQ pernr.
SELECT SINGLE * INTO t_t569v FROM t569v WHERE abkrs EQ t_abkrs
AND vwsaz EQ '01'.
IF sy-subrc EQ 0.
DATE3+0(4) = t_t569v-pabrj.
DATE3+4(2) = t_t569v-pabrp.
DATE3+6(2) = '01'.
date3 = date3 - 1.
IF t_t569v-state NE '0' OR date > date3.
msg = text-006.
EXIT.
ENDIF.
ELSE.
msg = text-007.
EXIT.
ENDIF.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
archive_mode = '1'
destination = 'LP00'
immediately = ' '
new_list_id = 'X'
line_size = '118'
line_count = '90'
layout = 'X_90_120'
data_set = spoolpds
expiration = '1'
list_name = listname
no_dialog = 'X'
IMPORTING
out_parameters = pripar
valid = valid.
IF date+0(6) EQ sy-datum+0(6).
* SUBMIT ZRPCEDT39 TO SAP-SPOOL WITHOUT SPOOL DYNPRO
* SPOOL PARAMETERS pripar
** ARCHIVE PARAMETERS arcpar
SUBMIT zrpcedt39 ""EXPORTING LIST TO MEMORY
TO SAP-SPOOL WITHOUT SPOOL DYNPRO
SPOOL PARAMETERS pripar
WITH pnpxabkr eq 'RG'
WITH pnptimr9 eq 'X'
* with PNPTIMRA eq 'X'
* with PNPPABRP eq fec1
* with PNPPABRJ eq fec2
WITH pnppernr eq pernr
WITH formular eq 'HIST'
WITH andruck eq 'A'
WITH rueckd eq 'X'
WITH rueckr eq 'J'
WITH sort_rr eq '1'
WITH sprache eq 'B'
WITH cur_fp eq 'X'
WITH prt_prot eq ' '
AND RETURN.
msg = text-010.
ELSE.
* SUBMIT ZRPCEDT39 TO SAP-SPOOL WITHOUT SPOOL DYNPRO
* SPOOL PARAMETERS pripar
** ARCHIVE PARAMETERS arcpar
SUBMIT zrpcedt39 ""EXPORTING LIST TO MEMORY
TO SAP-SPOOL WITHOUT SPOOL DYNPRO
SPOOL PARAMETERS pripar
WITH pnpxabkr eq 'RG'
* with PNPTIMR9 eq 'X'
WITH pnptimra eq 'X'
WITH pnppabrp eq fec1
WITH pnppabrj eq fec2
WITH pnppernr eq pernr
WITH formular eq 'HIST'
WITH andruck eq 'A'
WITH rueckd eq 'X'
WITH rueckr eq 'J'
WITH sort_rr eq '1'
WITH sprache eq 'B'
WITH cur_fp eq 'X'
WITH prt_prot eq ' '
AND RETURN.
msg = text-010.
ENDIF.
CALL FUNCTION 'RSPO_FIND_SPOOL_REQUESTS'
EXPORTING
rq0name = spoolnam
rq2name = spooldsn
TABLES
spoolrequests = spoolids
EXCEPTIONS
OTHERS = 0.
LOOP AT spoolids.
spoolid = spoolids-rqident.
CALL FUNCTION 'ZHR_RFC_SPOOL2PDF'
EXPORTING
iv_spoid = spoolid
IMPORTING
ev_pdfsz = pdfsize
TABLES
et_pdftx = pdftable.
CHECK NOT pdftable[] IS INITIAL.
pdfcsize = pdfsize.
LOOP AT pdftable.
IF pdfcsize > 134.
pdflsize = 134.
ELSE.
pdflsize = pdfcsize.
ENDIF.
ASSIGN pdftable TO <p> TYPE 'X'.
CONCATENATE pdfxstr <p>(pdflsize)
INTO pdfxstr IN BYTE MODE.
pdfcsize = pdfcsize - 134.
ENDLOOP.
CLEAR pdfstr.
CALL FUNCTION 'SSFC_BASE64_ENCODE'
EXPORTING
bindata = pdfxstr
binleng = pdfsize
IMPORTING
b64data = pdfstr.
l_dstix = 0.
l_dstln = STRLEN( pdfstr ).
WHILE l_dstix < l_dstln.
l_catln = l_dstln - l_dstix.
IF l_catln > c_maxlinsize.
l_catln = c_maxlinsize.
ENDIF.
APPEND pdfstr+l_dstix(l_catln) TO l_bas64_table.
l_dstix = l_dstix + l_catln.
ENDWHILE.
sali[] = l_bas64_table[].
ENDLOOP.
ENDFORM. " Liquida_pdf
No hay comentarios:
Publicar un comentario