Hi,
On the ALV Tool Bar provide a TRANSFER button. When User clicks on this button, you want to transfer the data from ALV ( This would be available in an internal table ) to be transferred to a file.
Once user clicks on TRANSFER button, use EXPORT FROM DATABASE command to export the internal table data to the background report program.
Then use JOB_OPEN, JOB_SUBMIT ( pass the report program name here ), JOB_CLOSE.
Create a report program and Use
IMPORT FROM DATABASE... to import the internal table data.
Open Dataset .
Transfer.
Close Dataset.
This would download the data from internal table to application server in background.
The following thread might be useful :
download-to-application-server
Best regards,
Prashant
Hello Emanuel,
U can try like. U should get the file name from the user.
PARAMETERS: P_FILE TYPE RLGRAP-FILENAME.
IF SY-BATCH = 'X'.
IF NOT P_FILE IS INITIAL.
PERFORM DOWNLOAD_DATA.
ENDIF.
ENDIF.
FORM DOWNLOAD_DATA.
DATA: OUTPUT TYPE STRING.
OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE.
IF SY-SUBRC = 0.
LOOP AT G_T_OUTTAB.
CLEAR L_F_NETWR.
WRITE: G_T_OUTTAB-NETWR TO L_F_NETWR,
G_T_OUTTAB-ERDAT_OR TO L_F_ERDAT_OR,
G_T_OUTTAB-ERDAT_IN TO L_F_ERDAT_IN,
G_T_OUTTAB-ERDAT_DE TO L_F_ERDAT_DE.
CONCATENATE G_T_OUTTAB-VBELN
G_T_OUTTAB-POSNR
G_T_OUTTAB-VKBUR
L_F_POSID
G_T_OUTTAB-BSTKD
L_F_NETWR
L_F_ERDAT_OR
L_F_ERDAT_IN
G_T_OUTTAB-VBELN_IN
L_F_ERDAT_DE
G_T_OUTTAB-VBELN_DE
INTO OUTPUT
SEPARATED BY SPACE.
TRANSFER OUTPUT TO P_FILE.
ENDLOOP.
ELSE.
MESSAGE E041(S9) WITH P_FILE.
ENDIF.
CLOSE DATASET P_FILE.
ENDFORM. " DOWNLOAD_DATA
This code will download the file to the application server when the report is executed in background.
If u want to download the file in foreground also. Remove the first If statment.
If useful reward.
Vasanth
Thanks for all the input. I think the requirement is a little bit more complicated.
The user requires that the file be specified on the selection screen and generate the report automatically.
This means that the variant and the filters associated with it needs to be considered as well. I'm having quite a difficult time trying to figure out how to extract the data to the file at the same time or even before the ALV report is being generated ( or, even not at all for background job scheduling).
Add a comment