Application Development and Automation 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: 
Read only

GETTING DUMP

Former Member
0 Likes
611

I AM GEETING DUMP WHICH SAYS

FIELD SYMBOL NOT ASSINED.PLASE CHECK MY CODE.

I WANT TO SEND THE INTERNAL DATA INTO EXCEL FILE.

*---tables

TABLES:VBAK,VBAP.

*-----types statement for vbak

TYPES:BEGIN OF TY_VBAK,

VBELN TYPE VBELN,

ERDAT TYPE ERDAT,

ERZET TYPE ERZET,

ERNAM TYPE ERNAM,

END OF TY_VBAK.

*-----types statement for vbap

TYPES:BEGIN OF TY_VBAP,

VBELN TYPE VBELN,

POSNR TYPE POSNR,

MATNR TYPE MATNR,

MATWA TYPE MATWA,

PMATN TYPE PMATN,

END OF TY_VBAP.

*------types statemet for final

TYPES:BEGIN OF TY_FINAL,

VBELN TYPE VBELN,

ERDAT TYPE ERDAT,

ERZET TYPE ERZET,

ERNAM TYPE ERNAM,

VBELN1 TYPE VBELN,

POSNR TYPE POSNR,

MATNR TYPE MATNR,

MATWA TYPE MATWA,

PMATN TYPE PMATN,

END OF TY_FINAL.

*----internal table declarations

*----internal table to hold vbak data

DATA:IT_VBAK TYPE STANDARD TABLE OF TY_VBAK WITH HEADER LINE.

*----internal table to hold vbap data

DATA:IT_VBAP TYPE STANDARD TABLE OF TY_VBAP WITH HEADER LINE.

*----internal table to hold final data

DATA:IT_FINAL TYPE STANDARD TABLE OF TY_FINAL WITH HEADER LINE.

*----internal table to hold the fieldname

DATA:IT_FIELDNAME(200) OCCURS 0 WITH HEADER LINE.

*----selection-screen declarations

SELECTION-SCREEN BEGIN OF BLOCK A WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS:S_VBELN FOR VBAK-VBELN.

SELECTION-SCREEN END OF BLOCK A.

*-----at selection-screen declaration

AT SELECTION-SCREEN.

IF S_VBELN IS INITIAL.

MESSAGE E000.

SET CURSOR FIELD S_VBELN.

ENDIF.

*------start-of-selection declarations

START-OF-SELECTION.

*--clear

CLEAR:IT_VBAK,IT_VBAK[].

*---check the selection-screen

IF NOT S_VBELN[] IS INITIAL.

*------get the data form vbak

PERFORM GET_DATA_VBAK.

ENDIF.

*----check the it_vbak data

IF NOT IT_VBAK[] IS INITIAL.

*----get the data from vbap

PERFORM GET_DATA_VBAP.

ENDIF.

*-----collec the data into final

PERFORM GET_DATA_FINAL.

*----send the final data into exelfile

*----along with field name.

PERFORM SEND_DATA_XL.

&----


*& Form get_data_vbak

&----


  • text

FORM GET_DATA_VBAK .

SELECT VBELN

ERDAT

ERZET

ERNAM

FROM VBAK

INTO TABLE IT_VBAK

WHERE VBELN IN S_VBELN.

*---sy-subrc

IF SY-SUBRC = 0.

*--sort the data

SORT IT_VBAK BY VBELN.

ENDIF.

ENDFORM. " get_data_vbak

&----


*& Form get_data_vbap

&----


  • text

FORM GET_DATA_VBAP .

*----clear

CLEAR:IT_VBAP,IT_VBAP[].

SELECT VBELN

POSNR

MATNR

MATWA

FROM VBAP

INTO TABLE IT_VBAP

FOR ALL ENTRIES IN IT_VBAK

WHERE VBELN = IT_VBAK-VBELN.

IF SY-SUBRC = 0.

SORT IT_VBAP BY VBELN.

ENDIF.

ENDFORM. " get_data_vbap

&----


*& Form get_data_final

&----


  • text

FORM GET_DATA_FINAL .

*---clear

CLEAR:IT_FINAL,IT_FINAL[].

LOOP AT IT_VBAP.

IT_FINAL-VBELN1 = IT_VBAP-VBELN.

IT_FINAL-POSNR = IT_VBAP-POSNR.

IT_FINAL-MATNR = IT_VBAP-MATNR.

IT_FINAL-MATWA = IT_VBAP-MATWA.

IT_FINAL-PMATN = IT_VBAP-PMATN.

READ TABLE IT_VBAK WITH KEY VBELN = IT_VBAP-VBELN.

*--sy-subrc

IF SY-SUBRC = 0.

IT_FINAL-VBELN = IT_VBAK-VBELN.

IT_FINAL-ERDAT = IT_VBAK-ERDAT.

IT_FINAL-ERZET = IT_VBAK-ERZET.

IT_FINAL-ERNAM = IT_VBAK-ERNAM.

ENDIF.

APPEND IT_FINAL.

CLEAR IT_FINAL.

ENDLOOP.

ENDFORM. " get_data_final

&----


*& Form send_data_xl

&----


  • text

FORM SEND_DATA_XL .

*----CLEAR

CLEAR:IT_FIELDNAME,IT_FIELDNAME[].

APPEND 'Sales Document' TO IT_FIELDNAME.

APPEND 'Sales Document Item' TO IT_FIELDNAME.

APPEND 'Material Number' TO IT_FIELDNAME.

APPEND 'Material entered' TO IT_FIELDNAME.

APPEND 'Pricing reference' TO IT_FIELDNAME.

APPEND 'Sales Document1' TO IT_FIELDNAME.

APPEND 'Date on which' TO IT_FIELDNAME.

APPEND 'Entry time' TO IT_FIELDNAME.

APPEND 'Name of Person' TO IT_FIELDNAME.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = 'C:\WINDOWS\ONE.XLS'

FILETYPE = 'ASC'

  • APPEND = ' '

WRITE_FIELD_SEPARATOR = 'X'

  • 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 = ' '

  • IMPORTING

  • FILELENGTH = FILELENGTH

TABLES

DATA_TAB = IT_FINAL

FIELDNAMES = IT_FIELDNAME

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 <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
530

Here is your fix, the problem is that your internal table for the fieldnames is not defined correctly, it needs at least one field.




TYPES:BEGIN OF ty_head,
  fieldname TYPE char40,
END OF ty_head.

DATA:it_fieldname type table of TY_HEAD with  HEADER LINE.

*----CLEAR
  CLEAR:it_fieldname,it_fieldname[].

*  APPEND 'Sales Document' TO it_fieldname.
*  APPEND 'Sales Document Item' TO it_fieldname.
*  APPEND 'Material Number' TO it_fieldname.
*  APPEND 'Material entered' TO it_fieldname.
*  APPEND 'Pricing reference' TO it_fieldname.
*  APPEND 'Sales Document1' TO it_fieldname.
*  APPEND 'Date on which' TO it_fieldname.
*  APPEND 'Entry time' TO it_fieldname.
*  APPEND 'Name of Person' TO it_fieldname.
it_fieldname-fieldname = 'Sales Document'. append it_fieldname.
it_fieldname-fieldname = 'Creation Date'. append it_fieldname.
it_fieldname-fieldname  = 'Creation Time'. append it_fieldname.
it_fieldname-fieldname  = 'Person who created'. append it_fieldname.
it_fieldname-fieldname = 'Sales DOcument1'. append it_fieldname.
it_fieldname-fieldname = 'Sales Document Item'. append it_fieldname.
it_fieldname-fieldname = 'Material Number'. append it_fieldname.
it_fieldname-fieldname = 'Material Entered'. append it_fieldname.
it_fieldname-fieldname = 'Pricing Reference'. append it_fieldname.


  CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
  filename = 'C:ONE.XLS'
  filetype = 'ASC'
* APPEND = ' '
  write_field_separator = 'X'
* 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 = ' '
* IMPORTING
* FILELENGTH = FILELENGTH
  TABLES
  data_tab = it_final
  fieldnames = it_fieldname
  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 <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDFORM.                    "send_data_xl

Regards,

RIch Heilman

3 REPLIES 3
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
531

Here is your fix, the problem is that your internal table for the fieldnames is not defined correctly, it needs at least one field.




TYPES:BEGIN OF ty_head,
  fieldname TYPE char40,
END OF ty_head.

DATA:it_fieldname type table of TY_HEAD with  HEADER LINE.

*----CLEAR
  CLEAR:it_fieldname,it_fieldname[].

*  APPEND 'Sales Document' TO it_fieldname.
*  APPEND 'Sales Document Item' TO it_fieldname.
*  APPEND 'Material Number' TO it_fieldname.
*  APPEND 'Material entered' TO it_fieldname.
*  APPEND 'Pricing reference' TO it_fieldname.
*  APPEND 'Sales Document1' TO it_fieldname.
*  APPEND 'Date on which' TO it_fieldname.
*  APPEND 'Entry time' TO it_fieldname.
*  APPEND 'Name of Person' TO it_fieldname.
it_fieldname-fieldname = 'Sales Document'. append it_fieldname.
it_fieldname-fieldname = 'Creation Date'. append it_fieldname.
it_fieldname-fieldname  = 'Creation Time'. append it_fieldname.
it_fieldname-fieldname  = 'Person who created'. append it_fieldname.
it_fieldname-fieldname = 'Sales DOcument1'. append it_fieldname.
it_fieldname-fieldname = 'Sales Document Item'. append it_fieldname.
it_fieldname-fieldname = 'Material Number'. append it_fieldname.
it_fieldname-fieldname = 'Material Entered'. append it_fieldname.
it_fieldname-fieldname = 'Pricing Reference'. append it_fieldname.


  CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
  filename = 'C:ONE.XLS'
  filetype = 'ASC'
* APPEND = ' '
  write_field_separator = 'X'
* 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 = ' '
* IMPORTING
* FILELENGTH = FILELENGTH
  TABLES
  data_tab = it_final
  fieldnames = it_fieldname
  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 <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDFORM.                    "send_data_xl

Regards,

RIch Heilman

Read only

Former Member
0 Likes
530

Hi Venkat,

Rich is right...but if you don't want fieldnames to be displayed in excelsheet, then comment out the "FIELDNAMES = IT_FIELDNAME" line in the following function module which is highlighted and it will work.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = 'C:\WINDOWS\ONE.XLS'

FILETYPE = 'ASC'

  • APPEND = ' '

WRITE_FIELD_SEPARATOR = 'X'

  • 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 = ' '

  • IMPORTING

  • FILELENGTH = FILELENGTH

TABLES

DATA_TAB = IT_FINAL

<b>*FIELDNAMES = IT_FIELDNAME</b>

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 <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Regards,

Vivek

Read only

Clemenss
Active Contributor
0 Likes
530

Hi,

please mark your code with the mouse and click the 'Code' button above. This helps read the code.

Please post some lines of the dump at least the code lines where dump occurs.

Thank you.

Regards,

Clemens