10-01-2007 10:50 AM
I have a report which has the filename as input parameter which has to upload the file from presentation server.
When i execute the report in foreground , it is displaying the output. But i cant seee the output when i execute the the report in back-ground mode.
10-01-2007 11:09 AM
Manju,
When you are running a particular prog in background - any call to FM like WS_UPLOAD or GUI_UPLOAD wont work. because in background mode any call to your PC functions is not possible ( think of a scenario when you have submitted the Job and logged off from your logonpad - i.e. saplogon.exe is not running on ur PC).
So the solution is - you upload the file to the appliation server and adjust your code so that it reads the file from there. ( you can use AL11 to view app server files).
Hope it explains.
(P.S. No FM or methods like ALMSM_EXCEL* can do the trick for reading file from your PC when you are executing them in background)
10-01-2007 10:53 AM
If you are using WS_UPLOAD (or similar) to upload the file from the presentation server then it is not possible to do this in background.
Regards,
Nick
10-01-2007 10:55 AM
Then what Function Module should i use to execute in background?
10-01-2007 10:58 AM
You can't upload from the presentation server in background, the application server cannot make a connection to the PC without SAPgui.
You will need to copy your file to the application server and upload it using ABAP commands OPEN DATASET, TRANSFER and CLOSE DATASET.
Regards,
Nick
10-01-2007 10:59 AM
10-01-2007 11:10 AM
SAP GUI in the sense ? Why asked this question is , generally the presentation server is nothing but the sapgui.exe.
As the GUI is present , it should work naaa ?
10-01-2007 11:45 AM
By SAPgui I meant a dialog user logged on using SAPgui, not just that the software is installed. Sorry if this was not clear.
Regards,
Nick
10-01-2007 11:00 AM
Dear Manju,
Please go though the following lines of code:
************************************************************************
D A T A D E C L A R A T I O N *
************************************************************************
TABLES: ANEP,
BKPF.
TYPES: BEGIN OF TY_TABDATA,
MANDT LIKE SY-MANDT, " Client
ZSLNUM LIKE ZSHIFTDEPN-ZSLNUM, " Serial Number
ZASSET LIKE ZSHIFTDEPN-ZASSET, " Original asset that was transferred
ZYEAR LIKE ZSHIFTDEPN-ZYEAR, " Fiscal Year
ZPERIOD LIKE ZSHIFTDEPN-ZPERIOD, " Fiscal Period
ZSHIFT1 LIKE ZSHIFTDEPN-ZSHIFT1, " Shift No. 1
ZSHIFT2 LIKE ZSHIFTDEPN-ZSHIFT1, " Shift No. 2
ZSHIFT3 LIKE ZSHIFTDEPN-ZSHIFT1, " Shift No. 3
END OF TY_TABDATA.
*----
Declaration of the Internal Table with Header Line comprising of the uploaded data.
*----
DATA: BEGIN OF IT_FILE_UPLOAD OCCURS 0.
INCLUDE STRUCTURE ALSMEX_TABLINE. " Rows for Table with Excel Data
DATA: END OF IT_FILE_UPLOAD.
************************************************************************
S E L E C T I O N - S C R E E N *
************************************************************************
SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME,
BEGIN OF BLOCK B2 WITH FRAME.
PARAMETERS: P_FNAME LIKE RLGRAP-FILENAME OBLIGATORY.
SELECTION-SCREEN: END OF BLOCK B2,
END OF BLOCK B1.
************************************************************************
E V E N T : AT S E L E C T I O N - S C R E E N *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
STATIC = 'X'
MASK = '.'
CHANGING
FILE_NAME = P_FNAME
EXCEPTIONS
MASK_TOO_LONG = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
************************************************************************
E V E N T : S T A R T - O F - S E L E C T I O N *
************************************************************************
START-OF-SELECTION.
--------------------------------------
Upload Excel file into Internal Table.
--------------------------------------
PERFORM UPLOAD_EXCEL_FILE.
-------------------------------------------------------
Organize the uploaded data into another Internal Table.
-------------------------------------------------------
PERFORM ORGANIZE_UPLOADED_DATA.
************************************************************************
E V E N T : E N D - O F - S E L E C T I O N *
************************************************************************
END-OF-SELECTION.
&----
*& Form UPLOAD_EXCEL_FILE
&----
text
----
--> p1 text
<-- p2 text
----
FORM UPLOAD_EXCEL_FILE .
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FNAME
I_BEGIN_COL = 1
I_BEGIN_ROW = 3
I_END_COL = 7
I_END_ROW = 32000
TABLES
INTERN = IT_FILE_UPLOAD
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
.
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. " UPLOAD_EXCEL_FILE
&----
*& Form ORGANIZE_UPLOADED_DATA
&----
text
----
--> p1 text
<-- p2 text
----
FORM ORGANIZE_UPLOADED_DATA .
SORT IT_FILE_UPLOAD BY ROW
COL.
LOOP AT IT_FILE_UPLOAD.
CASE IT_FILE_UPLOAD-COL.
....................................................
WHEN 1.
WA_TABDATA-ZSLNUM = IT_FILE_UPLOAD-VALUE.
WHEN 2.
WA_TABDATA-ZASSET = IT_FILE_UPLOAD-VALUE.
WHEN 3.
WA_TABDATA-ZYEAR = IT_FILE_UPLOAD-VALUE.
WHEN 4.
WA_TABDATA-ZPERIOD = IT_FILE_UPLOAD-VALUE.
WHEN 5.
WA_TABDATA-ZSHIFT1 = IT_FILE_UPLOAD-VALUE.
WHEN 6.
WA_TABDATA-ZSHIFT2 = IT_FILE_UPLOAD-VALUE.
WHEN 7.
WA_TABDATA-ZSHIFT3 = IT_FILE_UPLOAD-VALUE.
....................................................
ENDCASE.
AT END OF ROW.
WA_TABDATA-MANDT = SY-MANDT.
APPEND WA_TABDATA TO IT_TABDATA.
CLEAR: WA_TABDATA.
ENDAT.
ENDLOOP.
ENDFORM. " ORGANIZE_UPLOADED_DATA
In the subroutine --> ORGANIZE_UPLOADED_DATA, data are organized as per the structure declared above.
Regards,
Abir
***********************************
Don't forget to award points *
10-01-2007 11:01 AM
10-01-2007 11:11 AM
Dear Manju,
Go to SM36 define a background job.
Give the ABAP Program Name & Variant Name.
Make the processing : Immediate.
Regards,
Abir
***************************************
Don't forget to Reward Points *
10-01-2007 11:09 AM
Manju,
When you are running a particular prog in background - any call to FM like WS_UPLOAD or GUI_UPLOAD wont work. because in background mode any call to your PC functions is not possible ( think of a scenario when you have submitted the Job and logged off from your logonpad - i.e. saplogon.exe is not running on ur PC).
So the solution is - you upload the file to the appliation server and adjust your code so that it reads the file from there. ( you can use AL11 to view app server files).
Hope it explains.
(P.S. No FM or methods like ALMSM_EXCEL* can do the trick for reading file from your PC when you are executing them in background)
10-01-2007 1:23 PM
Hi Manjunath..
In this scenario you have to create a background job dynamically to process the Session in background (for program RSBDCBTC)
This is the Basic code to Achieve that.
Call Function 'JOB_OPEN'
SUBMIT RSBDCBTC
via background Job <Job info>
With QIE = <QID Returned by BDC_OPEN_Group FM>
AND RETURN.
Call Function 'JOB_CLOSE'
<b>reward if Helpful.</b>