‎2007 Feb 02 8:43 AM
hi,
i wanna upload a CSD file into the application server is there any FM to do these.
while the program is executed i wanna check whether it is being executed in the foreground or background,if the report is executed is executed in the background a CSD file has to be generated.
its urgent and surely pionts are granted.
‎2007 Feb 02 8:44 AM
you can check,
sy-batch is initial. "Means prog schedule for background.
‎2007 Feb 02 8:49 AM
1) if it is one time only then u can make use of transaction CG3Y and CG3Z to download/upload fiel frm or to application server.
0r
2) refer this code to donwload/upload file on Aserver
REPORT ZGILL_AS message-id rp .
tables: pa0001,pa0002.
select-options s_pernr for pa0001-pernr no intervals MODIF ID XYZ.
parameters: p_dwnld AS CHECKBOX ,
p_upld AS CHECKBOX DEFAULT 'X'.
parameters: P_DSNI(75) TYPE C MODIF ID ABG 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.
data: s_eof(3).
start-of-selection.
if p_upld = 'X'.
OPEN DATASET P_DSNI FOR OUTPUT IN LEGACY TEXT MODE.
PERFORM FETCH_DATA.
STOP.
elseif p_dwnld = 'X'.
OPEN DATASET P_DSNI FOR INPUT IN LEGACY TEXT MODE.
IF SY-SUBRC NE 0.
MESSAGE E016 WITH
'Error opening seq. file, RC:' SY-SUBRC.
EXIT.
ENDIF.
CLEAR S_EOF.
DO.
PERFORM FETCH_file.
IF S_EOF EQ 'YES'. stop. ENDIF.
ENDDO.
endif.
END-OF-SELECTION.
if itab[] is not initial.
perform print_file1 tables itab.
else.
write:/ 'No records exists'.
endif.
&----
*& 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. " FETCH_DATA
&----
*& Form FETCH_file
&----
text
----
--> p1 text
<-- p2 text
----
FORM FETCH_file .
READ DATASET P_DSNI INTO itab.
append itab.
clear itab.
IF SY-SUBRC NE 0.
S_EOF = 'YES'. EXIT.
ENDIF.
ENDFORM. " FETCH_file
&----
*& Form print_file1
&----
text
----
-->P_ITAB text
----
FORM print_file1 tables P_ITAB structure itab .
write:/2 'EmpNo',
14 'Personnel Area',
34 'Emp Group',
47 'Emp SubGroup'.
skip 1.
loop at p_itab.
write:2 p_itab-pernr,
14 p_itab-werks,
34 p_itab-persg,
47 p_itab-persk.
skip 1.
endloop.
ENDFORM. " print_file1
3) for ur third requirement make use of sy-batch field.
‎2007 Feb 02 8:48 AM
Hi ravi,
You have to use the open dataset, transfer and close dataset commands.
Use GUI_UPLOAD function module to upload the CSD file from the presentation server into an internal table itab.
Then do the following:
open dataset <dataset name> for output in text mode.
if sy-subrc = 0.
loop at itab.
transfer itab to <dataset>.
endif.
close dataset <dataset name>.
To check for execution in background or not: do this
if sy-batch = 'X'.
Exceution is in background.
else.
Exceution is in foreground.
endif.
‎2007 Feb 02 8:48 AM
Ravi,
I_FINAL is the Final internal Table.Whwere all your data get stored.
***This is Heading Colums of the file
I_FINAL-DOCNUM = 'IDOCNO'.
I_FINAL-STATXT = 'ERROR TEXT'.
I_FINAL-STAPA1 = 'ERROR DETAILS'.
I_FINAL-QMNUM = 'NOTIFICATION'.
I_FINAL-ZASSETCLASS = 'ASSETCLASS'.
I_FINAL-ZDATACODE = 'DATACODE'.
I_FINAL-ZMFRCODE = 'MANUFACTURER'.
I_FINAL-ZMODELCODE = 'MODELCODE'.
I_FINAL-ZSERNO = 'SERIALNO'.
**************************
INSERT I_FINAL INDEX 1.
CLEAR I_FINAL.
IF SY-BATCH = 'X'. " Background processing
LOOP AT I_FINAL.
CONCATENATE
I_FINAL-DOCNUM
I_FINAL-STATXT
I_FINAL-STAPA1
I_FINAL-QMNUM
I_FINAL-ZASSETCLASS
I_FINAL-ZDATACODE
I_FINAL-ZMFRCODE
I_FINAL-ZMODELCODE
I_FINAL-ZSERNO
into I_DISPLAY-REC SEPARATED BY C_COMMA.
APPEND I_DISPLAY.
CLEAR I_DISPLAY.
ENDLOOP.
OPEN DATASET FNAME FOR OUTPUT IN TEXT MODE.
LOOP AT I_DISPLAY.
TRANSFER I_DISPLAY TO FNAME.
ENDLOOP.
CLOSE DATASET FNAME.
***End of Changes
ELSE.
CALL FUNCTION 'WS_EXCEL'
TABLES
DATA = I_FINAL.
ENDIF.
Pls. Mark if useful
‎2007 Feb 02 8:54 AM
‎2007 Feb 02 9:23 AM
Hi Ravi,
Use upload / ws_upload / Gui upload to load the file into internal table, say itab.
then use the following code.
open dataset <dataset name> for input in text mode.
if sy-subrc = 0.
loop at itab.
transfer itab to <dataset name>.
endloop.
endif.
close dataset <dataset name>.
to chechk for back ground execution , just see if sy-batch is 'x', else it is in fore ground.