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: 

problem while Downloading

Former Member
0 Kudos

Hi friends ,

This is program to download the report to excel file when ever it encounter a non string or numerical Heading its going to short dump .

What I have to do for headings which are numbericals.

data : Begin of itab occurs 0,

t1 type i value 8,

end of itab.

append itab.

DATA: begin of tb occurs 0,

reptext like dfies-reptext,

end of tb.

tb-reptext = 'mar'.

append tb.

CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'

EXPORTING

FILE_NAME = 'C:\T001'

  • CREATE_PIVOT = 0

DATA_SHEET_NAME = 'Companies'

  • PIVOT_SHEET_NAME = ' '

  • PASSWORD = ' '

  • PASSWORD_OPTION = 0

TABLES

  • PIVOT_FIELD_TAB =

DATA_TAB = Itab

FIELDNAMES = tb

EXCEPTIONS

FILE_NOT_EXIST = 1

FILENAME_EXPECTED = 2

COMMUNICATION_ERROR = 3

OLE_OBJECT_METHOD_ERROR = 4

OLE_OBJECT_PROPERTY_ERROR = 5

INVALID_FILENAME = 6

INVALID_PIVOT_FIELDS = 7

DOWNLOAD_PROBLEM = 8

OTHERS = 9

.

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

SantoshKallem
Active Contributor
0 Kudos

ANY INPUTS..

12 REPLIES 12

Former Member
0 Kudos

Hi Satya,

Just obesrve that Dump analysis in ST22. it will show u clear information what happend and where is the problem. it seems dump due to length of any variable or itab mismatchig between source and target things. so observe dump analysis. Reply for queries..

Regards,

Kumar.

Former Member
0 Kudos

Satya,

why did you put append here.

data : Begin of itab occurs 0,

t1 type i value 8,

end of itab.

********append itab.

attach your dump.....

SantoshKallem
Active Contributor
0 Kudos

FOR ME TOO HAVE THE SAME PROBLEM.

HERE IS MY CODE, CAN ANY ONE RECTIFY THIS.

&----


  • Program ZSAN_ACCDOC1

  • Author Santosh

  • Date OF creation : 08th march 2007

  • Date Of Modification

  • Changes

  • Change Request No CL3K900193

  • Package ZSANTOSH

&----


REPORT zsan_accdoc NO STANDARD PAGE HEADING LINE-SIZE 143.

----


  • TABLE DECLARATION

----


TABLES: bseg.

----


  • INTERNAL TABLE DECLARATION

----


DATA: BEGIN OF tab_gl OCCURS 0,

bukrs(4) TYPE C, "Company code

gjahr(4) TYPE C, "Fiscal Year

belnr(10) TYPE C, "Accounting Document Number

buzei(13) TYPE C, "Number of Line Item Within Accounting Document

koart(11) TYPE C, "Account Type

shkzg(11) TYPE C, "Debit/Credit Indicator

gsber(14) TYPE C, "Business Area

dmbtr TYPE I, "Amount in Local Currency

kostl(10) TYPE C, "Cost Center

saknr(10) TYPE C, "G/L Account Number

hkont(10) TYPE C, "General Ledger Account

zlsch(11) TYPE C, "Payment Method

END OF tab_gl.

DATA: BEGIN OF tab_gl1 OCCURS 0,

belnr(10) TYPE C, "Accounting Document Number

buzei(13) TYPE C, "Number of Line Item Within Accounting Document

koart(11) TYPE C, "Account Type

shkzg(11) TYPE C, "Debit/Credit Indicator

gsber(14) TYPE C, "Business Area

dmbtr TYPE I, "Amount in Local Currency

kostl(10) TYPE C, "Cost Center

saknr(10) TYPE C, "G/L Account Number

hkont(10) TYPE C, "General Ledger Account

zlsch(11) TYPE C, "Payment Method

END OF tab_gl1.

data: begin of tab_header occurs 0,

HEAD(12) TYPE C,

end of tab_header.

tab_header-HEAD = 'DOCNUM'.

APPEND tab_header.

tab_header-HEAD = 'LINE ITEM'.

APPEND tab_header.

tab_header-HEAD = 'ACC TYPE'.

APPEND tab_header.

tab_header-HEAD = 'INDI'.

APPEND tab_header.

tab_header-HEAD = 'BUSS AREA'.

APPEND tab_header.

*tab_header-head = 651415 . (IF I USE THIS ITS WORKING)

TAB_HEADER-HEAD = 'AMOUNT'. (IF I USE THIS GIVING DUMP, POSTED AT LAST)

APPEND tab_header.

tab_header-HEAD = 'COST CENTER'.

APPEND tab_header.

tab_header-HEAD = 'G/LACC NO'.

APPEND tab_header.

tab_header-HEAD = 'G/L Account'.

APPEND tab_header.

tab_header-HEAD = 'PAY METHOD'.

APPEND tab_header.

----


  • SELECTION SCREEN

----


SELECT-OPTIONS: acc FOR bseg-belnr.

----


  • START OF SELECTION

----


START-OF-SELECTION.

SELECT bukrs

gjahr

belnr

buzei

koart

shkzg

gsber

dmbtr

kostl

saknr

hkont

zlsch

FROM bseg INTO CORRESPONDING FIELDS OF TABLE tab_gl

WHERE belnr IN acc.

----


  • END OF SELECTION

----


LOOP AT tab_gl.

IF tab_gl-zlsch = ''.

tab_gl-zlsch = '*****'.

MODIFY tab_gl.

ENDIF.

IF tab_gl-kostl = ''.

tab_gl-kostl = '*****'.

MODIFY tab_gl.

ENDIF.

IF tab_gl-gsber = ''.

tab_gl-gsber = '*****'.

MODIFY tab_gl.

ENDIF.

IF tab_gl-saknr = ''.

tab_gl-saknr = '*****'.

MODIFY tab_gl.

ENDIF.

ENDLOOP.

LOOP AT tab_gl.

tab_gl1-belnr = tab_gl-belnr.

tab_gl1-buzei = tab_gl-buzei.

tab_gl1-koart = tab_gl-koart.

tab_gl1-shkzg = tab_gl-shkzg.

tab_gl1-gsber = tab_gl-gsber.

tab_gl1-dmbtr = tab_gl-dmbtr.

tab_gl1-kostl = tab_gl-kostl.

tab_gl1-saknr = tab_gl-saknr.

tab_gl1-hkont = tab_gl-hkont.

tab_gl1-zlsch = tab_gl-zlsch.

APPEND tab_gl1.

ENDLOOP.

SORT tab_gl BY belnr bukrs gjahr .

LOOP AT tab_gl.

WRITE: sy-uline.

AT NEW gjahr.

PERFORM header.

ENDAT.

FORMAT COLOR OFF.

WRITE:/ sy-vline, tab_gl-belnr COLOR 1, sy-vline,

(10) tab_gl-buzei CENTERED, sy-vline,

(10) tab_gl-koart CENTERED, sy-vline,

(10) tab_gl-shkzg CENTERED, sy-vline,

(11) tab_gl-gsber CENTERED, sy-vline,

(16) tab_gl-dmbtr RIGHT-JUSTIFIED, sy-vline,

(12) tab_gl-kostl CENTERED, sy-vline,

(11) tab_gl-saknr CENTERED, sy-vline,

(11) tab_gl-hkont CENTERED, sy-vline,

(11) tab_gl-zlsch CENTERED, sy-vline.

ENDLOOP.

  • ---------------------------------------------------------------------

  • FOR DOWNLOADING TO EXCEL

----


SET PF-STATUS 'ZEXCEL'.

AT USER-COMMAND.

CASE sy-ucomm.

WHEN 'DOWN'.

  • perform browse.

  • CALL FUNCTION 'GUI_DOWNLOAD'

  • EXPORTING

  • filename = 'P_FILE'

  • filetype = 'DAT'

  • TABLES

  • data_tab = tab_header.

*

  • CALL FUNCTION 'GUI_DOWNLOAD'

  • EXPORTING

  • filename = 'P_FILE'

  • filetype = 'DAT'

  • append = 'X'

  • TABLES

  • data_tab = tab_gl1[].

CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'

EXPORTING

file_name = 'C:\SANNN.DAT'

  • CREATE_PIVOT = 0

  • DATA_SHEET_NAME = ' '

  • PIVOT_SHEET_NAME = ' '

  • PASSWORD = ' '

  • PASSWORD_OPTION = 0

TABLES

  • PIVOT_FIELD_TAB =

DATA_TAB = TAB_GL1[]

FIELDNAMES = TAB_HEADER[]

  • EXCEPTIONS

  • FILE_NOT_EXIST = 1

  • FILENAME_EXPECTED = 2

  • COMMUNICATION_ERROR = 3

  • OLE_OBJECT_METHOD_ERROR = 4

  • OLE_OBJECT_PROPERTY_ERROR = 5

  • INVALID_PIVOT_FIELDS = 6

  • DOWNLOAD_PROBLEM = 7

  • OTHERS = 8

.

IF sy-subrc <> 0.

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

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

ENDIF.

ENDCASE.

----


  • TOP OF PAGE

----


TOP-OF-PAGE.

&----


*& Form header

&----


  • text

----


FORM header.

FORMAT COLOR 6 INVERSE ON.

SKIP 2.

FORMAT COLOR 6 INVERSE OFF.

FORMAT COLOR 4 INVERSE ON.

WRITE:/ 'COMPANY CODE:', tab_gl-bukrs,

88 'FISCAL YEAR:', tab_gl-gjahr.

FORMAT COLOR 4 INVERSE OFF.

ULINE.

LOOP AT tab_header.

write: tab_header.

ENDLOOP.

ULINE.

ENDFORM. "header

DUMP IS

UNABLE TO INTERPRET AMOUNT AS NUMBER.

PLEASE HELP

0 Kudos

Declare all fields as character type of desired output lengths

Former Member
0 Kudos

Hi,

This is the problem with your code:

Field DMBTR is defined as type I and that is the reason for the dump. While selection the select statement looks for a same type for the target field, here singe the defined type is integer and the selected data type is of CURR.

To rectify the error definr DMBTR as TYPE CURR or

DMBTR LIKE BSEG-DMBTR.

Naveen,

SantoshKallem
Active Contributor
0 Kudos

HI NAVEEN, I CAN'T DECLARE THE TYPE CURR IN REPORT.(IT IS IN DATABASE LEVEL)

IF I DECLARE AS LIKE BSEG-DMBTR, GETTING THE SAME DUMP AS

UNABLE TO INTERPRET 'AMOUNT' AS NUMBER

ANY INPUTS EXPERTS.

PLZ ITS URGENT.

SantoshKallem
Active Contributor
0 Kudos

ANY INPUTS..

0 Kudos

create an internal table only for the sake of downloading where the new dmbtr is of type "N"---Numerical Character ....Pass the records into this one and then call the download routine....It will work.

It is not possible to assign a character string to a field of type I but vice versa is possible....

The only hitch is that, in excel the amounts will be filled from left to right than otherwise in the normal case.

Hope this will solve your problem..

PS : Please award points if the solution is helpful and mark the thread as closed

Former Member
0 Kudos

In the fielfds of the internal table declaration ,Declare all fields as character type of desired output lengths.

Then you don't get the short dump

SantoshKallem
Active Contributor
0 Kudos

hi mijesh mohan and rama pammi.

thanx for u r replies. my problem is solved.

sorry that i cant reward u as this thread is not opened by me..

hi satya. did u solved u r problem.

if so reward all helpful and close the thread.

regrds..

santhosh reddy

0 Kudos

Hi santhosh ,

Could you please forward the modified program.

With Regards,

satya.

SantoshKallem
Active Contributor
0 Kudos

hi satya,

this is my code

REPORT zsan_accdoc NO STANDARD PAGE HEADING LINE-SIZE 143.

----


  • TABLE DECLARATION

----


TABLES: bseg.

----


  • INTERNAL TABLE DECLARATION

----


DATA: BEGIN OF tab_gl OCCURS 0,

bukrs(4) TYPE C, "Company code

gjahr(4) TYPE C, "Fiscal Year

belnr(10) TYPE C, "Accounting Document Number

buzei(13) TYPE C, "Number of Line Item Within Accounting Document

koart(11) TYPE C, "Account Type

shkzg(11) TYPE C, "Debit/Credit Indicator

gsber(14) TYPE C, "Business Area

<b>dmbtr like bseg-dmbtr, "Amount in Local Currency</b>

kostl(10) TYPE C, "Cost Center

saknr(10) TYPE C, "G/L Account Number

hkont(10) TYPE C, "General Ledger Account

zlsch(11) TYPE C, "Payment Method

END OF tab_gl.

DATA: BEGIN OF tab_gl1 OCCURS 0,

belnr(10) TYPE C, "Accounting Document Number

buzei(13) TYPE C, "Number of Line Item Within Accounting Document

koart(11) TYPE C, "Account Type

shkzg(11) TYPE C, "Debit/Credit Indicator

gsber(14) TYPE C, "Business Area

<b>dmbtr(20) TYPE c, "Amount in Local Currency</b>

kostl(10) TYPE C, "Cost Center

saknr(10) TYPE C, "G/L Account Number

hkont(10) TYPE C, "General Ledger Account

zlsch(11) TYPE C, "Payment Method

END OF tab_gl1.

data: begin of tab_header occurs 0,

HEAD(12) TYPE C,

end of tab_header.

tab_header-HEAD = 'DOCNUM'.

APPEND tab_header.

tab_header-HEAD = 'LINE ITEM'.

APPEND tab_header.

tab_header-HEAD = 'ACC TYPE'.

APPEND tab_header.

tab_header-HEAD = 'INDI'.

APPEND tab_header.

tab_header-HEAD = 'BUSS AREA'.

APPEND tab_header.

TAB_HEADER-HEAD = 'AMOUNT'.

APPEND tab_header.

tab_header-HEAD = 'COST CENTER'.

APPEND tab_header.

tab_header-HEAD = 'G/LACC NO'.

APPEND tab_header.

tab_header-HEAD = 'G/L Account'.

APPEND tab_header.

tab_header-HEAD = 'PAY METHOD'.

APPEND tab_header.

----


  • SELECTION SCREEN

----


SELECT-OPTIONS: acc FOR bseg-belnr.

----


  • START OF SELECTION

----


START-OF-SELECTION.

SELECT bukrs

gjahr

belnr

buzei

koart

shkzg

gsber

dmbtr

kostl

saknr

hkont

zlsch

FROM bseg INTO CORRESPONDING FIELDS OF TABLE tab_gl

WHERE belnr IN acc.

----


  • END OF SELECTION

----


LOOP AT tab_gl.

IF tab_gl-zlsch = ''.

tab_gl-zlsch = '*****'.

MODIFY tab_gl.

ENDIF.

IF tab_gl-kostl = ''.

tab_gl-kostl = '*****'.

MODIFY tab_gl.

ENDIF.

IF tab_gl-gsber = ''.

tab_gl-gsber = '*****'.

MODIFY tab_gl.

ENDIF.

IF tab_gl-saknr = ''.

tab_gl-saknr = '*****'.

MODIFY tab_gl.

ENDIF.

ENDLOOP.

LOOP AT tab_gl.

tab_gl1-belnr = tab_gl-belnr.

tab_gl1-buzei = tab_gl-buzei.

tab_gl1-koart = tab_gl-koart.

tab_gl1-shkzg = tab_gl-shkzg.

tab_gl1-gsber = tab_gl-gsber.

<b>tab_gl1-dmbtr = tab_gl-dmbtr.</b>

tab_gl1-kostl = tab_gl-kostl.

tab_gl1-saknr = tab_gl-saknr.

tab_gl1-hkont = tab_gl-hkont.

tab_gl1-zlsch = tab_gl-zlsch.

APPEND tab_gl1.

ENDLOOP.

SORT tab_gl BY belnr bukrs gjahr .

LOOP AT tab_gl.

WRITE: sy-uline.

AT NEW gjahr.

PERFORM header.

ENDAT.

FORMAT COLOR OFF.

WRITE:/ sy-vline, tab_gl-belnr COLOR 1, sy-vline,

(10) tab_gl-buzei CENTERED, sy-vline,

(10) tab_gl-koart CENTERED, sy-vline,

(10) tab_gl-shkzg CENTERED, sy-vline,

(11) tab_gl-gsber CENTERED, sy-vline,

(16) tab_gl-dmbtr RIGHT-JUSTIFIED, sy-vline,

(12) tab_gl-kostl CENTERED, sy-vline,

(11) tab_gl-saknr CENTERED, sy-vline,

(11) tab_gl-hkont CENTERED, sy-vline,

(11) tab_gl-zlsch CENTERED, sy-vline.

ENDLOOP.

  • ---------------------------------------------------------------------

  • FOR DOWNLOADING TO EXCEL

----


SET PF-STATUS 'ZEXCEL'.

AT USER-COMMAND.

CASE sy-ucomm.

WHEN 'DOWN'.

CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'

EXPORTING

file_name = 'C:\SANNN.DAT'

TABLES

DATA_TAB = TAB_GL1[]

FIELDNAMES = TAB_HEADER[].

ENDIF.

ENDCASE.

----


  • TOP OF PAGE

----


TOP-OF-PAGE.

&----


*& Form header

&----


  • text

----


FORM header.

FORMAT COLOR 6 INVERSE ON.

SKIP 2.

FORMAT COLOR 6 INVERSE OFF.

FORMAT COLOR 4 INVERSE ON.

WRITE:/ 'COMPANY CODE:', tab_gl-bukrs,

88 'FISCAL YEAR:', tab_gl-gjahr.

FORMAT COLOR 4 INVERSE OFF.

ULINE.

LOOP AT tab_header.

write: tab_header.

ENDLOOP.

ULINE.

ENDFORM. "header

Message was edited by:

santhosh reddy