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

Application servrer

Former Member
0 Likes
1,207

Dear gurus,

I want to write a bapi such that

i have to take some datas from Mara table

and convert this as .CSV file anf write it into

the application server ( it is located in differnt place)

can i have the code for this??

thanx in advance

senthil

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,165

Hello Senthil,

What is the sy-subrc when u execute OPEN stmt? I think it must be non zero and this is because the path which u are specifing would be wrong.

13 REPLIES 13
Read only

Former Member
0 Likes
1,165

any ideas on this gurus??

waiting for u r eplies

senthil

Read only

Former Member
0 Likes
1,165

U can write a BAPI in which u can include the select code to fetch data from MARA.

The internal table data can be either sent to Application server or presentation server...If sending to presentation server u can convert to .CSV and use GUI_DOWNLOAD...but if u want to send data to Application server u have to use...Open Dataset....Transfer Dataset....Close Dataset.

Read only

0 Likes
1,165

can i have sample code for this

thanx in advance

senthil

Read only

Former Member
0 Likes
1,165

Hi Senthil,

Please refer the following link to download a file to the application server using OPEN DATASET..TRANSFER..CLOSE DATASET.

<a href="http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb3c8c358411d1829f0000e829fbfe/frameset.htm">http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb3c8c358411d1829f0000e829fbfe/frameset.htm</a>

Regards,

Chetan.

PS: Reward points if this helps.

Read only

Former Member
0 Likes
1,165

try to like this to send data to application server

tables mara.

data:begin of itab occurs 0,

matnr like mara-matnr,

mtart like mara-mtart,

matkl like mara-matkl,

end of itab.

data:file(200) type c value 'c:/ (give here applicationserer name)'.

select matnr

mtart

matkl

from mara

into table itab

where matnr = mara-matnr.

open dataset file for output in binary mode or text mode.

loop at itab.

transfer itab to file.

endloop.

close dataset file.

if it helpful kindly reward me.

regards,

ravi

Read only

0 Likes
1,165

hi thanks for the reply

when i am executing the code

TABLES mara.

DATA:BEGIN OF itab OCCURS 0,

matnr LIKE mara-matnr,

mtart LIKE mara-mtart,

matkl LIKE mara-matkl,

END OF itab.

DATA:file(200) TYPE c VALUE 'c:/XXX/'.

IF sy-subrc EQ 0.

SELECT matnr mtart matkl

FROM mara INTO TABLE itab

WHERE matnr = matnr.

ELSE.

ENDIF.

OPEN DATASET file FOR OUTPUT IN BINARY MODE .

LOOP AT itab.

TRANSFER itab TO file.

ENDLOOP.

CLOSE DATASET file.

it says

The file "c:/XXX/" has not been opened.

and throws a short dump

what could be the problem

senthil

Read only

0 Likes
1,165

hi senthil,

the file name u r giving may be wrong..pls go to transaction AL11 and it wil give u directories list and u can choose any appropriate directory and then open ur file from tht particular directory for e.g -

'/usr/local/sapdata/amit.dat' ,where /usr/local/sapdata/ is the directory which exists in AL11 and amit.dat is the file name ,hence pls change the file name u have given as per the directories which u see in Al11..ex code -

parameters: P_DSNI(75) TYPE C DEFAULT

'/usr/local/sapdata/amit.dat' LOWER CASE.

data: begin of itab occurs 0,

pernr(8),

sp1(1) value ',',

werks(4),

sp2(1) value ',',

persg(1),

sp3(1) value ',',

persk(2),

end of itab.

OPEN DATASET P_DSNI FOR OUTPUT IN LEGACY TEXT MODE.

PERFORM FETCH_DATA.

&----


*& Form FETCH_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM FETCH_DATA .

SELECT * FROM PA0001 WHERE PERNR IN S_PERNR.

MOVE-CORRESPONDING PA0001 TO ITAB.

TRANSFER ITAB TO P_DSNI.

APPEND ITAB.

ENDSELECT.

CLOSE DATASET P_DSNI.

ENDFORM.

hope this helps..

pls reward poitns if helpful

Read only

0 Likes
1,165

thanx for the reply

but still the dump comes

any ideas

senthil

Read only

Former Member
0 Likes
1,166

Hello Senthil,

What is the sy-subrc when u execute OPEN stmt? I think it must be non zero and this is because the path which u are specifing would be wrong.

Read only

0 Likes
1,165

Sy-subrc is non-zero only

what else i have do changes for that

senthil

Read only

0 Likes
1,165

just confrm the directory from al11 thts it..ur directory seems to be wrong and also check if u have access to transaction AL11 or not,it can also be the cause of error..can u try out any directory which u see in AL11 and then specify filename..it shud work..

Read only

Former Member
0 Likes
1,165

Hello Senthil,

It is clear then that the directory which u have specified is not available. What is the path u are giving? Check in AL11 if that dir exists.

Read only

0 Likes
1,165

thanx for u r help

senthil