You are on page 1of 5

08/06/2015

AnSAPConsultant:WebDynproABAPDownloadfile

An SAP Consultant
HOME

ABAP

ALV

SMART FORMS

ADOBE FORMS

HR ABAP

WORKFLOW

WEB DYNPRO ABAP

HCM

Follow by Email

Thursday, March 15, 2012

Web Dynpro ABAP Download file


We use method CL_WD_RUNTIME_SERVICES=>ATTACH_FILE_TO_RESPONSE to download file from Web Dynpro
Application.

Emailaddress...

FindusonFacebook

AnSAPConsultant

Example to achieve the functionality

Like

Create Web Dynpro Component and Save it a local object.

1,267peoplelikeAnSAPConsultant.

Facebooksocialplugin

Followers
Jointhissite

When we specify Window name and View name when we create web dynpro component, View is embedded in

withGoogleFriendConnect

Window.

Members(50) More

Go to Component Controller
Context tab->Create node EMP_DET with cardinality 0..n

Alreadyamember?Signin

Popular Posts

ABAPALVReportexamplewithsteps

ExecuteABAPReportusingSUBMIT
statement

WebDynproABAPALVON_CLICKevent

ABAPSendingemailwithpdfattachment

ABAPStepbysteptutorialonSmartForms
TemplateNode

ABAPDynamicWHEREclause

ABAPDownloadreportoutputasPDFfile

SAPABAPCL_ABAP_CHAR_UTILITIES
classusage

ABAPALVDemoprograms

10

WebdynproabapError/Successmessage
sampleprogram

Method tab->Create GET_DATA method to prepare data for EMP_DET node.

http://www.ansapconsultant.com/2012/03/webdynproabapdownloadfile.html

1/5

08/06/2015

AnSAPConsultant:WebDynproABAPDownloadfile

Code

Websites I follow

METHODget_data.
DATAlo_nd_emp_detTYPEREFTOif_wd_context_node.
DATAlt_emp_detTYPEwd_this>elements_emp_det.

HTML/CSS/Javscript Generator

*navigatefrom<CONTEXT>to<EMP_DET>vialeadselection
lo_nd_emp_det=wd_context>get_child_node(name=wd_this>wdctx_emp_det).
SELECT*
FROMpa0002
INTOCORRESPONDINGFIELDSOFTABLElt_emp_detUPTO30ROWS.
lo_nd_emp_det>bind_table(new_items=lt_emp_detset_initial_elements=abap_true

Easy CSS3 Generator


Digital Inspiration
Shout ME Loud
Twitter Feed

Web Dynpro ABAP Book

ENDMETHOD.

Go to view DOWNLOAD_V
Context tab->Map Component Controller context to View Context.

Layout tab->Change layout property of ROOTUIELEMENTCONTAINER to MatrixLayout.


Layout tab->Create Table UI element ->Bind EMP_DET context node to table element->Set Layout data
property to MatrixHeadData

Layout tab->Create Button UI element for downloading file-> Create OnAction event DOWNLOAD_DATA for
the button.

http://www.ansapconsultant.com/2012/03/webdynproabapdownloadfile.html

2/5

08/06/2015

AnSAPConsultant:WebDynproABAPDownloadfile

Code for theONACTIONDOWNLOAD_DATA method.

Code
METHODonactiondownload_data.
DATAlo_nd_emp_detTYPEREFTOif_wd_context_node.
DATA:
lt_emp_detTYPEwd_this>elements_emp_det,
ls_emp_detTYPEwd_this>element_emp_det.
DATA:
strTYPEstring,
xstrTYPExstring.
*navigatefrom<CONTEXT>to<EMP_DET>vialeadselection
lo_nd_emp_det=wd_context>get_child_node(name=wd_this>wdctx_emp_det).
lo_nd_emp_det>get_static_attributes_table(IMPORTINGtable=lt_emp_det).
"Preparedownloadfile.
LOOPATlt_emp_detINTOls_emp_det.
CONCATENATEstr
ls_emp_detpernr
ls_emp_detnachn
ls_emp_detvorna
ls_emp_detgbdat
cl_abap_char_utilities=>newline
INTOstr
SEPARATEDBYcl_abap_char_utilities=>horizontal_tab.
ENDLOOP.
CALLFUNCTION'SCMS_STRING_TO_XSTRING'
EXPORTING
text=str
IMPORTING
buffer=xstr
EXCEPTIONS
failed=1.
"Attachfile
CALLMETHODcl_wd_runtime_services=>attach_file_to_response
http://www.ansapconsultant.com/2012/03/webdynproabapdownloadfile.html

3/5

08/06/2015

AnSAPConsultant:WebDynproABAPDownloadfile

EXPORTING
i_filename='Download.xls'
i_content=xstr
i_mime_type='EXCEL'
i_in_new_window=abap_false
i_inplace=abap_false.
ENDMETHOD.
Methods tab->Call GET_DATA method in WDDOINIT method to get EMP_DET node elements to display in
Table.

methodWDDOINIT.
DATAlo_componentcontrollerTYPEREFTOig_componentcontroller.
lo_componentcontroller=wd_this>get_componentcontroller_ctr().
lo_componentcontroller>get_data().
endmethod.
Save and Activate Web Dynpro component.
Create Web Dynpro Application and Save it as local object.

Run Web Dynpro Application.

http://www.ansapconsultant.com/2012/03/webdynproabapdownloadfile.html

4/5

08/06/2015

AnSAPConsultant:WebDynproABAPDownloadfile
Recommend this on Google

3 comments:
Sukaniya Mishra May 4, 2013 at 6:26 PM
I am a SAP ABAP/ITS Consultant. I am working for one of the largest MNC in India as a SAP ABAP/ ITS developer from past one year.
During this period I have been working on ABAP and Internet Transaction Server(ITS). My major work has been on ITS(Both of my
Projects). So I would like to know whether I should continue working on ABAP/ITS or I should pursue a career in SAP WebDynpro
and later go SAP EP Cretfication. Which would add much better value to my Career? Working on ABAP or a career in SAP
WebDynpro?
Well got across this online course for SAP as well. http://www.wiziq.com/course/8153-sap-web-dynpro-pro-abap-training
Wonder it works for me.
Reply

john son August 5, 2014 at 2:04 PM


Wonderful blog & good post.Its really helpful for me, awaiting for more new post. Keep Blogging!
SAP ABAP Training in Chennai
Reply

john son August 5, 2014 at 2:05 PM


Wonderful blog & good post.Its really helpful for me, awaiting for more new post. Keep Blogging!
SAP ABAP Training in Chennai
Reply

Enteryourcomment...

Commentas:

Publish

GoogleAccount

Preview

Your useful comments, suggestions are appreciated.Your comments are moderated.

An SAP Consultant

Follow US

If you are interested in writing about the new stuff

Contact US
About US
Privacy Policy

Want to Contribute ?
you learn everyday while working, please write to

Facebook

the.sap.consultants@gmail.com.

Twitter
Google

Click on Contribution for more details.

2014ansapconsultant.comAllrightsreserved.

http://www.ansapconsultant.com/2012/03/webdynproabapdownloadfile.html

5/5

You might also like