2007 Sep 12 8:40 AM
Hi,
I have an internal table in which one line item is of length 467 chars. When i am downloading the contents from this internal table to apps server the length is getting truncated i.e. all the fields were not getting downloaded. I am opening the file in text mode and transferring the field contents into a string separated by space and transferring the same to application server file.
Any help will be appreciable.
2007 Sep 12 8:50 AM
Hi,
Well, you can always write a text file onto the application server and rename it as a .xls file
But, it will not be excel formatted
If you want to get columns and rows in the file, then you can make a csv file which can be written to the application server with the 'open dataset' concept
the csv formatting has to be done manually
ie: insert commas between each value
You cannot write an excel file to the application server directly
One other workaround is to write the file to the presentation server as an excel file and then move it to the application server via the transaction CG3Z or the function 'C13Z_FRONT_END_TO_APPL'.
Regards,
hari krsihna
2007 Sep 12 9:02 AM
Hi,
it should work fine... any how..try using length option.
<b>TRANSFER dobj TO dset [LENGTH len]</b> .
could u paste ur code??
2007 Sep 12 9:13 AM
This is the code am working on..........
REPORT yyytesttt.
TABLES : bkpf,
bseg,
t001,
t003.
DATA : BEGIN OF x_bkpf,
bukrs TYPE bkpf-bukrs,
belnr TYPE bkpf-belnr,
awkey TYPE bkpf-awkey,
gjahr TYPE bkpf-gjahr,
blart TYPE bkpf-blart,
bldat TYPE bkpf-bldat,
budat TYPE bkpf-budat,
monat TYPE bkpf-monat,
cpudt TYPE bkpf-cpudt,
wwert TYPE bkpf-wwert,
usnam TYPE bkpf-usnam,
tcode TYPE bkpf-tcode,
stjah TYPE bkpf-stjah,
xrueb TYPE bkpf-xrueb,
xblnr TYPE bkpf-xblnr,
bktxt TYPE bkpf-bktxt,
waers TYPE bkpf-waers,
kursf TYPE bkpf-kursf,
bvorg TYPE bkpf-bvorg,
stblg TYPE bkpf-stblg,
bstat TYPE bkpf-bstat,
hwaer TYPE bkpf-hwaer,
hwae2 TYPE bkpf-hwae2,
hwae3 TYPE bkpf-hwae3,
xmwst TYPE bkpf-xmwst,
txkrs TYPE bkpf-txkrs,
stgrd TYPE bkpf-stgrd,
END OF x_bkpf.
DATA : BEGIN OF x_bseg,
bukrs TYPE bseg-bukrs,
belnr TYPE bseg-belnr,
gjahr TYPE bseg-gjahr,
buzei TYPE bseg-buzei,
buzid TYPE bseg-buzid,
augdt TYPE bseg-augdt,
augcp TYPE bseg-augcp,
augbl TYPE bseg-augbl,
txjcd TYPE bseg-txjcd,
kostl TYPE bseg-kostl,
bschl TYPE bseg-bschl,
kokrs TYPE bseg-kokrs,
koart TYPE bseg-koart,
gsber TYPE bseg-gsber,
mwskz TYPE bseg-mwskz,
dmbtr TYPE bseg-dmbtr,
wrbtr TYPE bseg-wrbtr,
mwsts TYPE bseg-mwsts,
wmwst TYPE bseg-wmwst,
dmbe2 TYPE bseg-dmbe2,
dmbe3 TYPE bseg-dmbe3,
mwst2 TYPE bseg-mwst2,
mwst3 TYPE bseg-mwst3,
anln1 TYPE bseg-anln1,
hkont TYPE bseg-hkont,
kunnr TYPE bseg-kunnr,
lifnr TYPE bseg-lifnr,
navhw TYPE bseg-navhw,
navfw TYPE bseg-navfw,
matnr TYPE bseg-matnr,
werks TYPE bseg-werks,
menge TYPE bseg-menge,
meins TYPE bseg-meins,
ebeln TYPE bseg-ebeln,
ebelp TYPE bseg-ebelp,
zekkn TYPE bseg-zekkn,
stceg TYPE bseg-stceg,
prctr TYPE bseg-prctr,
kstrg TYPE bseg-kstrg,
projk TYPE bseg-projk,
sgtxt TYPE bseg-sgtxt,
zuonr TYPE bseg-zuonr,
shkzg TYPE bseg-shkzg,
END OF x_bseg.
DATA : BEGIN OF x_final,
bukrs TYPE bkpf-bukrs,
belnr TYPE bkpf-belnr,
awkey TYPE bkpf-awkey,
gjahr(4) TYPE C,
blart TYPE bkpf-blart,
bldat(8) TYPE C,
budat(8) TYPE C,
monat(2) TYPE C,
cpudt(8) TYPE C,
wwert(8) TYPE C,
usnam TYPE bkpf-usnam,
tcode TYPE bkpf-tcode,
stjah(4) TYPE C,
xrueb TYPE bkpf-xrueb,
xblnr TYPE bkpf-xblnr,
bktxt TYPE bkpf-bktxt,
waers(5) TYPE C,
kursf(10) TYPE c,
bvorg TYPE bkpf-bvorg,
stblg TYPE bkpf-stblg,
bstat TYPE bkpf-bstat,
hwaer(5) TYPE C,
hwae2(5) TYPE C,
hwae3(5) TYPE C,
xmwst TYPE bkpf-xmwst,
txkrs(9) TYPE c,
stgrd TYPE bkpf-stgrd,
buzei(3) TYPE C,
buzid TYPE bseg-buzid,
augdt(8) TYPE C,
augcp(8) TYPE C,
augbl TYPE bseg-augbl,
txjcd TYPE bseg-txjcd,
kostl TYPE bseg-kostl,
bschl TYPE bseg-bschl,
kokrs TYPE bseg-kokrs,
koart TYPE bseg-koart,
gsber TYPE bseg-gsber,
mwskz TYPE bseg-mwskz,
dmbtr(16) TYPE c,
wrbtr(16) TYPE c,
mwsts(16) TYPE c,
wmwst(16) TYPE c,
dmbe2(16) TYPE c,
dmbe3(16) TYPE c,
mwst2(16) TYPE c,
mwst3(16) TYPE c,
anln1 TYPE bseg-anln1,
hkont TYPE bseg-hkont,
kunnr TYPE bseg-kunnr,
lifnr TYPE bseg-lifnr,
navhw(16) TYPE c,
navfw(16) TYPE c,
matnr TYPE bseg-matnr,
werks TYPE bseg-werks,
menge(17) TYPE c,
meins(3) TYPE C,
ebeln TYPE bseg-ebeln,
ebelp(5) TYPE C,
zekkn(2) TYPE C,
stceg TYPE bseg-stceg,
prctr TYPE bseg-prctr,
kstrg TYPE bseg-kstrg,
projk(8) TYPE C,
sgtxt TYPE bseg-sgtxt,
zuonr TYPE bseg-zuonr,
shkzg TYPE bseg-shkzg,
END OF x_final.
DATA : t_bkpf LIKE STANDARD TABLE OF x_bkpf,
t_bseg LIKE STANDARD TABLE OF x_bseg,
t_final LIKE STANDARD TABLE OF x_final.
DATA : wa_bkpf LIKE LINE OF t_bkpf,
wa_bseg LIKE LINE OF t_bseg,
wa_final LIKE LINE OF t_final.
*----
*selection-screen
*----
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_bukrs FOR bkpf-bukrs, "company code
s_belnr FOR bkpf-belnr, "document number
s_gjahr FOR bkpf-gjahr, "fiscal year
s_monat FOR bkpf-monat, "accounting period
s_blart FOR bkpf-blart, "document type
s_budat FOR bkpf-budat. "posting date
PARAMETER p_file(100) TYPE c DEFAULT '/usr/sap/trans/log/test.txt' LOWER
CASE.
SELECTION-SCREEN END OF BLOCK b1.
*----
*selection-screen validation
*----
AT SELECTION-SCREEN.
PERFORM sub_validation.
*----
*start-of-selection
*----
START-OF-SELECTION.
PERFORM sub_get_data_bkpf.
PERFORM sub_get_data_bseg.
PERFORM sub_map_data.
data : l_file(120) type c,
l_str type string.
l_file = p_file.
OPEN DATASET l_file FOR OUTPUT in text mode.
LOOP AT t_final INTO wa_final.
concatenate wa_final-BUKRS
wa_final-belnr
wa_final-awkey
wa_final-gjahr
wa_final-blart
wa_final-bldat
wa_final-budat
wa_final-monat
wa_final-cpudt
wa_final-wwert
wa_final-usnam
wa_final-tcode
wa_final-stjah
wa_final-xrueb
wa_final-xblnr
wa_final-bktxt
wa_final-waers
wa_final-kursf
wa_final-bvorg
wa_final-stblg
wa_final-bstat
wa_final-hwaer
wa_final-hwae2
wa_final-hwae3
wa_final-xmwst
wa_final-txkrs
wa_final-stgrd
wa_final-BUZEI
wa_final-BUZID
wa_final-AUGDT
wa_final-AUGCP
wa_final-AUGBL
wa_final-TXJCD
wa_final-KOSTL
wa_final-BSCHL
wa_final-KOKRS
wa_final-KOART
wa_final-GSBER
wa_final-MWSKZ
wa_final-DMBTR
wa_final-WRBTR
wa_final-MWSTS
wa_final-WMWST
wa_final-DMBE2
wa_final-DMBE3
wa_final-MWST2
wa_final-MWST3
wa_final-ANLN1
wa_final-HKONT
wa_final-KUNNR
wa_final-LIFNR
wa_final-NAVHW
wa_final-NAVFW
wa_final-MATNR
wa_final-WERKS
wa_final-MENGE
wa_final-MEINS
wa_final-EBELN
wa_final-EBELP
wa_final-ZEKKN
wa_final-STCEG
wa_final-PRCTR
wa_final-KSTRG
wa_final-PROJK
wa_final-SGTXT
wa_final-ZUONR
wa_final-SHKZG
into l_str separated by space.
TRANSFER l_str TO l_file length 1500.
ENDLOOP.
*----
*end-of-selection.
*----
END-OF-SELECTION.
CLOSE DATASET l_file.
FREE : t_bkpf,
t_bseg,
t_final.
&----
*& Form sub_validation
&----
text
----
FORM sub_validation.
IF s_bukrs-low NE space.
SELECT SINGLE bukrs FROM t001 INTO t001-bukrs WHERE bukrs = s_bukrs-low.
IF sy-subrc NE 0.
MESSAGE e208(00) WITH 'Please enter a valid Company Code'.
ENDIF.
ENDIF.
IF s_bukrs-high NE space.
SELECT SINGLE bukrs FROM t001 INTO t001-bukrs WHERE bukrs = s_bukrs-high
.
IF sy-subrc NE 0.
MESSAGE e208(00) WITH 'Please enter a valid Company Code'.
ENDIF.
ENDIF.
IF s_blart-low NE space.
SELECT SINGLE blart FROM t003 INTO t003-blart WHERE blart = s_blart-low.
IF sy-subrc NE 0.
MESSAGE e208(00) WITH 'Please enter a valid Document Type'.
ENDIF.
ENDIF.
IF s_blart-high NE space.
SELECT SINGLE blart FROM t003 INTO t003-blart WHERE blart = s_blart-high
.
IF sy-subrc NE 0.
MESSAGE e208(00) WITH 'Please enter a valid Document Type'.
ENDIF.
ENDIF.
IF NOT p_file IS INITIAL.
OPEN DATASET p_file FOR OUTPUT IN TEXT MODE.
IF sy-subrc NE 0.
MESSAGE e208(00) WITH 'Invalid File Path'.
ENDIF.
ENDIF.
ENDFORM. " sub_validation
&----
*& Form sub_get_data_bkpf
&----
text
----
FORM sub_get_data_bkpf.
SELECT bukrs belnr awkey gjahr blart bldat budat monat cpudt wwert
usnam tcode stjah xrueb xblnr bktxt waers kursf bvorg stblg
bstat hwaer hwae2 hwae3 xmwst txkrs stgrd
FROM bkpf INTO TABLE t_bkpf
WHERE bukrs IN s_bukrs
AND belnr IN s_belnr
AND gjahr IN s_gjahr
AND blart IN s_blart
AND budat IN s_budat
AND monat IN s_monat.
IF sy-subrc NE 0.
MESSAGE s208(00) WITH 'No data found for the given selection criteria'.
ENDIF.
ENDFORM. " sub_get_data_bkpf
&----
*& Form sub_get_data_bseg
&----
text
----
FORM sub_get_data_bseg.
IF NOT t_bkpf[] IS INITIAL.
SELECT bukrs belnr gjahr buzei buzid augdt augcp augbl txjcd kostl bschl
kokrs koart gsber mwskz dmbtr wrbtr mwsts wmwst dmbe2 dmbe3 mwst2
mwst3 anln1 hkont kunnr lifnr navhw navfw matnr werks menge meins
ebeln ebelp zekkn stceg prctr kstrg projk sgtxt zuonr shkzg
FROM bseg INTO TABLE t_bseg
FOR ALL ENTRIES IN t_bkpf
WHERE bukrs = t_bkpf-bukrs
AND belnr = t_bkpf-belnr
AND gjahr = t_bkpf-gjahr.
ENDIF.
ENDFORM. " sub_get_data_bseg
&----
*& Form sub_map_data
&----
text
----
FORM sub_map_data.
SORT t_bkpf BY bukrs belnr gjahr.
SORT t_bseg BY bukrs belnr gjahr.
IF NOT t_bseg[] IS INITIAL.
LOOP AT t_bseg INTO wa_bseg.
READ TABLE t_bkpf INTO wa_bkpf WITH KEY
bukrs = wa_bseg-bukrs
belnr = wa_bseg-belnr
gjahr = wa_bseg-gjahr.
IF sy-subrc EQ 0.
wa_final-bukrs = wa_bkpf-bukrs.
wa_final-belnr = wa_bkpf-belnr.
wa_final-awkey = wa_bkpf-awkey.
wa_final-gjahr = wa_bkpf-gjahr.
wa_final-blart = wa_bkpf-blart.
wa_final-bldat = wa_bkpf-bldat.
wa_final-budat = wa_bkpf-budat.
wa_final-monat = wa_bkpf-monat.
wa_final-cpudt = wa_bkpf-cpudt.
wa_final-wwert = wa_bkpf-wwert.
wa_final-usnam = wa_bkpf-usnam.
wa_final-tcode = wa_bkpf-tcode.
wa_final-stjah = wa_bkpf-stjah.
wa_final-xrueb = wa_bkpf-xrueb.
wa_final-xblnr = wa_bkpf-xblnr.
wa_final-bktxt = wa_bkpf-bktxt.
wa_final-waers = wa_bkpf-waers.
wa_final-kursf = wa_bkpf-kursf.
wa_final-bvorg = wa_bkpf-bvorg.
wa_final-stblg = wa_bkpf-stblg.
wa_final-bstat = wa_bkpf-bstat.
wa_final-hwaer = wa_bkpf-hwaer.
wa_final-hwae2 = wa_bkpf-hwae2.
wa_final-hwae3 = wa_bkpf-hwae3.
wa_final-xmwst = wa_bkpf-xmwst.
wa_final-txkrs = wa_bkpf-txkrs.
wa_final-stgrd = wa_bkpf-stgrd.
wa_final-buzei = wa_bseg-buzei.
wa_final-buzid = wa_bseg-buzid.
wa_final-augdt = wa_bseg-augdt.
wa_final-augcp = wa_bseg-augcp.
wa_final-augbl = wa_bseg-augbl.
wa_final-txjcd = wa_bseg-txjcd.
wa_final-kostl = wa_bseg-kostl.
wa_final-bschl = wa_bseg-bschl.
wa_final-kokrs = wa_bseg-kokrs.
wa_final-koart = wa_bseg-koart.
wa_final-gsber = wa_bseg-gsber.
wa_final-mwskz = wa_bseg-mwskz.
wa_final-dmbtr = wa_bseg-dmbtr.
wa_final-wrbtr = wa_bseg-wrbtr.
wa_final-mwsts = wa_bseg-mwsts.
wa_final-wmwst = wa_bseg-wmwst.
wa_final-dmbe2 = wa_bseg-dmbe2.
wa_final-dmbe3 = wa_bseg-dmbe3.
wa_final-mwst2 = wa_bseg-mwst2.
wa_final-mwst3 = wa_bseg-mwst3.
wa_final-anln1 = wa_bseg-anln1.
wa_final-hkont = wa_bseg-hkont.
wa_final-kunnr = wa_bseg-kunnr.
wa_final-lifnr = wa_bseg-lifnr.
wa_final-navhw = wa_bseg-navhw.
wa_final-navfw = wa_bseg-navfw.
wa_final-matnr = wa_bseg-matnr.
wa_final-werks = wa_bseg-werks.
wa_final-menge = wa_bseg-menge.
wa_final-meins = wa_bseg-meins.
wa_final-ebeln = wa_bseg-ebeln.
wa_final-ebelp = wa_bseg-ebelp.
wa_final-zekkn = wa_bseg-zekkn.
wa_final-stceg = wa_bseg-stceg.
wa_final-prctr = wa_bseg-prctr.
wa_final-kstrg = wa_bseg-kstrg.
wa_final-projk = wa_bseg-projk.
wa_final-sgtxt = wa_bseg-sgtxt.
wa_final-zuonr = wa_bseg-zuonr.
wa_final-shkzg = wa_bseg-shkzg.
ENDIF.
APPEND wa_final TO t_final.
CLEAR wa_final.
ENDLOOP.
ENDIF.
SORT t_final BY bukrs belnr buzei gjahr.
ENDFORM. " sub_map_data
2007 Sep 12 9:32 AM
Hi Sayanthan,
Can you increase the length 1500 in your TRANSFER Command ?
See the documentation: -
LENGTH len
The length of the data object to be written is defined by len, where len can be either a constant or a variable. The length is specified in bytes if the file is opened in BINARY MODE or LEGACY MODE. Note that alignment bytes are included in the length, if the data object is a structure. If the file is opened in TEXT MODE, the length refers to the number of characters that are to be written.
<b>If len is shorter than the data object f, the system truncates f on the right.</b>
With type I or F fields, unexpected results may occur if len is shorter than the default length for the field type.
Increase the length and let me know if it downloaded properly....
Regards,
hari krsihna