Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Message no. FES004

0 Kudos

Good morning, how are you ?

I made a program to print the result in PDF, and it didn't give any error.

But when I run it it gives me this error message.

Message no. FES004

Could you help me with this?

2 REPLIES 2

FredericGirod
Active Contributor
0 Kudos

Could you give detail about what you tried to do ? and how

0 Kudos

I made an ALV report, and I put a button for PDF, but when executing the error Message no. FES004

I used the following functions:

'GET_PRINT_PARAMETERS'

'CONVERT_ABAPSPOOLJOB_2_PDF'

'GUI_DOWNLOAD'.

Below is my program code:

*&---------------------------------------------------------------------*
*& Report ZR0020
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZR0020.



*TABELA TRANSPARENTE
TABLES: ZT0005.

*TABELAS INTERNAS
DATA: T_ZT0005 TYPE TABLE OF ZT0005,
T_ZT0001 TYPE TABLE OF ZT0001,
T_SAIDA TYPE TABLE OF ZS0001,
T_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
T_SORT TYPE SLIS_T_SORTINFO_ALV,
T_HEADER TYPE SLIS_T_LISTHEADER.

*WORK AREA
DATA: W_ZT0005 TYPE ZT0005,
W_ZT0001 TYPE ZT0001,
W_SAIDA TYPE ZS0001,
W_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
W_SORT TYPE SLIS_SORTINFO_ALV,
W_LAYOUT TYPE SLIS_LAYOUT_ALV,
W_HEADER TYPE SLIS_LISTHEADER,
W_VARIANT TYPE DISVARIANT.


*TELA DE SELECAO
SELECTION-SCREEN BEGIN OF BLOCK BC01 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_TPMAT FOR ZT0005-TPMAT,
S_MATER FOR ZT0005-MATER.
SELECTION-SCREEN END OF BLOCK BC01.

SELECTION-SCREEN BEGIN OF BLOCK BC02 WITH FRAME TITLE TEXT-002.
PARAMETERS: P_VARIAN TYPE SLIS_VARI.
SELECTION-SCREEN END OF BLOCK BC02.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARIAN.
PERFORM F_VARIANT_F4 CHANGING P_VARIAN.


START-OF-SELECTION.

PERFORM F_SELECIONA_DADOS.
PERFORM F_MONTA_TABELA_SAIDA.
PERFORM F_MONTA_ALV.
PERFORM GET_PDF.

*&---------------------------------------------------------------------*
*& Form F_SELECIONA_DADOS
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM F_SELECIONA_DADOS .

SELECT * FROM ZT0005 INTO TABLE T_ZT0005
WHERE TPMAT IN S_TPMAT
AND MATER IN S_MATER.

IF SY-SUBRC IS INITIAL.

SELECT * FROM ZT0001 INTO TABLE T_ZT0001
FOR ALL ENTRIES IN T_ZT0005
WHERE TPMAT = T_ZT0005-TPMAT.

ELSE.
MESSAGE TEXT-003 TYPE 'I'."NAO FOI ENCONTRADO NENHUM REGISTRO COM ESSES PARAMETROS
STOP.
ENDIF.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form F_MONTA_TABELA_SAIDA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM F_MONTA_TABELA_SAIDA .

LOOP AT T_ZT0005 INTO W_ZT0005.
CLEAR W_SAIDA.

W_SAIDA-MATER = W_ZT0005-MATER.
W_SAIDA-DENOM = W_ZT0005-DENOM.
W_SAIDA-BRGEW = W_ZT0005-BRGEW.
W_SAIDA-NTGEW = W_ZT0005-NTGEW.
W_SAIDA-GEWEI = W_ZT0005-GEWEI.
W_SAIDA-STATUS = W_ZT0005-STATUS.
W_SAIDA-TPMAT = W_ZT0005-TPMAT.

READ TABLE T_ZT0001 INTO W_ZT0001 WITH KEY TPMAT = W_ZT0005-TPMAT.
IF SY-SUBRC IS INITIAL.
W_SAIDA-DENOM_TP = W_ZT0001-DENOM.
ENDIF.

APPEND W_SAIDA TO T_SAIDA.

ENDLOOP.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form F_MONTA_ALV
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM F_MONTA_ALV .

PERFORM F_DEFINE_FIELDCAT.
PERFORM F_ORDENA.
PERFORM F_LAYOUT.
PERFORM F_IMPRIMI_ALV.


ENDFORM.
*&---------------------------------------------------------------------*
*& Form F_DEFINE_FIELDCAT
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM F_DEFINE_FIELDCAT .

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_INTERNAL_TABNAME = 'T_SAIDA'
I_STRUCTURE_NAME = 'ZS0001'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_INCLNAME =
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = T_FIELDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE TEXT-006 TYPE 'I'. "ERRO NA DEFINICAO DA FIELDCAT
STOP.
ELSE.
LOOP AT T_FIELDCAT INTO W_FIELDCAT.

CASE W_FIELDCAT-FIELDNAME.
WHEN 'BRGEW'.
W_FIELDCAT-SELTEXT_S = W_FIELDCAT-SELTEXT_M = W_FIELDCAT-SELTEXT_L = W_FIELDCAT-REPTEXT_DDIC = TEXT-004."PESO BRUTO
WHEN 'NTGEW'.
W_FIELDCAT-SELTEXT_S = W_FIELDCAT-SELTEXT_M = W_FIELDCAT-SELTEXT_L = W_FIELDCAT-REPTEXT_DDIC = TEXT-005."PESO LIQUIDO
WHEN 'MATER'.
W_FIELDCAT-HOTSPOT = 'X'.
WHEN 'DENOM'.
W_FIELDCAT-EDIT = 'X'.

ENDCASE.

MODIFY T_FIELDCAT FROM W_FIELDCAT INDEX SY-TABIX TRANSPORTING SELTEXT_S SELTEXT_M SELTEXT_L REPTEXT_DDIC HOTSPOT EDIT.

ENDLOOP.
* Implement suitable error handling here
ENDIF.


ENDFORM.
*&---------------------------------------------------------------------*
*& Form F_ORDENA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM F_ORDENA .

CLEAR W_SORT.
W_SORT-SPOS = 1.
W_SORT-FIELDNAME = 'MATER'.
W_SORT-TABNAME = 'T_MATER'.
W_SORT-UP = 'X'.
APPEND W_SORT TO T_SORT.


ENDFORM.
*&---------------------------------------------------------------------*
*& Form F_LAYOUT
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM F_LAYOUT .

W_LAYOUT-ZEBRA = 'X'.
W_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form F_IMPRIMI_ALV
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM F_IMPRIMI_ALV .
W_VARIANT-VARIANT = P_VARIAN.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = 'ZR0020'
* I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'F_CABECALHO'
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
IS_LAYOUT = W_LAYOUT
IT_FIELDCAT = T_FIELDCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
IT_SORT = T_SORT
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
I_SAVE = 'X'
IS_VARIANT = W_VARIANT
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = T_SAIDA
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.



ENDFORM.

FORM F_CABECALHO.

CLEAR W_HEADER.
REFRESH T_HEADER.

W_HEADER-TYP = 'H'.
W_HEADER-INFO = TEXT-007."RELATORIO DE MATERIAIS
APPEND W_HEADER TO T_HEADER.

W_HEADER-TYP = 'S'.
W_HEADER-KEY = TEXT-008. "DATA.:
WRITE SY-DATUM TO W_HEADER-INFO.
APPEND W_HEADER TO T_HEADER.

W_HEADER-TYP = 'S'.
W_HEADER-KEY = TEXT-009. "HORA.:
WRITE SY-UZEIT TO W_HEADER-INFO.
APPEND W_HEADER TO T_HEADER.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = T_HEADER
I_LOGO = 'ENJOYSAP_LOGO'
* I_END_OF_LIST_GRID =
* I_ALV_FORM =
.




ENDFORM.
*&---------------------------------------------------------------------*
*& Form F_VARIANT_F4
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
* <--P_P_VARIAN text
*&---------------------------------------------------------------------*
FORM F_VARIANT_F4 CHANGING P_P_VARIAN.

DATA: VL_VARIANT TYPE DISVARIANT.

VL_VARIANT-REPORT = SY-REPID.

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
IS_VARIANT = VL_VARIANT
* I_TABNAME_HEADER =
* I_TABNAME_ITEM =
* IT_DEFAULT_FIELDCAT =
I_SAVE = 'A'
* I_DISPLAY_VIA_GRID = ' '
IMPORTING
* E_EXIT =
ES_VARIANT = VL_VARIANT
EXCEPTIONS
NOT_FOUND = 1
PROGRAM_ERROR = 2
OTHERS = 3
.
IF SY-SUBRC = 0.
P_P_VARIAN = VL_VARIANT-VARIANT.
ENDIF.


ENDFORM.

FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.

DATA: TL_VIMSELLIST TYPE STANDARD TABLE OF VIMSELLIST,
WL_VIMSELLIST TYPE VIMSELLIST.

IF RS_SELFIELD-SEL_TAB_FIELD = 'T_SAIDA-MATER'.

WL_VIMSELLIST-VIEWFIELD = 'MATER'.
WL_VIMSELLIST-OPERATOR = 'EQ'.
WL_VIMSELLIST-VALUE = RS_SELFIELD-VALUE.
APPEND WL_VIMSELLIST TO TL_VIMSELLIST.

CALL FUNCTION 'VIEW_MAINTENANCE_CALL'
EXPORTING
ACTION = 'S'
* CORR_NUMBER = ' '
* GENERATE_MAINT_TOOL_IF_MISSING = ' '
* SHOW_SELECTION_POPUP = ' '
VIEW_NAME = 'ZT0005'
* NO_WARNING_FOR_CLIENTINDEP = ' '
* RFC_DESTINATION_FOR_UPGRADE = ' '
* CLIENT_FOR_UPGRADE = ' '
* VARIANT_FOR_SELECTION = ' '
* COMPLEX_SELCONDS_USED = ' '
* CHECK_DDIC_MAINFLAG = ' '
* SUPPRESS_WA_POPUP = ' '
TABLES
DBA_SELLIST = TL_VIMSELLIST
* EXCL_CUA_FUNCT =
EXCEPTIONS
CLIENT_REFERENCE = 1
FOREIGN_LOCK = 2
INVALID_ACTION = 3
NO_CLIENTINDEPENDENT_AUTH = 4
NO_DATABASE_FUNCTION = 5
NO_EDITOR_FUNCTION = 6
NO_SHOW_AUTH = 7
NO_TVDIR_ENTRY = 8
NO_UPD_AUTH = 9
ONLY_SHOW_ALLOWED = 10
SYSTEM_FAILURE = 11
UNKNOWN_FIELD_IN_DBA_SELLIST = 12
VIEW_NOT_FOUND = 13
MAINTENANCE_PROHIBITED = 14
OTHERS = 15
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.


ENDIF.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form GET_PDF
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM GET_PDF .
DATA: l_params TYPE pri_params,
l_valid TYPE c,
it_pdf TYPE TABLE OF tline,
l_spool type tsp01-rqident.

CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
* ARCHIVE_ID = C_CHAR_UNKNOWN
* ARCHIVE_INFO = C_CHAR_UNKNOWN
* ARCHIVE_MODE = C_CHAR_UNKNOWN
* ARCHIVE_TEXT = C_CHAR_UNKNOWN
* AR_OBJECT = C_CHAR_UNKNOWN
* ARCHIVE_REPORT = C_CHAR_UNKNOWN
* AUTHORITY = C_CHAR_UNKNOWN
* COPIES = C_NUM3_UNKNOWN
* COVER_PAGE = C_CHAR_UNKNOWN
* IN_ARCHIVE_PARAMETERS = ' '
* IN_PARAMETERS = l_params
* LAYOUT = C_CHAR_UNKNOWN
* LINE_COUNT = C_INT_UNKNOWN
* LINE_SIZE = C_INT_UNKNOWN
* LIST_NAME = C_CHAR_UNKNOWN
* LIST_TEXT = C_CHAR_UNKNOWN
* MODE = ' '
* NEW_LIST_ID = C_CHAR_UNKNOWN
* PROTECT_LIST = C_CHAR_UNKNOWN
no_dialog = 'X'
IMPORTING
* OUT_ARCHIVE_PARAMETERS =
out_parameters = l_params
valid = l_valid
* VALID_FOR_SPOOL_CREATION =
.

NEW-PAGE PRINT ON PARAMETERS l_params NO DIALOG.
perform F_IMPRIMI_ALV.
NEW-PAGE PRINT OFF.

l_spool = sy-spono.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = l_spool
no_dialog = 'X'
* DST_DEVICE =
* PDF_DESTINATION =
* NO_BACKGROUND =
* GET_SIZE_FROM_FORMAT =
* USE_CASCADING = ' '
* IMPORTING
* PDF_BYTECOUNT =
* PDF_SPOOLID =
* LIST_PAGECOUNT =
* BTC_JOBNAME =
* BTC_JOBCOUNT =
* BIN_FILE =
TABLES
pdf = it_pdf
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = 'C:\Users\FLEITE\Desktop\TESTE.pdf'
FILETYPE = 'PDF'
* APPEND = ' '
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE
* SHOW_TRANSFER_STATUS = ABAP_TRUE
* VIRUS_SCAN_PROFILE = '/SCET/GUI_DOWNLOAD'
* IMPORTING
* FILELENGTH =
tables
data_tab = it_pdf
* FIELDNAMES =
* EXCEPTIONS
* FILE_WRITE_ERROR = 1
* OTHERS = 22
.
IF sy-subrc <> 0.

ENDIF.
ENDFORM. " GET_PDF